Hi Rob,
Rob Leslie rob@mars.org wrote:
On Friday, March 21, 2003, at 11:43 PM, Andre wrote:
Would it perhaps be better to clip at less than full scale during requantisation ?? This would reduce the chance of overflow in the IMDCT routine (which potentially corrupts far more data).
There are many reasons not to. Subband samples above full scale may just as well be canceled during IMDCT rather than overflow.
Each value returned by III_requantize is used multiple times within the imdct. Although the chance of an individual addition/subtraction overflowing is 50:50, the chance of an overflow happening at some point is much higher.
Also the mere time required to check each sample would affect performance.
III_requantize checks each value for overflow already ?!? My suggestion was simply to clip values caught by this test to a slightly lower level. Performance cost is zero.
diff -ruN mad-0.14.2b_orig/libmad/layer3.c mad-0.14.2b/libmad/layer3.c --- mad-0.14.2b_orig/libmad/layer3.c Thu Nov 8 15:28:02 2001 +++ mad-0.14.2b/libmad/layer3.c Tue Mar 25 15:21:12 2003 @@ -910,7 +910,7 @@ fprintf(stderr, "requantize overflow (%f * 2^%d)\n", mad_f_todouble(requantized), exp); # endif - requantized = MAD_F_MAX; + requantized = MAD_F_MAX / 2; } else requantized <<= exp;
In any case, I've never seen samples wildly beyond full scale occur in practice.
I'm sure I had a version of Lame from about a year ago which produced streams which regularly caused III_requantize to clip ('value' was always 1 when clipping occurred, but 'exp' was way off in the clouds somewhere). I don't know if more recent versions of Lame have fixed the bug or not...
Andre --
__________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com