Apparently, negative exponents are possible when decoding exponential VLC. Should fix occasional glitches that happened in files of all bitrates.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14571 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Giacomelli 2007-09-02 03:28:49 +00:00
parent f2ed1e4008
commit a514c60fd0
2 changed files with 9 additions and 1 deletions

View file

@ -1456,8 +1456,13 @@ const fixed64 pow_table[] =
0x14f2e7a000000LL,0x1781474000000LL,0x1a5f7f4000000LL,0x1d974de000000LL,0x2133a18000000LL 0x14f2e7a000000LL,0x1781474000000LL,0x1a5f7f4000000LL,0x1d974de000000LL,0x2133a18000000LL
}; };
/*10^(index/16). We'll need to accomidate negative indicies too*/
const fixed32 pow_10_to_yover16[] ICONST_ATTR= const fixed32 pow_10_to_yover16[] ICONST_ATTR=
{ {
/*16 negative indicies (-16 to -1)*/
0x199a,0x1d90,0x2223,0x276c,0x2d86,0x3492,0x3cb5,0x461b,0x50f4,0x5d7c,0x6bf4,0x7caa,0x8ff6,0xa63e,
0xbff9, 0xddb0,
/*non-negative indicies*/
0x10000,0x127a0,0x15562,0x18a39,0x1c73d,0x20db4,0x25f12,0x2bd09,0x3298b,0x3a6d9,0x4378b,0x4dea3, 0x10000,0x127a0,0x15562,0x18a39,0x1c73d,0x20db4,0x25f12,0x2bd09,0x3298b,0x3a6d9,0x4378b,0x4dea3,
0x59f98,0x67e6b,0x77fbb,0x8a8de,0xa0000,0xb8c3e,0xd55d1,0xf6636,0x11c865,0x148906,0x17b6b8,0x1b625b, 0x59f98,0x67e6b,0x77fbb,0x8a8de,0xa0000,0xb8c3e,0xd55d1,0xf6636,0x11c865,0x148906,0x17b6b8,0x1b625b,
0x1f9f6e,0x248475,0x2a2b6e,0x30b25f,0x383bf0,0x40f02c,0x4afd4b,0x5698b0,0x640000,0x737a6b,0x855a26, 0x1f9f6e,0x248475,0x2a2b6e,0x30b25f,0x383bf0,0x40f02c,0x4afd4b,0x5698b0,0x640000,0x737a6b,0x855a26,

View file

@ -1110,6 +1110,9 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
fixed32 v, max_scale; fixed32 v, max_scale;
fixed32 *q,*q_end; fixed32 *q,*q_end;
/*accommodate the 16 negative indices */
fixed32 *pow_10_to_yover16_ptr = &pow_10_to_yover16[16];
band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
ptr = band_ptr; ptr = band_ptr;
q = s->exponents[ch]; q = s->exponents[ch];
@ -1142,7 +1145,7 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
/* NOTE: this offset is the same as MPEG4 AAC ! */ /* NOTE: this offset is the same as MPEG4 AAC ! */
last_exp += code - 60; last_exp += code - 60;
/* XXX: use a table */ /* XXX: use a table */
v = pow_10_to_yover16[last_exp]; v = pow_10_to_yover16_ptr[last_exp];
if (v > max_scale) if (v > max_scale)
{ {
max_scale = v; max_scale = v;