aboutsummaryrefslogtreecommitdiffstats
path: root/libSACdec/src/sac_process.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_process.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_process.cpp')
-rw-r--r--libSACdec/src/sac_process.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/libSACdec/src/sac_process.cpp b/libSACdec/src/sac_process.cpp
index 95128f3..22091a9 100644
--- a/libSACdec/src/sac_process.cpp
+++ b/libSACdec/src/sac_process.cpp
@@ -187,8 +187,12 @@ SACDEC_ERROR SpatialDecQMFAnalysis(spatialDec *self, const PCM_MPS *inData,
if (!isTwoChMode(self->upmixType) && !bypassMode) {
int i;
for (i = 0; i < self->qmfBands; i++) {
- qmfReal[ch][i] = fMult(qmfReal[ch][i], self->clipProtectGain__FDK);
- qmfImag[ch][i] = fMult(qmfImag[ch][i], self->clipProtectGain__FDK);
+ qmfReal[ch][i] = fMult(
+ scaleValueSaturate(qmfReal[ch][i], self->sacInDataHeadroom - (1)),
+ self->clipProtectGain__FDK);
+ qmfImag[ch][i] = fMult(
+ scaleValueSaturate(qmfImag[ch][i], self->sacInDataHeadroom - (1)),
+ self->clipProtectGain__FDK);
}
}
}
@@ -216,16 +220,17 @@ SACDEC_ERROR SpatialDecFeedQMF(spatialDec *self, FIXP_DBL **qmfInDataReal,
/* Write Input data to pQmfRealAnalysis. */
if (self->bShareDelayWithSBR) {
- FDK_QmfDomain_GetSlot(
- &self->pQmfDomain->QmfDomainIn[ch], ts + HYBRID_FILTER_DELAY, 0,
- MAX_QMF_BANDS_TO_HYBRID, pQmfRealAnalysis, pQmfImagAnalysis, 15);
+ FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch],
+ ts + HYBRID_FILTER_DELAY, 0,
+ MAX_QMF_BANDS_TO_HYBRID, pQmfRealAnalysis,
+ pQmfImagAnalysis, 15 + (1));
FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch], ts,
MAX_QMF_BANDS_TO_HYBRID, self->qmfBands,
- pQmfRealAnalysis, pQmfImagAnalysis, 15);
+ pQmfRealAnalysis, pQmfImagAnalysis, 15 + (1));
} else {
FDK_QmfDomain_GetSlot(&self->pQmfDomain->QmfDomainIn[ch], ts, 0,
self->qmfBands, pQmfRealAnalysis,
- pQmfImagAnalysis, 15);
+ pQmfImagAnalysis, 15 + (1));
}
if (ts == self->pQmfDomain->globalConf.nQmfTimeSlots - 1) {
/* Is currently also needed in case we dont have any overlap. We need to
@@ -501,8 +506,8 @@ SACDEC_ERROR SpatialDecApplyM2_Mode212_ResidualsPlusPhaseCoding(
for (pb = 0, qs = 3; pb < 2; pb++) {
INT s;
FIXP_DBL maxVal;
- FIXP_SGL mReal1;
- FIXP_SGL mReal0, mImag0;
+ FIXP_DBL mReal1;
+ FIXP_DBL mReal0, mImag0;
FIXP_DBL iReal0, iImag0, iReal1;
iReal0 = interpolateParameter(alpha, MReal0[pb], MRealPrev0[pb]);
@@ -515,9 +520,9 @@ SACDEC_ERROR SpatialDecApplyM2_Mode212_ResidualsPlusPhaseCoding(
s = fMax(CntLeadingZeros(maxVal) - 1, 0);
s = fMin(s, scale_param_m2);
- mReal0 = FX_DBL2FX_SGL(iReal0 << s);
- mImag0 = FX_DBL2FX_SGL(iImag0 << s);
- mReal1 = FX_DBL2FX_SGL(iReal1 << s);
+ mReal0 = iReal0 << s;
+ mImag0 = iImag0 << s;
+ mReal1 = iReal1 << s;
s = scale_param_m2 - s;
@@ -934,6 +939,7 @@ SACDEC_ERROR SpatialDecSynthesis(spatialDec *self, const INT ts,
self->pQmfDomain->QmfDomainIn[outCh].scaling.lb_scale -=
self->clipProtectGainSF__FDK;
+ self->pQmfDomain->QmfDomainIn[outCh].scaling.lb_scale -= (1);
} else {
/* Call the QMF synthesis for dry. */
err = CalculateSpaceSynthesisQmf(&self->pQmfDomain->QmfDomainOut[outCh],