summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 20:20:52 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-02-15 20:20:52 +0000
commit86fc47c33a63b1797219610aa55846adb2f0c19b (patch)
tree0d1fc44a7e797e317965bdbbc1bcf5617572e30b
parentf38efac9e2f43e4c327d1c264c9daeb00b6893f6 (diff)
downloadrockbox-86fc47c33a63b1797219610aa55846adb2f0c19b.tar.gz
rockbox-86fc47c33a63b1797219610aa55846adb2f0c19b.zip
Minor atrac3 codec optimization. Refacturate requantization of spectral lines, unroll loops.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24672 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libatrac/atrac3.c57
1 files changed, 47 insertions, 10 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index ff6e639a3b..b2f675ef18 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -374,17 +374,61 @@ static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int coding
374 374
375 375
376/** 376/**
377 * Requantize the spectrum.
378 *
379 * @param *mantissas pointer to mantissas for each spectral line
380 * @param pOut requantized band spectrum
381 * @param first first spectral line in subband
382 * @param last last spectral line in subband
383 * @param SF scalefactor for all spectral lines of this band
384 */
385
386static void inverseQuantizeSpectrum(int *mantissas, int32_t *pOut,
387 int32_t first, int32_t last, int32_t SF)
388{
389 int *pIn = mantissas;
390
391 /* Inverse quantize the coefficients. */
392 if((first/256) &1) {
393 /* Odd band - Reverse coefficients */
394 do {
395 pOut[last--] = fixmul16(*pIn++, SF);
396 pOut[last--] = fixmul16(*pIn++, SF);
397 pOut[last--] = fixmul16(*pIn++, SF);
398 pOut[last--] = fixmul16(*pIn++, SF);
399 pOut[last--] = fixmul16(*pIn++, SF);
400 pOut[last--] = fixmul16(*pIn++, SF);
401 pOut[last--] = fixmul16(*pIn++, SF);
402 pOut[last--] = fixmul16(*pIn++, SF);
403 } while (last>first);
404 } else {
405 /* Even band - Do not reverse coefficients */
406 do {
407 pOut[first++] = fixmul16(*pIn++, SF);
408 pOut[first++] = fixmul16(*pIn++, SF);
409 pOut[first++] = fixmul16(*pIn++, SF);
410 pOut[first++] = fixmul16(*pIn++, SF);
411 pOut[first++] = fixmul16(*pIn++, SF);
412 pOut[first++] = fixmul16(*pIn++, SF);
413 pOut[first++] = fixmul16(*pIn++, SF);
414 pOut[first++] = fixmul16(*pIn++, SF);
415 } while (first<last);
416 }
417}
418
419
420/**
377 * Restore the quantized band spectrum coefficients 421 * Restore the quantized band spectrum coefficients
378 * 422 *
379 * @param gb the GetBit context 423 * @param gb the GetBit context
380 * @param pOut decoded band spectrum 424 * @param pOut decoded band spectrum
381 * @return outSubbands subband counter, fix for broken specification/files 425 * @return outSubbands subband counter, fix for broken specification/files
382 */ 426 */
383 427
384int decodeSpectrum (GetBitContext *gb, int32_t *pOut) ICODE_ATTR; 428int decodeSpectrum (GetBitContext *gb, int32_t *pOut) ICODE_ATTR;
385int decodeSpectrum (GetBitContext *gb, int32_t *pOut) 429int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
386{ 430{
387 int numSubbands, codingMode, cnt, first, last, subbWidth, *pIn; 431 int numSubbands, codingMode, cnt, first, last, subbWidth;
388 int subband_vlc_index[32], SF_idxs[32]; 432 int subband_vlc_index[32], SF_idxs[32];
389 int mantissas[128]; 433 int mantissas[128];
390 int32_t SF; 434 int32_t SF;
@@ -423,14 +467,7 @@ int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
423 SF <<= 2; 467 SF <<= 2;
424 468
425 /* Inverse quantize the coefficients. */ 469 /* Inverse quantize the coefficients. */
426 if((first/256) &1) { 470 inverseQuantizeSpectrum(mantissas, pOut, first, last, SF);
427 /* Odd band - Reverse coefficients */
428 for (pIn=mantissas ; last>first; last--, pIn++)
429 pOut[last] = fixmul16(*pIn, SF);
430 } else {
431 for (pIn=mantissas ; first<last; first++, pIn++)
432 pOut[first] = fixmul16(*pIn, SF);
433 }
434 471
435 } else { 472 } else {
436 /* This subband was not coded, so zero the entire subband. */ 473 /* This subband was not coded, so zero the entire subband. */