From 2557251351641702e11c17bcacfc6e079cd3d046 Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Sat, 20 Dec 2008 05:43:58 +0000 Subject: [PATCH] Correctly implement remaining portions of ffmpeg's r8627 that I'd forgotten about. This fixes a table overflow in low bitrate files that use noise coding, and in theory should be substantial improvement, but I haven't found any files were it makes a difference. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19500 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libwma/wmadeci.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index 00c9fb7c83..2ee6574a1a 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c @@ -1195,13 +1195,13 @@ static int wma_decode_block(WMADecodeContext *s, int32_t *scratch_buffer) } - /* finally compute the MDCT coefficients */ + /* finally compute the MDCT coefficients */ for(ch = 0; ch < s->nb_channels; ++ch) { if (s->channel_coded[ch]) { int16_t *coefs1; - fixed32 *exponents, *exp_ptr; + fixed32 *exponents; fixed32 *coefs, atemp; fixed64 mult; fixed64 mult1; @@ -1215,7 +1215,6 @@ static int wma_decode_block(WMADecodeContext *s, int32_t *scratch_buffer) exponents = s->exponents[ch]; esize = s->exponents_bsize[ch]; coefs = (*(s->coefs))[ch]; - n=0; /* @@ -1237,16 +1236,14 @@ static int wma_decode_block(WMADecodeContext *s, int32_t *scratch_buffer) /* very low freqs : noise */ for(i = 0;i < s->coefs_start; ++i) { - *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index],(*exponents++))>>4),Fixed32From64(mult1)) >>2; + *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index],exponents[i<>esize])>>4),Fixed32From64(mult1)) >>2; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); } n1 = s->exponent_high_sizes[bsize]; /* compute power of high bands */ - exp_ptr = exponents + - s->high_band_start[bsize] - - s->coefs_start; + exponents = s->exponents[ch] +(s->high_band_start[bsize]<>4; + v = exponents[i<>esize]>>4; e2 += fixmul32(v, v)>>3; } exp_power[j] = e2/n; /*n is an int...*/ last_high_band = j; } - exp_ptr += n; + exponents += n<exponents[ch] + (s->coefs_start<high_band_values[ch][j]+20]) >> 16; - /*this step has a fairly high degree of error for some reason*/ - mult1 = fixdiv64(mult1,fixmul32(s->max_exponent[ch],s->noise_mult)); - + mult1 = fixdiv64(mult1,fixmul32(s->max_exponent[ch],s->noise_mult)); mult1 = mult1*mdct_norm>>PRECISION; for(i = 0;i < n; ++i) { noise = s->noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); - *coefs++ = fixmul32((fixmul32(*exponents,noise)>>4),Fixed32From64(mult1)) >>2; - ++exponents; + *coefs++ = fixmul32((fixmul32(exponents[i<>esize],noise)>>4),Fixed32From64(mult1)) >>2; + } + exponents += n<noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); /*don't forget to renormalize the noise*/ temp1 = (((int32_t)*coefs1++)<<16) + (noise>>4); - temp2 = fixmul32(*exponents, mult>>18); + temp2 = fixmul32(exponents[i<>esize], mult>>18); *coefs++ = fixmul32(temp1, temp2); - ++exponents; } + exponents += n<block_len - s->coefs_end[bsize]; - mult2 = fixmul32(mult>>16,exponents[-1]) ; /*the work around for 32.32 vars are getting stupid*/ + mult2 = fixmul32(mult>>16,exponents[((-1<>esize]) ; /*the work around for 32.32 vars are getting stupid*/ for (i = 0; i < n; ++i) { /*renormalize the noise product and then reduce to 14.18 precison*/