[SCM] libav/experimental: fix av_reduce() with things like 1/0 and 0/0

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 15:54:42 UTC 2013


The following commit has been merged in the experimental branch:
commit 6880edab82a83506f717127793fddb764e95a83d
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Tue Jan 9 11:58:06 2007 +0000

    fix av_reduce() with things like 1/0 and 0/0
    
    Originally committed as revision 7431 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavutil/rational.c b/libavutil/rational.c
index 0e018c4..0480aa8 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -38,8 +38,10 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
     int sign= (nom<0) ^ (den<0);
     int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
 
-    nom = FFABS(nom)/gcd;
-    den = FFABS(den)/gcd;
+    if(gcd){
+        nom = FFABS(nom)/gcd;
+        den = FFABS(den)/gcd;
+    }
     if(nom<=max && den<=max){
         a1= (AVRational){nom, den};
         den=0;
@@ -65,7 +67,7 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
         nom= den;
         den= next_den;
     }
-    assert(ff_gcd(a1.num, a1.den) == 1);
+    assert(ff_gcd(a1.num, a1.den) <= 1U);
 
     *dst_nom = sign ? -a1.num : a1.num;
     *dst_den = a1.den;

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list