aboutsummaryrefslogtreecommitdiffstats
path: root/libSACdec/src
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2019-11-13 16:06:24 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2020-01-14 14:50:26 -0800
commited5a207a1f32c7b5aef053866c04f0bd8501ec57 (patch)
tree7aac20a025691e0ce503a1af1e45a75a5c6b8a25 /libSACdec/src
parent1a0335287fffe56e811a67e1a3eb04f940cf178a (diff)
downloadfdk-aac-ed5a207a1f32c7b5aef053866c04f0bd8501ec57.tar.gz
fdk-aac-ed5a207a1f32c7b5aef053866c04f0bd8501ec57.tar.bz2
fdk-aac-ed5a207a1f32c7b5aef053866c04f0bd8501ec57.zip
Avoid signed integer overflow in combineSignalCplx*().
Bug: 146937324 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I3f5516085483ac349f9873e7267c6ff7f9c6f816
Diffstat (limited to 'libSACdec/src')
-rw-r--r--libSACdec/src/sac_stp.cpp41
1 files changed, 10 insertions, 31 deletions
diff --git a/libSACdec/src/sac_stp.cpp b/libSACdec/src/sac_stp.cpp
index 6ac5a56..bb66277 100644
--- a/libSACdec/src/sac_stp.cpp
+++ b/libSACdec/src/sac_stp.cpp
@@ -206,29 +206,6 @@ struct STP_DEC {
int update_old_ener;
};
-inline void combineSignalReal(FIXP_DBL *hybOutputRealDry,
- FIXP_DBL *hybOutputRealWet, int bands) {
- int n;
-
- for (n = bands - 1; n >= 0; n--) {
- *hybOutputRealDry = *hybOutputRealDry + *hybOutputRealWet;
- hybOutputRealDry++, hybOutputRealWet++;
- }
-}
-
-inline void combineSignalRealScale1(FIXP_DBL *hybOutputRealDry,
- FIXP_DBL *hybOutputRealWet, FIXP_DBL scaleX,
- int bands) {
- int n;
-
- for (n = bands - 1; n >= 0; n--) {
- *hybOutputRealDry =
- *hybOutputRealDry +
- (fMultDiv2(*hybOutputRealWet, scaleX) << (SF_SCALE + 1));
- hybOutputRealDry++, hybOutputRealWet++;
- }
-}
-
inline void combineSignalCplx(FIXP_DBL *hybOutputRealDry,
FIXP_DBL *hybOutputImagDry,
FIXP_DBL *hybOutputRealWet,
@@ -236,8 +213,8 @@ inline void combineSignalCplx(FIXP_DBL *hybOutputRealDry,
int n;
for (n = bands - 1; n >= 0; n--) {
- *hybOutputRealDry = *hybOutputRealDry + *hybOutputRealWet;
- *hybOutputImagDry = *hybOutputImagDry + *hybOutputImagWet;
+ *hybOutputRealDry = fAddSaturate(*hybOutputRealDry, *hybOutputRealWet);
+ *hybOutputImagDry = fAddSaturate(*hybOutputImagDry, *hybOutputImagWet);
hybOutputRealDry++, hybOutputRealWet++;
hybOutputImagDry++, hybOutputImagWet++;
}
@@ -253,12 +230,14 @@ inline void combineSignalCplxScale1(FIXP_DBL *hybOutputRealDry,
FIXP_DBL scaleY;
for (n = bands - 1; n >= 0; n--) {
scaleY = fMultDiv2(scaleX, *pBP);
- *hybOutputRealDry =
- *hybOutputRealDry +
- (fMultDiv2(*hybOutputRealWet, scaleY) << (SF_SCALE + 2));
- *hybOutputImagDry =
- *hybOutputImagDry +
- (fMultDiv2(*hybOutputImagWet, scaleY) << (SF_SCALE + 2));
+ *hybOutputRealDry = SATURATE_LEFT_SHIFT(
+ (*hybOutputRealDry >> 1) +
+ (fMultDiv2(*hybOutputRealWet, scaleY) << (SF_SCALE + 1)),
+ 1, DFRACT_BITS);
+ *hybOutputImagDry = SATURATE_LEFT_SHIFT(
+ (*hybOutputImagDry >> 1) +
+ (fMultDiv2(*hybOutputImagWet, scaleY) << (SF_SCALE + 1)),
+ 1, DFRACT_BITS);
hybOutputRealDry++, hybOutputRealWet++;
hybOutputImagDry++, hybOutputImagWet++;
pBP++;