From aad908c262eaffec9728851ff410c7991893111a Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Thu, 9 Apr 2020 17:54:10 +0200 Subject: Prevent integer overflow in subbandTPApply() energy update. Bug: 176246647 Test: atest DecoderTestXheAac DecoderTestAacDrc Change-Id: I9ed8b33414907706808956cffad252052928c799 --- libSACdec/src/sac_stp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libSACdec/src/sac_stp.cpp') diff --git a/libSACdec/src/sac_stp.cpp b/libSACdec/src/sac_stp.cpp index bb66277..b328c82 100644 --- a/libSACdec/src/sac_stp.cpp +++ b/libSACdec/src/sac_stp.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -369,15 +369,15 @@ SACDEC_ERROR subbandTPApply(spatialDec *self, const SPATIAL_BS_FRAME *frame) { hStpDec->update_old_ener = 1; for (ch = 0; ch < self->numInputChannels; ch++) { hStpDec->oldDryEnerLD64[ch] = - CalcLdData(hStpDec->runDryEner[ch] + ABS_THR__FDK); + CalcLdData(fAddSaturate(hStpDec->runDryEner[ch], ABS_THR__FDK)); } for (ch = 0; ch < self->numOutputChannels; ch++) { if (self->treeConfig == TREE_212) hStpDec->oldWetEnerLD64[ch] = - CalcLdData(hStpDec->runWetEner[ch] + ABS_THR__FDK); + CalcLdData(fAddSaturate(hStpDec->runWetEner[ch], ABS_THR__FDK)); else hStpDec->oldWetEnerLD64[ch] = - CalcLdData(hStpDec->runWetEner[ch] + ABS_THR2__FDK); + CalcLdData(fAddSaturate(hStpDec->runWetEner[ch], ABS_THR2__FDK)); } } else { hStpDec->update_old_ener++; -- cgit v1.2.3 From ecc0e332069862da177c745137493545dd0cd63b Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 8 May 2020 16:40:31 +0200 Subject: 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 --- libSACdec/src/sac_stp.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libSACdec/src/sac_stp.cpp') 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++; } -- cgit v1.2.3 From 773ff1d3e8921ed2c9d2def344cf4b6b47f861c8 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Tue, 16 Mar 2021 14:50:04 +0100 Subject: Adapt scaling in combineSignalCplxScale*() to prevent signed integer overflows. Bug: 186777497 Test: atest android.media.cts.DecoderTestAacFormat android.media.cts.DecoderTestXheAac android.media.cts.DecoderTestAacDrc Change-Id: If773c90ccd256fd03641446c7f8bd82d04a100e4 --- libSACdec/src/sac_stp.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'libSACdec/src/sac_stp.cpp') diff --git a/libSACdec/src/sac_stp.cpp b/libSACdec/src/sac_stp.cpp index be332c7..0e6affa 100644 --- a/libSACdec/src/sac_stp.cpp +++ b/libSACdec/src/sac_stp.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2021 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -229,15 +229,13 @@ inline void combineSignalCplxScale1(FIXP_DBL *hybOutputRealDry, int n; FIXP_DBL scaleY; for (n = bands - 1; n >= 0; n--) { - scaleY = fMultDiv2(scaleX, *pBP); + scaleY = fMult(scaleX, *pBP); *hybOutputRealDry = SATURATE_LEFT_SHIFT( - (*hybOutputRealDry >> 1) + - (fMultDiv2(*hybOutputRealWet, scaleY) << (SF_SCALE + 1)), - 1, DFRACT_BITS); + (*hybOutputRealDry >> SF_SCALE) + fMult(*hybOutputRealWet, scaleY), + SF_SCALE, DFRACT_BITS); *hybOutputImagDry = SATURATE_LEFT_SHIFT( - (*hybOutputImagDry >> 1) + - (fMultDiv2(*hybOutputImagWet, scaleY) << (SF_SCALE + 1)), - 1, DFRACT_BITS); + (*hybOutputImagDry >> SF_SCALE) + fMult(*hybOutputImagWet, scaleY), + SF_SCALE, DFRACT_BITS); hybOutputRealDry++, hybOutputRealWet++; hybOutputImagDry++, hybOutputImagWet++; pBP++; @@ -253,14 +251,11 @@ inline void combineSignalCplxScale2(FIXP_DBL *hybOutputRealDry, for (n = bands - 1; n >= 0; n--) { *hybOutputRealDry = SATURATE_LEFT_SHIFT( - (*hybOutputRealDry >> 1) + - (fMultDiv2(*hybOutputRealWet, scaleX) << SF_SCALE), - 1, DFRACT_BITS); + (*hybOutputRealDry >> SF_SCALE) + fMult(*hybOutputRealWet, scaleX), + SF_SCALE, DFRACT_BITS); *hybOutputImagDry = SATURATE_LEFT_SHIFT( - (*hybOutputImagDry >> 1) + - (fMultDiv2(*hybOutputImagWet, scaleX) << SF_SCALE), - 1, DFRACT_BITS); - ; + (*hybOutputImagDry >> SF_SCALE) + fMult(*hybOutputImagWet, scaleX), + SF_SCALE, DFRACT_BITS); hybOutputRealDry++, hybOutputRealWet++; hybOutputImagDry++, hybOutputImagWet++; } -- cgit v1.2.3