diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-01-09 11:58:06 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-01-09 11:58:06 +0000 |
commit | 6880edab82a83506f717127793fddb764e95a83d (patch) | |
tree | 4dcaf3015074277f20931d7141c47a0de561af85 /libavutil/rational.c | |
parent | dfc58c5d64076c6091e57fde3fbddb2d44d490ac (diff) | |
download | ffmpeg-6880edab82a83506f717127793fddb764e95a83d.tar.gz |
fix av_reduce() with things like 1/0 and 0/0
Originally committed as revision 7431 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/rational.c')
-rw-r--r-- | libavutil/rational.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavutil/rational.c b/libavutil/rational.c index 0e018c41b6..0480aa882f 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; |