diff --git a/libSACdec/src/sac_dec.cpp b/libSACdec/src/sac_dec.cpp index 649c18d..a26e251 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: @@ -1362,7 +1389,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(