diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2021-05-07 21:49:56 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-07 21:49:56 +0000 |
commit | 9b481d3556f82e756169e1638284f8fa59f42aeb (patch) | |
tree | 7bb5301c79f1088f43f6320cec2331dd6e090b01 | |
parent | 877f2d687c66b9bab9533e53cedc8f2ec5147beb (diff) | |
parent | 2a40fde39dfcc264e1cda3c429b482246621e60c (diff) | |
download | fdk-aac-9b481d3556f82e756169e1638284f8fa59f42aeb.tar.gz fdk-aac-9b481d3556f82e756169e1638284f8fa59f42aeb.tar.bz2 fdk-aac-9b481d3556f82e756169e1638284f8fa59f42aeb.zip |
Prevent too large shift exponent in apply_inter_tes() and merge two loops. am: 2a40fde39d
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/14471061
Change-Id: Iaa3a1546fa0d8a92de3b1434b93d810b6e00e1a7
-rw-r--r-- | libSBRdec/src/env_calc.cpp | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/libSBRdec/src/env_calc.cpp b/libSBRdec/src/env_calc.cpp index ad5edfe..cefa612 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 - 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 @@ -664,7 +664,7 @@ static void apply_inter_tes(FIXP_DBL **qmfReal, FIXP_DBL **qmfImag, gain_sf[i] = mult_sf - total_power_low_sf + sf2; gain[i] = sqrtFixp_lookup(gain[i], &gain_sf[i]); if (gain_sf[i] < 0) { - gain[i] >>= -gain_sf[i]; + gain[i] >>= fMin(DFRACT_BITS - 1, -gain_sf[i]); gain_sf[i] = 0; } } else { @@ -683,11 +683,6 @@ static void apply_inter_tes(FIXP_DBL **qmfReal, FIXP_DBL **qmfImag, /* gain[i] = g_inter[i] */ for (i = 0; i < nbSubsample; ++i) { - if (gain_sf[i] < 0) { - gain[i] >>= -gain_sf[i]; - gain_sf[i] = 0; - } - /* calculate: gain[i] = 1.0f + gamma * (gain[i] - 1.0f); */ FIXP_DBL one = (FIXP_DBL)MAXVAL_DBL >> gain_sf[i]; /* to substract this from gain[i] */ @@ -755,23 +750,15 @@ static void apply_inter_tes(FIXP_DBL **qmfReal, FIXP_DBL **qmfImag, int gain_adj_sf = gain_adj_2_sf; for (i = 0; i < nbSubsample; ++i) { - gain[i] = fMult(gain[i], gain_adj); - gain_sf[i] += gain_adj_sf; - - /* limit gain */ - if (gain_sf[i] > INTER_TES_SF_CHANGE) { - gain[i] = (FIXP_DBL)MAXVAL_DBL; - gain_sf[i] = INTER_TES_SF_CHANGE; - } - } - - for (i = 0; i < nbSubsample; ++i) { - /* equalize gain[]'s scale factors */ - gain[i] >>= INTER_TES_SF_CHANGE - gain_sf[i]; + int gain_e = fMax( + fMin(gain_sf[i] + gain_adj_sf - INTER_TES_SF_CHANGE, DFRACT_BITS - 1), + -(DFRACT_BITS - 1)); + FIXP_DBL gain_final = fMult(gain[i], gain_adj); + gain_final = scaleValueSaturate(gain_final, gain_e); for (j = lowSubband; j < highSubband; j++) { - qmfReal[startPos + i][j] = fMult(qmfReal[startPos + i][j], gain[i]); - qmfImag[startPos + i][j] = fMult(qmfImag[startPos + i][j], gain[i]); + qmfReal[startPos + i][j] = fMult(qmfReal[startPos + i][j], gain_final); + qmfImag[startPos + i][j] = fMult(qmfImag[startPos + i][j], gain_final); } } } else { /* gamma_idx == 0 */ |