Commit 839ae290 authored by Martin Storsjo's avatar Martin Storsjo

Use saturating adds to avoid overflow

These additions can overflow, triggering assertions later.
parent d8e8f1ac
......@@ -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++;
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment