diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-06-01 14:42:00 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-06-01 14:42:00 +0200 |
commit | e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121 (patch) | |
tree | f49619fc806249da71afaf2ac14f99e088d24153 /fdk-aac/libFDK/src | |
parent | 5ad4acef6721a67b8156cd6f7b45ad59849ca09b (diff) | |
download | ODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.tar.gz ODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.tar.bz2 ODR-AudioEnc-e0835d4cbde8e3b61b0c965afcd41f8f4b7ac121.zip |
Update fdk to v2.0.2
Diffstat (limited to 'fdk-aac/libFDK/src')
-rw-r--r-- | fdk-aac/libFDK/src/FDK_bitbuffer.cpp | 9 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/FDK_core.cpp | 6 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/FDK_decorrelate.cpp | 80 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/FDK_hybrid.cpp | 34 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/FDK_qmf_domain.cpp | 49 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/dct.cpp | 18 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/fft_rad2.cpp | 2 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/fixpoint_math.cpp | 8 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/mdct.cpp | 6 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/mips/scale_mips.cpp | 2 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/nlc_dec.cpp | 10 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/qmf.cpp | 384 | ||||
-rw-r--r-- | fdk-aac/libFDK/src/scale.cpp | 26 |
13 files changed, 153 insertions, 481 deletions
diff --git a/fdk-aac/libFDK/src/FDK_bitbuffer.cpp b/fdk-aac/libFDK/src/FDK_bitbuffer.cpp index 98905ea..9b7f5b8 100644 --- a/fdk-aac/libFDK/src/FDK_bitbuffer.cpp +++ b/fdk-aac/libFDK/src/FDK_bitbuffer.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 @@ -368,7 +368,10 @@ void FDK_Feed(HANDLE_FDK_BITBUF hBitBuf, const UCHAR *RESTRICT inputBuffer, UINT bTotal = 0; - UINT bToRead = (hBitBuf->bufBits - hBitBuf->ValidBits) >> 3; + UINT bToRead = + fMin(hBitBuf->bufBits, + (UINT)fMax(0, ((INT)hBitBuf->bufBits - (INT)hBitBuf->ValidBits))) >> + 3; UINT noOfBytes = fMin(bToRead, *bytesValid); //(bToRead < *bytesValid) ? bToRead : *bytesValid ; @@ -384,7 +387,7 @@ void FDK_Feed(HANDLE_FDK_BITBUF hBitBuf, const UCHAR *RESTRICT inputBuffer, bToRead * sizeof(UCHAR)); /* add noOfBits to number of valid bits in buffer */ - hBitBuf->ValidBits += bToRead << 3; + hBitBuf->ValidBits = (UINT)((INT)hBitBuf->ValidBits + (INT)(bToRead << 3)); bTotal += bToRead; inputBuffer += bToRead; diff --git a/fdk-aac/libFDK/src/FDK_core.cpp b/fdk-aac/libFDK/src/FDK_core.cpp index 75ea8a2..48db17e 100644 --- a/fdk-aac/libFDK/src/FDK_core.cpp +++ b/fdk-aac/libFDK/src/FDK_core.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 @@ -104,10 +104,10 @@ amm-info@iis.fraunhofer.de /* FDK tools library info */ #define FDK_TOOLS_LIB_VL0 3 -#define FDK_TOOLS_LIB_VL1 0 +#define FDK_TOOLS_LIB_VL1 1 #define FDK_TOOLS_LIB_VL2 0 #define FDK_TOOLS_LIB_TITLE "FDK Tools" -#ifdef __ANDROID__ +#ifdef SUPPRESS_BUILD_DATE_INFO #define FDK_TOOLS_LIB_BUILD_DATE "" #define FDK_TOOLS_LIB_BUILD_TIME "" #else diff --git a/fdk-aac/libFDK/src/FDK_decorrelate.cpp b/fdk-aac/libFDK/src/FDK_decorrelate.cpp index c5de79a..324983a 100644 --- a/fdk-aac/libFDK/src/FDK_decorrelate.cpp +++ b/fdk-aac/libFDK/src/FDK_decorrelate.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 @@ -227,7 +227,7 @@ static inline int SpatialDecGetQmfBand(int paramBand, const UCHAR *tab) { } #define DUCKER_MAX_NRG_SCALE (24) -#define DUCKER_HEADROOM_BITS (3) +#define DUCKER_HEADROOM_BITS (2) #define FILTER_SF (2) @@ -606,10 +606,6 @@ static INT DecorrFilterApplyPASS(DECORR_FILTER_INSTANCE const filter[], dataImagIn += start; dataRealOut += start; dataImagOut += start; -#ifdef FUNCTION_DecorrFilterApplyPASS_func1 - DecorrFilterApplyPASS_func1(i, dataRealIn, dataImagIn, dataRealOut, - dataImagOut, pDelayBuffer, offset); -#else do { FIXP_DBL delay_re, delay_im, real, imag; @@ -623,7 +619,6 @@ static INT DecorrFilterApplyPASS(DECORR_FILTER_INSTANCE const filter[], *dataImagOut++ = delay_im; pDelayBuffer += offset; } while (--i != 0); -#endif } } @@ -1061,24 +1056,15 @@ static INT DuckerCalcEnergy(DUCKER_INSTANCE *const self, FIXP_DBL maxVal = FL2FXCONST_DBL(-1.0f); if (maxVal == FL2FXCONST_DBL(-1.0f)) { -#ifdef FUNCTION_DuckerCalcEnergy_func2 - maxVal = DuckerCalcEnergy_func2(inputReal, inputImag, startHybBand, - maxHybBand, maxHybridBand); -#else - FIXP_DBL localMaxVal = FL2FXCONST_DBL(0.0f); - for (qs = startHybBand; qs <= maxHybBand; qs++) { - localMaxVal |= fAbs(inputReal[qs]); - localMaxVal |= fAbs(inputImag[qs]); - } - for (; qs <= maxHybridBand; qs++) { - localMaxVal |= fAbs(inputReal[qs]); - } - maxVal = localMaxVal; -#endif + clz = fMin(getScalefactor(&inputReal[startHybBand], + fMax(0, maxHybridBand - startHybBand + 1)), + getScalefactor(&inputImag[startHybBand], + fMax(0, maxHybBand - startHybBand + 1))); + } else { + clz = CntLeadingZeros(maxVal) - 1; } - clz = fixMax(0, CntLeadingZeros(maxVal) - DUCKER_HEADROOM_BITS); - clz = fixMin(clz, DUCKER_MAX_NRG_SCALE); + clz = fMin(fMax(0, clz - DUCKER_HEADROOM_BITS), DUCKER_MAX_NRG_SCALE); *nrgScale = (SCHAR)clz << 1; /* Initialize pb since it would stay uninitialized for the case startHybBand @@ -1086,9 +1072,10 @@ 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] = - fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) + - fPow2Div2(inputImag[qs] << clz)); + energy[pb] = SATURATE_LEFT_SHIFT( + (energy[pb] >> 1) + (fPow2Div2(inputReal[qs] << clz) >> 1) + + (fPow2Div2(inputImag[qs] << clz) >> 1), + 1, DFRACT_BITS); } pb++; @@ -1112,43 +1099,29 @@ static INT DuckerCalcEnergy(DUCKER_INSTANCE *const self, maxVal = inputMaxVal; if (maxVal == FL2FXCONST_DBL(-1.0f)) { -#ifdef FUNCTION_DuckerCalcEnergy_func2 - maxVal = DuckerCalcEnergy_func2(inputReal, inputImag, startHybBand, - maxHybBand, maxHybridBand); -#else - FIXP_DBL localMaxVal = FL2FXCONST_DBL(0.0f); - for (qs = startHybBand; qs <= maxHybBand; qs++) { - localMaxVal |= fAbs(inputReal[qs]); - localMaxVal |= fAbs(inputImag[qs]); - } - for (; qs <= maxHybridBand; qs++) { - localMaxVal |= fAbs(inputReal[qs]); - } - maxVal = localMaxVal; -#endif + clz = fMin(getScalefactor(&inputReal[startHybBand], + fMax(0, maxHybridBand - startHybBand + 1)), + getScalefactor(&inputImag[startHybBand], + fMax(0, maxHybBand - startHybBand + 1))); + } else { + clz = CntLeadingZeros(maxVal) - 1; } - clz = fixMax(0, CntLeadingZeros(maxVal) - DUCKER_HEADROOM_BITS); - clz = fixMin(clz, DUCKER_MAX_NRG_SCALE); + clz = fMin(fMax(0, clz - DUCKER_HEADROOM_BITS), DUCKER_MAX_NRG_SCALE); *nrgScale = (SCHAR)clz << 1; -#ifdef FUNCTION_DuckerCalcEnergy_func4 - DuckerCalcEnergy_func4(inputReal, inputImag, energy, - self->mapHybBands2ProcBands, clz, startHybBand, - maxHybBand, maxHybridBand); -#else for (qs = startHybBand; qs <= maxHybBand; qs++) { int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands); - energy[pb] = - fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz) + - fPow2Div2(inputImag[qs] << clz)); + energy[pb] = SATURATE_LEFT_SHIFT( + (energy[pb] >> 1) + (fPow2Div2(inputReal[qs] << clz) >> 1) + + (fPow2Div2(inputImag[qs] << clz) >> 1), + 1, DFRACT_BITS); } for (; qs <= maxHybridBand; qs++) { int pb = SpatialDecGetProcessingBand(qs, self->mapHybBands2ProcBands); energy[pb] = fAddSaturate(energy[pb], fPow2Div2(inputReal[qs] << clz)); } -#endif /* FUNCTION_DuckerCalcEnergy_func4 */ } { @@ -1295,10 +1268,6 @@ static INT DuckerApply(DUCKER_INSTANCE *const self, } } -#ifdef FUNCTION_DuckerApply_func1 - qs = DuckerApply_func1(qs, hybBands, qs_next, outputReal, outputImag, - duckGain); -#else /* general gain*output section */ if (qs < hybBands) { /* true for about 39% */ for (; qs < qs_next; qs++) { /* runs about 2 times */ @@ -1310,7 +1279,6 @@ static INT DuckerApply(DUCKER_INSTANCE *const self, outputReal[qs] = fMultDiv2(outputReal[qs], duckGain) << 2; } } -#endif } /* pb */ self->headroomSmoothDirRevNrg = diff --git a/fdk-aac/libFDK/src/FDK_hybrid.cpp b/fdk-aac/libFDK/src/FDK_hybrid.cpp index b661f82..08d32a8 100644 --- a/fdk-aac/libFDK/src/FDK_hybrid.cpp +++ b/fdk-aac/libFDK/src/FDK_hybrid.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 @@ -142,11 +142,12 @@ amm-info@iis.fraunhofer.de } /* How to arrange the packed values. */ struct FDK_HYBRID_SETUP { - UCHAR nrQmfBands; /*!< Number of QMF bands to be converted to hybrid. */ - UCHAR nHybBands[3]; /*!< Number of Hybrid bands generated by nrQmfBands. */ - SCHAR kHybrid[3]; /*!< Filter configuration of each QMF band. */ - UCHAR protoLen; /*!< Prototype filter length. */ - UCHAR filterDelay; /*!< Delay caused by hybrid filter. */ + UCHAR nrQmfBands; /*!< Number of QMF bands to be converted to hybrid. */ + UCHAR nHybBands[3]; /*!< Number of Hybrid bands generated by nrQmfBands. */ + UCHAR synHybScale[3]; /*!< Headroom needed in hybrid synthesis filterbank. */ + SCHAR kHybrid[3]; /*!< Filter configuration of each QMF band. */ + UCHAR protoLen; /*!< Prototype filter length. */ + UCHAR filterDelay; /*!< Delay caused by hybrid filter. */ const INT *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, 5, 6, 7, 8, 9, 10, 11, 12}; -static const FDK_HYBRID_SETUP setup_3_16 = {3, {8, 4, 4}, {8, 4, 4}, - 13, (13 - 1) / 2, ringbuffIdxTab}; -static const FDK_HYBRID_SETUP setup_3_12 = {3, {8, 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}, - 13, (13 - 1) / 2, ringbuffIdxTab}; +static const FDK_HYBRID_SETUP setup_3_16 = { + 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}, {4, 2, 2}, {8, 2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab}; +static const FDK_HYBRID_SETUP setup_3_10 = { + 3, {6, 2, 2}, {3, 2, 2}, {-8, -2, 2}, 13, (13 - 1) / 2, ringbuffIdxTab}; static const FIXP_HTP HybFilterCoef8[] = { HTCP(0x10000000, 0x00000000), HTCP(0x0df26407, 0xfa391882), @@ -477,17 +478,18 @@ void FDKhybridSynthesisApply(HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter, */ for (k = 0; k < nrQmfBandsLF; k++) { const int nHybBands = hSynthesisHybFilter->pSetup->nHybBands[k]; + const int scale = hSynthesisHybFilter->pSetup->synHybScale[k]; FIXP_DBL accu1 = FL2FXCONST_DBL(0.f); FIXP_DBL accu2 = FL2FXCONST_DBL(0.f); /* Perform hybrid filtering. */ for (n = 0; n < nHybBands; n++) { - accu1 += pHybridReal[hybOffset + n]; - accu2 += pHybridImag[hybOffset + n]; + accu1 += pHybridReal[hybOffset + n] >> scale; + accu2 += pHybridImag[hybOffset + n] >> scale; } - pQmfReal[k] = accu1; - pQmfImag[k] = accu2; + pQmfReal[k] = SATURATE_LEFT_SHIFT(accu1, scale, DFRACT_BITS); + pQmfImag[k] = SATURATE_LEFT_SHIFT(accu2, scale, DFRACT_BITS); hybOffset += nHybBands; } diff --git a/fdk-aac/libFDK/src/FDK_qmf_domain.cpp b/fdk-aac/libFDK/src/FDK_qmf_domain.cpp index 3245deb..77c5ca2 100644 --- a/fdk-aac/libFDK/src/FDK_qmf_domain.cpp +++ b/fdk-aac/libFDK/src/FDK_qmf_domain.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 @@ -106,35 +106,31 @@ amm-info@iis.fraunhofer.de #include "common_fix.h" #define WORKBUFFER1_TAG 0 -#define WORKBUFFER2_TAG 1 - #define WORKBUFFER3_TAG 4 #define WORKBUFFER4_TAG 5 -#define WORKBUFFER5_TAG 6 #define WORKBUFFER6_TAG 7 +#define WORKBUFFER7_TAG 8 C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore1, FIXP_DBL, QMF_WB_SECTION_SIZE, SECT_DATA_L1, WORKBUFFER1_TAG) -C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore2, FIXP_DBL, QMF_WB_SECTION_SIZE, - SECT_DATA_L2, WORKBUFFER2_TAG) C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore3, FIXP_DBL, QMF_WB_SECTION_SIZE, SECT_DATA_L2, WORKBUFFER3_TAG) C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore4, FIXP_DBL, QMF_WB_SECTION_SIZE, SECT_DATA_L2, WORKBUFFER4_TAG) -C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore5, FIXP_DBL, QMF_WB_SECTION_SIZE, - SECT_DATA_L2, WORKBUFFER5_TAG) C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore6, FIXP_DBL, QMF_WB_SECTION_SIZE, SECT_DATA_L2, WORKBUFFER6_TAG) +C_ALLOC_MEM_OVERLAY(QmfWorkBufferCore7, FIXP_DBL, QMF_WB_SECTION_SIZE, + SECT_DATA_L2, WORKBUFFER7_TAG) /*! Analysis states buffer. <br> Dimension: #((8) + (1)) */ -C_ALLOC_MEM2(AnaQmfStates, FIXP_QAS, 10 * QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS, - ((8) + (1))) +C_AALLOC_MEM2(AnaQmfStates, FIXP_DBL, 10 * QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS, + ((8) + (1))) /*! Synthesis states buffer. <br> Dimension: #((8) + (1)) */ -C_ALLOC_MEM2(SynQmfStates, FIXP_QSS, 9 * QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS, - ((8) + (1))) +C_AALLOC_MEM2(SynQmfStates, FIXP_QSS, 9 * QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS, + ((8) + (1))) /*! Pointer to real qmf data for each time slot. <br> Dimension: #((8) + (1)) */ @@ -156,18 +152,17 @@ C_AALLOC_MEM2(QmfOverlapBuffer, FIXP_DBL, /*! Analysis states buffer. <br> Dimension: #((8) + (1)) */ -C_ALLOC_MEM2(AnaQmfStates16, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_16, - ((8) + (1))) - +C_AALLOC_MEM2(AnaQmfStates16, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_16, + ((8) + (1))) /*! Analysis states buffer. <br> Dimension: #((8) + (1)) */ -C_ALLOC_MEM2(AnaQmfStates24, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_24, - ((8) + (1))) +C_AALLOC_MEM2(AnaQmfStates24, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_24, + ((8) + (1))) /*! Analysis states buffer. <br> Dimension: #((8) + (1)) */ -C_ALLOC_MEM2(AnaQmfStates32, FIXP_QAS, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_32, - ((8) + (1))) +C_AALLOC_MEM2(AnaQmfStates32, FIXP_DBL, 10 * QMF_DOMAIN_ANALYSIS_QMF_BANDS_32, + ((8) + (1))) /*! Pointer to real qmf data for each time slot. <br> Dimension: #((8) + (1)) */ @@ -642,10 +637,10 @@ void FDK_QmfDomain_GetSlot(const HANDLE_FDK_QMF_DOMAIN_IN qd_ch, const int ts, if (pQmfOutImag == NULL) { for (; b < fMin(lsb, stop_band); b++) { - pQmfOutReal[b] = scaleValue(real[b], lb_sf); + pQmfOutReal[b] = scaleValueSaturate(real[b], lb_sf); } for (; b < fMin(usb, stop_band); b++) { - pQmfOutReal[b] = scaleValue(real[b], hb_sf); + pQmfOutReal[b] = scaleValueSaturate(real[b], hb_sf); } for (; b < stop_band; b++) { pQmfOutReal[b] = (FIXP_DBL)0; @@ -653,12 +648,12 @@ void FDK_QmfDomain_GetSlot(const HANDLE_FDK_QMF_DOMAIN_IN qd_ch, const int ts, } else { FDK_ASSERT(imag != NULL); for (; b < fMin(lsb, stop_band); b++) { - pQmfOutReal[b] = scaleValue(real[b], lb_sf); - pQmfOutImag[b] = scaleValue(imag[b], lb_sf); + pQmfOutReal[b] = scaleValueSaturate(real[b], lb_sf); + pQmfOutImag[b] = scaleValueSaturate(imag[b], lb_sf); } for (; b < fMin(usb, stop_band); b++) { - pQmfOutReal[b] = scaleValue(real[b], hb_sf); - pQmfOutImag[b] = scaleValue(imag[b], hb_sf); + pQmfOutReal[b] = scaleValueSaturate(real[b], hb_sf); + pQmfOutImag[b] = scaleValueSaturate(imag[b], hb_sf); } for (; b < stop_band; b++) { pQmfOutReal[b] = (FIXP_DBL)0; @@ -950,7 +945,7 @@ QMF_DOMAIN_ERROR FDK_QmfDomain_Configure(HANDLE_FDK_QMF_DOMAIN hqd) { if ((size > 4 * QMF_WB_SECTION_SIZE) && (pWorkBuffer[4] == NULL)) { /* get work buffer of size QMF_WB_SECTION_SIZE */ - pWorkBuffer[4] = GetQmfWorkBufferCore5(); + pWorkBuffer[4] = GetQmfWorkBufferCore7(); } /* 8. distribute workbuffer over processing channels */ @@ -996,7 +991,7 @@ static void FDK_QmfDomain_FreeWorkBuffer(HANDLE_FDK_QMF_DOMAIN hqd) { if (pWorkBuffer[1]) FreeQmfWorkBufferCore1(&pWorkBuffer[1]); if (pWorkBuffer[2]) FreeQmfWorkBufferCore3(&pWorkBuffer[2]); if (pWorkBuffer[3]) FreeQmfWorkBufferCore4(&pWorkBuffer[3]); - if (pWorkBuffer[4]) FreeQmfWorkBufferCore5(&pWorkBuffer[4]); + if (pWorkBuffer[4]) FreeQmfWorkBufferCore7(&pWorkBuffer[4]); } void FDK_QmfDomain_FreeMem(HANDLE_FDK_QMF_DOMAIN hqd) { diff --git a/fdk-aac/libFDK/src/dct.cpp b/fdk-aac/libFDK/src/dct.cpp index 776493e..bd26736 100644 --- a/fdk-aac/libFDK/src/dct.cpp +++ b/fdk-aac/libFDK/src/dct.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 @@ -489,18 +489,18 @@ void dst_IV(FIXP_DBL *pDat, int L, int *pDat_e) { for (i = 0; i < M - 1; i += 2, pDat_0 += 2, pDat_1 -= 2) { FIXP_DBL accu1, accu2, accu3, accu4; - accu1 = pDat_1[1]; - accu2 = -pDat_0[0]; - accu3 = pDat_0[1]; - accu4 = -pDat_1[0]; + accu1 = pDat_1[1] >> 1; + accu2 = -(pDat_0[0] >> 1); + accu3 = pDat_0[1] >> 1; + accu4 = -(pDat_1[0] >> 1); cplxMultDiv2(&accu1, &accu2, accu1, accu2, twiddle[i]); cplxMultDiv2(&accu3, &accu4, accu4, accu3, twiddle[i + 1]); - pDat_0[0] = accu2 >> 1; - pDat_0[1] = accu1 >> 1; - pDat_1[0] = accu4 >> 1; - pDat_1[1] = -(accu3 >> 1); + pDat_0[0] = accu2; + pDat_0[1] = accu1; + pDat_1[0] = accu4; + pDat_1[1] = -accu3; } if (M & 1) { FIXP_DBL accu1, accu2; diff --git a/fdk-aac/libFDK/src/fft_rad2.cpp b/fdk-aac/libFDK/src/fft_rad2.cpp index 27f3aa0..f457f8b 100644 --- a/fdk-aac/libFDK/src/fft_rad2.cpp +++ b/fdk-aac/libFDK/src/fft_rad2.cpp @@ -109,7 +109,7 @@ amm-info@iis.fraunhofer.de #if defined(__arm__) #include "arm/fft_rad2_arm.cpp" -#elif defined(__GNUC__) && defined(__mips__) && defined(__mips_dsp) +#elif defined(__GNUC__) && defined(__mips__) && defined(__mips_dsp) && !defined(__mips16) #include "mips/fft_rad2_mips.cpp" #endif diff --git a/fdk-aac/libFDK/src/fixpoint_math.cpp b/fdk-aac/libFDK/src/fixpoint_math.cpp index 6c656fa..1e26420 100644 --- a/fdk-aac/libFDK/src/fixpoint_math.cpp +++ b/fdk-aac/libFDK/src/fixpoint_math.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 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -650,6 +650,12 @@ FIXP_DBL fPow(FIXP_DBL base_m, INT base_e, FIXP_DBL exp_m, INT exp_e, INT ans_lg2_e, baselg2_e; FIXP_DBL base_lg2, ans_lg2, result; + if (base_m <= (FIXP_DBL)0) { + result = (FIXP_DBL)0; + *result_e = 0; + return result; + } + /* Calc log2 of base */ base_lg2 = fLog2(base_m, base_e, &baselg2_e); diff --git a/fdk-aac/libFDK/src/mdct.cpp b/fdk-aac/libFDK/src/mdct.cpp index f5aa284..c864fa1 100644 --- a/fdk-aac/libFDK/src/mdct.cpp +++ b/fdk-aac/libFDK/src/mdct.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 @@ -572,7 +572,7 @@ INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum, */ for (i = 0; i < hMdct->prev_nr; i++) { FIXP_DBL x = -(*pOvl--); - *pOut0 = IMDCT_SCALE_DBL(x + hMdct->pFacZir[i]); + *pOut0 = fAddSaturate(x, IMDCT_SCALE_DBL(hMdct->pFacZir[i])); pOut0++; } hMdct->pFacZir = NULL; @@ -681,7 +681,7 @@ INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum, FIXP_DBL *pOut = pOut0 - fl / 2; FDK_ASSERT(fl / 2 <= 128); for (i = 0; i < fl / 2; i++) { - pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]); + pOut[i] = fAddSaturate(pOut[i], IMDCT_SCALE_DBL(hMdct->pFacZir[i])); } hMdct->pFacZir = NULL; } diff --git a/fdk-aac/libFDK/src/mips/scale_mips.cpp b/fdk-aac/libFDK/src/mips/scale_mips.cpp index 1a3d33c..ff295d9 100644 --- a/fdk-aac/libFDK/src/mips/scale_mips.cpp +++ b/fdk-aac/libFDK/src/mips/scale_mips.cpp @@ -100,7 +100,7 @@ amm-info@iis.fraunhofer.de *******************************************************************************/ -#if defined(__mips_dsp) +#if defined(__mips_dsp) && !defined(__mips16) #ifndef FUNCTION_getScalefactor_DBL #define FUNCTION_getScalefactor_DBL diff --git a/fdk-aac/libFDK/src/nlc_dec.cpp b/fdk-aac/libFDK/src/nlc_dec.cpp index 6e98ce0..8b2f97d 100644 --- a/fdk-aac/libFDK/src/nlc_dec.cpp +++ b/fdk-aac/libFDK/src/nlc_dec.cpp @@ -568,7 +568,7 @@ bail: static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, SCHAR* out_data_2, DATA_TYPE data_type, DIFF_TYPE diff_type_1, DIFF_TYPE diff_type_2, - int num_val, CODING_SCHEME* cdg_scheme, int ldMode) { + int num_val, int* cdg_scheme, int ldMode) { ERROR_t err = HUFFDEC_OK; DIFF_TYPE diff_type; @@ -597,14 +597,14 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, /* Coding scheme */ data = FDKreadBits(strm, 1); - *cdg_scheme = (CODING_SCHEME)(data << PAIR_SHIFT); + *cdg_scheme = (data << PAIR_SHIFT); if (*cdg_scheme >> PAIR_SHIFT == HUFF_2D) { if ((out_data_1 != NULL) && (out_data_2 != NULL) && (ldMode == 0)) { data = FDKreadBits(strm, 1); - *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | data); + *cdg_scheme = (*cdg_scheme | data); } else { - *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | FREQ_PAIR); + *cdg_scheme = (*cdg_scheme | FREQ_PAIR); } } @@ -843,7 +843,7 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, SCHAR* pDataVec[2] = {NULL, NULL}; DIFF_TYPE diff_type[2] = {DIFF_FREQ, DIFF_FREQ}; - CODING_SCHEME cdg_scheme = HUFF_1D; + int cdg_scheme = HUFF_1D; DIRECTION direction = BACKWARDS; switch (data_type) { diff --git a/fdk-aac/libFDK/src/qmf.cpp b/fdk-aac/libFDK/src/qmf.cpp index 6fca043..440bec2 100644 --- a/fdk-aac/libFDK/src/qmf.cpp +++ b/fdk-aac/libFDK/src/qmf.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 @@ -147,88 +147,6 @@ amm-info@iis.fraunhofer.de /* moved to qmf_pcm.h: -> qmfSynPrototypeFirSlot_NonSymmetric */ /* moved to qmf_pcm.h: -> qmfSynthesisFilteringSlot */ -#ifndef FUNCTION_qmfAnaPrototypeFirSlot -/*! - \brief Perform Analysis Prototype Filtering on a single slot of input data. -*/ -static void qmfAnaPrototypeFirSlot( - FIXP_DBL *analysisBuffer, - INT no_channels, /*!< Number channels of analysis filter */ - const FIXP_PFT *p_filter, INT p_stride, /*!< Stride of analysis filter */ - FIXP_QAS *RESTRICT pFilterStates) { - INT k; - - FIXP_DBL accu; - const FIXP_PFT *RESTRICT p_flt = p_filter; - FIXP_DBL *RESTRICT pData_0 = analysisBuffer + 2 * no_channels - 1; - FIXP_DBL *RESTRICT pData_1 = analysisBuffer; - - FIXP_QAS *RESTRICT sta_0 = (FIXP_QAS *)pFilterStates; - FIXP_QAS *RESTRICT sta_1 = - (FIXP_QAS *)pFilterStates + (2 * QMF_NO_POLY * no_channels) - 1; - INT pfltStep = QMF_NO_POLY * (p_stride); - INT staStep1 = no_channels << 1; - INT staStep2 = (no_channels << 3) - 1; /* Rewind one less */ - - /* FIR filters 127..64 0..63 */ - for (k = 0; k < no_channels; k++) { - accu = fMultDiv2(p_flt[0], *sta_1); - sta_1 -= staStep1; - accu += fMultDiv2(p_flt[1], *sta_1); - sta_1 -= staStep1; - accu += fMultDiv2(p_flt[2], *sta_1); - sta_1 -= staStep1; - accu += fMultDiv2(p_flt[3], *sta_1); - sta_1 -= staStep1; - accu += fMultDiv2(p_flt[4], *sta_1); - *pData_1++ = (accu << 1); - sta_1 += staStep2; - - p_flt += pfltStep; - accu = fMultDiv2(p_flt[0], *sta_0); - sta_0 += staStep1; - accu += fMultDiv2(p_flt[1], *sta_0); - sta_0 += staStep1; - accu += fMultDiv2(p_flt[2], *sta_0); - sta_0 += staStep1; - accu += fMultDiv2(p_flt[3], *sta_0); - sta_0 += staStep1; - accu += fMultDiv2(p_flt[4], *sta_0); - *pData_0-- = (accu << 1); - sta_0 -= staStep2; - } -} -#endif /* !defined(FUNCTION_qmfAnaPrototypeFirSlot) */ - -#ifndef FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric -/*! - \brief Perform Analysis Prototype Filtering on a single slot of input data. -*/ -static void qmfAnaPrototypeFirSlot_NonSymmetric( - FIXP_DBL *analysisBuffer, - int no_channels, /*!< Number channels of analysis filter */ - const FIXP_PFT *p_filter, int p_stride, /*!< Stride of analysis filter */ - FIXP_QAS *RESTRICT pFilterStates) { - const FIXP_PFT *RESTRICT p_flt = p_filter; - int p, k; - - for (k = 0; k < 2 * no_channels; k++) { - FIXP_DBL accu = (FIXP_DBL)0; - - p_flt += QMF_NO_POLY * (p_stride - 1); - - /* - Perform FIR-Filter - */ - for (p = 0; p < QMF_NO_POLY; p++) { - accu += fMultDiv2(*p_flt++, pFilterStates[2 * no_channels * p]); - } - analysisBuffer[2 * no_channels - 1 - k] = (accu << 1); - pFilterStates++; - } -} -#endif /* FUNCTION_qmfAnaPrototypeFirSlot_NonSymmetric */ - /*! * * \brief Perform real-valued forward modulation of the time domain @@ -244,7 +162,7 @@ static void qmfForwardModulationLP_even( int i; int L = anaQmf->no_channels; int M = L >> 1; - int scale; + int scale = 0; FIXP_DBL accu; const FIXP_DBL *timeInTmp1 = (FIXP_DBL *)&timeIn[3 * M]; @@ -381,211 +299,6 @@ static void qmfForwardModulationHQ( } #endif /* FUNCTION_qmfForwardModulationHQ */ -/* - * \brief Perform one QMF slot analysis of the time domain data of timeIn - * with specified stride and stores the real part of the subband - * samples in rSubband, and the imaginary part in iSubband - * - * Note: anaQmf->lsb can be greater than anaQmf->no_channels in case - * of implicit resampling (USAC with reduced 3/4 core frame length). - */ -#if (SAMPLE_BITS != DFRACT_BITS) && (QAS_BITS == DFRACT_BITS) -void qmfAnalysisFilteringSlot( - HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */ - FIXP_DBL *qmfReal, /*!< Low and High band, real */ - FIXP_DBL *qmfImag, /*!< Low and High band, imag */ - const LONG *RESTRICT timeIn, /*!< Pointer to input */ - const int stride, /*!< stride factor of input */ - FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */ -) { - int offset = anaQmf->no_channels * (QMF_NO_POLY * 2 - 1); - /* - Feed time signal into oldest anaQmf->no_channels states - */ - { - FIXP_DBL *FilterStatesAnaTmp = ((FIXP_DBL *)anaQmf->FilterStates) + offset; - - /* Feed and scale actual time in slot */ - for (int i = anaQmf->no_channels >> 1; i != 0; i--) { - /* Place INT_PCM value left aligned in scaledTimeIn */ - - *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn; - timeIn += stride; - *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn; - timeIn += stride; - } - } - - if (anaQmf->flags & QMF_FLAG_NONSYMMETRIC) { - qmfAnaPrototypeFirSlot_NonSymmetric(pWorkBuffer, anaQmf->no_channels, - anaQmf->p_filter, anaQmf->p_stride, - (FIXP_QAS *)anaQmf->FilterStates); - } else { - qmfAnaPrototypeFirSlot(pWorkBuffer, anaQmf->no_channels, anaQmf->p_filter, - anaQmf->p_stride, (FIXP_QAS *)anaQmf->FilterStates); - } - - if (anaQmf->flags & QMF_FLAG_LP) { - if (anaQmf->flags & QMF_FLAG_CLDFB) - qmfForwardModulationLP_odd(anaQmf, pWorkBuffer, qmfReal); - else - qmfForwardModulationLP_even(anaQmf, pWorkBuffer, qmfReal); - - } else { - qmfForwardModulationHQ(anaQmf, pWorkBuffer, qmfReal, qmfImag); - } - /* - Shift filter states - - Should be realized with modulo adressing on a DSP instead of a true buffer - shift - */ - FDKmemmove(anaQmf->FilterStates, - (FIXP_QAS *)anaQmf->FilterStates + anaQmf->no_channels, - offset * sizeof(FIXP_QAS)); -} -#endif - -void qmfAnalysisFilteringSlot( - HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */ - FIXP_DBL *qmfReal, /*!< Low and High band, real */ - FIXP_DBL *qmfImag, /*!< Low and High band, imag */ - const INT_PCM *RESTRICT timeIn, /*!< Pointer to input */ - const int stride, /*!< stride factor of input */ - FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */ -) { - int offset = anaQmf->no_channels * (QMF_NO_POLY * 2 - 1); - /* - Feed time signal into oldest anaQmf->no_channels states - */ - { - FIXP_QAS *FilterStatesAnaTmp = ((FIXP_QAS *)anaQmf->FilterStates) + offset; - - /* Feed and scale actual time in slot */ - for (int i = anaQmf->no_channels >> 1; i != 0; i--) { - /* Place INT_PCM value left aligned in scaledTimeIn */ -#if (QAS_BITS == SAMPLE_BITS) - *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn; - timeIn += stride; - *FilterStatesAnaTmp++ = (FIXP_QAS)*timeIn; - timeIn += stride; -#elif (QAS_BITS > SAMPLE_BITS) - *FilterStatesAnaTmp++ = ((FIXP_QAS)*timeIn) << (QAS_BITS - SAMPLE_BITS); - timeIn += stride; - *FilterStatesAnaTmp++ = ((FIXP_QAS)*timeIn) << (QAS_BITS - SAMPLE_BITS); - timeIn += stride; -#else - *FilterStatesAnaTmp++ = (FIXP_QAS)((*timeIn) >> (SAMPLE_BITS - QAS_BITS)); - timeIn += stride; - *FilterStatesAnaTmp++ = (FIXP_QAS)((*timeIn) >> (SAMPLE_BITS - QAS_BITS)); - timeIn += stride; -#endif - } - } - - if (anaQmf->flags & QMF_FLAG_NONSYMMETRIC) { - qmfAnaPrototypeFirSlot_NonSymmetric(pWorkBuffer, anaQmf->no_channels, - anaQmf->p_filter, anaQmf->p_stride, - (FIXP_QAS *)anaQmf->FilterStates); - } else { - qmfAnaPrototypeFirSlot(pWorkBuffer, anaQmf->no_channels, anaQmf->p_filter, - anaQmf->p_stride, (FIXP_QAS *)anaQmf->FilterStates); - } - - if (anaQmf->flags & QMF_FLAG_LP) { - if (anaQmf->flags & QMF_FLAG_CLDFB) - qmfForwardModulationLP_odd(anaQmf, pWorkBuffer, qmfReal); - else - qmfForwardModulationLP_even(anaQmf, pWorkBuffer, qmfReal); - - } else { - qmfForwardModulationHQ(anaQmf, pWorkBuffer, qmfReal, qmfImag); - } - /* - Shift filter states - - Should be realized with modulo adressing on a DSP instead of a true buffer - shift - */ - FDKmemmove(anaQmf->FilterStates, - (FIXP_QAS *)anaQmf->FilterStates + anaQmf->no_channels, - offset * sizeof(FIXP_QAS)); -} - -/*! - * - * \brief Perform complex-valued subband filtering of the time domain - * data of timeIn and stores the real part of the subband - * samples in rAnalysis, and the imaginary part in iAnalysis - * The qmf coefficient table is symmetric. The symmetry is expoited by - * shrinking the coefficient table to half the size. The addressing mode - * takes care of the symmetries. - * - * - * \sa PolyphaseFiltering - */ -#if (SAMPLE_BITS != DFRACT_BITS) && (QAS_BITS == DFRACT_BITS) -void qmfAnalysisFiltering( - HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */ - FIXP_DBL **qmfReal, /*!< Pointer to real subband slots */ - FIXP_DBL **qmfImag, /*!< Pointer to imag subband slots */ - QMF_SCALE_FACTOR *scaleFactor, const LONG *timeIn, /*!< Time signal */ - const int timeIn_e, const int stride, - FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */ -) { - int i; - int no_channels = anaQmf->no_channels; - - scaleFactor->lb_scale = - -ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK - timeIn_e; - scaleFactor->lb_scale -= anaQmf->filterScale; - - for (i = 0; i < anaQmf->no_col; i++) { - FIXP_DBL *qmfImagSlot = NULL; - - if (!(anaQmf->flags & QMF_FLAG_LP)) { - qmfImagSlot = qmfImag[i]; - } - - qmfAnalysisFilteringSlot(anaQmf, qmfReal[i], qmfImagSlot, timeIn, stride, - pWorkBuffer); - - timeIn += no_channels * stride; - - } /* no_col loop i */ -} -#endif - -void qmfAnalysisFiltering( - HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */ - FIXP_DBL **qmfReal, /*!< Pointer to real subband slots */ - FIXP_DBL **qmfImag, /*!< Pointer to imag subband slots */ - QMF_SCALE_FACTOR *scaleFactor, const INT_PCM *timeIn, /*!< Time signal */ - const int timeIn_e, const int stride, - FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */ -) { - int i; - int no_channels = anaQmf->no_channels; - - scaleFactor->lb_scale = - -ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK - timeIn_e; - scaleFactor->lb_scale -= anaQmf->filterScale; - - for (i = 0; i < anaQmf->no_col; i++) { - FIXP_DBL *qmfImagSlot = NULL; - - if (!(anaQmf->flags & QMF_FLAG_LP)) { - qmfImagSlot = qmfImag[i]; - } - - qmfAnalysisFilteringSlot(anaQmf, qmfReal[i], qmfImagSlot, timeIn, stride, - pWorkBuffer); - - timeIn += no_channels * stride; - - } /* no_col loop i */ -} - /*! * * \brief Perform low power inverse modulation of the subband @@ -603,15 +316,15 @@ inline static void qmfInverseModulationLP_even( int i; int L = synQmf->no_channels; int M = L >> 1; - int scale; + int scale = 0; FIXP_DBL tmp; FIXP_DBL *RESTRICT tReal = pTimeOut; FIXP_DBL *RESTRICT tImag = pTimeOut + L; /* Move input to output vector with offset */ - scaleValues(&tReal[0], &qmfReal[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); + scaleValuesSaturate(&tReal[0], &qmfReal[0], synQmf->lsb, scaleFactorLowBand); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); FDKmemclear(&tReal[0 + synQmf->usb], (L - synQmf->usb) * sizeof(FIXP_DBL)); /* Dct type-2 transform */ @@ -662,9 +375,9 @@ inline static void qmfInverseModulationLP_odd( int shift = 0; /* Move input to output vector with offset */ - scaleValues(pTimeOut + M, qmfReal, synQmf->lsb, scaleFactorLowBand); - scaleValues(pTimeOut + M + synQmf->lsb, qmfReal + synQmf->lsb, - synQmf->usb - synQmf->lsb, scaleFactorHighBand); + scaleValuesSaturate(pTimeOut + M, qmfReal, synQmf->lsb, scaleFactorLowBand); + scaleValuesSaturate(pTimeOut + M + synQmf->lsb, qmfReal + synQmf->lsb, + synQmf->usb - synQmf->lsb, scaleFactorHighBand); FDKmemclear(pTimeOut + M + synQmf->usb, (L - synQmf->usb) * sizeof(FIXP_DBL)); dct_IV(pTimeOut + M, L, &shift); @@ -698,26 +411,27 @@ inline static void qmfInverseModulationHQ( FIXP_DBL *RESTRICT tImag = pWorkBuffer + L; if (synQmf->flags & QMF_FLAG_CLDFB) { - for (i = 0; i < synQmf->lsb; i++) { - cplxMult(&tImag[i], &tReal[i], scaleValue(qmfImag[i], scaleFactorLowBand), - scaleValue(qmfReal[i], scaleFactorLowBand), synQmf->t_cos[i], - synQmf->t_sin[i]); - } - for (; i < synQmf->usb; i++) { - cplxMult(&tImag[i], &tReal[i], - scaleValue(qmfImag[i], scaleFactorHighBand), - scaleValue(qmfReal[i], scaleFactorHighBand), synQmf->t_cos[i], - synQmf->t_sin[i]); + for (i = 0; i < synQmf->usb; i++) { + cplxMultDiv2(&tImag[i], &tReal[i], qmfImag[i], qmfReal[i], + synQmf->t_cos[i], synQmf->t_sin[i]); } + scaleValuesSaturate(&tReal[0], synQmf->lsb, scaleFactorLowBand + 1); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], synQmf->usb - synQmf->lsb, + scaleFactorHighBand + 1); + scaleValuesSaturate(&tImag[0], synQmf->lsb, scaleFactorLowBand + 1); + scaleValuesSaturate(&tImag[0 + synQmf->lsb], synQmf->usb - synQmf->lsb, + scaleFactorHighBand + 1); } if ((synQmf->flags & QMF_FLAG_CLDFB) == 0) { - scaleValues(&tReal[0], &qmfReal[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); - scaleValues(&tImag[0], &qmfImag[0], synQmf->lsb, (int)scaleFactorLowBand); - scaleValues(&tImag[0 + synQmf->lsb], &qmfImag[0 + synQmf->lsb], - synQmf->usb - synQmf->lsb, (int)scaleFactorHighBand); + scaleValuesSaturate(&tReal[0], &qmfReal[0], synQmf->lsb, + scaleFactorLowBand); + scaleValuesSaturate(&tReal[0 + synQmf->lsb], &qmfReal[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); + scaleValuesSaturate(&tImag[0], &qmfImag[0], synQmf->lsb, + scaleFactorLowBand); + scaleValuesSaturate(&tImag[0 + synQmf->lsb], &qmfImag[0 + synQmf->lsb], + synQmf->usb - synQmf->lsb, scaleFactorHighBand); } FDKmemclear(&tReal[synQmf->usb], @@ -1004,35 +718,6 @@ static inline void qmfAdaptFilterStates( * \return 0 if succesful * */ -int qmfInitAnalysisFilterBank( - HANDLE_QMF_FILTER_BANK h_Qmf, /*!< Returns handle */ - FIXP_QAS *pFilterStates, /*!< Handle to filter states */ - int noCols, /*!< Number of timeslots per frame */ - int lsb, /*!< lower end of QMF */ - int usb, /*!< upper end of QMF */ - int no_channels, /*!< Number of channels (bands) */ - int flags) /*!< Low Power flag */ -{ - int err = qmfInitFilterBank(h_Qmf, pFilterStates, noCols, lsb, usb, - no_channels, flags, 0); - if (!(flags & QMF_FLAG_KEEP_STATES) && (h_Qmf->FilterStates != NULL)) { - FDKmemclear(h_Qmf->FilterStates, - (2 * QMF_NO_POLY - 1) * h_Qmf->no_channels * sizeof(FIXP_QAS)); - } - - FDK_ASSERT(h_Qmf->no_channels >= h_Qmf->lsb); - - return err; -} - -/*! - * - * \brief Create QMF filter bank instance - * - * - * \return 0 if succesful - * - */ int qmfInitSynthesisFilterBank( HANDLE_QMF_FILTER_BANK h_Qmf, /*!< Returns handle */ FIXP_QSS *pFilterStates, /*!< Handle to filter states */ @@ -1128,8 +813,21 @@ void qmfChangeOutGain( synQmf->outGain_e = outputGainScale; } -/* When QMF_16IN_32OUT is set, synthesis functions for 16 and 32 bit parallel - * output is compiled */ #define INT_PCM_QMFOUT INT_PCM #define SAMPLE_BITS_QMFOUT SAMPLE_BITS #include "qmf_pcm.h" +#if SAMPLE_BITS == 16 + /* also create a 32 bit output version */ +#undef INT_PCM_QMFOUT +#undef SAMPLE_BITS_QMFOUT +#undef QMF_PCM_H +#undef FIXP_QAS +#undef QAS_BITS +#undef INT_PCM_QMFIN +#define INT_PCM_QMFOUT LONG +#define SAMPLE_BITS_QMFOUT 32 +#define FIXP_QAS FIXP_DBL +#define QAS_BITS 32 +#define INT_PCM_QMFIN LONG +#include "qmf_pcm.h" +#endif diff --git a/fdk-aac/libFDK/src/scale.cpp b/fdk-aac/libFDK/src/scale.cpp index 24a8a5b..6192170 100644 --- a/fdk-aac/libFDK/src/scale.cpp +++ b/fdk-aac/libFDK/src/scale.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 @@ -250,10 +250,10 @@ void scaleValuesSaturate(FIXP_DBL *vector, /*!< Vector */ */ #define FUNCTION_scaleValuesSaturate_DBL_DBL SCALE_INLINE -void scaleValuesSaturate(FIXP_DBL *dst, /*!< Output */ - FIXP_DBL *src, /*!< Input */ - INT len, /*!< Length */ - INT scalefactor /*!< Scalefactor */ +void scaleValuesSaturate(FIXP_DBL *dst, /*!< Output */ + const FIXP_DBL *src, /*!< Input */ + INT len, /*!< Length */ + INT scalefactor /*!< Scalefactor */ ) { INT i; @@ -285,10 +285,10 @@ void scaleValuesSaturate(FIXP_DBL *dst, /*!< Output */ */ #define FUNCTION_scaleValuesSaturate_SGL_DBL SCALE_INLINE -void scaleValuesSaturate(FIXP_SGL *dst, /*!< Output */ - FIXP_DBL *src, /*!< Input */ - INT len, /*!< Length */ - INT scalefactor) /*!< Scalefactor */ +void scaleValuesSaturate(FIXP_SGL *dst, /*!< Output */ + const FIXP_DBL *src, /*!< Input */ + INT len, /*!< Length */ + INT scalefactor) /*!< Scalefactor */ { INT i; scalefactor = fixmax_I(fixmin_I(scalefactor, (INT)DFRACT_BITS - 1), @@ -345,10 +345,10 @@ void scaleValuesSaturate(FIXP_SGL *vector, /*!< Vector */ */ #define FUNCTION_scaleValuesSaturate_SGL_SGL SCALE_INLINE -void scaleValuesSaturate(FIXP_SGL *dst, /*!< Output */ - FIXP_SGL *src, /*!< Input */ - INT len, /*!< Length */ - INT scalefactor /*!< Scalefactor */ +void scaleValuesSaturate(FIXP_SGL *dst, /*!< Output */ + const FIXP_SGL *src, /*!< Input */ + INT len, /*!< Length */ + INT scalefactor /*!< Scalefactor */ ) { INT i; |