Use saturating adds to avoid overflow

These additions can overflow, triggering assertions later.
This commit is contained in:
Martin Storsjo 2012-08-10 00:51:37 +03:00
parent d8e8f1ac46
commit 839ae290c1
2 changed files with 3 additions and 3 deletions

View File

@ -1150,8 +1150,8 @@ static INT FDKaacEnc_AutoToParcor(
for(j=numOfCoeff-i-1; j>=0; j--) {
FIXP_DBL accu1 = fMult(tmp, input[j]);
FIXP_DBL accu2 = fMult(tmp, workBuffer[j]);
workBuffer[j] += accu1;
input[j] += accu2;
workBuffer[j] = fAddSaturate(workBuffer[j], accu1);
input[j] = fAddSaturate(input[j], accu2);
}
workBuffer++;

View File

@ -195,7 +195,7 @@ FDKaacEnc_groupShortData(FIXP_DBL *mdctSpectrum, /* in-out
FIXP_DBL energy = sfbEnergy->Short[wnd][sfb];
for (j=1; j<groupLen[grp]; j++)
{
energy += sfbEnergy->Short[wnd+j][sfb];
energy = fAddSaturate(energy, sfbEnergy->Short[wnd+j][sfb]);
}
sfbEnergy->Long[i++] = energy;
}