[PATCH 01/13] Avoid cast of double nan to int. It may cause exceptions on some platform.

Stefano Sabatini stefano.sabatini-lala
Fri Oct 1 18:00:31 CEST 2010


---
 libavutil/rational.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavutil/rational.c b/libavutil/rational.c
index 0e0571e..efed674 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;
-- 
1.7.1


--BOKacYhQ+x31HxR3
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-Make-av_d2q-manage-the-case-in-which-the-value-to-co.patch"




More information about the ffmpeg-devel mailing list