diff options
-rw-r--r-- | apps/codecs/libfaad/sbr_qmf.c | 96 |
1 files changed, 44 insertions, 52 deletions
diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c index a0b01661f8..85dc60ca3b 100644 --- a/apps/codecs/libfaad/sbr_qmf.c +++ b/apps/codecs/libfaad/sbr_qmf.c | |||
@@ -42,10 +42,12 @@ | |||
42 | #define FAAD_SYNTHESIS_SCALE(X) ((X)>>1) | 42 | #define FAAD_SYNTHESIS_SCALE(X) ((X)>>1) |
43 | #define FAAD_ANALYSIS_SCALE1(X) ((X)>>4) | 43 | #define FAAD_ANALYSIS_SCALE1(X) ((X)>>4) |
44 | #define FAAD_ANALYSIS_SCALE2(X) ((X)) | 44 | #define FAAD_ANALYSIS_SCALE2(X) ((X)) |
45 | #define FAAD_ANALYSIS_SCALE3(X) ((X)) | ||
45 | #else | 46 | #else |
46 | #define FAAD_ANALYSIS_SCALE1(X) ((X)*scale) | 47 | #define FAAD_ANALYSIS_SCALE1(X) ((X)*scale) |
47 | #define FAAD_ANALYSIS_SCALE1(X) ((X)) | 48 | #define FAAD_ANALYSIS_SCALE1(X) ((X)) |
48 | #define FAAD_ANALYSIS_SCALE2(X) (2.*(X)) | 49 | #define FAAD_ANALYSIS_SCALE2(X) (2.*(X)) |
50 | #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0) | ||
49 | #endif | 51 | #endif |
50 | 52 | ||
51 | qmfa_info *qmfa_init(uint8_t channels) | 53 | qmfa_info *qmfa_init(uint8_t channels) |
@@ -186,42 +188,6 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, | |||
186 | } | 188 | } |
187 | } | 189 | } |
188 | 190 | ||
189 | static const complex_t qmf32_pre_twiddle[] = | ||
190 | { | ||
191 | { FRAC_CONST(0.999924701839145), FRAC_CONST(-0.012271538285720) }, | ||
192 | { FRAC_CONST(0.999322384588350), FRAC_CONST(-0.036807222941359) }, | ||
193 | { FRAC_CONST(0.998118112900149), FRAC_CONST(-0.061320736302209) }, | ||
194 | { FRAC_CONST(0.996312612182778), FRAC_CONST(-0.085797312344440) }, | ||
195 | { FRAC_CONST(0.993906970002356), FRAC_CONST(-0.110222207293883) }, | ||
196 | { FRAC_CONST(0.990902635427780), FRAC_CONST(-0.134580708507126) }, | ||
197 | { FRAC_CONST(0.987301418157858), FRAC_CONST(-0.158858143333861) }, | ||
198 | { FRAC_CONST(0.983105487431216), FRAC_CONST(-0.183039887955141) }, | ||
199 | { FRAC_CONST(0.978317370719628), FRAC_CONST(-0.207111376192219) }, | ||
200 | { FRAC_CONST(0.972939952205560), FRAC_CONST(-0.231058108280671) }, | ||
201 | { FRAC_CONST(0.966976471044852), FRAC_CONST(-0.254865659604515) }, | ||
202 | { FRAC_CONST(0.960430519415566), FRAC_CONST(-0.278519689385053) }, | ||
203 | { FRAC_CONST(0.953306040354194), FRAC_CONST(-0.302005949319228) }, | ||
204 | { FRAC_CONST(0.945607325380521), FRAC_CONST(-0.325310292162263) }, | ||
205 | { FRAC_CONST(0.937339011912575), FRAC_CONST(-0.348418680249435) }, | ||
206 | { FRAC_CONST(0.928506080473216), FRAC_CONST(-0.371317193951838) }, | ||
207 | { FRAC_CONST(0.919113851690058), FRAC_CONST(-0.393992040061048) }, | ||
208 | { FRAC_CONST(0.909167983090522), FRAC_CONST(-0.416429560097637) }, | ||
209 | { FRAC_CONST(0.898674465693954), FRAC_CONST(-0.438616238538528) }, | ||
210 | { FRAC_CONST(0.887639620402854), FRAC_CONST(-0.460538710958240) }, | ||
211 | { FRAC_CONST(0.876070094195407), FRAC_CONST(-0.482183772079123) }, | ||
212 | { FRAC_CONST(0.863972856121587), FRAC_CONST(-0.503538383725718) }, | ||
213 | { FRAC_CONST(0.851355193105265), FRAC_CONST(-0.524589682678469) }, | ||
214 | { FRAC_CONST(0.838224705554838), FRAC_CONST(-0.545324988422046) }, | ||
215 | { FRAC_CONST(0.824589302785025), FRAC_CONST(-0.565731810783613) }, | ||
216 | { FRAC_CONST(0.810457198252595), FRAC_CONST(-0.585797857456439) }, | ||
217 | { FRAC_CONST(0.795836904608884), FRAC_CONST(-0.605511041404326) }, | ||
218 | { FRAC_CONST(0.780737228572094), FRAC_CONST(-0.624859488142386) }, | ||
219 | { FRAC_CONST(0.765167265622459), FRAC_CONST(-0.643831542889791) }, | ||
220 | { FRAC_CONST(0.749136394523459), FRAC_CONST(-0.662415777590172) }, | ||
221 | { FRAC_CONST(0.732654271672413), FRAC_CONST(-0.680600997795453) }, | ||
222 | { FRAC_CONST(0.715730825283819), FRAC_CONST(-0.698376249408973) } | ||
223 | }; | ||
224 | |||
225 | qmfs_info *qmfs_init(uint8_t channels) | 191 | qmfs_info *qmfs_init(uint8_t channels) |
226 | { | 192 | { |
227 | qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info)); | 193 | qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info)); |
@@ -266,13 +232,8 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 | |||
266 | /* calculate 64 samples */ | 232 | /* calculate 64 samples */ |
267 | for (k = 0; k < 16; k++) | 233 | for (k = 0; k < 16; k++) |
268 | { | 234 | { |
269 | #ifdef FIXED_POINT | 235 | y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][31-k]))); |
270 | y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k])); | 236 | x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][31-k]))); |
271 | x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k])); | ||
272 | #else | ||
273 | y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k])) / 32.0; | ||
274 | x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k])) / 32.0; | ||
275 | #endif | ||
276 | } | 237 | } |
277 | 238 | ||
278 | /* even n samples */ | 239 | /* even n samples */ |
@@ -282,7 +243,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 | |||
282 | 243 | ||
283 | for (n = 8; n < 24; n++) | 244 | for (n = 8; n < 24; n++) |
284 | { | 245 | { |
285 | qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 640 + n*2] = x[n-8]; | 246 | qmfs->v[qmfs->v_index + n*2 ] = qmfs->v[qmfs->v_index + 640 + n*2 ] = x[n-8]; |
286 | qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 640 + n*2+1] = y[n-8]; | 247 | qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 640 + n*2+1] = y[n-8]; |
287 | } | 248 | } |
288 | for (n = 0; n < 16; n++) | 249 | for (n = 0; n < 16; n++) |
@@ -336,13 +297,8 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 | |||
336 | /* calculate 128 samples */ | 297 | /* calculate 128 samples */ |
337 | for (k = 0; k < 32; k++) | 298 | for (k = 0; k < 32; k++) |
338 | { | 299 | { |
339 | #ifdef FIXED_POINT | 300 | y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][63-k]))); |
340 | y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k])); | 301 | x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][63-k]))); |
341 | x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k])); | ||
342 | #else | ||
343 | y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k])) / 32.0; | ||
344 | x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k])) / 32.0; | ||
345 | #endif | ||
346 | } | 302 | } |
347 | 303 | ||
348 | /* even n samples */ | 304 | /* even n samples */ |
@@ -352,7 +308,7 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 | |||
352 | 308 | ||
353 | for (n = 16; n < 48; n++) | 309 | for (n = 16; n < 48; n++) |
354 | { | 310 | { |
355 | qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 1280 + n*2] = x[n-16]; | 311 | qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 1280 + n*2 ] = x[n-16]; |
356 | qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 1280 + n*2+1] = y[n-16]; | 312 | qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 1280 + n*2+1] = y[n-16]; |
357 | } | 313 | } |
358 | for (n = 0; n < 32; n++) | 314 | for (n = 0; n < 32; n++) |
@@ -388,6 +344,42 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 | |||
388 | } | 344 | } |
389 | #else /* #ifdef SBR_LOW_POWER */ | 345 | #else /* #ifdef SBR_LOW_POWER */ |
390 | 346 | ||
347 | static const complex_t qmf32_pre_twiddle[] = | ||
348 | { | ||
349 | { FRAC_CONST(0.999924701839145), FRAC_CONST(-0.012271538285720) }, | ||
350 | { FRAC_CONST(0.999322384588350), FRAC_CONST(-0.036807222941359) }, | ||
351 | { FRAC_CONST(0.998118112900149), FRAC_CONST(-0.061320736302209) }, | ||
352 | { FRAC_CONST(0.996312612182778), FRAC_CONST(-0.085797312344440) }, | ||
353 | { FRAC_CONST(0.993906970002356), FRAC_CONST(-0.110222207293883) }, | ||
354 | { FRAC_CONST(0.990902635427780), FRAC_CONST(-0.134580708507126) }, | ||
355 | { FRAC_CONST(0.987301418157858), FRAC_CONST(-0.158858143333861) }, | ||
356 | { FRAC_CONST(0.983105487431216), FRAC_CONST(-0.183039887955141) }, | ||
357 | { FRAC_CONST(0.978317370719628), FRAC_CONST(-0.207111376192219) }, | ||
358 | { FRAC_CONST(0.972939952205560), FRAC_CONST(-0.231058108280671) }, | ||
359 | { FRAC_CONST(0.966976471044852), FRAC_CONST(-0.254865659604515) }, | ||
360 | { FRAC_CONST(0.960430519415566), FRAC_CONST(-0.278519689385053) }, | ||
361 | { FRAC_CONST(0.953306040354194), FRAC_CONST(-0.302005949319228) }, | ||
362 | { FRAC_CONST(0.945607325380521), FRAC_CONST(-0.325310292162263) }, | ||
363 | { FRAC_CONST(0.937339011912575), FRAC_CONST(-0.348418680249435) }, | ||
364 | { FRAC_CONST(0.928506080473216), FRAC_CONST(-0.371317193951838) }, | ||
365 | { FRAC_CONST(0.919113851690058), FRAC_CONST(-0.393992040061048) }, | ||
366 | { FRAC_CONST(0.909167983090522), FRAC_CONST(-0.416429560097637) }, | ||
367 | { FRAC_CONST(0.898674465693954), FRAC_CONST(-0.438616238538528) }, | ||
368 | { FRAC_CONST(0.887639620402854), FRAC_CONST(-0.460538710958240) }, | ||
369 | { FRAC_CONST(0.876070094195407), FRAC_CONST(-0.482183772079123) }, | ||
370 | { FRAC_CONST(0.863972856121587), FRAC_CONST(-0.503538383725718) }, | ||
371 | { FRAC_CONST(0.851355193105265), FRAC_CONST(-0.524589682678469) }, | ||
372 | { FRAC_CONST(0.838224705554838), FRAC_CONST(-0.545324988422046) }, | ||
373 | { FRAC_CONST(0.824589302785025), FRAC_CONST(-0.565731810783613) }, | ||
374 | { FRAC_CONST(0.810457198252595), FRAC_CONST(-0.585797857456439) }, | ||
375 | { FRAC_CONST(0.795836904608884), FRAC_CONST(-0.605511041404326) }, | ||
376 | { FRAC_CONST(0.780737228572094), FRAC_CONST(-0.624859488142386) }, | ||
377 | { FRAC_CONST(0.765167265622459), FRAC_CONST(-0.643831542889791) }, | ||
378 | { FRAC_CONST(0.749136394523459), FRAC_CONST(-0.662415777590172) }, | ||
379 | { FRAC_CONST(0.732654271672413), FRAC_CONST(-0.680600997795453) }, | ||
380 | { FRAC_CONST(0.715730825283819), FRAC_CONST(-0.698376249408973) } | ||
381 | }; | ||
382 | |||
391 | #define FAAD_CMPLX_PRETWIDDLE_SUB(k) \ | 383 | #define FAAD_CMPLX_PRETWIDDLE_SUB(k) \ |
392 | (MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - \ | 384 | (MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - \ |
393 | MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]))) | 385 | MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]))) |