aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2020-04-09 17:58:01 +0200
committerJean-Michel Trivi <jmtrivi@google.com>2020-12-28 09:21:16 -0800
commitd6a7375bfa25ebcdd47900e5f32958c6c8deb57f (patch)
tree619dc3a13ed725aaea25e49731c5f01d09406f44
parentbfd912da32b1253c9020a82d5520f1754dadcfc5 (diff)
downloadfdk-aac-d6a7375bfa25ebcdd47900e5f32958c6c8deb57f.tar.gz
fdk-aac-d6a7375bfa25ebcdd47900e5f32958c6c8deb57f.tar.bz2
fdk-aac-d6a7375bfa25ebcdd47900e5f32958c6c8deb57f.zip
Revise bypass mode in SpatialDecApplyParameterSets() to prevent an assert in fDivNorm().
Bug: 176246647 Test: atest android.media.cts.DecoderTestAacFormat android.media.cts.DecoderTestXheAac android.media.cts.DecoderTestAacDrc Change-Id: I198747688f1677b82f27a17a2fcf40229c92b1da
-rw-r--r--libSACdec/src/sac_dec.cpp61
1 files changed, 44 insertions, 17 deletions
diff --git a/libSACdec/src/sac_dec.cpp b/libSACdec/src/sac_dec.cpp
index a7b50df..f0d24fb 100644
--- a/libSACdec/src/sac_dec.cpp
+++ b/libSACdec/src/sac_dec.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -1098,6 +1098,28 @@ static void SpatialDecApplyBypass(spatialDec *self, FIXP_DBL **hybInputReal,
}
}
+/**
+ * \brief Set internal error and reset error status
+ *
+ * \param self spatialDec handle.
+ * \param bypassMode pointer to bypassMode.
+ * \param err error status.
+ *
+ * \return error status.
+ */
+static SACDEC_ERROR SpatialDecSetInternalError(spatialDec *self,
+ int *bypassMode,
+ SACDEC_ERROR err) {
+ *bypassMode = 1;
+
+ if (self->errInt == MPS_OK) {
+ /* store internal error before it gets overwritten */
+ self->errInt = err;
+ }
+
+ return MPS_OK;
+}
+
/*******************************************************************************
Functionname: SpatialDecApplyParameterSets
*******************************************************************************
@@ -1118,7 +1140,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
const FDK_channelMapDescr *const mapDescr) {
SACDEC_ERROR err = MPS_OK;
- FIXP_SGL alpha;
+ FIXP_SGL alpha = FL2FXCONST_SGL(0.0);
int ts;
int ch;
@@ -1141,20 +1163,22 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
ts++, ts_io++) {
int currSlot = frame->paramSlot[ps];
+ err = (currSlot < ts) ? MPS_WRONG_PARAMETERSETS : MPS_OK;
+ if (err != MPS_OK) {
+ err = SpatialDecSetInternalError(self, &bypassMode, err);
+ }
+
/*
* Get new parameter set
*/
if (ts == prevSlot + 1) {
- err = SpatialDecCalculateM1andM2(self, ps,
- frame); /* input: ottCLD, ottICC, ... */
- /* output: M1param(Real/Imag), M2(Real/Imag) */
- if (err != MPS_OK) {
- bypassMode = 1;
- if (self->errInt == MPS_OK) {
- /* store internal error befor it gets overwritten */
- self->errInt = err;
+ if (bypassMode == 0) {
+ err = SpatialDecCalculateM1andM2(
+ self, ps, frame); /* input: ottCLD, ottICC, ... */
+ /* output: M1param(Real/Imag), M2(Real/Imag) */
+ if (err != MPS_OK) {
+ err = SpatialDecSetInternalError(self, &bypassMode, err);
}
- err = MPS_OK;
}
if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) {
@@ -1168,13 +1192,16 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bOverwriteM1M2prev = 0;
}
- SpatialDecSmoothM1andM2(
- self, frame,
- ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */
- /* output: M1param(Real/Imag), M2(Real/Imag) */
+ if (bypassMode == 0) {
+ SpatialDecSmoothM1andM2(
+ self, frame,
+ ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */
+ } /* output: M1param(Real/Imag), M2(Real/Imag) */
}
- alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot));
+ if (bypassMode == 0) {
+ alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot));
+ }
switch (mode) {
case INPUTMODE_QMF_SBR:
@@ -1360,7 +1387,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
} /* !self->tempShapeConfig == 1 */
} /* !bypassMode */
- if (self->phaseCoding == 1) {
+ if ((self->phaseCoding == 1) && (bypassMode == 0)) {
/* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */
SpatialDecApplyPhase(