Mercurial > libavutil.hg
comparison rational.c @ 927:1b749f49aebf libavutil
Convert NaN to 0/0 in av_d2q
This fixes aspect ratio calculation for encoding from files with 0/0 stored,
common with ogg/theora
author | conrad |
---|---|
date | Mon, 24 May 2010 00:44:02 +0000 |
parents | 0795a743bda1 |
children |
comparison
equal
deleted
inserted
replaced
926:c2a912cceb52 | 927:1b749f49aebf |
---|---|
96 AVRational av_d2q(double d, int max){ | 96 AVRational av_d2q(double d, int max){ |
97 AVRational a; | 97 AVRational a; |
98 #define LOG2 0.69314718055994530941723212145817656807550013436025 | 98 #define LOG2 0.69314718055994530941723212145817656807550013436025 |
99 int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); | 99 int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); |
100 int64_t den= 1LL << (61 - exponent); | 100 int64_t den= 1LL << (61 - exponent); |
101 if (isnan(d)) | |
102 return (AVRational){0,0}; | |
101 av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); | 103 av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); |
102 | 104 |
103 return a; | 105 return a; |
104 } | 106 } |
105 | 107 |