diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2020-04-09 17:53:51 +0200 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2020-12-23 14:50:36 -0800 |
commit | 4305167cebc29610cbfeb0295c06f0e94cfbf6a6 (patch) | |
tree | 3b791443f8fefea4810de2deada145f393791428 /libSBRdec/src/env_calc.cpp | |
parent | 2b281bb5a38685988e145b5b2fcbbcb6fb547bdc (diff) | |
download | fdk-aac-4305167cebc29610cbfeb0295c06f0e94cfbf6a6.tar.gz fdk-aac-4305167cebc29610cbfeb0295c06f0e94cfbf6a6.tar.bz2 fdk-aac-4305167cebc29610cbfeb0295c06f0e94cfbf6a6.zip |
Limit smoothedNoise values to avoid integer overflows in adjustTimeSlotHQ() and adjustTimeSlotHQ_GainAndNoise().
Bug: 176246647
Test: atest DecoderTestXheAac DecoderTestAacDrc
Change-Id: Ib630d56a626ddd59a9155df38cda2011c3165346
Diffstat (limited to 'libSBRdec/src/env_calc.cpp')
-rw-r--r-- | libSBRdec/src/env_calc.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libSBRdec/src/env_calc.cpp b/libSBRdec/src/env_calc.cpp index 0b2f651..ad5edfe 100644 --- a/libSBRdec/src/env_calc.cpp +++ b/libSBRdec/src/env_calc.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 @@ -1398,6 +1398,17 @@ void calculateSbrEnvelope( */ noise_e = (start_pos < no_cols) ? adj_e : final_e; + if (start_pos >= no_cols) { + int diff = h_sbr_cal_env->filtBufferNoise_e - noise_e; + if (diff > 0) { + int s = getScalefactor(h_sbr_cal_env->filtBufferNoise, noSubbands); + if (diff > s) { + final_e += diff - s; + noise_e = final_e; + } + } + } + /* Convert energies to amplitude levels */ @@ -2741,6 +2752,9 @@ static void adjustTimeSlotHQ_GainAndNoise( fMult(direct_ratio, noiseLevel[k]); } + smoothedNoise = fMax(fMin(smoothedNoise, (FIXP_DBL)(MAXVAL_DBL / 2)), + (FIXP_DBL)(MINVAL_DBL / 2)); + /* The next 2 multiplications constitute the actual envelope adjustment of the signal and should be carried out with full accuracy @@ -2930,6 +2944,9 @@ static void adjustTimeSlotHQ( fMult(direct_ratio, noiseLevel[k]); } + smoothedNoise = fMax(fMin(smoothedNoise, (FIXP_DBL)(MAXVAL_DBL / 2)), + (FIXP_DBL)(MINVAL_DBL / 2)); + /* The next 2 multiplications constitute the actual envelope adjustment of the signal and should be carried out with full accuracy |