aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/rational.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-02 09:50:56 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-02 09:50:56 +0000
commit1405782cf4eaae7fd4bcb3d9da2c39f655314b41 (patch)
treec1199ea5518ab46228fc57f891eaa741f49fa91f /libavutil/rational.c
parent8bf256bcc064ffa073b67e237f3141427d1f396c (diff)
downloadffmpeg-1405782cf4eaae7fd4bcb3d9da2c39f655314b41.tar.gz
Avoid cast of double nan to int.
It may cause exceptions on some platform. Originally committed as revision 25311 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/rational.c')
-rw-r--r--libavutil/rational.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavutil/rational.c b/libavutil/rational.c
index 0e0571e136..efed674a32 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -96,10 +96,12 @@ AVRational av_sub_q(AVRational b, AVRational c){
AVRational av_d2q(double d, int max){
AVRational a;
#define LOG2 0.69314718055994530941723212145817656807550013436025
- int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
- int64_t den= 1LL << (61 - exponent);
+ int exponent;
+ int64_t den;
if (isnan(d))
return (AVRational){0,0};
+ exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
+ den = 1LL << (61 - exponent);
av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
return a;