aboutsummaryrefslogtreecommitdiffstats
path: root/libSACdec/src/sac_dec.cpp
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2019-12-19 17:28:15 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2020-02-14 10:53:51 -0800
commite016635f0d3a5c7532b00711ce461f97a13f7bc2 (patch)
tree44d6676c2975eec965bb3e6c2562e1632eaf4385 /libSACdec/src/sac_dec.cpp
parent57c9355de0269afb462ad4a8aa8814f6a6486ff1 (diff)
downloadfdk-aac-e016635f0d3a5c7532b00711ce461f97a13f7bc2.tar.gz
fdk-aac-e016635f0d3a5c7532b00711ce461f97a13f7bc2.tar.bz2
fdk-aac-e016635f0d3a5c7532b00711ce461f97a13f7bc2.zip
Avoid decoder internal clipping by converting the whole audio sample data path from 16 to 32 bit data width (FDKdec v3.2.0).
Bug: 149514474 Test: atest DecoderTestXheAac DecoderTestAacDrc Change-Id: I8a504ab709e42e27a61fe29840212953742283a5
Diffstat (limited to 'libSACdec/src/sac_dec.cpp')
-rw-r--r--libSACdec/src/sac_dec.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/libSACdec/src/sac_dec.cpp b/libSACdec/src/sac_dec.cpp
index c1832f1..a7b50df 100644
--- a/libSACdec/src/sac_dec.cpp
+++ b/libSACdec/src/sac_dec.cpp
@@ -766,7 +766,7 @@ SACDEC_ERROR FDK_SpatialDecInit(spatialDec *self, SPATIAL_BS_FRAME *frame,
/* output scaling */
for (nCh = 0; nCh < self->numOutputChannelsAT; nCh++) {
- int outputScale = 0, outputGain_e = 0, scale = 0;
+ int outputScale = 0, outputGain_e = 0, scale = -(8) + (1);
FIXP_DBL outputGain_m = getChGain(self, nCh, &outputGain_e);
if (!isTwoChMode(self->upmixType) && !bypassMode) {
@@ -775,7 +775,7 @@ SACDEC_ERROR FDK_SpatialDecInit(spatialDec *self, SPATIAL_BS_FRAME *frame,
synthesis qmf */
}
- scale = outputScale;
+ scale += outputScale;
qmfChangeOutScalefactor(&self->pQmfDomain->QmfDomainOut[nCh].fb, scale);
qmfChangeOutGain(&self->pQmfDomain->QmfDomainOut[nCh].fb, outputGain_m,
@@ -1223,18 +1223,24 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
!(self->stereoConfigIndex == 3)) {
for (i = 0; i < self->qmfBands; i++) {
self_qmfResidualReal__FDK_0_0[i] =
- fMult(self_qmfResidualReal__FDK_0_0[i] << 1,
+ fMult(scaleValueSaturate(self_qmfResidualReal__FDK_0_0[i],
+ 1 + self->sacInDataHeadroom - (1)),
self->clipProtectGain__FDK);
self_qmfResidualImag__FDK_0_0[i] =
- fMult(self_qmfResidualImag__FDK_0_0[i] << 1,
+ fMult(scaleValueSaturate(self_qmfResidualImag__FDK_0_0[i],
+ 1 + self->sacInDataHeadroom - (1)),
self->clipProtectGain__FDK);
}
} else {
for (i = 0; i < self->qmfBands; i++) {
- self_qmfResidualReal__FDK_0_0[i] = fMult(
- self_qmfResidualReal__FDK_0_0[i], self->clipProtectGain__FDK);
- self_qmfResidualImag__FDK_0_0[i] = fMult(
- self_qmfResidualImag__FDK_0_0[i], self->clipProtectGain__FDK);
+ self_qmfResidualReal__FDK_0_0[i] =
+ fMult(scaleValueSaturate(self_qmfResidualReal__FDK_0_0[i],
+ self->sacInDataHeadroom - (1)),
+ self->clipProtectGain__FDK);
+ self_qmfResidualImag__FDK_0_0[i] =
+ fMult(scaleValueSaturate(self_qmfResidualImag__FDK_0_0[i],
+ self->sacInDataHeadroom - (1)),
+ self->clipProtectGain__FDK);
}
}
}
@@ -1416,6 +1422,7 @@ SACDEC_ERROR SpatialDecApplyFrame(
FDK_ASSERT(self != NULL);
FDK_ASSERT(pControlFlags != NULL);
FDK_ASSERT(pcmOutBuf != NULL);
+ FDK_ASSERT(self->sacInDataHeadroom >= (1));
self->errInt = err; /* Init internal error */