diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-02-21 21:18:05 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-02-21 21:18:05 +0000 |
commit | d67e25d3b9a9c85b6fcd9a6465a3bbd825a7e6d0 (patch) | |
tree | 526dc1de5d988761b8cb7e95f500ce7d9ba96849 /apps/codecs/libcook | |
parent | 0b5338a6e9097c98223ea1e06b962b1cc78ea57b (diff) | |
download | rockbox-d67e25d3b9a9c85b6fcd9a6465a3bbd825a7e6d0.tar.gz rockbox-d67e25d3b9a9c85b6fcd9a6465a3bbd825a7e6d0.zip |
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
Diffstat (limited to 'apps/codecs/libcook')
-rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 37 | ||||
-rw-r--r-- | apps/codecs/libcook/cookdata_fixpoint.h | 2 |
2 files changed, 15 insertions, 24 deletions
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] = { | |||
58 | static inline FIXP fixp_pow2(FIXP x, int i) | 58 | static inline FIXP fixp_pow2(FIXP x, int i) |
59 | { | 59 | { |
60 | if (i < 0) | 60 | if (i < 0) |
61 | return (x >> -i) + ((x >> (-i-1)) & 1); | 61 | return (x >> -i); |
62 | else | 62 | else |
63 | return x << i; /* no check for overflow */ | 63 | return x << i; /* no check for overflow */ |
64 | } | 64 | } |
65 | 65 | ||
66 | static inline FIXP fixp_pow2_neg(FIXP x, int i) | ||
67 | { | ||
68 | return (x >> i) + ((x >> (i-1)) & 1); | ||
69 | } | ||
70 | |||
71 | /** | 66 | /** |
72 | * Fixed point multiply by fraction. | 67 | * Fixed point multiply by fraction. |
73 | * | 68 | * |
@@ -143,13 +138,13 @@ static void scalar_dequant_math(COOKContext *q, int index, | |||
143 | else | 138 | else |
144 | { | 139 | { |
145 | for(i=0 ; i<SUBBAND_SIZE ; i++) { | 140 | for(i=0 ; i<SUBBAND_SIZE ; i++) { |
146 | f = table[subband_coef_index[i]]; | 141 | f = (table[subband_coef_index[i]])>>s; |
147 | /* noise coding if subband_coef_index[i] == 0 */ | 142 | /* noise coding if subband_coef_index[i] == 0 */ |
148 | if (((subband_coef_index[i] == 0) && cook_random(q)) || | 143 | if (((subband_coef_index[i] == 0) && cook_random(q)) || |
149 | ((subband_coef_index[i] != 0) && subband_coef_sign[i])) | 144 | ((subband_coef_index[i] != 0) && subband_coef_sign[i])) |
150 | f = -f; | 145 | f = -f; |
151 | 146 | ||
152 | *mlt_p++ = fixp_pow2_neg(f, s); | 147 | *mlt_p++ = f; |
153 | } | 148 | } |
154 | } | 149 | } |
155 | } | 150 | } |
@@ -171,29 +166,26 @@ void imlt_math(COOKContext *q, FIXP *in) | |||
171 | { | 166 | { |
172 | const int n = q->samples_per_channel; | 167 | const int n = q->samples_per_channel; |
173 | const int step = 2 << (10 - av_log2(n)); | 168 | const int step = 2 << (10 - av_log2(n)); |
169 | REAL_T *mdct_out = q->mono_mdct_output; | ||
170 | REAL_T tmp; | ||
174 | int i = 0, j = 0; | 171 | int i = 0, j = 0; |
175 | 172 | ||
176 | ff_imdct_calc(q->mdct_nbits, q->mono_mdct_output, in); | 173 | ff_imdct_calc(q->mdct_nbits, q->mono_mdct_output, in); |
177 | 174 | ||
178 | do { | 175 | do { |
179 | FIXP tmp = q->mono_mdct_output[i]; | 176 | tmp = mdct_out[i]; |
180 | 177 | mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j ])); | |
181 | q->mono_mdct_output[i] = | 178 | mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j+1])); |
182 | fixmul31(-q->mono_mdct_output[n + i], (sincos_lookup0[j])); | ||
183 | |||
184 | q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j+1]) ); | ||
185 | 179 | ||
186 | j += step; | 180 | j += step; |
187 | |||
188 | } while (++i < n/2); | 181 | } while (++i < n/2); |
189 | 182 | ||
190 | do { | 183 | do { |
191 | FIXP tmp = q->mono_mdct_output[i]; | ||
192 | |||
193 | j -= step; | 184 | j -= step; |
194 | q->mono_mdct_output[i] = | 185 | |
195 | fixmul31(-q->mono_mdct_output[n + i], (sincos_lookup0[j+1]) ); | 186 | tmp = mdct_out[i]; |
196 | q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j]) ); | 187 | mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j+1])); |
188 | mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j ])); | ||
197 | } while (++i < n); | 189 | } while (++i < n); |
198 | } | 190 | } |
199 | 191 | ||
@@ -219,8 +211,7 @@ void overlap_math(COOKContext *q, int gain, FIXP buffer[]) | |||
219 | 211 | ||
220 | } else { | 212 | } else { |
221 | for(i=0 ; i<q->samples_per_channel ; i++) { | 213 | for(i=0 ; i<q->samples_per_channel ; i++) { |
222 | q->mono_mdct_output[i] = | 214 | q->mono_mdct_output[i] = (q->mono_mdct_output[i]>>-gain) + buffer[i]; |
223 | (q->mono_mdct_output[i] >> -gain) + ((q->mono_mdct_output[i] >> (-gain-1)) & 1)+ buffer[i]; | ||
224 | } | 215 | } |
225 | } | 216 | } |
226 | #else | 217 | #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] = { | |||
65 | * Index 2: [0..7] - category | 65 | * Index 2: [0..7] - category |
66 | * Index 3: [0] - dither_table, [1..13] - quant_centroid_table | 66 | * Index 3: [0] - dither_table, [1..13] - quant_centroid_table |
67 | */ | 67 | */ |
68 | static const FIXP quant_tables[2][8][14] = {{{ | 68 | static const FIXP quant_tables[2][8][14] ICONST_ATTR = {{{ |
69 | 0x00000000, 0x0645a1cb, 0x0c2d0e56, 0x11eb851f, 0x17a1cac1, 0x1d4fdf3b, | 69 | 0x00000000, 0x0645a1cb, 0x0c2d0e56, 0x11eb851f, 0x17a1cac1, 0x1d4fdf3b, |
70 | 0x22ed9168, 0x28a7ef9e, 0x2e49ba5e, 0x33eb851f, 0x39916873, 0x3f126e98, | 70 | 0x22ed9168, 0x28a7ef9e, 0x2e49ba5e, 0x33eb851f, 0x39916873, 0x3f126e98, |
71 | 0x449ba5e3, 0x4b958106 | 71 | 0x449ba5e3, 0x4b958106 |