summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-09-14 06:03:39 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-09-14 06:03:39 +0000
commitcba9d259b05a88302a78669cba0953ba0c98274d (patch)
treec0315cb6619437b2021d7210c365e2630d345f57 /apps
parentf24e130017b1bac8b99134f597cfa5549273a0e9 (diff)
Further libfaad cleanup. Make libfaad compilable for floating point. Floating point cannot be used as reference though, as errorous noise is the result.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28071 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-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;
/* Use if target platform has address generators with autoincrement */
//#define PREFER_POINTERS
-#ifdef _WIN32_WCE
-#define FIXED_POINT
-#endif
-
-
#define ERROR_RESILIENCE
@@ -328,7 +323,7 @@ char *strchr(), *strrchr();
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
}
-
+/* rockbox: must be commented to build for non-FP
#if defined(_WIN32) && !defined(__MINGW32__)
#define HAS_LRINTF
static INLINE int lrintf(float f)
@@ -355,7 +350,7 @@ char *strchr(), *strrchr();
return i;
}
#endif
-
+*/
#ifdef __ICL /* only Intel C compiler has fmath ??? */
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],
#endif
#ifdef SBR_LOW_POWER
- QMF_RE(Xhigh[l + offset][k]) =
- temp3_r
- +(MUL_R(a0_r, temp2_r) +
- MUL_R(a1_r, temp1_r));
+ QMF_RE(Xhigh[l + offset][k]) = temp3_r +
+ (MUL_R(a0_r, temp2_r) + MUL_R(a1_r, temp1_r));
#else
- QMF_RE(Xhigh[l + offset][k]) =
- temp3_r
- +(MUL_R(a0_r, temp2_r) -
- MUL_R(a0_i, temp2_i) +
- MUL_R(a1_r, temp1_r) -
- MUL_R(a1_i, temp1_i));
- QMF_IM(Xhigh[l + offset][k]) =
- temp3_i
- +(MUL_R(a0_i, temp2_r) +
- MUL_R(a0_r, temp2_i) +
- MUL_R(a1_i, temp1_r) +
- MUL_R(a1_r, temp1_i));
+ QMF_RE(Xhigh[l + offset][k]) = temp3_r +
+ (MUL_R(a0_r, temp2_r) - MUL_R(a0_i, temp2_i) +
+ MUL_R(a1_r, temp1_r) - MUL_R(a1_i, temp1_i));
+ QMF_IM(Xhigh[l + offset][k]) = temp3_i +
+ (MUL_R(a0_i, temp2_r) + MUL_R(a0_r, temp2_i) +
+ MUL_R(a1_i, temp1_r) + MUL_R(a1_r, temp1_i));
#endif
}
} else {
@@ -199,6 +191,7 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
uint8_t bd, uint8_t len)
{
real_t r01 = 0, r02 = 0, r11 = 0;
+ real_t tmp1, tmp2;
int8_t j;
uint8_t offset = sbr->tHFAdj;
#ifdef FIXED_POINT
@@ -233,12 +226,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
r02 += MUL_R(buf_j , buf_j_2);
r11 += MUL_R(buf_j_1, buf_j_1);
}
- RE(ac->r12) = r01 -
- MUL_R(((QMF_RE(buffer[len+offset-1][bd]))>>exp), ((QMF_RE(buffer[len+offset-2][bd]))>>exp)) +
- MUL_R(((QMF_RE(buffer[ offset-1][bd]))>>exp), ((QMF_RE(buffer[ offset-2][bd]))>>exp));
- RE(ac->r22) = r11 -
- MUL_R(((QMF_RE(buffer[len+offset-2][bd]))>>exp), ((QMF_RE(buffer[len+offset-2][bd]))>>exp)) +
- MUL_R(((QMF_RE(buffer[ offset-2][bd]))>>exp), ((QMF_RE(buffer[ offset-2][bd]))>>exp));
+ tmp1 = (QMF_RE(buffer[len+offset-1][bd]))>>exp;
+ tmp2 = (QMF_RE(buffer[ offset-1][bd]))>>exp;
+ RE(ac->r12) = r01 - MUL_R(tmp1, tmp1) + MUL_R(tmp2, tmp2);
+
+ tmp1 = (QMF_RE(buffer[len+offset-2][bd]))>>exp;
+ tmp2 = (QMF_RE(buffer[ offset-2][bd]))>>exp;
+ RE(ac->r22) = r11 - MUL_R(tmp1, tmp1) + MUL_R(tmp2, tmp2);
#else
for (j = offset; j < len + offset; j++)
{
@@ -246,12 +240,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
r02 += QMF_RE(buffer[j ][bd]) * QMF_RE(buffer[j-2][bd]);
r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
}
- RE(ac->r12) = r01 -
- QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
- QMF_RE(buffer[ offset-1][bd]) * QMF_RE(buffer[ offset-2][bd]);
- RE(ac->r22) = r11 -
- QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
- QMF_RE(buffer[ offset-2][bd]) * QMF_RE(buffer[ offset-2][bd]);
+ tmp1 = (QMF_RE(buffer[len+offset-1][bd]));
+ tmp2 = (QMF_RE(buffer[ offset-1][bd]));
+ RE(ac->r12) = r01 - tmp1*tmp1 + tmp2*tmp2;
+
+ tmp1 = (QMF_RE(buffer[len+offset-2][bd]));
+ tmp2 = (QMF_RE(buffer[ offset-2][bd]));
+ RE(ac->r22) = r11 - tmp1*tmp1 + tmp2*tmp2;
#endif
RE(ac->r01) = r01;
RE(ac->r02) = r02;
@@ -313,30 +308,13 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
}
- // These are actual values in temporary variable at this point
- // temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
- // temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
- // temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
- // temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
- // temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
- // temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
- // temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
- // temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
- // temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
- // temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
-
- RE(ac->r12) = r01r -
- (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
- (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
- IM(ac->r12) = r01i -
- (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
- (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
- RE(ac->r22) = r11r -
- (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
- (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
-
+ RE(ac->r12) = r01r - (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
+ (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
+ IM(ac->r12) = r01i - (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
+ (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
+ RE(ac->r22) = r11r - (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
+ (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
#else
-
temp2_r = QMF_RE(buffer[offset-2][bd]);
temp2_i = QMF_IM(buffer[offset-2][bd]);
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
for (j = offset; j < len + offset; j++)
{
- temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
- temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
- temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
- temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
+ temp1_r = temp2_r;
+ temp1_i = temp2_i;
+ temp2_r = temp3_r;
+ temp2_i = temp3_i;
temp3_r = QMF_RE(buffer[j][bd]);
temp3_i = QMF_IM(buffer[j][bd]);
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
r11r += temp2_r * temp2_r + temp2_i * temp2_i;
}
- // These are actual values in temporary variable at this point
- // temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
- // temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
- // temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
- // temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
- // temp3_r = QMF_RE(buffer[len+offset-1][bd]);
- // temp3_i = QMF_IM(buffer[len+offset-1][bd]);
- // temp4_r = QMF_RE(buffer[offset-2][bd]);
- // temp4_i = QMF_IM(buffer[offset-2][bd]);
- // temp5_r = QMF_RE(buffer[offset-1][bd]);
- // temp5_i = QMF_IM(buffer[offset-1][bd]);
-
- RE(ac->r12) = r01r -
- (temp3_r * temp2_r + temp3_i * temp2_i) +
- (temp5_r * temp4_r + temp5_i * temp4_i);
- IM(ac->r12) = r01i -
- (temp3_i * temp2_r - temp3_r * temp2_i) +
- (temp5_i * temp4_r - temp5_r * temp4_i);
- RE(ac->r22) = r11r -
- (temp2_r * temp2_r + temp2_i * temp2_i) +
- (temp4_r * temp4_r + temp4_i * temp4_i);
-
+ RE(ac->r12) = r01r - (temp3_r * temp2_r + temp3_i * temp2_i) +
+ (temp5_r * temp4_r + temp5_i * temp4_i);
+ IM(ac->r12) = r01i - (temp3_i * temp2_r - temp3_r * temp2_i) +
+ (temp5_i * temp4_r - temp5_r * temp4_i);
+ RE(ac->r22) = r11r - (temp2_r * temp2_r + temp2_i * temp2_i) +
+ (temp4_r * temp4_r + temp4_i * temp4_i);
#endif
-
RE(ac->r01) = r01r;
IM(ac->r01) = r01i;
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 @@
#define FAAD_ANALYSIS_SCALE2(X) ((X))
#define FAAD_ANALYSIS_SCALE3(X) ((X))
#else
- #define FAAD_ANALYSIS_SCALE1(X) ((X)*scale)
+ #define FAAD_SYNTHESIS_SCALE(X) ((X)*scale)
#define FAAD_ANALYSIS_SCALE1(X) ((X))
#define FAAD_ANALYSIS_SCALE2(X) (2.*(X))
#define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0)