Commit 6880edab authored by Michael Niedermayer's avatar Michael Niedermayer

fix av_reduce() with things like 1/0 and 0/0

Originally committed as revision 7431 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent dfc58c5d
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment