From 89ca476e525187ca01bca3cfd87785d860e7bde8 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 8 Mar 2019 16:08:40 +0100 Subject: Fetch multiple samples of input channels from encoder input buffer. Bug: 132641988 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I548c62efcbe2629479f671befd4388895d835de7 --- libAACenc/src/aacenc_lib.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libAACenc') diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp index 08cd57a..0f0094f 100644 --- a/libAACenc/src/aacenc_lib.cpp +++ b/libAACenc/src/aacenc_lib.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 @@ -1761,6 +1761,10 @@ AACENC_ERROR aacEncEncode(const HANDLE_AACENCODER hAacEncoder, hAacEncoder->inputBuffer + (hAacEncoder->inputBufferOffset + hAacEncoder->nSamplesRead) / hAacEncoder->aacConfig.nChannels; + newSamples -= + (newSamples % + hAacEncoder->extParam + .nChannels); /* process multiple samples of input channels */ /* Copy new input samples to internal buffer */ if (inBufDesc->bufElSizes[idx] == (INT)sizeof(INT_PCM)) { -- cgit v1.2.3 From 55002323b3a94a8a827b66acc693cbdd38e57119 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 8 Mar 2019 16:08:24 +0100 Subject: Fix integer overflow in FDKaacEnc_IntensityStereoProcessing(). Bug: 132641988 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Id2a7e26fff499146a39cea757b1b7fc787b54b31 --- libAACenc/src/intensity.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'libAACenc') diff --git a/libAACenc/src/intensity.cpp b/libAACenc/src/intensity.cpp index a160a4f..0944fa3 100644 --- a/libAACenc/src/intensity.cpp +++ b/libAACenc/src/intensity.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 @@ -661,6 +661,7 @@ void FDKaacEnc_IntensityStereoProcessing( for (sfboffs = 0; sfboffs < maxSfbPerGroup; sfboffs++) { INT sL, sR; FIXP_DBL inv_n; + INT mdct_spec_sf = MDCT_SPEC_SF; msMask[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( (sfbOffset[sfb + sfboffs + 1] - sfbOffset[sfb + sfboffs]) >> 1); // scaled with 2 to compensate fMultDiv2() in subsequent loop @@ -707,11 +714,11 @@ void FDKaacEnc_IntensityStereoProcessing( j++) { d = ((mdctSpectrumLeft[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; 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) { tmp = tmp >> 1; s2 = s2 + 1; @@ -748,12 +755,12 @@ void FDKaacEnc_IntensityStereoProcessing( s = ((mdctSpectrumLeft[j] << s0) >> 1) + ((mdctSpectrumRight[j] << s0) >> 1); es += fMultDiv2(s, s) >> - (MDCT_SPEC_SF - - 1); // scaled 2*(mdctScale - s0 + 1) + MDCT_SPEC_SF + (mdct_spec_sf - + 1); // scaled 2*(mdctScale - s0 + 1) + mdct_spec_sf } msMask[sfb + sfboffs] = 0; 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) { tmp = tmp >> 1; s2 = s2 + 1; -- cgit v1.2.3 From 5def92cb0fa9284064890d9fe5cb0a54d9e03589 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 3 May 2019 10:25:48 +0200 Subject: Integer overflow fix in FDKaacEnc_initAvoidHoleFlag() Bug: 121226473 Test: see bug with specific audio stream to encode Change-Id: I282506f0856130fa00c7f7c6e94b18e1162c8593 --- libAACenc/src/adj_thr.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'libAACenc') diff --git a/libAACenc/src/adj_thr.cpp b/libAACenc/src/adj_thr.cpp index 6e19680..226d003 100644 --- a/libAACenc/src/adj_thr.cpp +++ b/libAACenc/src/adj_thr.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 @@ -591,13 +591,11 @@ static void FDKaacEnc_initAvoidHoleFlag( if (sfbEn > avgEn) { FIXP_DBL tmpMinSnrLdData; if (psyOutChannel[ch]->lastWindowSequence == LONG_WINDOW) - tmpMinSnrLdData = - fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData), - (FIXP_DBL)SnrLdMin1); + tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData, + SnrLdMin1 - SnrLdFac); else - tmpMinSnrLdData = - fixMax(SnrLdFac + (FIXP_DBL)(avgEnLdData - sfbEnLdData), - (FIXP_DBL)SnrLdMin3); + tmpMinSnrLdData = SnrLdFac + fixMax(avgEnLdData - sfbEnLdData, + SnrLdMin3 - SnrLdFac); qcOutChan->sfbMinSnrLdData[sfbGrp + sfb] = fixMin( qcOutChan->sfbMinSnrLdData[sfbGrp + sfb], tmpMinSnrLdData); -- cgit v1.2.3