Use a saturating shift to avoid overflow

When the shift overflowed, asserts were triggered later, where
the values were assumed to be non-negative.
This commit is contained in:
Martin Storsjo 2012-09-02 22:13:09 +02:00
parent e036dbc8eb
commit 8e4d5d9d2f

View File

@ -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++)