aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libAACdec/src/aacdecoder.cpp14
-rw-r--r--libAACdec/src/stereo.cpp40
-rw-r--r--libAACdec/src/usacdec_acelp.cpp4
-rw-r--r--libAACdec/src/usacdec_lpc.cpp36
-rw-r--r--libMpegTPDec/src/tpdec_latm.cpp6
5 files changed, 48 insertions, 52 deletions
diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp
index b15fc80..6b5a86c 100644
--- a/libAACdec/src/aacdecoder.cpp
+++ b/libAACdec/src/aacdecoder.cpp
@@ -3388,7 +3388,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
* LR) */
if ((aacChannels == 2) && bsPseudoLr) {
int i, offset2;
- const FIXP_SGL invSqrt2 = FL2FXCONST_SGL(0.707106781186547f);
+ const FIXP_SGL invSqrt2 =
+ FL2FXCONST_SGL(0.353553390593273f); /* scaled by -1 */
FIXP_PCM *pTD = pTimeData;
offset2 = timeDataChannelOffset;
@@ -3399,11 +3400,14 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
L = fMult(L, invSqrt2);
R = fMult(R, invSqrt2);
#if (SAMPLE_BITS == 16)
- pTD[0] = FX_DBL2FX_PCM(fAddSaturate(L + R, (FIXP_DBL)0x8000));
- pTD[offset2] = FX_DBL2FX_PCM(fAddSaturate(L - R, (FIXP_DBL)0x8000));
+ pTD[0] = (FIXP_SGL)SATURATE_RIGHT_SHIFT(L + R + (FIXP_DBL)(1 << 14),
+ 15, FRACT_BITS);
+ pTD[offset2] = (FIXP_SGL)SATURATE_RIGHT_SHIFT(
+ L - R + (FIXP_DBL)(1 << 14), 15, FRACT_BITS);
#else
- pTD[0] = FX_DBL2FX_PCM(L + R);
- pTD[offset2] = FX_DBL2FX_PCM(L - R);
+ pTD[0] = SATURATE_LEFT_SHIFT(FX_DBL2FX_PCM(L + R), 1, DFRACT_BITS);
+ pTD[offset2] =
+ SATURATE_LEFT_SHIFT(FX_DBL2FX_PCM(L - R), 1, DFRACT_BITS);
#endif
pTD++;
}
diff --git a/libAACdec/src/stereo.cpp b/libAACdec/src/stereo.cpp
index a90ae35..47f1a31 100644
--- a/libAACdec/src/stereo.cpp
+++ b/libAACdec/src/stereo.cpp
@@ -989,7 +989,7 @@ void CJointStereo_ApplyMS(
} /* if ( pJointStereoData->complex_coef == 1 ) */
/* 4. upmix process */
- INT pred_dir = cplxPredictionData->pred_dir ? -1 : 1;
+ LONG pred_dir = cplxPredictionData->pred_dir ? -1 : 1;
/* 0.1 in Q-3.34 */
const FIXP_DBL pointOne = 0x66666666; /* 0.8 */
/* Shift value for the downmix */
@@ -1039,34 +1039,24 @@ void CJointStereo_ApplyMS(
the downmix. "dmx_re" and "specL" are two different pointers
pointing to separate arrays, which may or may not contain the
same data (with different scaling).
- */
-
- /* help1: alpha_re[i] * dmx_re[i] */
- FIXP_DBL help1 = fMultDiv2(alpha_re_tmp, *p2dmxRe++);
-
- /* tmp: dmx_im[i] */
- FIXP_DBL tmp = (*p2dmxIm++) << shift_dmx;
- /* help2: alpha_im[i] * dmx_im[i] */
- FIXP_DBL help2 = fMultDiv2(alpha_im_tmp, tmp);
-
- /* help3: alpha_re[i] * dmx_re[i] + alpha_im[i] * dmx_im[i] */
- FIXP_DBL help3 = help1 + help2;
+ specL[i] = + (specL[i] + side);
+ specR[i] = -/+ (specL[i] - side);
+ */
+ FIXP_DBL side, left, right;
- /* side (= help4) = specR[i] - (dmx_re[i] * specL[i] + alpha_im[i]
- * * dmx_im[i]) */
- FIXP_DBL help4 = *p2CoeffR - scaleValue(help3, help3_shift);
+ side = fMultAddDiv2(fMultDiv2(alpha_re_tmp, *p2dmxRe++),
+ alpha_im_tmp, (*p2dmxIm++) << shift_dmx);
+ side = ((*p2CoeffR) >> 2) -
+ (FIXP_DBL)SATURATE_SHIFT(side, -(help3_shift - 2),
+ DFRACT_BITS - 2);
- /* We calculate the left and right output by using the helper
- * function */
- /* specR[i] = -/+ (specL[i] - side); */
- *p2CoeffR =
- (FIXP_DBL)((LONG)(*p2CoeffL - help4) * (LONG)pred_dir);
- p2CoeffR++;
+ left = ((*p2CoeffL) >> 2) + side;
+ right = ((*p2CoeffL) >> 2) - side;
+ right = (FIXP_DBL)((LONG)right * pred_dir);
- /* specL[i] = specL[i] + side; */
- *p2CoeffL = *p2CoeffL + help4;
- p2CoeffL++;
+ *p2CoeffL++ = SATURATE_LEFT_SHIFT_ALT(left, 2, DFRACT_BITS);
+ *p2CoeffR++ = SATURATE_LEFT_SHIFT_ALT(right, 2, DFRACT_BITS);
}
}
diff --git a/libAACdec/src/usacdec_acelp.cpp b/libAACdec/src/usacdec_acelp.cpp
index c836c6a..1ac8c9f 100644
--- a/libAACdec/src/usacdec_acelp.cpp
+++ b/libAACdec/src/usacdec_acelp.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
@@ -131,7 +131,7 @@ void E_UTIL_preemph(const FIXP_DBL *in, FIXP_DBL *out, INT L) {
int i;
for (i = 0; i < L; i++) {
- out[i] = in[i] - fMult(PREEMPH_FAC, in[i - 1]);
+ out[i] = fAddSaturate(in[i], -fMult(PREEMPH_FAC, in[i - 1]));
}
return;
diff --git a/libAACdec/src/usacdec_lpc.cpp b/libAACdec/src/usacdec_lpc.cpp
index 271463f..88601b7 100644
--- a/libAACdec/src/usacdec_lpc.cpp
+++ b/libAACdec/src/usacdec_lpc.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
@@ -231,7 +231,7 @@ void nearest_neighbor_2D8(FIXP_ZF x[8], int y[8]) {
void RE8_PPV(FIXP_ZF x[], SHORT y[], int r) {
int i, y0[8], y1[8];
FIXP_ZF x1[8], tmp;
- FIXP_DBL e;
+ INT64 e;
/* find the nearest neighbor y0 of x in 2D8 */
nearest_neighbor_2D8(x, y0);
@@ -245,16 +245,16 @@ void RE8_PPV(FIXP_ZF x[], SHORT y[], int r) {
}
/* compute e0=||x-y0||^2 and e1=||x-y1||^2 */
- e = (FIXP_DBL)0;
+ e = 0;
for (i = 0; i < 8; i++) {
tmp = x[i] - INT2ZF(y0[i], 0);
- e += fPow2Div2(
+ e += (INT64)fPow2Div2(
tmp << r); /* shift left to ensure that no fract part bits get lost. */
tmp = x[i] - INT2ZF(y1[i], 0);
- e -= fPow2Div2(tmp << r);
+ e -= (INT64)fPow2Div2(tmp << r);
}
/* select best candidate y0 or y1 to minimize distortion */
- if (e < (FIXP_DBL)0) {
+ if (e < 0) {
for (i = 0; i < 8; i++) {
y[i] = y0[i];
}
@@ -565,7 +565,8 @@ static void lsf_weight_2st(FIXP_LPC *lsfq, FIXP_DBL *xq, int nk_mode) {
/* add non-weighted residual LSF vector to LSF1st */
for (i = 0; i < M_LP_FILTER_ORDER; i++) {
w = (LONG)fMultDiv2(factor, sqrtFixp(fMult(d[i], d[i + 1])));
- lsfq[i] = fAddSaturate(lsfq[i], FX_DBL2FX_LPC((FIXP_DBL)(w * (LONG)xq[i])));
+ lsfq[i] = fAddSaturate(lsfq[i],
+ FX_DBL2FX_LPC((FIXP_DBL)((INT64)w * (LONG)xq[i])));
}
return;
@@ -1138,9 +1139,12 @@ static void get_lsppol(FIXP_LPC lsp[], FIXP_DBL f[], int n, int flag) {
for (i = 2; i <= n; i++) {
plsp += 2;
b = -FX_LPC2FX_DBL(*plsp);
- f[i] = ((fMultDiv2(b, f[i - 1]) << 1) + (f[i - 2])) << 1;
+ f[i] = SATURATE_LEFT_SHIFT((fMultDiv2(b, f[i - 1]) + (f[i - 2] >> 1)), 2,
+ DFRACT_BITS);
for (j = i - 1; j > 1; j--) {
- f[j] = f[j] + (fMultDiv2(b, f[j - 1]) << 2) + f[j - 2];
+ f[j] = SATURATE_LEFT_SHIFT(
+ ((f[j] >> 2) + fMultDiv2(b, f[j - 1]) + (f[j - 2] >> 2)), 2,
+ DFRACT_BITS);
}
f[1] = f[1] + (b >> (SF_F - 1));
}
@@ -1167,6 +1171,9 @@ void E_LPC_f_lsp_a_conversion(FIXP_LPC *lsp, FIXP_LPC *a, INT *a_exp) {
/*-----------------------------------------------------*
* Multiply F1(z) by (1+z^-1) and F2(z) by (1-z^-1) *
*-----------------------------------------------------*/
+ scaleValues(f1, NC + 1, -2);
+ scaleValues(f2, NC + 1, -2);
+
for (i = NC; i > 0; i--) {
f1[i] += f1[i - 1];
f2[i] -= f2[i - 1];
@@ -1175,13 +1182,8 @@ void E_LPC_f_lsp_a_conversion(FIXP_LPC *lsp, FIXP_LPC *a, INT *a_exp) {
FIXP_DBL aDBL[M_LP_FILTER_ORDER];
for (i = 1, k = M_LP_FILTER_ORDER - 1; i <= NC; i++, k--) {
- FIXP_DBL tmp1, tmp2;
-
- tmp1 = f1[i] >> 1;
- tmp2 = f2[i] >> 1;
-
- aDBL[i - 1] = (tmp1 + tmp2);
- aDBL[k] = (tmp1 - tmp2);
+ aDBL[i - 1] = f1[i] + f2[i];
+ aDBL[k] = f1[i] - f2[i];
}
int headroom_a = getScalefactor(aDBL, M_LP_FILTER_ORDER);
@@ -1190,5 +1192,5 @@ void E_LPC_f_lsp_a_conversion(FIXP_LPC *lsp, FIXP_LPC *a, INT *a_exp) {
a[i] = FX_DBL2FX_LPC(aDBL[i] << headroom_a);
}
- *a_exp = 8 - headroom_a;
+ *a_exp = SF_F + (2 - 1) - headroom_a;
}
diff --git a/libMpegTPDec/src/tpdec_latm.cpp b/libMpegTPDec/src/tpdec_latm.cpp
index 2edf055..3b71db8 100644
--- a/libMpegTPDec/src/tpdec_latm.cpp
+++ b/libMpegTPDec/src/tpdec_latm.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
@@ -367,10 +367,10 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig(
}
if (pLatmDemux->m_AudioMuxVersion == 1) {
FDK_BITSTREAM tmpBs;
- UINT ascLen = 0;
+ INT ascLen = 0;
ascLen = CLatmDemux_GetValue(bs);
/* The ascLen could be wrong, so check if validBits<=bufBits*/
- if (ascLen > FDKgetValidBits(bs)) {
+ if (ascLen < 0 || ascLen > (INT)FDKgetValidBits(bs)) {
ErrorStatus = TRANSPORTDEC_PARSE_ERROR;
goto bail;
}