aboutsummaryrefslogtreecommitdiffstats
path: root/libSACdec/src
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2019-11-13 16:06:13 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2020-01-14 14:49:15 -0800
commit1a0335287fffe56e811a67e1a3eb04f940cf178a (patch)
treea9daccb369a37d625de88c56737e488dda4e4682 /libSACdec/src
parent063d5f30864c6293855da6f7b8dd482d7c408158 (diff)
downloadfdk-aac-1a0335287fffe56e811a67e1a3eb04f940cf178a.tar.gz
fdk-aac-1a0335287fffe56e811a67e1a3eb04f940cf178a.tar.bz2
fdk-aac-1a0335287fffe56e811a67e1a3eb04f940cf178a.zip
Prevent signed integer overflow in TsdApply().
Bug: 146937678 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Ia7b58caf9eb86c19e3ae10b3cc624490b2a5f07b
Diffstat (limited to 'libSACdec/src')
-rw-r--r--libSACdec/src/sac_tsd.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/libSACdec/src/sac_tsd.cpp b/libSACdec/src/sac_tsd.cpp
index 30acca8..a07447b 100644
--- a/libSACdec/src/sac_tsd.cpp
+++ b/libSACdec/src/sac_tsd.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -123,12 +123,15 @@ static const UCHAR nBitsTsdCW_64slots[64] = {
RAM_ALIGN
LNK_SECTION_CONSTDATA
-static const FIXP_STP phiTsd[8] = {
- STCP(0x7fffffff, 0x00000000), STCP(0x5a82799a, 0x5a82799a),
- STCP(0x00000000, 0x7fffffff), STCP(0xa57d8666, 0x5a82799a),
- STCP(0x80000000, 0x00000000), STCP(0xa57d8666, 0xa57d8666),
- STCP(0x00000000, 0x80000000), STCP(0x5a82799a, 0xa57d8666),
-};
+static const FIXP_DPK phiTsd[8] = {
+ {{(FIXP_DBL)0x7fffffff, (FIXP_DBL)0x00000000}},
+ {{(FIXP_DBL)0x5a82799a, (FIXP_DBL)0x5a82799a}},
+ {{(FIXP_DBL)0x00000000, (FIXP_DBL)0x7fffffff}},
+ {{(FIXP_DBL)0xa57d8666, (FIXP_DBL)0x5a82799a}},
+ {{(FIXP_DBL)0x80000000, (FIXP_DBL)0x00000000}},
+ {{(FIXP_DBL)0xa57d8666, (FIXP_DBL)0xa57d8666}},
+ {{(FIXP_DBL)0x00000000, (FIXP_DBL)0x80000000}},
+ {{(FIXP_DBL)0x5a82799a, (FIXP_DBL)0xa57d8666}}};
/*** Static Functions ***/
static void longmult1(USHORT a[], USHORT b, USHORT d[], int len) {
@@ -333,16 +336,19 @@ void TsdApply(const int numHybridBands, const TSD_DATA *pTsdData, int *pTsdTs,
if (isTrSlot(pTsdData, ts)) {
int k;
- const FIXP_STP *phi = &phiTsd[pTsdData->bsTsdTrPhaseData[ts]];
+ const FIXP_DPK *phi = &phiTsd[pTsdData->bsTsdTrPhaseData[ts]];
FDK_ASSERT((pTsdData->bsTsdTrPhaseData[ts] >= 0) &&
(pTsdData->bsTsdTrPhaseData[ts] < 8));
/* d = d_nonTr + v_direct * exp(j * bsTsdTrPhaseData[ts]/4 * pi ) */
for (k = TSD_START_BAND; k < numHybridBands; k++) {
FIXP_DBL tempReal, tempImag;
- cplxMult(&tempReal, &tempImag, pVdirectReal[k], pVdirectImag[k], *phi);
- pDnonTrReal[k] += tempReal;
- pDnonTrImag[k] += tempImag;
+ cplxMultDiv2(&tempReal, &tempImag, pVdirectReal[k], pVdirectImag[k],
+ *phi);
+ pDnonTrReal[k] = SATURATE_LEFT_SHIFT(
+ (pDnonTrReal[k] >> 2) + (tempReal >> 1), 2, DFRACT_BITS);
+ pDnonTrImag[k] = SATURATE_LEFT_SHIFT(
+ (pDnonTrImag[k] >> 2) + (tempImag >> 1), 2, DFRACT_BITS);
}
}