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/wmadeci.c | |
parent | 030dce6f886865b026bf8e2413b58e1f6485a81e (diff) | |
download | rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.tar.gz rockbox-93bc5ef1d64ee140d6c578c9a3cab39d5f267bda.zip |
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/wmadeci.c')
-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 cd01c030c8..f018cfbc53 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c | |||
@@ -630,16 +630,7 @@ void ff_imdct_calc(MDCTContext *s, | |||
630 | in2 -= 2; | 630 | in2 -= 2; |
631 | } | 631 | } |
632 | 632 | ||
633 | for(k = 0; k < n4; k++){ | ||
634 | z[k].re >>=1; | ||
635 | z[k].im >>=1; | ||
636 | } | ||
637 | |||
638 | //rb->splash(HZ, "in MDCT calc"); | ||
639 | scale = fft_calc_unscaled(&s->fft, z); | 633 | scale = fft_calc_unscaled(&s->fft, z); |
640 | // scale = fft_calc(&s->fft, z); | ||
641 | |||
642 | //rb->splash(HZ, "in MDCT calc2"); | ||
643 | 634 | ||
644 | /* post rotation + reordering */ | 635 | /* post rotation + reordering */ |
645 | 636 | ||
@@ -1764,8 +1755,7 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1764 | { | 1755 | { |
1765 | 1756 | ||
1766 | /* XXX: optimize more */ | 1757 | /* XXX: optimize more */ |
1767 | for(i = 0;i < s->coefs_start; ++i) | 1758 | |
1768 | *coefs++ = 0; //why do we do this step?! | ||
1769 | n = nb_coefs[ch]; | 1759 | n = nb_coefs[ch]; |
1770 | 1760 | ||
1771 | 1761 | ||
@@ -1773,15 +1763,17 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1773 | 1763 | ||
1774 | for(i = 0;i < n; ++i) | 1764 | for(i = 0;i < n; ++i) |
1775 | { | 1765 | { |
1766 | /* | ||
1767 | * Previously the IMDCT was run in 17.15 precision to avoid overflow. However rare files could | ||
1768 | * overflow here as well, so switch to 17.15 now. As a bonus, this saves us a shift later on. | ||
1769 | */ | ||
1776 | 1770 | ||
1777 | atemp = (fixed32)(coefs1[i]*mult>>16); | ||
1778 | //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); //this "works" in the sense that the mdcts converge | ||
1779 | |||
1780 | //this can still overflow in rare cases | ||
1781 | //running a full scale value square wave through here does bad things | ||
1782 | 1771 | ||
1783 | *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); | 1772 | atemp = (fixed32)(coefs1[i]*mult>>17); |
1773 | //this "works" in the sense that the mdcts converge | ||
1774 | //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); | ||
1784 | 1775 | ||
1776 | *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); | ||
1785 | 1777 | ||
1786 | } | 1778 | } |
1787 | n = s->block_len - s->coefs_end[bsize]; | 1779 | n = s->block_len - s->coefs_end[bsize]; |