summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2007-07-08 06:06:00 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2007-07-08 06:06:00 +0000
commit93bc5ef1d64ee140d6c578c9a3cab39d5f267bda (patch)
treeff6d5c3883c0132d5211d0be333b00cf14beb503 /apps/codecs
parent030dce6f886865b026bf8e2413b58e1f6485a81e (diff)
downloadrockbox-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')
-rw-r--r--apps/codecs/libwma/wmadeci.c26
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];