[Opencore-amr-commits] [fdk-aac] Use a saturating shift to avoid overflow
Audio codecs extracted from Android Open Source Project
Brought to you by:
mstorsjo
From: Martin Storsjö <mst...@us...> - 2012-09-02 20:28:49
|
Module: fdk-aac Branch: master Commit: 8e4d5d9d2fb16e29e4b30a1ae867ab269b1781b3 Author: Martin Storsjo <ma...@ma...> Date: Sun Sep 2 22:13:09 2012 +0200 URL: http://opencore-amr.git.sf.net/git/gitweb.cgi?p=opencore-amr/fdk-aac;a=commit;h=8e4d5d9d2fb16e29e4b30a1ae867ab269b1781b3 Use a saturating shift to avoid overflow When the shift overflowed, asserts were triggered later, where the values were assumed to be non-negative. --- libAACenc/src/band_nrg.cpp | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libAACenc/src/band_nrg.cpp b/libAACenc/src/band_nrg.cpp index 458aa9c..c672c6c 100644 --- a/libAACenc/src/band_nrg.cpp +++ b/libAACenc/src/band_nrg.cpp @@ -267,7 +267,7 @@ FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum, FIXP_DBL spec = mdctSpectrum[j]<<leadingBits; tmp = fPow2AddDiv2(tmp, spec); } - bandEnergy[i] = tmp<<1; + bandEnergy[i] = scaleValueSaturate(tmp, 1); } for(i=0; i<numBands; i++) |