mirror of
https://github.com/mstorsjo/fdk-aac.git
synced 2025-02-16 19:30:34 +01:00
Introduce scaling in FDKhybridSynthesisApply() to avoid potential signed integer overflow.
Bug: 146937225 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Ifa3d157a842828c2a66694d95dad5d4992ff6d87
This commit is contained in:
parent
7019272646
commit
76c229c018
@ -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
|
||||||
@ -142,11 +142,12 @@ amm-info@iis.fraunhofer.de
|
|||||||
} /* How to arrange the packed values. */
|
} /* How to arrange the packed values. */
|
||||||
|
|
||||||
struct FDK_HYBRID_SETUP {
|
struct FDK_HYBRID_SETUP {
|
||||||
UCHAR nrQmfBands; /*!< Number of QMF bands to be converted to hybrid. */
|
UCHAR nrQmfBands; /*!< Number of QMF bands to be converted to hybrid. */
|
||||||
UCHAR nHybBands[3]; /*!< Number of Hybrid bands generated by nrQmfBands. */
|
UCHAR nHybBands[3]; /*!< Number of Hybrid bands generated by nrQmfBands. */
|
||||||
SCHAR kHybrid[3]; /*!< Filter configuration of each QMF band. */
|
UCHAR synHybScale[3]; /*!< Headroom needed in hybrid synthesis filterbank. */
|
||||||
UCHAR protoLen; /*!< Prototype filter length. */
|
SCHAR kHybrid[3]; /*!< Filter configuration of each QMF band. */
|
||||||
UCHAR filterDelay; /*!< Delay caused by hybrid filter. */
|
UCHAR protoLen; /*!< Prototype filter length. */
|
||||||
|
UCHAR filterDelay; /*!< Delay caused by hybrid filter. */
|
||||||
const INT
|
const INT
|
||||||
*pReadIdxTable; /*!< Helper table to access input data ringbuffer. */
|
*pReadIdxTable; /*!< Helper table to access input data ringbuffer. */
|
||||||
};
|
};
|
||||||
@ -156,12 +157,12 @@ static const INT ringbuffIdxTab[2 * 13] = {0, 1, 2, 3, 4, 5, 6, 7, 8,
|
|||||||
9, 10, 11, 12, 0, 1, 2, 3, 4,
|
9, 10, 11, 12, 0, 1, 2, 3, 4,
|
||||||
5, 6, 7, 8, 9, 10, 11, 12};
|
5, 6, 7, 8, 9, 10, 11, 12};
|
||||||
|
|
||||||
static const FDK_HYBRID_SETUP setup_3_16 = {3, {8, 4, 4}, {8, 4, 4},
|
static const FDK_HYBRID_SETUP setup_3_16 = {
|
||||||
13, (13 - 1) / 2, ringbuffIdxTab};
|
3, {8, 4, 4}, {4, 3, 3}, {8, 4, 4}, 13, (13 - 1) / 2, ringbuffIdxTab};
|
||||||
static const FDK_HYBRID_SETUP setup_3_12 = {3, {8, 2, 2}, {8, 2, 2},
|
static const FDK_HYBRID_SETUP setup_3_12 = {
|
||||||
13, (13 - 1) / 2, ringbuffIdxTab};
|
3, {8, 2, 2}, {4, 2, 2}, {8, 2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab};
|
||||||
static const FDK_HYBRID_SETUP setup_3_10 = {3, {6, 2, 2}, {-8, -2, 2},
|
static const FDK_HYBRID_SETUP setup_3_10 = {
|
||||||
13, (13 - 1) / 2, ringbuffIdxTab};
|
3, {6, 2, 2}, {3, 2, 2}, {-8, -2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab};
|
||||||
|
|
||||||
static const FIXP_HTP HybFilterCoef8[] = {
|
static const FIXP_HTP HybFilterCoef8[] = {
|
||||||
HTCP(0x10000000, 0x00000000), HTCP(0x0df26407, 0xfa391882),
|
HTCP(0x10000000, 0x00000000), HTCP(0x0df26407, 0xfa391882),
|
||||||
@ -477,17 +478,18 @@ void FDKhybridSynthesisApply(HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter,
|
|||||||
*/
|
*/
|
||||||
for (k = 0; k < nrQmfBandsLF; k++) {
|
for (k = 0; k < nrQmfBandsLF; k++) {
|
||||||
const int nHybBands = hSynthesisHybFilter->pSetup->nHybBands[k];
|
const int nHybBands = hSynthesisHybFilter->pSetup->nHybBands[k];
|
||||||
|
const int scale = hSynthesisHybFilter->pSetup->synHybScale[k];
|
||||||
|
|
||||||
FIXP_DBL accu1 = FL2FXCONST_DBL(0.f);
|
FIXP_DBL accu1 = FL2FXCONST_DBL(0.f);
|
||||||
FIXP_DBL accu2 = FL2FXCONST_DBL(0.f);
|
FIXP_DBL accu2 = FL2FXCONST_DBL(0.f);
|
||||||
|
|
||||||
/* Perform hybrid filtering. */
|
/* Perform hybrid filtering. */
|
||||||
for (n = 0; n < nHybBands; n++) {
|
for (n = 0; n < nHybBands; n++) {
|
||||||
accu1 += pHybridReal[hybOffset + n];
|
accu1 += pHybridReal[hybOffset + n] >> scale;
|
||||||
accu2 += pHybridImag[hybOffset + n];
|
accu2 += pHybridImag[hybOffset + n] >> scale;
|
||||||
}
|
}
|
||||||
pQmfReal[k] = accu1;
|
pQmfReal[k] = SATURATE_LEFT_SHIFT(accu1, scale, DFRACT_BITS);
|
||||||
pQmfImag[k] = accu2;
|
pQmfImag[k] = SATURATE_LEFT_SHIFT(accu2, scale, DFRACT_BITS);
|
||||||
|
|
||||||
hybOffset += nHybBands;
|
hybOffset += nHybBands;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user