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
This commit is contained in:
Fraunhofer IIS FDK 2020-04-09 17:58:01 +02:00 committed by Ray Essick
parent 87e01ef1e7
commit a1a8f69b14
1 changed files with 44 additions and 17 deletions

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 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 Functionname: SpatialDecApplyParameterSets
******************************************************************************* *******************************************************************************
@ -1118,7 +1140,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
const FDK_channelMapDescr *const mapDescr) { const FDK_channelMapDescr *const mapDescr) {
SACDEC_ERROR err = MPS_OK; SACDEC_ERROR err = MPS_OK;
FIXP_SGL alpha; FIXP_SGL alpha = FL2FXCONST_SGL(0.0);
int ts; int ts;
int ch; int ch;
@ -1141,20 +1163,22 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
ts++, ts_io++) { ts++, ts_io++) {
int currSlot = frame->paramSlot[ps]; 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 * Get new parameter set
*/ */
if (ts == prevSlot + 1) { if (ts == prevSlot + 1) {
err = SpatialDecCalculateM1andM2(self, ps, if (bypassMode == 0) {
frame); /* input: ottCLD, ottICC, ... */ err = SpatialDecCalculateM1andM2(
/* output: M1param(Real/Imag), M2(Real/Imag) */ self, ps, frame); /* input: ottCLD, ottICC, ... */
if (err != MPS_OK) { /* output: M1param(Real/Imag), M2(Real/Imag) */
bypassMode = 1; if (err != MPS_OK) {
if (self->errInt == MPS_OK) { err = SpatialDecSetInternalError(self, &bypassMode, err);
/* store internal error befor it gets overwritten */
self->errInt = err;
} }
err = MPS_OK;
} }
if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) { if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) {
@ -1168,13 +1192,16 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bOverwriteM1M2prev = 0; self->bOverwriteM1M2prev = 0;
} }
SpatialDecSmoothM1andM2( if (bypassMode == 0) {
self, frame, SpatialDecSmoothM1andM2(
ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */ self, frame,
/* output: M1param(Real/Imag), M2(Real/Imag) */ 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) { switch (mode) {
case INPUTMODE_QMF_SBR: case INPUTMODE_QMF_SBR:
@ -1362,7 +1389,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
} /* !self->tempShapeConfig == 1 */ } /* !self->tempShapeConfig == 1 */
} /* !bypassMode */ } /* !bypassMode */
if (self->phaseCoding == 1) { if ((self->phaseCoding == 1) && (bypassMode == 0)) {
/* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */ /* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */
SpatialDecApplyPhase( SpatialDecApplyPhase(