aboutsummaryrefslogtreecommitdiffstats
path: root/libAACdec/src/ldfiltbank.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-01 14:25:25 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-01 14:25:25 +0200
commite778887e4e5589528b06b04404ce4c71aaae267a (patch)
treefcce7bfb237a99ac174e16611f39bf363f6b280c /libAACdec/src/ldfiltbank.cpp
parent97182034e8829014bdfc0449c2116d629196f1d4 (diff)
parent801f67f671929311e0c9952c5f92d6e147c7b003 (diff)
downloadfdk-aac-e778887e4e5589528b06b04404ce4c71aaae267a.tar.gz
fdk-aac-e778887e4e5589528b06b04404ce4c71aaae267a.tar.bz2
fdk-aac-e778887e4e5589528b06b04404ce4c71aaae267a.zip
Merge v2.0.2 into dabplus2
Diffstat (limited to 'libAACdec/src/ldfiltbank.cpp')
-rw-r--r--libAACdec/src/ldfiltbank.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/libAACdec/src/ldfiltbank.cpp b/libAACdec/src/ldfiltbank.cpp
index c7d2928..13e61a5 100644
--- a/libAACdec/src/ldfiltbank.cpp
+++ b/libAACdec/src/ldfiltbank.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -112,17 +112,20 @@ amm-info@iis.fraunhofer.de
#if defined(__arm__)
#endif
-static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
+static void multE2_DinvF_fdk(PCM_DEC *output, FIXP_DBL *x, const FIXP_WTB *fb,
FIXP_DBL *z, const int N) {
int i;
- /* scale for FIXP_DBL -> INT_PCM conversion. */
- const int scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM;
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
+ /* scale for FIXP_DBL -> PCM_DEC conversion: */
+ const int scale = (DFRACT_BITS - PCM_OUT_BITS) - LDFB_HEADROOM + (3);
+
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
FIXP_DBL rnd_val_wts0 = (FIXP_DBL)0;
FIXP_DBL rnd_val_wts1 = (FIXP_DBL)0;
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - WTS0 - 1) > 0)
if (-WTS0 - 1 + scale)
rnd_val_wts0 = (FIXP_DBL)(1 << (-WTS0 - 1 + scale - 1));
+#endif
if (-WTS1 - 1 + scale)
rnd_val_wts1 = (FIXP_DBL)(1 << (-WTS1 - 1 + scale - 1));
#endif
@@ -131,24 +134,26 @@ static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
FIXP_DBL z0, z2, tmp;
z2 = x[N / 2 + i];
- z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
+ z0 = fAddSaturate(z2,
+ (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)));
- z[N / 2 + i] = x[N / 2 - 1 - i] +
- (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
+ z[N / 2 + i] = fAddSaturate(
+ x[N / 2 - 1 - i],
+ (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1)));
tmp = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
FDK_ASSERT((-WTS1 - 1 + scale) >= 0);
FDK_ASSERT(tmp <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
- output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
+ output[(N * 3 / 4 - 1 - i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
tmp + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT((WTS1 + 1 - scale) >= 0);
output[(N * 3 / 4 - 1 - i)] =
- (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
+ (PCM_DEC)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif
z[i] = z0;
@@ -159,32 +164,34 @@ static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
FIXP_DBL z0, z2, tmp0, tmp1;
z2 = x[N / 2 + i];
- z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
+ z0 = fAddSaturate(z2,
+ (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)));
- z[N / 2 + i] = x[N / 2 - 1 - i] +
- (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
+ z[N / 2 + i] = fAddSaturate(
+ x[N / 2 - 1 - i],
+ (fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1)));
tmp0 = (fMultDiv2(z[N / 2 + i], fb[N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N / 2 + i]));
tmp1 = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts0)); /* rounding must not cause overflow */
FDK_ASSERT(tmp1 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
- output[(i - N / 4)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
+ output[(i - N / 4)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
- output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
+ output[(N * 3 / 4 - 1 - i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
tmp1 + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(i - N / 4)] =
- (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
+ (PCM_DEC)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
output[(N * 3 / 4 - 1 - i)] =
- (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
+ (PCM_DEC)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif
z[i] = z0;
z[N + i] = z2;
@@ -194,22 +201,22 @@ static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
for (i = 0; i < N / 4; i++) {
FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N / 2 + i]);
-#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
+#if ((DFRACT_BITS - PCM_OUT_BITS - LDFB_HEADROOM + (3) - 1) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts0)); /* rounding must not cause overflow */
- output[(N * 3 / 4 + i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
+ output[(N * 3 / 4 + i)] = (PCM_DEC)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(N * 3 / 4 + i)] =
- (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
+ (PCM_DEC)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
#endif
}
}
int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctData, const int mdctData_e,
- FIXP_PCM *output, FIXP_DBL *fs_buffer,
+ PCM_DEC *output, FIXP_DBL *fs_buffer,
const int N) {
const FIXP_WTB *coef;
FIXP_DBL gain = (FIXP_DBL)0;