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

backport r23280 by conrad


Originally committed as revision 23283 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6
This commit is contained in:
Diego Biurrun 2010-05-24 02:27:43 +00:00
parent a2a26d108b
commit 0b374e40b1
1 changed files with 2 additions and 0 deletions

View File

@ -98,6 +98,8 @@ AVRational av_d2q(double d, int max){
#define LOG2 0.69314718055994530941723212145817656807550013436025
int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
int64_t den= 1LL << (61 - exponent);
if (isnan(d))
return (AVRational){0,0};
av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
return a;