diff options
author | Michael Giacomelli <giac2000@hotmail.com> | 2012-04-30 23:28:57 -0400 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2012-05-01 05:42:38 +0200 |
commit | 87d3dde15a1f0af6eaac21107d74aa240515fd0c (patch) | |
tree | f0148dd45df72e22b610b9069d5d1563adc715b7 | |
parent | f5d9a45e3ffb1326dced431025cc10814ea4b7d8 (diff) | |
download | rockbox-87d3dde15a1f0af6eaac21107d74aa240515fd0c.tar.gz rockbox-87d3dde15a1f0af6eaac21107d74aa240515fd0c.zip |
Fix corrupt when repeatidly playing very low bitrate WMA files.
The LSP feature in WMA requires that the noise table values be
doubled verses when it is not used. Unfortunately, the previous
code would double the same values every time a LSP file was
decoded without first resetting them to their original values.
Change the code to check if the values are already doubled, and
then double/halve them as needed. This is still a bit ugly,
in the future consider using the built in rockbox dither instead
of a lookup table.
Fixes playback when skipping back and forth between low and high
bitrate WMA.
Change-Id: I4c393092e4a789bc8f98d74274fe207400b9550e
Reviewed-on: http://gerrit.rockbox.org/226
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested-by: Michael Giacomelli <giac2000@hotmail.com>
-rwxr-xr-x[-rw-r--r--] | lib/rbcodec/codecs/libwma/wmadata.h | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/rbcodec/codecs/libwma/wmadeci.c | 20 |
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libwma/wmadata.h b/lib/rbcodec/codecs/libwma/wmadata.h index 07a55df19a..7f97a75676 100644..100755 --- a/lib/rbcodec/codecs/libwma/wmadata.h +++ b/lib/rbcodec/codecs/libwma/wmadata.h | |||
@@ -1578,7 +1578,8 @@ const fixed64 lsp_pow_e_table[] ICONST_ATTR_WMA_XL_IRAM = | |||
1578 | 0x0LL | 1578 | 0x0LL |
1579 | }; | 1579 | }; |
1580 | 1580 | ||
1581 | /* table of exp noise values multiplied by 16 in order to reduce rounding error */ | 1581 | /* table of exp noise values multiplied by 16 in order to reduce rounding error, |
1582 | * note that that first value (0x5) is used as a magic number in the init code*/ | ||
1582 | fixed32 noisetable_exp[] = | 1583 | fixed32 noisetable_exp[] = |
1583 | { | 1584 | { |
1584 | 0x5, 0xfffffa2e, 0xc2c, 0xb47, 0xffffaebe, 0xfffffa63, 0xfffff7ff, 0x16bd, | 1585 | 0x5, 0xfffffa2e, 0xc2c, 0xb47, 0xffffaebe, 0xfffffa63, 0xfffff7ff, 0x16bd, |
diff --git a/lib/rbcodec/codecs/libwma/wmadeci.c b/lib/rbcodec/codecs/libwma/wmadeci.c index d7a836dd97..69bdbeaca2 100644..100755 --- a/lib/rbcodec/codecs/libwma/wmadeci.c +++ b/lib/rbcodec/codecs/libwma/wmadeci.c | |||
@@ -487,23 +487,33 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) | |||
487 | 487 | ||
488 | s->reset_block_lengths = 1; | 488 | s->reset_block_lengths = 1; |
489 | 489 | ||
490 | if (s->use_noise_coding) | 490 | if (s->use_noise_coding) /* init the noise generator */ |
491 | { | 491 | { |
492 | /* init the noise generator */ | 492 | /* LSP values are simply 2x the EXP values */ |
493 | if (s->use_exp_vlc) | 493 | if (s->use_exp_vlc) |
494 | { | 494 | { |
495 | s->noise_mult = 0x51f; | 495 | s->noise_mult = 0x51f; |
496 | /*unlikely, but we may have previoiusly used this table for LSP, | ||
497 | so halve the values if needed*/ | ||
498 | if(noisetable_exp[0] == 0x10) { | ||
499 | for (i=0;i<NOISE_TAB_SIZE;++i) | ||
500 | noisetable_exp[i] >>= 1; | ||
501 | } | ||
496 | s->noise_table = noisetable_exp; | 502 | s->noise_table = noisetable_exp; |
497 | } | 503 | } |
498 | else | 504 | else |
499 | { | 505 | { |
500 | s->noise_mult = 0xa3d; | 506 | s->noise_mult = 0xa3d; |
501 | /* LSP values are simply 2x the EXP values */ | 507 | /*check that we haven't already doubled this table*/ |
502 | for (i=0;i<NOISE_TAB_SIZE;++i) | 508 | if(noisetable_exp[0] == 0x5) { |
503 | noisetable_exp[i] = noisetable_exp[i]<< 1; | 509 | for (i=0;i<NOISE_TAB_SIZE;++i) |
510 | noisetable_exp[i] <<= 1; | ||
511 | } | ||
504 | s->noise_table = noisetable_exp; | 512 | s->noise_table = noisetable_exp; |
505 | } | 513 | } |
506 | #if 0 | 514 | #if 0 |
515 | /*TODO: Rockbox has a dither function. Consider using it for noise coding*/ | ||
516 | |||
507 | /* We use a lookup table computered in advance, so no need to do this*/ | 517 | /* We use a lookup table computered in advance, so no need to do this*/ |
508 | { | 518 | { |
509 | unsigned int seed; | 519 | unsigned int seed; |