From d67e25d3b9a9c85b6fcd9a6465a3bbd825a7e6d0 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sun, 21 Feb 2010 21:18:05 +0000 Subject: Further work on cook codec. Rounding is not needed when using a large fract part in the internal sample representation. Move quantization array to iram. Beautification of mdct post processing. Speed up of 0.2 MHz on PP5022. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24821 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libcook/cook_fixpoint.h | 37 +++++++++++++-------------------- apps/codecs/libcook/cookdata_fixpoint.h | 2 +- 2 files changed, 15 insertions(+), 24 deletions(-) (limited to 'apps') diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index 57c217dc43..1d8b3ffa2f 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h @@ -58,16 +58,11 @@ static const FIXPU* cplscales[5] = { static inline FIXP fixp_pow2(FIXP x, int i) { if (i < 0) - return (x >> -i) + ((x >> (-i-1)) & 1); + return (x >> -i); else return x << i; /* no check for overflow */ } -static inline FIXP fixp_pow2_neg(FIXP x, int i) -{ - return (x >> i) + ((x >> (i-1)) & 1); -} - /** * Fixed point multiply by fraction. * @@ -143,13 +138,13 @@ static void scalar_dequant_math(COOKContext *q, int index, else { for(i=0 ; i>s; /* noise coding if subband_coef_index[i] == 0 */ if (((subband_coef_index[i] == 0) && cook_random(q)) || ((subband_coef_index[i] != 0) && subband_coef_sign[i])) f = -f; - *mlt_p++ = fixp_pow2_neg(f, s); + *mlt_p++ = f; } } } @@ -171,29 +166,26 @@ void imlt_math(COOKContext *q, FIXP *in) { const int n = q->samples_per_channel; const int step = 2 << (10 - av_log2(n)); + REAL_T *mdct_out = q->mono_mdct_output; + REAL_T tmp; int i = 0, j = 0; ff_imdct_calc(q->mdct_nbits, q->mono_mdct_output, in); do { - FIXP tmp = q->mono_mdct_output[i]; - - q->mono_mdct_output[i] = - fixmul31(-q->mono_mdct_output[n + i], (sincos_lookup0[j])); - - q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j+1]) ); + tmp = mdct_out[i]; + mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j ])); + mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j+1])); - j += step; - + j += step; } while (++i < n/2); do { - FIXP tmp = q->mono_mdct_output[i]; - j -= step; - q->mono_mdct_output[i] = - fixmul31(-q->mono_mdct_output[n + i], (sincos_lookup0[j+1]) ); - q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j]) ); + + tmp = mdct_out[i]; + mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j+1])); + mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j ])); } while (++i < n); } @@ -219,8 +211,7 @@ void overlap_math(COOKContext *q, int gain, FIXP buffer[]) } else { for(i=0 ; isamples_per_channel ; i++) { - q->mono_mdct_output[i] = - (q->mono_mdct_output[i] >> -gain) + ((q->mono_mdct_output[i] >> (-gain-1)) & 1)+ buffer[i]; + q->mono_mdct_output[i] = (q->mono_mdct_output[i]>>-gain) + buffer[i]; } } #else diff --git a/apps/codecs/libcook/cookdata_fixpoint.h b/apps/codecs/libcook/cookdata_fixpoint.h index 1bb0686306..b58666031d 100644 --- a/apps/codecs/libcook/cookdata_fixpoint.h +++ b/apps/codecs/libcook/cookdata_fixpoint.h @@ -65,7 +65,7 @@ static const FIXPU pow128_tab[128] = { * Index 2: [0..7] - category * Index 3: [0] - dither_table, [1..13] - quant_centroid_table */ -static const FIXP quant_tables[2][8][14] = {{{ +static const FIXP quant_tables[2][8][14] ICONST_ATTR = {{{ 0x00000000, 0x0645a1cb, 0x0c2d0e56, 0x11eb851f, 0x17a1cac1, 0x1d4fdf3b, 0x22ed9168, 0x28a7ef9e, 0x2e49ba5e, 0x33eb851f, 0x39916873, 0x3f126e98, 0x449ba5e3, 0x4b958106 -- cgit v1.2.3