1
0
Fork 0
forked from len0rd/rockbox

Clean up iMDCT coefficient calculations.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14451 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Giacomelli 2007-08-24 20:02:50 +00:00
parent c5683b3c18
commit 153d74443a

View file

@ -1456,14 +1456,22 @@ static int wma_decode_block(WMADecodeContext *s)
coefs1 = s->coefs1[ch]; coefs1 = s->coefs1[ch];
exponents = s->exponents[ch]; exponents = s->exponents[ch];
esize = s->exponents_bsize[ch]; esize = s->exponents_bsize[ch];
mult = fixdiv64(pow_table[total_gain+20],Fixed32To64(s->max_exponent[ch]));
mult = fixmul64byfixed(mult, mdct_norm); //what the hell? This is actually fixed64*2^16!
coefs = (*(s->coefs))[ch]; coefs = (*(s->coefs))[ch];
n=0; n=0;
/*
* 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 during coefs calculation.
*/
if (s->use_noise_coding) if (s->use_noise_coding)
{ {
/*TODO: mult should be converted to 32 bit to speed up noise coding*/
mult = fixdiv64(pow_table[total_gain+20],Fixed32To64(s->max_exponent[ch]));
mult = mult* mdct_norm; //what the hell? This is actually fixed64*2^16!
mult1 = mult; mult1 = mult;
/* very low freqs : noise */ /* very low freqs : noise */
@ -1565,29 +1573,23 @@ static int wma_decode_block(WMADecodeContext *s)
} }
else else
{ {
/*Noise coding not used, simply convert from exp to fixed representation*/
/* XXX: optimize more */
fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+20],Fixed32To64(s->max_exponent[ch])));
mult3 = fixmul32(mult3, mdct_norm);
n = nb_coefs[ch]; n = nb_coefs[ch];
/* XXX: optimize more, unrolling this loop in asm might be a good idea */
for(i = 0;i < n; ++i) for(i = 0;i < n; ++i)
{ {
/* atemp = (coefs1[i] * mult3)>>1;
* 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>>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]); *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]);
} }
n = s->block_len - s->coefs_end[bsize]; n = s->block_len - s->coefs_end[bsize];
for(i = 0;i < n; ++i) memset(coefs, 0, n*sizeof(fixed32));
*coefs++ = 0;
} }
} }
} }