diff options
author | Michael Giacomelli <giac2000@hotmail.com> | 2007-07-06 02:44:58 +0000 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2007-07-06 02:44:58 +0000 |
commit | 2f1da8d24af7f4250d3ab5130a64a8810aa98cd3 (patch) | |
tree | c2549800f80f6effd8400de4848317d45bd9a70e /apps | |
parent | e0473717e5831fbf4adb7369ea6d6fdc122001dc (diff) | |
download | rockbox-2f1da8d24af7f4250d3ab5130a64a8810aa98cd3.tar.gz rockbox-2f1da8d24af7f4250d3ab5130a64a8810aa98cd3.zip |
Merged in first part of ffmpeg accuracy improvments. No change on my samples, but brings us closer to ffmpeg's source and clears the way for additional bug fixes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13804 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/libwma/wmadec.h | 1 | ||||
-rw-r--r-- | apps/codecs/libwma/wmadeci.c | 53 |
2 files changed, 17 insertions, 37 deletions
diff --git a/apps/codecs/libwma/wmadec.h b/apps/codecs/libwma/wmadec.h index 89c100daba..0de50795c4 100644 --- a/apps/codecs/libwma/wmadec.h +++ b/apps/codecs/libwma/wmadec.h | |||
@@ -124,6 +124,7 @@ typedef struct WMADecodeContext | |||
124 | int block_pos; /* current position in frame */ | 124 | int block_pos; /* current position in frame */ |
125 | uint8_t ms_stereo; /* true if mid/side stereo mode */ | 125 | uint8_t ms_stereo; /* true if mid/side stereo mode */ |
126 | uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */ | 126 | uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */ |
127 | int exponents_bsize[MAX_CHANNELS]; // log2 ratio frame/exp. length | ||
127 | fixed32 exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]; | 128 | fixed32 exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]; |
128 | fixed32 max_exponent[MAX_CHANNELS]; | 129 | fixed32 max_exponent[MAX_CHANNELS]; |
129 | int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]; | 130 | int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]; |
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index 0ad1a7b2a7..1857e6a70d 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c | |||
@@ -1192,6 +1192,7 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) | |||
1192 | return 0; | 1192 | return 0; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | #if 0 | ||
1195 | /* interpolate values for a bigger or smaller block. The block must | 1196 | /* interpolate values for a bigger or smaller block. The block must |
1196 | have multiple sizes */ | 1197 | have multiple sizes */ |
1197 | static void interpolate_array(fixed32 *scale, int old_size, int new_size) | 1198 | static void interpolate_array(fixed32 *scale, int old_size, int new_size) |
@@ -1227,7 +1228,7 @@ static void interpolate_array(fixed32 *scale, int old_size, int new_size) | |||
1227 | } | 1228 | } |
1228 | } | 1229 | } |
1229 | } | 1230 | } |
1230 | 1231 | #endif | |
1231 | /* compute x^-0.25 with an exponent and mantissa table. We use linear | 1232 | /* compute x^-0.25 with an exponent and mantissa table. We use linear |
1232 | interpolation to reduce the mantissa table size at a small speed | 1233 | interpolation to reduce the mantissa table size at a small speed |
1233 | expense (linear interpolation approximately doubles the number of | 1234 | expense (linear interpolation approximately doubles the number of |
@@ -1397,7 +1398,7 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch) | |||
1397 | static int wma_decode_block(WMADecodeContext *s) | 1398 | static int wma_decode_block(WMADecodeContext *s) |
1398 | { | 1399 | { |
1399 | int n, v, a, ch, code, bsize; | 1400 | int n, v, a, ch, code, bsize; |
1400 | int coef_nb_bits, total_gain, parse_exponents; | 1401 | int coef_nb_bits, total_gain; |
1401 | //static fixed32 window[BLOCK_MAX_SIZE * 2]; //crap can't do this locally on the device! its big as the whole stack | 1402 | //static fixed32 window[BLOCK_MAX_SIZE * 2]; //crap can't do this locally on the device! its big as the whole stack |
1402 | int nb_coefs[MAX_CHANNELS]; | 1403 | int nb_coefs[MAX_CHANNELS]; |
1403 | fixed32 mdct_norm; | 1404 | fixed32 mdct_norm; |
@@ -1564,15 +1565,8 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1564 | } | 1565 | } |
1565 | } | 1566 | } |
1566 | 1567 | ||
1567 | /* exposant can be interpolated in short blocks. */ | 1568 | /* exponents can be reused in short blocks. */ |
1568 | parse_exponents = 1; | 1569 | if ((s->block_len_bits == s->frame_len_bits) || get_bits(&s->gb, 1)) { |
1569 | if (s->block_len_bits != s->frame_len_bits) | ||
1570 | { | ||
1571 | parse_exponents = get_bits(&s->gb, 1); | ||
1572 | } | ||
1573 | |||
1574 | if (parse_exponents) | ||
1575 | { | ||
1576 | 1570 | ||
1577 | for(ch = 0; ch < s->nb_channels; ++ch) | 1571 | for(ch = 0; ch < s->nb_channels; ++ch) |
1578 | { | 1572 | { |
@@ -1589,24 +1583,11 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1589 | { | 1583 | { |
1590 | decode_exp_lsp(s, ch); | 1584 | decode_exp_lsp(s, ch); |
1591 | } | 1585 | } |
1586 | s->exponents_bsize[ch] = bsize; | ||
1592 | } | 1587 | } |
1593 | } | 1588 | } |
1594 | } | 1589 | } |
1595 | else | 1590 | |
1596 | { | ||
1597 | for(ch = 0; ch < s->nb_channels; ++ch) | ||
1598 | { | ||
1599 | if (s->channel_coded[ch]) | ||
1600 | { | ||
1601 | interpolate_array(s->exponents[ch], | ||
1602 | 1 << s->prev_block_len_bits, | ||
1603 | s->block_len); | ||
1604 | } | ||
1605 | } | ||
1606 | } | ||
1607 | //ok up to here! | ||
1608 | //printf("got here!\n"); | ||
1609 | //rb->splash(HZ, "in wma_decode_block 2"); | ||
1610 | /* parse spectral coefficients : just RLE encoding */ | 1591 | /* parse spectral coefficients : just RLE encoding */ |
1611 | for(ch = 0; ch < s->nb_channels; ++ch) | 1592 | for(ch = 0; ch < s->nb_channels; ++ch) |
1612 | { | 1593 | { |
@@ -1693,8 +1674,6 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1693 | } | 1674 | } |
1694 | 1675 | ||
1695 | 1676 | ||
1696 | |||
1697 | //rb->splash(HZ, "in wma_decode_block 3"); | ||
1698 | /* finally compute the MDCT coefficients */ | 1677 | /* finally compute the MDCT coefficients */ |
1699 | for(ch = 0; ch < s->nb_channels; ++ch) | 1678 | for(ch = 0; ch < s->nb_channels; ++ch) |
1700 | { | 1679 | { |
@@ -1706,15 +1685,14 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1706 | fixed64 mult; | 1685 | fixed64 mult; |
1707 | fixed64 mult1; | 1686 | fixed64 mult1; |
1708 | fixed32 noise; | 1687 | fixed32 noise; |
1709 | int i, j, n, n1, last_high_band; | 1688 | int i, j, n, n1, last_high_band, esize; |
1710 | fixed32 exp_power[HIGH_BAND_MAX_SIZE]; | 1689 | fixed32 exp_power[HIGH_BAND_MAX_SIZE]; |
1711 | 1690 | ||
1712 | //double test, mul; | 1691 | //total_gain, coefs1, mdctnorm are lossless |
1713 | |||
1714 | //total_gain, coefs1, mdctnorm are lossless | ||
1715 | 1692 | ||
1716 | coefs1 = s->coefs1[ch]; | 1693 | coefs1 = s->coefs1[ch]; |
1717 | exponents = s->exponents[ch]; | 1694 | exponents = s->exponents[ch]; |
1695 | esize = s->exponents_bsize[ch]; | ||
1718 | mult = fixdiv64(pow_table[total_gain],Fixed32To64(s->max_exponent[ch])); | 1696 | mult = fixdiv64(pow_table[total_gain],Fixed32To64(s->max_exponent[ch])); |
1719 | // mul = fixtof64(pow_table[total_gain])/(s->block_len/2)/fixtof64(s->max_exponent[ch]); | 1697 | // mul = fixtof64(pow_table[total_gain])/(s->block_len/2)/fixtof64(s->max_exponent[ch]); |
1720 | 1698 | ||
@@ -1829,13 +1807,14 @@ static int wma_decode_block(WMADecodeContext *s) | |||
1829 | 1807 | ||
1830 | atemp = (fixed32)(coefs1[i]*mult>>16); | 1808 | atemp = (fixed32)(coefs1[i]*mult>>16); |
1831 | //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); //this "works" in the sense that the mdcts converge | 1809 | //atemp= ftofix32(coefs1[i] * fixtof64(exponents[i]) * fixtof64(mult>>16)); //this "works" in the sense that the mdcts converge |
1832 | *coefs++=fixmul32(atemp,exponents[i]); //this does not work | ||
1833 | 1810 | ||
1811 | //this can still overflow in rare cases | ||
1812 | //running a full scale value square wave through here does bad things | ||
1813 | |||
1814 | *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); | ||
1834 | 1815 | ||
1835 | //atemp = ftofix32( coefs1[i]*mul* fixtof64(exponents[i]) ); //this doesn't seem to help any at all. | ||
1836 | // *coefs++=atemp; | ||
1837 | 1816 | ||
1838 | } //coefs1 could underflow? | 1817 | } |
1839 | n = s->block_len - s->coefs_end[bsize]; | 1818 | n = s->block_len - s->coefs_end[bsize]; |
1840 | for(i = 0;i < n; ++i) | 1819 | for(i = 0;i < n; ++i) |
1841 | *coefs++ = 0; | 1820 | *coefs++ = 0; |