diff options
| author | Michael Giacomelli <giac2000@hotmail.com> | 2007-07-08 06:06:00 +0000 |
|---|---|---|
| committer | Michael Giacomelli <giac2000@hotmail.com> | 2007-07-08 06:06:00 +0000 |
| commit | 93bc5ef1d64ee140d6c578c9a3cab39d5f267bda (patch) | |
| tree | ff6d5c3883c0132d5211d0be333b00cf14beb503 /apps/codecs/libwma | |
| parent | 030dce6f886865b026bf8e2413b58e1f6485a81e (diff) | |
| download | rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.zip rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.tar.gz rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.tar.bz2 rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.tar.xz | |
Fix rare overflow when decoding MDCT coefficients. As a bonus, decoding is now slightly faster. Thanks to preglow for suggesting I test with a full scale normalized square wave.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13815 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwma')
| -rw-r--r-- | apps/codecs/libwma/wmadeci.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index cd01c03..f018cfb 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c @@ -630,16 +630,7 @@ void ff_imdct_calc(MDCTContext *s, in2 -= 2; } - for(k = 0; k < n4; k++){ - z[k].re >>=1; - z[k].im >>=1; - } - - //rb->splash(HZ, "in MDCT calc"); scale = fft_calc_unscaled(&s->fft, z); - // scale = fft_calc(&s->fft, z); - - //rb->splash(HZ, "in MDCT calc2"); /* post rotation + reordering */ @@ -1764,8 +1755,7 @@ static int wma_decode_block(WMADecodeContext *s) { /* XXX: optimize more */ - for(i = 0;i < s->coefs_start; ++i) - *coefs++ = 0; //why do we do this step?! + n = nb_coefs[ch]; @@ -1773,15 +1763,17 @@ static int wma_decode_block(WMADecodeContext *s) for(i = 0;i < n; ++i) { + /* + * Previously the IMDCT was run in 17.15 precision to avoid overflow. However rare files could + * overflow here as well, so switch to 17.15 now. As a bonus, this saves us a shift later on. + */ - atemp = (fixed32)(coefs1[i]*mult>>16); - //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); //this "works" in the sense that the mdcts converge - - //this can still overflow in rare cases - //running a full scale value square wave through here does bad things - *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); + atemp = (fixed32)(coefs1[i]*mult>>17); + //this "works" in the sense that the mdcts converge + //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); + *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); } n = s->block_len - s->coefs_end[bsize]; |