diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2019-11-13 16:09:14 +0100 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2020-01-16 12:15:04 -0800 |
commit | 86f7d2b69a00ae32d555f37fe687c001eaa99ddd (patch) | |
tree | 76f750b076023cd8922c63d03e74a36b97e22a90 /libSACdec/src/sac_reshapeBBEnv.cpp | |
parent | 5d095631969aa7136ac2cb7e0e13664516054097 (diff) | |
download | fdk-aac-86f7d2b69a00ae32d555f37fe687c001eaa99ddd.tar.gz fdk-aac-86f7d2b69a00ae32d555f37fe687c001eaa99ddd.tar.bz2 fdk-aac-86f7d2b69a00ae32d555f37fe687c001eaa99ddd.zip |
Prevent too large shift exponents in SpatialDecReshapeBBEnv().
Bug: 146937858
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: I9fbe0b364ae4d329c6e5cc1109a111ef5def552d
Diffstat (limited to 'libSACdec/src/sac_reshapeBBEnv.cpp')
-rw-r--r-- | libSACdec/src/sac_reshapeBBEnv.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libSACdec/src/sac_reshapeBBEnv.cpp b/libSACdec/src/sac_reshapeBBEnv.cpp index 588c866..b44ce4e 100644 --- a/libSACdec/src/sac_reshapeBBEnv.cpp +++ b/libSACdec/src/sac_reshapeBBEnv.cpp @@ -284,11 +284,14 @@ shapeBBEnv(FIXP_DBL *pHybOutputRealDry, FIXP_DBL *pHybOutputImagDry, } } else { for (qs = 0; qs < cplxBands; qs++) { - pHybOutputRealDry[qs] = fMultDiv2(pHybOutputRealDry[qs], dryFac) << scale; - pHybOutputImagDry[qs] = fMultDiv2(pHybOutputImagDry[qs], dryFac) << scale; + pHybOutputRealDry[qs] = SATURATE_LEFT_SHIFT( + fMultDiv2(pHybOutputRealDry[qs], dryFac), scale, DFRACT_BITS); + pHybOutputImagDry[qs] = SATURATE_LEFT_SHIFT( + fMultDiv2(pHybOutputImagDry[qs], dryFac), scale, DFRACT_BITS); } for (; qs < hybBands; qs++) { - pHybOutputRealDry[qs] = fMultDiv2(pHybOutputRealDry[qs], dryFac) << scale; + pHybOutputRealDry[qs] = SATURATE_LEFT_SHIFT( + fMultDiv2(pHybOutputRealDry[qs], dryFac), scale, DFRACT_BITS); } } } @@ -614,14 +617,16 @@ void SpatialDecReshapeBBEnv(spatialDec *self, const SPATIAL_BS_FRAME *frame, fixMax(3, fixMax(dryFacSF, slotAmpSF)); /* scale is at least with 3 bits to avoid overflows when calculating dryFac */ - dryFac = dryFac >> (scale - dryFacSF); - slotAmp_ratio = slotAmp_ratio >> (scale - slotAmpSF); + dryFac = dryFac >> fixMin(scale - dryFacSF, DFRACT_BITS - 1); + slotAmp_ratio = + slotAmp_ratio >> fixMin(scale - slotAmpSF, DFRACT_BITS - 1); /* limit dryFac */ dryFac = fixMax( FL2FXCONST_DBL(0.25f) >> (INT)fixMin(2 * scale, DFRACT_BITS - 1), - fMult(dryFac, slotAmp_ratio) - (slotAmp_ratio >> scale) + - (dryFac >> scale)); + fMult(dryFac, slotAmp_ratio) - + (slotAmp_ratio >> fixMin(scale, DFRACT_BITS - 1)) + + (dryFac >> fixMin(scale, DFRACT_BITS - 1))); dryFac = fixMin( FL2FXCONST_DBL(0.50f) >> (INT)fixMin(2 * scale - 3, DFRACT_BITS - 1), dryFac); /* reduce shift bits by 3, because upper @@ -635,8 +640,8 @@ void SpatialDecReshapeBBEnv(spatialDec *self, const SPATIAL_BS_FRAME *frame, /* shaping */ shapeBBEnv(&self->hybOutputRealDry__FDK[ch][6], - &self->hybOutputImagDry__FDK[ch][6], dryFac, scale, cplxBands, - hybBands); + &self->hybOutputImagDry__FDK[ch][6], dryFac, + fixMin(scale, DFRACT_BITS - 1), cplxBands, hybBands); } } } |