summaryrefslogtreecommitdiffstats
path: root/libSBRenc/src
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2012-08-11 21:56:42 +0300
committerMartin Storsjo <martin@martin.st>2012-08-11 22:28:54 +0300
commit6999980d671f70fdae19c8b4663efa5189f9ca6c (patch)
tree81c9e367a2fe48194be3caba183d216aa8727d11 /libSBRenc/src
parent010c75901e4e01aab6ac8a26c71f2192f454d659 (diff)
downloadfdk-aac-dabplus-6999980d671f70fdae19c8b4663efa5189f9ca6c.tar.gz
fdk-aac-dabplus-6999980d671f70fdae19c8b4663efa5189f9ca6c.tar.bz2
fdk-aac-dabplus-6999980d671f70fdae19c8b4663efa5189f9ca6c.zip
Use saturating adds to avoid overflow
When the addition overflowed, asserts were triggered later, where the values were assumed to be non-negative.
Diffstat (limited to 'libSBRenc/src')
-rw-r--r--libSBRenc/src/env_est.cpp4
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 */