From 36a85bf987eb7b5502edb7ddf15a293696ca845a Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Tue, 14 Mar 2017 14:29:20 +0200 Subject: [PATCH] Saturate additions in spectralChange This fixes a crash. --- libSBRenc/src/tran_det.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libSBRenc/src/tran_det.cpp b/libSBRenc/src/tran_det.cpp index 3b6765a..453a977 100644 --- a/libSBRenc/src/tran_det.cpp +++ b/libSBRenc/src/tran_det.cpp @@ -200,12 +200,12 @@ static FIXP_DBL spectralChange( /* Sum up energies in first half */ for (i = start; i < border; i++) { - accu1 += scaleValue(Energies[i][j], -energies_e_diff[i]); + accu1 = fAddSaturate(accu1, scaleValue(Energies[i][j], -energies_e_diff[i])); } /* Sum up energies in second half */ for (i = border; i < stop; i++) { - accu2 += scaleValue(Energies[i][j], -energies_e_diff[i]); + accu2 = fAddSaturate(accu2, scaleValue(Energies[i][j], -energies_e_diff[i])); } /* Ensure certain energy to prevent division by zero and to prevent