changeset 161:3c1966537d5e libavutil

fix av_reduce() with things like 1/0 and 0/0
author michael
date Tue, 09 Jan 2007 11:58:06 +0000
parents 162b19388ef8
children 4154bbb6cbd1
files rational.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rational.c	Sun Jan 07 11:11:49 2007 +0000
+++ b/rational.c	Tue Jan 09 11:58:06 2007 +0000
@@ -38,8 +38,10 @@
     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 @@
         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;