aboutsummaryrefslogtreecommitdiffstats
path: root/fdk-aac/libAACdec/src/usacdec_lpd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fdk-aac/libAACdec/src/usacdec_lpd.cpp')
-rw-r--r--fdk-aac/libAACdec/src/usacdec_lpd.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/fdk-aac/libAACdec/src/usacdec_lpd.cpp b/fdk-aac/libAACdec/src/usacdec_lpd.cpp
index e0a2631..fbf6fab 100644
--- a/fdk-aac/libAACdec/src/usacdec_lpd.cpp
+++ b/fdk-aac/libAACdec/src/usacdec_lpd.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
@@ -122,17 +122,21 @@ amm-info@iis.fraunhofer.de
#include "ac_arith_coder.h"
-void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
- const FIXP_SGL *filt, INT stop, int len) {
+void filtLP(const FIXP_DBL *syn, PCM_DEC *syn_out, FIXP_DBL *noise,
+ const FIXP_SGL *filt, const INT aacOutDataHeadroom, INT stop,
+ int len) {
INT i, j;
FIXP_DBL tmp;
+ FDK_ASSERT((aacOutDataHeadroom - 1) >= -(MDCT_OUTPUT_SCALE));
+
for (i = 0; i < stop; i++) {
tmp = fMultDiv2(noise[i], filt[0]); // Filt in Q-1.16
for (j = 1; j <= len; j++) {
- tmp += fMultDiv2((noise[i - j] + noise[i + j]), filt[j]);
+ tmp += fMult((noise[i - j] >> 1) + (noise[i + j] >> 1), filt[j]);
}
- syn_out[i] = (FIXP_PCM)(IMDCT_SCALE(syn[i] - tmp));
+ syn_out[i] = (PCM_DEC)(
+ IMDCT_SCALE((syn[i] >> 1) - (tmp >> 1), aacOutDataHeadroom - 1));
}
}
@@ -142,8 +146,10 @@ void bass_pf_1sf_delay(
FIXP_DBL *pit_gain,
const int frame_length, /* (i) : frame length (should be 768|1024) */
const INT l_frame,
- const INT l_next, /* (i) : look ahead for symmetric filtering */
- FIXP_PCM *synth_out, /* (o) : filtered synthesis (with delay of 1 subfr) */
+ const INT l_next, /* (i) : look ahead for symmetric filtering */
+ PCM_DEC *synth_out, /* (o) : filtered synthesis (with delay of 1 subfr) */
+ const INT aacOutDataHeadroom, /* (i) : headroom of the output time signal to
+ prevent clipping */
FIXP_DBL mem_bpf[]) /* i/o : memory state [L_FILT+L_SUBFR] */
{
INT i, sf, i_subfr, T, T2, lg;
@@ -335,17 +341,22 @@ void bass_pf_1sf_delay(
{
for (i = 0; i < lg; i++) {
- /* scaled with SF_SYNTH + gain_sf + 1 */
+ /* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
+ * one additional shift of syn values + fMult => fMultDiv2 */
noise_in[i] =
- (fMult(gainSGL, syn[i + i_subfr] - (syn[i + i_subfr - T] >> 1) -
- (syn[i + i_subfr + T] >> 1))) >>
- s1;
+ scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
+ (syn[i + i_subfr - T] >> 2) -
+ (syn[i + i_subfr + T] >> 2)),
+ 2 - s1);
}
for (i = lg; i < L_SUBFR; i++) {
- /* scaled with SF_SYNTH + gain_sf + 1 */
+ /* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
+ * one additional shift of syn values + fMult => fMultDiv2 */
noise_in[i] =
- (fMult(gainSGL, syn[i + i_subfr] - syn[i + i_subfr - T])) >> s1;
+ scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
+ (syn[i + i_subfr - T] >> 1)),
+ 2 - s1);
}
}
} else {
@@ -364,7 +375,7 @@ void bass_pf_1sf_delay(
{
filtLP(&syn[i_subfr - L_SUBFR], &synth_out[i_subfr], noise,
- fdk_dec_filt_lp, L_SUBFR, L_FILT);
+ fdk_dec_filt_lp, aacOutDataHeadroom, L_SUBFR, L_FILT);
}
}
@@ -377,9 +388,9 @@ void bass_pf_1sf_delay(
/* Output scaling of the BPF memory */
scaleValues(mem_bpf, (L_FILT + L_SUBFR), -1);
/* Copy the rest of the signal (after the fac) */
- scaleValuesSaturate((FIXP_PCM *)&synth_out[l_frame],
- (FIXP_DBL *)&syn[l_frame - L_SUBFR],
- (frame_length - l_frame), MDCT_OUT_HEADROOM);
+ scaleValuesSaturate(
+ (PCM_DEC *)&synth_out[l_frame], (FIXP_DBL *)&syn[l_frame - L_SUBFR],
+ (frame_length - l_frame), MDCT_OUT_HEADROOM - aacOutDataHeadroom);
}
return;
@@ -1222,7 +1233,7 @@ AAC_DECODER_ERROR CLpdChannelStream_Read(
(INT)(samplingRate * PIT_MIN_12k8 + (FSCALE_DENOM / 2)) / FSCALE_DENOM -
(INT)PIT_MIN_12k8;
- if ((samplingRate < 6000) || (samplingRate > 24000)) {
+ if ((samplingRate < FAC_FSCALE_MIN) || (samplingRate > FAC_FSCALE_MAX)) {
error = AAC_DEC_PARSE_ERROR;
goto bail;
}
@@ -1546,9 +1557,9 @@ void CLpdChannelStream_Decode(
AAC_DECODER_ERROR CLpd_RenderTimeSignal(
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
- CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM *pTimeData,
- INT lFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk, UINT flags,
- UINT strmFlags) {
+ CAacDecoderChannelInfo *pAacDecoderChannelInfo, PCM_DEC *pTimeData,
+ INT lFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk,
+ const INT aacOutDataHeadroom, UINT flags, UINT strmFlags) {
UCHAR *mod = pAacDecoderChannelInfo->data.usac.mod;
AAC_DECODER_ERROR error = AAC_DEC_OK;
int k, i_offset;
@@ -2011,7 +2022,8 @@ AAC_DECODER_ERROR CLpd_RenderTimeSignal(
{
bass_pf_1sf_delay(p2_synth, pitch, pit_gain, lFrame, lFrame / facFB,
mod[nbDiv - 1] ? (SynDelay - (lDiv / 2)) : SynDelay,
- pTimeData, pAacDecoderStaticChannelInfo->mem_bpf);
+ pTimeData, aacOutDataHeadroom,
+ pAacDecoderStaticChannelInfo->mem_bpf);
}
}