Fix overflows in accumulation, fixing crashes

This fixes github issue #83.
This commit is contained in:
Martin Storsjo 2018-05-04 12:46:44 +03:00
parent 5e053a4005
commit 1c6ad60e83
1 changed files with 2 additions and 2 deletions

View File

@ -285,12 +285,12 @@ static FIXP_DBL addLowbandEnergies(FIXP_DBL **Energies, int *scaleEnergies,
/* freqBandTable[LORES] has MAX_FREQ_COEFFS/2 +1 coeefs max. */
for (ts = tran_offdiv2; ts < YBufferWriteOffset; ts++) {
for (k = 0; k < freqBandTable[0]; k++) {
accu1 += Energies[ts][k] >> sc1;
accu1 = fAddSaturate(accu1, Energies[ts][k] >> sc1);
}
}
for (; ts < tran_offdiv2 + (slots >> nrgSzShift); ts++) {
for (k = 0; k < freqBandTable[0]; k++) {
accu2 += Energies[ts][k] >> sc2;
accu2 = fAddSaturate(accu2, Energies[ts][k] >> sc2);
}
}