summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac/atrac3.c
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 13:14:43 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 13:14:43 +0000
commitad1ba429b98b2f4803a5113a094812091d229c3f (patch)
tree37b8e8e8dbd806b7edf7fe4d2a34adfb8ec6bea8 /apps/codecs/libatrac/atrac3.c
parent9bea3493828db1cafa54a8dafd3488e371dc7b41 (diff)
downloadrockbox-ad1ba429b98b2f4803a5113a094812091d229c3f.tar.gz
rockbox-ad1ba429b98b2f4803a5113a094812091d229c3f.zip
Minor speed up of atrac3 codec. Applying 2 bits fract part to scalefactors instead of brute force adding it to the full spectrum. Move decodeSpectrum() to IRAM. Speeds up codec by 1.2 MHz (+2%) on ARM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24667 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/atrac3.c')
-rw-r--r--apps/codecs/libatrac/atrac3.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index 5ff3a8587b..18a4f120e1 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -374,7 +374,8 @@ static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int coding
374 * @return outSubbands subband counter, fix for broken specification/files 374 * @return outSubbands subband counter, fix for broken specification/files
375 */ 375 */
376 376
377static int decodeSpectrum (GetBitContext *gb, int32_t *pOut) 377int decodeSpectrum (GetBitContext *gb, int32_t *pOut) ICODE_ATTR;
378int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
378{ 379{
379 int numSubbands, codingMode, cnt, first, last, subbWidth, *pIn; 380 int numSubbands, codingMode, cnt, first, last, subbWidth, *pIn;
380 int subband_vlc_index[32], SF_idxs[32]; 381 int subband_vlc_index[32], SF_idxs[32];
@@ -408,6 +409,11 @@ static int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
408 409
409 /* Decode the scale factor for this subband. */ 410 /* Decode the scale factor for this subband. */
410 SF = fixmul31(SFTable_fixed[SF_idxs[cnt]], iMaxQuant_fix[subband_vlc_index[cnt]]); 411 SF = fixmul31(SFTable_fixed[SF_idxs[cnt]], iMaxQuant_fix[subband_vlc_index[cnt]]);
412 /* Remark: Hardcoded hack to add 2 bits (empty) fract part to internal sample
413 * representation. Needed for higher accuracy in internal calculations as
414 * well as for DSP configuration. See also: ../atrac3_rm.c, DSP_SET_SAMPLE_DEPTH
415 */
416 SF <<= 2;
411 417
412 /* Inverse quantize the coefficients. */ 418 /* Inverse quantize the coefficients. */
413 if((first/256) &1) { 419 if((first/256) &1) {
@@ -488,6 +494,11 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
488 coded_values = FFMIN(max_coded_values,coded_values); 494 coded_values = FFMIN(max_coded_values,coded_values);
489 495
490 scalefactor = fixmul31(SFTable_fixed[sfIndx], iMaxQuant_fix[quant_step_index]); 496 scalefactor = fixmul31(SFTable_fixed[sfIndx], iMaxQuant_fix[quant_step_index]);
497 /* Remark: Hardcoded hack to add 2 bits (empty) fract part to internal sample
498 * representation. Needed for higher accuracy in internal calculations as
499 * well as for DSP configuration. See also: ../atrac3_rm.c, DSP_SET_SAMPLE_DEPTH
500 */
501 scalefactor <<= 2;
491 502
492 readQuantSpectralCoeffs(gb, quant_step_index, coding_mode, mantissa, coded_values); 503 readQuantSpectralCoeffs(gb, quant_step_index, coding_mode, mantissa, coded_values);
493 504
@@ -790,16 +801,6 @@ static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_
790 numBands = (subbandTab[numSubbands] - 1) >> 8; 801 numBands = (subbandTab[numSubbands] - 1) >> 8;
791 if (lastTonal >= 0) 802 if (lastTonal >= 0)
792 numBands = FFMAX((lastTonal + 256) >> 8, numBands); 803 numBands = FFMAX((lastTonal + 256) >> 8, numBands);
793
794 /* Remark: Hardcoded hack to add 2 bits (empty) fract part to internal sample
795 * representation. Needed for higher accuracy in internal calculations as
796 * well as for DSP configuration. See also: ../atrac3_rm.c, DSP_SET_SAMPLE_DEPTH
797 * Todo: Check spectral requantisation for using and outputting samples with
798 * fract part. */
799 int32_t i;
800 for (i=0; i<1024; ++i) {
801 pSnd->spectrum[i] <<= 2;
802 }
803 804
804 /* Reconstruct time domain samples. */ 805 /* Reconstruct time domain samples. */
805 for (band=0; band<4; band++) { 806 for (band=0; band<4; band++) {