1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Andree Buschmann 2010-02-21 21:18:05 +00:00
parent 0b5338a6e9
commit d67e25d3b9
2 changed files with 15 additions and 24 deletions

View file

@ -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<SUBBAND_SIZE ; i++) {
f = table[subband_coef_index[i]];
f = (table[subband_coef_index[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;
} 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 ; i<q->samples_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

View file

@ -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