summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook/cook_fixpoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libcook/cook_fixpoint.h')
-rw-r--r--apps/codecs/libcook/cook_fixpoint.h37
1 files changed, 14 insertions, 23 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] = {
58static inline FIXP fixp_pow2(FIXP x, int i) 58static 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
66static 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