aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK/src
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2018-10-04 17:26:13 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-10-04 17:26:13 -0700
commitbc9d2aeb0b20843b74a9be0c6a039f9b47f11ea7 (patch)
tree68871b17f9c2fcc26b84a20d558f8f5af5e2d4c3 /libFDK/src
parent13846446b76a9a82b1d04ec6cde963bdc5a15bb1 (diff)
parent1f213910f0f0b63427047414f3b9154ef627d901 (diff)
downloadfdk-aac-bc9d2aeb0b20843b74a9be0c6a039f9b47f11ea7.tar.gz
fdk-aac-bc9d2aeb0b20843b74a9be0c6a039f9b47f11ea7.tar.bz2
fdk-aac-bc9d2aeb0b20843b74a9be0c6a039f9b47f11ea7.zip
Merge "Signed Integer Overflow in DuckerCalcEnergy()" am: 78f80da872 am: efe7d49245
am: 1f213910f0 Change-Id: I0892c5ac44b026f47a8c698277f402a633e1569f
Diffstat (limited to 'libFDK/src')
-rw-r--r--libFDK/src/FDK_decorrelate.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/libFDK/src/FDK_decorrelate.cpp b/libFDK/src/FDK_decorrelate.cpp
index 8e665b7..c5de79a 100644
--- a/libFDK/src/FDK_decorrelate.cpp
+++ b/libFDK/src/FDK_decorrelate.cpp
@@ -1086,8 +1086,9 @@ static INT DuckerCalcEnergy(DUCKER_INSTANCE *const self,
pb = SpatialDecGetProcessingBand(maxHybBand, self->mapHybBands2ProcBands);
for (qs = startHybBand; qs <= maxHybBand; qs++) {
pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
- energy[pb] +=
- (fPow2Div2(inputReal[qs] << clz) + fPow2Div2(inputImag[qs] << clz));
+ energy[pb] =
+ fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) +
+ fPow2Div2(inputImag[qs] << clz));
}
pb++;
@@ -1100,7 +1101,7 @@ static INT DuckerCalcEnergy(DUCKER_INSTANCE *const self,
FIXP_DBL nrg = 0;
qs_next = (int)self->qs_next[pb];
for (; qs < qs_next; qs++) {
- nrg += fPow2Div2(inputReal[qs] << clz);
+ nrg = fAddSaturate(nrg, fPow2Div2(inputReal[qs] << clz));
}
energy[pb] = nrg;
}
@@ -1138,13 +1139,14 @@ static INT DuckerCalcEnergy(DUCKER_INSTANCE *const self,
#else
for (qs = startHybBand; qs <= maxHybBand; qs++) {
int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
- energy[pb] +=
- (fPow2Div2(inputReal[qs] << clz) + fPow2Div2(inputImag[qs] << clz));
+ energy[pb] =
+ fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) +
+ fPow2Div2(inputImag[qs] << clz));
}
for (; qs <= maxHybridBand; qs++) {
int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands);
- energy[pb] += fPow2Div2(inputReal[qs] << clz);
+ energy[pb] = fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz));
}
#endif /* FUNCTION_DuckerCalcEnergy_func4 */
}
@@ -1237,9 +1239,9 @@ static INT DuckerApply(DUCKER_INSTANCE *const self,
tmp1 = scaleValue(tmp1, scaleSmoothDirRevNrg_asExponent);
tmp2 = scaleValue(tmp2, scaleSmoothDirRevNrg_asExponent);
- tmp1 = fMultAddDiv2(tmp1, directNrg[pb] >> scaleDirectNrg,
+ tmp1 = fMultAddDiv2(tmp1, scaleValue(directNrg[pb], -scaleDirectNrg),
DUCK_ONE_MINUS_ALPHA_X4_FDK);
- tmp2 = fMultAddDiv2(tmp2, reverbNrg[pb] >> scaleReverbNrg,
+ tmp2 = fMultAddDiv2(tmp2, scaleValue(reverbNrg[pb], -scaleReverbNrg),
DUCK_ONE_MINUS_ALPHA_X4_FDK);
} else {
tmp1 = fMultAddDiv2(tmp1, directNrg[pb], DUCK_ONE_MINUS_ALPHA_X4_FDK);