[Opencore-amr-commits] [fdk-aac] Use saturating adds to avoid overflow
Audio codecs extracted from Android Open Source Project
Brought to you by:
mstorsjo
From: Martin Storsjö <mst...@us...> - 2012-08-11 19:31:09
|
Module: fdk-aac Branch: master Commit: 6999980d671f70fdae19c8b4663efa5189f9ca6c Author: Martin Storsjo <ma...@ma...> Date: Sat Aug 11 21:56:42 2012 +0300 URL: http://opencore-amr.git.sf.net/git/gitweb.cgi?p=opencore-amr/fdk-aac;a=commit;h=6999980d671f70fdae19c8b4663efa5189f9ca6c Use saturating adds to avoid overflow When the addition overflowed, asserts were triggered later, where the values were assumed to be non-negative. --- libSBRenc/src/env_est.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libSBRenc/src/env_est.cpp b/libSBRenc/src/env_est.cpp index 9423f27..312e0ae 100644 --- a/libSBRenc/src/env_est.cpp +++ b/libSBRenc/src/env_est.cpp @@ -762,8 +762,8 @@ calculateSbrEnvelope (FIXP_DBL **RESTRICT YBufferLeft, /*! energy buffer left * /* save energies */ pNrgLeft[j] = nrgLeft; pNrgRight[j] = nrgRight; - envNrgLeft += nrgLeft; - envNrgRight += nrgRight; + envNrgLeft = fAddSaturate(envNrgLeft, nrgLeft); + envNrgRight = fAddSaturate(envNrgRight, nrgRight); } /* j */ |