summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/libfaad/common.h9
-rw-r--r--apps/codecs/libfaad/sbr_hfgen.c117
-rw-r--r--apps/codecs/libfaad/sbr_qmf.c2
3 files changed, 42 insertions, 86 deletions
diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h
index 5343de325c..e6cdcd8646 100644
--- a/apps/codecs/libfaad/common.h
+++ b/apps/codecs/libfaad/common.h
@@ -95,11 +95,6 @@ extern struct codec_api* ci;
95/* Use if target platform has address generators with autoincrement */ 95/* Use if target platform has address generators with autoincrement */
96//#define PREFER_POINTERS 96//#define PREFER_POINTERS
97 97
98#ifdef _WIN32_WCE
99#define FIXED_POINT
100#endif
101
102
103#define ERROR_RESILIENCE 98#define ERROR_RESILIENCE
104 99
105 100
@@ -328,7 +323,7 @@ char *strchr(), *strrchr();
328 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); 323 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
329 } 324 }
330 325
331 326/* rockbox: must be commented to build for non-FP
332 #if defined(_WIN32) && !defined(__MINGW32__) 327 #if defined(_WIN32) && !defined(__MINGW32__)
333 #define HAS_LRINTF 328 #define HAS_LRINTF
334 static INLINE int lrintf(float f) 329 static INLINE int lrintf(float f)
@@ -355,7 +350,7 @@ char *strchr(), *strrchr();
355 return i; 350 return i;
356 } 351 }
357 #endif 352 #endif
358 353*/
359 354
360 #ifdef __ICL /* only Intel C compiler has fmath ??? */ 355 #ifdef __ICL /* only Intel C compiler has fmath ??? */
361 356
diff --git a/apps/codecs/libfaad/sbr_hfgen.c b/apps/codecs/libfaad/sbr_hfgen.c
index 08d3af0253..fc1d188f4a 100644
--- a/apps/codecs/libfaad/sbr_hfgen.c
+++ b/apps/codecs/libfaad/sbr_hfgen.c
@@ -146,23 +146,15 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
146#endif 146#endif
147 147
148#ifdef SBR_LOW_POWER 148#ifdef SBR_LOW_POWER
149 QMF_RE(Xhigh[l + offset][k]) = 149 QMF_RE(Xhigh[l + offset][k]) = temp3_r +
150 temp3_r 150 (MUL_R(a0_r, temp2_r) + MUL_R(a1_r, temp1_r));
151 +(MUL_R(a0_r, temp2_r) +
152 MUL_R(a1_r, temp1_r));
153#else 151#else
154 QMF_RE(Xhigh[l + offset][k]) = 152 QMF_RE(Xhigh[l + offset][k]) = temp3_r +
155 temp3_r 153 (MUL_R(a0_r, temp2_r) - MUL_R(a0_i, temp2_i) +
156 +(MUL_R(a0_r, temp2_r) - 154 MUL_R(a1_r, temp1_r) - MUL_R(a1_i, temp1_i));
157 MUL_R(a0_i, temp2_i) + 155 QMF_IM(Xhigh[l + offset][k]) = temp3_i +
158 MUL_R(a1_r, temp1_r) - 156 (MUL_R(a0_i, temp2_r) + MUL_R(a0_r, temp2_i) +
159 MUL_R(a1_i, temp1_i)); 157 MUL_R(a1_i, temp1_r) + MUL_R(a1_r, temp1_i));
160 QMF_IM(Xhigh[l + offset][k]) =
161 temp3_i
162 +(MUL_R(a0_i, temp2_r) +
163 MUL_R(a0_r, temp2_i) +
164 MUL_R(a1_i, temp1_r) +
165 MUL_R(a1_r, temp1_i));
166#endif 158#endif
167 } 159 }
168 } else { 160 } else {
@@ -199,6 +191,7 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
199 uint8_t bd, uint8_t len) 191 uint8_t bd, uint8_t len)
200{ 192{
201 real_t r01 = 0, r02 = 0, r11 = 0; 193 real_t r01 = 0, r02 = 0, r11 = 0;
194 real_t tmp1, tmp2;
202 int8_t j; 195 int8_t j;
203 uint8_t offset = sbr->tHFAdj; 196 uint8_t offset = sbr->tHFAdj;
204#ifdef FIXED_POINT 197#ifdef FIXED_POINT
@@ -233,12 +226,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
233 r02 += MUL_R(buf_j , buf_j_2); 226 r02 += MUL_R(buf_j , buf_j_2);
234 r11 += MUL_R(buf_j_1, buf_j_1); 227 r11 += MUL_R(buf_j_1, buf_j_1);
235 } 228 }
236 RE(ac->r12) = r01 - 229 tmp1 = (QMF_RE(buffer[len+offset-1][bd]))>>exp;
237 MUL_R(((QMF_RE(buffer[len+offset-1][bd]))>>exp), ((QMF_RE(buffer[len+offset-2][bd]))>>exp)) + 230 tmp2 = (QMF_RE(buffer[ offset-1][bd]))>>exp;
238 MUL_R(((QMF_RE(buffer[ offset-1][bd]))>>exp), ((QMF_RE(buffer[ offset-2][bd]))>>exp)); 231 RE(ac->r12) = r01 - MUL_R(tmp1, tmp1) + MUL_R(tmp2, tmp2);
239 RE(ac->r22) = r11 - 232
240 MUL_R(((QMF_RE(buffer[len+offset-2][bd]))>>exp), ((QMF_RE(buffer[len+offset-2][bd]))>>exp)) + 233 tmp1 = (QMF_RE(buffer[len+offset-2][bd]))>>exp;
241 MUL_R(((QMF_RE(buffer[ offset-2][bd]))>>exp), ((QMF_RE(buffer[ offset-2][bd]))>>exp)); 234 tmp2 = (QMF_RE(buffer[ offset-2][bd]))>>exp;
235 RE(ac->r22) = r11 - MUL_R(tmp1, tmp1) + MUL_R(tmp2, tmp2);
242#else 236#else
243 for (j = offset; j < len + offset; j++) 237 for (j = offset; j < len + offset; j++)
244 { 238 {
@@ -246,12 +240,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
246 r02 += QMF_RE(buffer[j ][bd]) * QMF_RE(buffer[j-2][bd]); 240 r02 += QMF_RE(buffer[j ][bd]) * QMF_RE(buffer[j-2][bd]);
247 r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]); 241 r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
248 } 242 }
249 RE(ac->r12) = r01 - 243 tmp1 = (QMF_RE(buffer[len+offset-1][bd]));
250 QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) + 244 tmp2 = (QMF_RE(buffer[ offset-1][bd]));
251 QMF_RE(buffer[ offset-1][bd]) * QMF_RE(buffer[ offset-2][bd]); 245 RE(ac->r12) = r01 - tmp1*tmp1 + tmp2*tmp2;
252 RE(ac->r22) = r11 - 246
253 QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) + 247 tmp1 = (QMF_RE(buffer[len+offset-2][bd]));
254 QMF_RE(buffer[ offset-2][bd]) * QMF_RE(buffer[ offset-2][bd]); 248 tmp2 = (QMF_RE(buffer[ offset-2][bd]));
249 RE(ac->r22) = r11 - tmp1*tmp1 + tmp2*tmp2;
255#endif 250#endif
256 RE(ac->r01) = r01; 251 RE(ac->r01) = r01;
257 RE(ac->r02) = r02; 252 RE(ac->r02) = r02;
@@ -313,30 +308,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
313 r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i); 308 r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
314 } 309 }
315 310
316 // These are actual values in temporary variable at this point 311 RE(ac->r12) = r01r - (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
317 // temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp; 312 (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
318 // temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp; 313 IM(ac->r12) = r01i - (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
319 // temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp; 314 (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
320 // temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp; 315 RE(ac->r22) = r11r - (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
321 // temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp; 316 (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
322 // temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
323 // temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
324 // temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
325 // temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
326 // temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
327
328 RE(ac->r12) = r01r -
329 (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
330 (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
331 IM(ac->r12) = r01i -
332 (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
333 (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
334 RE(ac->r22) = r11r -
335 (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
336 (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
337
338#else 317#else
339
340 temp2_r = QMF_RE(buffer[offset-2][bd]); 318 temp2_r = QMF_RE(buffer[offset-2][bd]);
341 temp2_i = QMF_IM(buffer[offset-2][bd]); 319 temp2_i = QMF_IM(buffer[offset-2][bd]);
342 temp3_r = QMF_RE(buffer[offset-1][bd]); 320 temp3_r = QMF_RE(buffer[offset-1][bd]);
@@ -349,10 +327,10 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
349 327
350 for (j = offset; j < len + offset; j++) 328 for (j = offset; j < len + offset; j++)
351 { 329 {
352 temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd]; 330 temp1_r = temp2_r;
353 temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd]; 331 temp1_i = temp2_i;
354 temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd]; 332 temp2_r = temp3_r;
355 temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd]; 333 temp2_i = temp3_i;
356 temp3_r = QMF_RE(buffer[j][bd]); 334 temp3_r = QMF_RE(buffer[j][bd]);
357 temp3_i = QMF_IM(buffer[j][bd]); 335 temp3_i = QMF_IM(buffer[j][bd]);
358 r01r += temp3_r * temp2_r + temp3_i * temp2_i; 336 r01r += temp3_r * temp2_r + temp3_i * temp2_i;
@@ -362,30 +340,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
362 r11r += temp2_r * temp2_r + temp2_i * temp2_i; 340 r11r += temp2_r * temp2_r + temp2_i * temp2_i;
363 } 341 }
364 342
365 // These are actual values in temporary variable at this point 343 RE(ac->r12) = r01r - (temp3_r * temp2_r + temp3_i * temp2_i) +
366 // temp1_r = QMF_RE(buffer[len+offset-1-2][bd]; 344 (temp5_r * temp4_r + temp5_i * temp4_i);
367 // temp1_i = QMF_IM(buffer[len+offset-1-2][bd]; 345 IM(ac->r12) = r01i - (temp3_i * temp2_r - temp3_r * temp2_i) +
368 // temp2_r = QMF_RE(buffer[len+offset-1-1][bd]; 346 (temp5_i * temp4_r - temp5_r * temp4_i);
369 // temp2_i = QMF_IM(buffer[len+offset-1-1][bd]; 347 RE(ac->r22) = r11r - (temp2_r * temp2_r + temp2_i * temp2_i) +
370 // temp3_r = QMF_RE(buffer[len+offset-1][bd]); 348 (temp4_r * temp4_r + temp4_i * temp4_i);
371 // temp3_i = QMF_IM(buffer[len+offset-1][bd]);
372 // temp4_r = QMF_RE(buffer[offset-2][bd]);
373 // temp4_i = QMF_IM(buffer[offset-2][bd]);
374 // temp5_r = QMF_RE(buffer[offset-1][bd]);
375 // temp5_i = QMF_IM(buffer[offset-1][bd]);
376
377 RE(ac->r12) = r01r -
378 (temp3_r * temp2_r + temp3_i * temp2_i) +
379 (temp5_r * temp4_r + temp5_i * temp4_i);
380 IM(ac->r12) = r01i -
381 (temp3_i * temp2_r - temp3_r * temp2_i) +
382 (temp5_i * temp4_r - temp5_r * temp4_i);
383 RE(ac->r22) = r11r -
384 (temp2_r * temp2_r + temp2_i * temp2_i) +
385 (temp4_r * temp4_r + temp4_i * temp4_i);
386
387#endif 349#endif
388
389 RE(ac->r01) = r01r; 350 RE(ac->r01) = r01r;
390 IM(ac->r01) = r01i; 351 IM(ac->r01) = r01i;
391 RE(ac->r02) = r02r; 352 RE(ac->r02) = r02r;
diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c
index 3759329c3c..6008c72b11 100644
--- a/apps/codecs/libfaad/sbr_qmf.c
+++ b/apps/codecs/libfaad/sbr_qmf.c
@@ -44,7 +44,7 @@
44 #define FAAD_ANALYSIS_SCALE2(X) ((X)) 44 #define FAAD_ANALYSIS_SCALE2(X) ((X))
45 #define FAAD_ANALYSIS_SCALE3(X) ((X)) 45 #define FAAD_ANALYSIS_SCALE3(X) ((X))
46#else 46#else
47 #define FAAD_ANALYSIS_SCALE1(X) ((X)*scale) 47 #define FAAD_SYNTHESIS_SCALE(X) ((X)*scale)
48 #define FAAD_ANALYSIS_SCALE1(X) ((X)) 48 #define FAAD_ANALYSIS_SCALE1(X) ((X))
49 #define FAAD_ANALYSIS_SCALE2(X) (2.*(X)) 49 #define FAAD_ANALYSIS_SCALE2(X) (2.*(X))
50 #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0) 50 #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0)