[MPlayer-dev-eng] [PATCH] Fix int wrap around in af_gcd from /libaf/af.c

Michael Niedermayer michaelni at gmx.at
Mon Sep 18 12:28:25 CEST 2006


Hi

On Sat, Sep 16, 2006 at 02:22:36PM +0200, Ahmet ??nan wrote:
> i was wondering, why "-af resample=9600:0:2" worked from 44100hz files, but
> always failed from 48000hz files.
> 
> it turned out to be a problem in "af_gcd" from "/libaf/af.c", where:
> 
> "if (a * b_org < 0)"
> 
> would be fine, as long as the multiplication wouldnt leave the limits of "int".
> it does for 48000 * 96000 tho. so ive come up with this solution:
> 
> "if (a < 0 && b_org > 0 || a > 0 && b_org < 0)"
> 
> im sure, there are more elegant and better ways for this, but currently, this
> solves it for me. it would be nice to have this in the next release included.

id say use ff_gcd() adds a dependancy on libavutil to libaf but IMHO thats not
a problem if it is a problem then copy & paste ff_gcd() its just 4 lines and
works with the whole 64bit range while af_gcd is 16lines and doesnt even work
with 32 bit ints

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is



More information about the MPlayer-dev-eng mailing list