aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2020-05-08 16:40:31 +0200
committerJean-Michel Trivi <jmtrivi@google.com>2021-04-30 15:24:51 +0000
commitecc0e332069862da177c745137493545dd0cd63b (patch)
tree7aa3103b86b17c0c5eaeb76daa37d4804067a1dd
parent5a83a8e5e1cafceba6bef7ac61e68a57cc93d786 (diff)
downloadfdk-aac-ecc0e332069862da177c745137493545dd0cd63b.tar.gz
fdk-aac-ecc0e332069862da177c745137493545dd0cd63b.tar.bz2
fdk-aac-ecc0e332069862da177c745137493545dd0cd63b.zip
Avoid signed integer overflow in combineSignalCplxScale2().
Bug: 186706541 Test: atest android.media.cts.DecoderTestAacFormat android.media.cts.DecoderTestXheAac android.media.cts.DecoderTestAacDrc Change-Id: Ie35e34d982c99f0e328f8f9251bba32c7da8518c
-rw-r--r--libSACdec/src/sac_stp.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/libSACdec/src/sac_stp.cpp b/libSACdec/src/sac_stp.cpp
index b328c82..be332c7 100644
--- a/libSACdec/src/sac_stp.cpp
+++ b/libSACdec/src/sac_stp.cpp
@@ -252,12 +252,15 @@ inline void combineSignalCplxScale2(FIXP_DBL *hybOutputRealDry,
int n;
for (n = bands - 1; n >= 0; n--) {
- *hybOutputRealDry =
- *hybOutputRealDry +
- (fMultDiv2(*hybOutputRealWet, scaleX) << (SF_SCALE + 1));
- *hybOutputImagDry =
- *hybOutputImagDry +
- (fMultDiv2(*hybOutputImagWet, scaleX) << (SF_SCALE + 1));
+ *hybOutputRealDry = SATURATE_LEFT_SHIFT(
+ (*hybOutputRealDry >> 1) +
+ (fMultDiv2(*hybOutputRealWet, scaleX) << SF_SCALE),
+ 1, DFRACT_BITS);
+ *hybOutputImagDry = SATURATE_LEFT_SHIFT(
+ (*hybOutputImagDry >> 1) +
+ (fMultDiv2(*hybOutputImagWet, scaleX) << SF_SCALE),
+ 1, DFRACT_BITS);
+ ;
hybOutputRealDry++, hybOutputRealWet++;
hybOutputImagDry++, hybOutputImagWet++;
}