diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2019-10-29 13:10:23 +0100 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2019-12-27 10:25:23 -0800 |
commit | 5357a4411aff621ab7f2e4a2efcffac8673f4987 (patch) | |
tree | d1917ff52d64366e6230df3e4aa1753fde07976b /libFDK/src/qmf.cpp | |
parent | 9d40b65b15c780e8c37be4e5471247b802e20992 (diff) | |
download | fdk-aac-5357a4411aff621ab7f2e4a2efcffac8673f4987.tar.gz fdk-aac-5357a4411aff621ab7f2e4a2efcffac8673f4987.tar.bz2 fdk-aac-5357a4411aff621ab7f2e4a2efcffac8673f4987.zip |
Use saturate shift to prevent signed integer overflow in multiple qmfInverseModulation*() functions.
Bug: 145669510
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: I4cee10423bc14e3db26de877b5e70701ac3324da
Diffstat (limited to 'libFDK/src/qmf.cpp')
-rw-r--r-- | libFDK/src/qmf.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/libFDK/src/qmf.cpp b/libFDK/src/qmf.cpp index 69f7e05..19f1ea1 100644 --- a/libFDK/src/qmf.cpp +++ b/libFDK/src/qmf.cpp @@ -609,9 +609,9 @@ inline static void qmfInverseModulationLP_even( FIXP_DBL *RESTRICT tImag = pTimeOut + L; /* Move input to output vector with offset */ - scaleValues(&tReal[0], &qmfReal[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); + scaleValuesSaturate(&tReal[0], &qmfReal[0], synQmf->lsb, scaleFactorLowBand); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); FDKmemclear(&tReal[0 + synQmf->usb], (L - synQmf->usb) * sizeof(FIXP_DBL)); /* Dct type-2 transform */ @@ -662,9 +662,9 @@ inline static void qmfInverseModulationLP_odd( int shift = 0; /* Move input to output vector with offset */ - scaleValues(pTimeOut + M, qmfReal, synQmf->lsb, scaleFactorLowBand); - scaleValues(pTimeOut + M + synQmf->lsb, qmfReal + synQmf->lsb, - synQmf->usb - synQmf->lsb, scaleFactorHighBand); + scaleValuesSaturate(pTimeOut + M, qmfReal, synQmf->lsb, scaleFactorLowBand); + scaleValuesSaturate(pTimeOut + M + synQmf->lsb, qmfReal + synQmf->lsb, + synQmf->usb - synQmf->lsb, scaleFactorHighBand); FDKmemclear(pTimeOut + M + synQmf->usb, (L - synQmf->usb) * sizeof(FIXP_DBL)); dct_IV(pTimeOut + M, L, &shift); @@ -698,26 +698,27 @@ inline static void qmfInverseModulationHQ( FIXP_DBL *RESTRICT tImag = pWorkBuffer + L; if (synQmf->flags & QMF_FLAG_CLDFB) { - for (i = 0; i < synQmf->lsb; i++) { - cplxMult(&tImag[i], &tReal[i], scaleValue(qmfImag[i], scaleFactorLowBand), - scaleValue(qmfReal[i], scaleFactorLowBand), synQmf->t_cos[i], - synQmf->t_sin[i]); - } - for (; i < synQmf->usb; i++) { - cplxMult(&tImag[i], &tReal[i], - scaleValue(qmfImag[i], scaleFactorHighBand), - scaleValue(qmfReal[i], scaleFactorHighBand), synQmf->t_cos[i], - synQmf->t_sin[i]); + for (i = 0; i < synQmf->usb; i++) { + cplxMultDiv2(&tImag[i], &tReal[i], qmfImag[i], qmfReal[i], + synQmf->t_cos[i], synQmf->t_sin[i]); } + scaleValuesSaturate(&tReal[0], synQmf->lsb, scaleFactorLowBand + 1); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], synQmf->usb - synQmf->lsb, + scaleFactorHighBand + 1); + scaleValuesSaturate(&tImag[0], synQmf->lsb, scaleFactorLowBand + 1); + scaleValuesSaturate(&tImag[0 + synQmf->lsb], synQmf->usb - synQmf->lsb, + scaleFactorHighBand + 1); } if ((synQmf->flags & QMF_FLAG_CLDFB) == 0) { - scaleValues(&tReal[0], &qmfReal[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); - scaleValues(&tImag[0], &qmfImag[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tImag[0 + synQmf->lsb], &qmfImag[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); + scaleValuesSaturate(&tReal[0], &qmfReal[0], synQmf->lsb, + scaleFactorLowBand); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); + scaleValuesSaturate(&tImag[0], &qmfImag[0], synQmf->lsb, + scaleFactorLowBand); + scaleValuesSaturate(&tImag[0 + synQmf->lsb], &qmfImag[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); } FDKmemclear(&tReal[synQmf->usb], |