Fix integer overflow in FDKaacEnc_IntensityStereoProcessing().

am: 55002323b3

Change-Id: I7f14e3b7bd79110eff8b01184483ab4e2c4fc9b3
This commit is contained in:
Fraunhofer IIS FDK 2019-05-15 19:05:13 -07:00 committed by android-build-merger
commit d4a622c288
1 changed files with 13 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -661,6 +661,7 @@ void FDKaacEnc_IntensityStereoProcessing(
for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) { for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) {
INT sL, sR; INT sL, sR;
FIXP_DBL inv_n; FIXP_DBL inv_n;
INT mdct_spec_sf = MDCT_SPEC_SF;
msMask[sfb + sfboffs] = 0; msMask[sfb + sfboffs] = 0;
if (isMask[sfb + sfboffs] == 0) { if (isMask[sfb + sfboffs] == 0) {
@ -682,6 +683,12 @@ void FDKaacEnc_IntensityStereoProcessing(
} }
} }
if (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs] >
1 << mdct_spec_sf) {
mdct_spec_sf++; /* This is for rare cases where the number of bins in a
scale factor band is > 64 */
}
inv_n = GetInvInt( inv_n = GetInvInt(
(sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >> (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >>
1); // scaled with 2 to compensate fMultDiv2() in subsequent loop 1); // scaled with 2 to compensate fMultDiv2() in subsequent loop
@ -707,11 +714,11 @@ void FDKaacEnc_IntensityStereoProcessing(
j++) { j++) {
d = ((mdctSpectrumLeft[j] << s0) >> 1) - d = ((mdctSpectrumLeft[j] << s0) >> 1) -
((mdctSpectrumRight[j] << s0) >> 1); ((mdctSpectrumRight[j] << s0) >> 1);
ed += fMultDiv2(d, d) >> (MDCT_SPEC_SF - 1); ed += fMultDiv2(d, d) >> (mdct_spec_sf - 1);
} }
msMask[sfb + sfboffs] = 1; msMask[sfb + sfboffs] = 1;
tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], ed, &s1); tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], ed, &s1);
s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF; s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
if (s2 & 1) { if (s2 & 1) {
tmp = tmp >> 1; tmp = tmp >> 1;
s2 = s2 + 1; s2 = s2 + 1;
@ -748,12 +755,12 @@ void FDKaacEnc_IntensityStereoProcessing(
s = ((mdctSpectrumLeft[j] << s0) >> 1) + s = ((mdctSpectrumLeft[j] << s0) >> 1) +
((mdctSpectrumRight[j] << s0) >> 1); ((mdctSpectrumRight[j] << s0) >> 1);
es += fMultDiv2(s, s) >> es += fMultDiv2(s, s) >>
(MDCT_SPEC_SF - (mdct_spec_sf -
1); // scaled 2*(mdctScale - s0 + 1) + MDCT_SPEC_SF 1); // scaled 2*(mdctScale - s0 + 1) + mdct_spec_sf
} }
msMask[sfb + sfboffs] = 0; msMask[sfb + sfboffs] = 0;
tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], es, &s1); tmp = fDivNorm(sfbEnergyLeft[sfb + sfboffs], es, &s1);
s2 = (s1) + (2 * s0) - 2 - MDCT_SPEC_SF; s2 = (s1) + (2 * s0) - 2 - mdct_spec_sf;
if (s2 & 1) { if (s2 & 1) {
tmp = tmp >> 1; tmp = tmp >> 1;
s2 = s2 + 1; s2 = s2 + 1;