diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-04-30 22:53:15 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-30 22:53:15 +0000 |
commit | 5a192951da6024c45c96fd5ae8b0343b34a0a702 (patch) | |
tree | 43e8eac1bc30cbfa2ef667fe1722b20da53a2769 /libSBRdec/src/lpp_tran.cpp | |
parent | 6edbc9a7e816074947dac672ffccaa6e58e5c43c (diff) | |
parent | 236cd75f1cfab3bf7de0abd1a051014a5e55c1de (diff) | |
download | fdk-aac-5a192951da6024c45c96fd5ae8b0343b34a0a702.tar.gz fdk-aac-5a192951da6024c45c96fd5ae8b0343b34a0a702.tar.bz2 fdk-aac-5a192951da6024c45c96fd5ae8b0343b34a0a702.zip |
Merge "Prevent signed integer overflow in complex path of calc_qmfBuffer()." into sc-dev am: dff30034b9 am: 236cd75f1c
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/14387482
Change-Id: I1186682bef5fc6a7324bcd8c6509e824dc466737
Diffstat (limited to 'libSBRdec/src/lpp_tran.cpp')
-rw-r--r-- | libSBRdec/src/lpp_tran.cpp | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/libSBRdec/src/lpp_tran.cpp b/libSBRdec/src/lpp_tran.cpp index 93e1158..bdbafa6 100644 --- a/libSBRdec/src/lpp_tran.cpp +++ b/libSBRdec/src/lpp_tran.cpp @@ -132,10 +132,6 @@ amm-info@iis.fraunhofer.de #include "HFgen_preFlat.h" -#if defined(__arm__) -#include "arm/lpp_tran_arm.cpp" -#endif - #define LPC_SCALE_FACTOR 2 /*! @@ -771,45 +767,45 @@ void lppTransposer( } else { /* bw <= 0 */ if (!useLP) { - int descale = - fixMin(DFRACT_BITS - 1, (LPC_SCALE_FACTOR + dynamicScale)); -#ifdef FUNCTION_LPPTRANSPOSER_func1 - lppTransposer_func1( - lowBandReal + LPC_ORDER + startSample, - lowBandImag + LPC_ORDER + startSample, - qmfBufferReal + startSample, qmfBufferImag + startSample, - stopSample - startSample, (int)hiBand, dynamicScale, descale, a0r, - a0i, a1r, a1i, fPreWhitening, preWhiteningGains[loBand], - preWhiteningGains_exp[loBand] + 1); -#else + const int dynscale = fixMax(0, dynamicScale - 2) + 1; + const int rescale = -fixMin(0, dynamicScale - 2) + 1; + const int descale = fixMin(DFRACT_BITS - 1, + LPC_SCALE_FACTOR + dynamicScale + rescale); + for (i = startSample; i < stopSample; i++) { FIXP_DBL accu1, accu2; - accu1 = (fMultDiv2(a0r, lowBandReal[LPC_ORDER + i - 1]) - - fMultDiv2(a0i, lowBandImag[LPC_ORDER + i - 1]) + - fMultDiv2(a1r, lowBandReal[LPC_ORDER + i - 2]) - - fMultDiv2(a1i, lowBandImag[LPC_ORDER + i - 2])) >> - dynamicScale; - accu2 = (fMultDiv2(a0i, lowBandReal[LPC_ORDER + i - 1]) + - fMultDiv2(a0r, lowBandImag[LPC_ORDER + i - 1]) + - fMultDiv2(a1i, lowBandReal[LPC_ORDER + i - 2]) + - fMultDiv2(a1r, lowBandImag[LPC_ORDER + i - 2])) >> - dynamicScale; - - accu1 = (lowBandReal[LPC_ORDER + i] >> descale) + (accu1 << 1); - accu2 = (lowBandImag[LPC_ORDER + i] >> descale) + (accu2 << 1); + accu1 = ((fMultDiv2(a0r, lowBandReal[LPC_ORDER + i - 1]) - + fMultDiv2(a0i, lowBandImag[LPC_ORDER + i - 1])) >> + 1) + + ((fMultDiv2(a1r, lowBandReal[LPC_ORDER + i - 2]) - + fMultDiv2(a1i, lowBandImag[LPC_ORDER + i - 2])) >> + 1); + accu2 = ((fMultDiv2(a0i, lowBandReal[LPC_ORDER + i - 1]) + + fMultDiv2(a0r, lowBandImag[LPC_ORDER + i - 1])) >> + 1) + + ((fMultDiv2(a1i, lowBandReal[LPC_ORDER + i - 2]) + + fMultDiv2(a1r, lowBandImag[LPC_ORDER + i - 2])) >> + 1); + + accu1 = + (lowBandReal[LPC_ORDER + i] >> descale) + (accu1 >> dynscale); + accu2 = + (lowBandImag[LPC_ORDER + i] >> descale) + (accu2 >> dynscale); if (fPreWhitening) { - accu1 = scaleValueSaturate( + qmfBufferReal[i][hiBand] = scaleValueSaturate( fMultDiv2(accu1, preWhiteningGains[loBand]), - preWhiteningGains_exp[loBand] + 1); - accu2 = scaleValueSaturate( + preWhiteningGains_exp[loBand] + 1 + rescale); + qmfBufferImag[i][hiBand] = scaleValueSaturate( fMultDiv2(accu2, preWhiteningGains[loBand]), - preWhiteningGains_exp[loBand] + 1); + preWhiteningGains_exp[loBand] + 1 + rescale); + } else { + qmfBufferReal[i][hiBand] = + SATURATE_LEFT_SHIFT(accu1, rescale, DFRACT_BITS); + qmfBufferImag[i][hiBand] = + SATURATE_LEFT_SHIFT(accu2, rescale, DFRACT_BITS); } - qmfBufferReal[i][hiBand] = accu1; - qmfBufferImag[i][hiBand] = accu2; } -#endif } else { FDK_ASSERT(dynamicScale >= 0); calc_qmfBufferReal( |