From 86fc47c33a63b1797219610aa55846adb2f0c19b Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Mon, 15 Feb 2010 20:20:52 +0000 Subject: 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 --- apps/codecs/libatrac/atrac3.c | 57 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'apps/codecs') 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 @@ -373,18 +373,62 @@ static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int coding } +/** + * Requantize the spectrum. + * + * @param *mantissas pointer to mantissas for each spectral line + * @param pOut requantized band spectrum + * @param first first spectral line in subband + * @param last last spectral line in subband + * @param SF scalefactor for all spectral lines of this band + */ + +static void inverseQuantizeSpectrum(int *mantissas, int32_t *pOut, + int32_t first, int32_t last, int32_t SF) +{ + int *pIn = mantissas; + + /* Inverse quantize the coefficients. */ + if((first/256) &1) { + /* Odd band - Reverse coefficients */ + do { + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + } while (last>first); + } else { + /* Even band - Do not reverse coefficients */ + do { + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + } while (firstfirst; last--, pIn++) - pOut[last] = fixmul16(*pIn, SF); - } else { - for (pIn=mantissas ; first