You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.0 KiB

  1. From a50eecf65b5ce5d4f03768c5c2cb4b492d2badad Mon Sep 17 00:00:00 2001
  2. From: Martin Storsjo <martin@martin.st>
  3. Date: Fri, 4 May 2018 12:46:44 +0300
  4. Subject: [PATCH] Fix overflows in accumulation, fixing crashes
  5. This fixes github issue #83.
  6. ---
  7. libSBRenc/src/tran_det.cpp | 4 ++--
  8. 1 file changed, 2 insertions(+), 2 deletions(-)
  9. diff --git a/libSBRenc/src/tran_det.cpp b/libSBRenc/src/tran_det.cpp
  10. index 0e35ec3..51d6efe 100644
  11. --- a/libSBRenc/src/tran_det.cpp
  12. +++ b/libSBRenc/src/tran_det.cpp
  13. @@ -256,12 +256,12 @@ static FIXP_DBL addLowbandEnergies(FIXP_DBL **Energies,
  14. /* freqBandTable[LORES] has MAX_FREQ_COEFFS/2 +1 coeefs max. */
  15. for (ts=tran_offdiv2; ts<YBufferWriteOffset; ts++) {
  16. for (k = 0; k < freqBandTable[0]; k++) {
  17. - accu1 += Energies[ts][k] >> 6;
  18. + accu1 = fAddSaturate(accu1, Energies[ts][k] >> 6);
  19. }
  20. }
  21. for (; ts<tran_offdiv2+(slots>>nrgSzShift); ts++) {
  22. for (k = 0; k < freqBandTable[0]; k++) {
  23. - accu2 += Energies[ts][k] >> 9;
  24. + accu2 = fAddSaturate(accu2, Energies[ts][k] >> 9);
  25. }
  26. }