diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-01-05 17:50:19 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-01-05 17:50:19 +0100 |
commit | 571316f329948dc464cc2be37b210f0b3e7816f7 (patch) | |
tree | 8396262af9d84f5a0490af9805cde11cf5fc9eed /libFDK/src | |
parent | e778887e4e5589528b06b04404ce4c71aaae267a (diff) | |
parent | 716f4394641d53f0d79c9ddac3fa93b03a49f278 (diff) | |
download | fdk-aac-dabplus2.tar.gz fdk-aac-dabplus2.tar.bz2 fdk-aac-dabplus2.zip |
Merge fdk-aac 'v2.0.3' into dabplus2dabplus2
Diffstat (limited to 'libFDK/src')
-rw-r--r-- | libFDK/src/FDK_hybrid.cpp | 26 | ||||
-rw-r--r-- | libFDK/src/autocorr2nd.cpp | 43 | ||||
-rw-r--r-- | libFDK/src/dct.cpp | 28 | ||||
-rw-r--r-- | libFDK/src/fft.cpp | 6 | ||||
-rw-r--r-- | libFDK/src/nlc_dec.cpp | 28 |
5 files changed, 63 insertions, 68 deletions
diff --git a/libFDK/src/FDK_hybrid.cpp b/libFDK/src/FDK_hybrid.cpp index 08d32a8..d208abd 100644 --- a/libFDK/src/FDK_hybrid.cpp +++ b/libFDK/src/FDK_hybrid.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2019 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 @@ -539,11 +539,11 @@ static void dualChannelFiltering(const FIXP_DBL *const pQmfReal, i6 = pQmfImag[pReadIdx[6]] >> 2; FDK_ASSERT((invert == 0) || (invert == 1)); - mHybridReal[0 + invert] = (r6 + r1) << 1; - mHybridImag[0 + invert] = (i6 + i1) << 1; + mHybridReal[0 + invert] = SATURATE_LEFT_SHIFT((r6 + r1), 1, DFRACT_BITS); + mHybridImag[0 + invert] = SATURATE_LEFT_SHIFT((i6 + i1), 1, DFRACT_BITS); - mHybridReal[1 - invert] = (r6 - r1) << 1; - mHybridImag[1 - invert] = (i6 - i1) << 1; + mHybridReal[1 - invert] = SATURATE_LEFT_SHIFT((r6 - r1), 1, DFRACT_BITS); + mHybridImag[1 - invert] = SATURATE_LEFT_SHIFT((i6 - i1), 1, DFRACT_BITS); } static void fourChannelFiltering(const FIXP_DBL *const pQmfReal, @@ -766,15 +766,15 @@ static void eightChannelFiltering(const FIXP_DBL *const pQmfReal, mHybridReal[3] = pfft[FFT_IDX_R(1)] << sc; mHybridImag[3] = pfft[FFT_IDX_I(1)] << sc; - mHybridReal[4] = pfft[FFT_IDX_R(2)] << sc; - mHybridReal[4] += pfft[FFT_IDX_R(5)] << sc; - mHybridImag[4] = pfft[FFT_IDX_I(2)] << sc; - mHybridImag[4] += pfft[FFT_IDX_I(5)] << sc; + mHybridReal[4] = SATURATE_LEFT_SHIFT( + (pfft[FFT_IDX_R(2)] + pfft[FFT_IDX_R(5)]), sc, DFRACT_BITS); + mHybridImag[4] = SATURATE_LEFT_SHIFT( + (pfft[FFT_IDX_I(2)] + pfft[FFT_IDX_I(5)]), sc, DFRACT_BITS); - mHybridReal[5] = pfft[FFT_IDX_R(3)] << sc; - mHybridReal[5] += pfft[FFT_IDX_R(4)] << sc; - mHybridImag[5] = pfft[FFT_IDX_I(3)] << sc; - mHybridImag[5] += pfft[FFT_IDX_I(4)] << sc; + mHybridReal[5] = SATURATE_LEFT_SHIFT( + (pfft[FFT_IDX_R(3)] + pfft[FFT_IDX_R(4)]), sc, DFRACT_BITS); + mHybridImag[5] = SATURATE_LEFT_SHIFT( + (pfft[FFT_IDX_I(3)] + pfft[FFT_IDX_I(4)]), sc, DFRACT_BITS); } else { for (k = 0; k < 8; k++) { mHybridReal[k] = pfft[FFT_IDX_R(k)] << sc; diff --git a/libFDK/src/autocorr2nd.cpp b/libFDK/src/autocorr2nd.cpp index 718a555..8c5673c 100644 --- a/libFDK/src/autocorr2nd.cpp +++ b/libFDK/src/autocorr2nd.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 @@ -102,11 +102,6 @@ amm-info@iis.fraunhofer.de #include "autocorr2nd.h" -/* If the accumulator does not provide enough overflow bits, - products have to be shifted down in the autocorrelation below. */ -#define SHIFT_FACTOR (5) -#define SHIFT >> (SHIFT_FACTOR) - /*! * * \brief Calculate second order autocorrelation using 2 accumulators @@ -126,45 +121,49 @@ INT autoCorr2nd_real( const FIXP_DBL *realBuf = reBuffer; + const int len_scale = fMax(DFRACT_BITS - fNormz((FIXP_DBL)(len / 2)), 1); /* r11r,r22r r01r,r12r r02r */ pReBuf = realBuf - 2; - accu5 = ((fMultDiv2(pReBuf[0], pReBuf[2]) + fMultDiv2(pReBuf[1], pReBuf[3])) - SHIFT); + accu5 = + ((fMultDiv2(pReBuf[0], pReBuf[2]) + fMultDiv2(pReBuf[1], pReBuf[3])) >> + len_scale); pReBuf++; /* len must be even */ - accu1 = fPow2Div2(pReBuf[0]) SHIFT; - accu3 = fMultDiv2(pReBuf[0], pReBuf[1]) SHIFT; + accu1 = fPow2Div2(pReBuf[0]) >> len_scale; + accu3 = fMultDiv2(pReBuf[0], pReBuf[1]) >> len_scale; pReBuf++; for (j = (len - 2) >> 1; j != 0; j--, pReBuf += 2) { - accu1 += ((fPow2Div2(pReBuf[0]) + fPow2Div2(pReBuf[1])) SHIFT); + accu1 += ((fPow2Div2(pReBuf[0]) + fPow2Div2(pReBuf[1])) >> len_scale); - accu3 += ((fMultDiv2(pReBuf[0], pReBuf[1]) + - fMultDiv2(pReBuf[1], pReBuf[2])) SHIFT); + accu3 += + ((fMultDiv2(pReBuf[0], pReBuf[1]) + fMultDiv2(pReBuf[1], pReBuf[2])) >> + len_scale); - accu5 += ((fMultDiv2(pReBuf[0], pReBuf[2]) + - fMultDiv2(pReBuf[1], pReBuf[3])) SHIFT); + accu5 += + ((fMultDiv2(pReBuf[0], pReBuf[2]) + fMultDiv2(pReBuf[1], pReBuf[3])) >> + len_scale); } - accu2 = (fPow2Div2(realBuf[-2]) SHIFT); + accu2 = (fPow2Div2(realBuf[-2]) >> len_scale); accu2 += accu1; - accu1 += (fPow2Div2(realBuf[len - 2]) SHIFT); + accu1 += (fPow2Div2(realBuf[len - 2]) >> len_scale); - accu4 = (fMultDiv2(realBuf[-1], realBuf[-2]) SHIFT); + accu4 = (fMultDiv2(realBuf[-1], realBuf[-2]) >> len_scale); accu4 += accu3; - accu3 += (fMultDiv2(realBuf[len - 1], realBuf[len - 2]) SHIFT); + accu3 += (fMultDiv2(realBuf[len - 1], realBuf[len - 2]) >> len_scale); mScale = CntLeadingZeros( (accu1 | accu2 | fAbs(accu3) | fAbs(accu4) | fAbs(accu5))) - 1; - autoCorrScaling = mScale - 1 - SHIFT_FACTOR; /* -1 because of fMultDiv2*/ + autoCorrScaling = mScale - 1 - len_scale; /* -1 because of fMultDiv2*/ /* Scale to common scale factor */ ac->r11r = accu1 << mScale; @@ -190,7 +189,7 @@ INT autoCorr2nd_cplx( const FIXP_DBL *imBuffer, /*!< Pointer to imag part of input samples */ const int len /*!< Number of input samples (should be smaller than 128) */ ) { - int j, autoCorrScaling, mScale, len_scale; + int j, autoCorrScaling, mScale; FIXP_DBL accu0, accu1, accu2, accu3, accu4, accu5, accu6, accu7, accu8; @@ -199,7 +198,7 @@ INT autoCorr2nd_cplx( const FIXP_DBL *realBuf = reBuffer; const FIXP_DBL *imagBuf = imBuffer; - (len > 64) ? (len_scale = 6) : (len_scale = 5); + const int len_scale = fMax(DFRACT_BITS - fNormz((FIXP_DBL)len), 1); /* r00r, r11r,r22r diff --git a/libFDK/src/dct.cpp b/libFDK/src/dct.cpp index bd26736..35507b5 100644 --- a/libFDK/src/dct.cpp +++ b/libFDK/src/dct.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2019 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 @@ -305,9 +305,8 @@ void dct_II( { for (i = 0; i < M; i++) { - tmp[i] = pDat[2 * i] >> 1; /* dit_fft expects 1 bit scaled input values */ - tmp[L - 1 - i] = - pDat[2 * i + 1] >> 1; /* dit_fft expects 1 bit scaled input values */ + tmp[i] = pDat[2 * i] >> 2; + tmp[L - 1 - i] = pDat[2 * i + 1] >> 2; } } @@ -337,15 +336,14 @@ void dct_II( a1 = ((pTmp_0[0] >> 1) + (pTmp_1[0] >> 1)); a2 = ((pTmp_0[1] >> 1) - (pTmp_1[1] >> 1)); - cplxMultDiv2(&accu3, &accu4, (a1 + accu2), -(accu1 + a2), - sin_twiddle[i * inc]); - pDat[L - i] = accu4; - pDat[i] = accu3; + cplxMult(&accu3, &accu4, (accu1 + a2), (a1 + accu2), sin_twiddle[i * inc]); + pDat[L - i] = -accu3; + pDat[i] = accu4; - cplxMultDiv2(&accu3, &accu4, (a1 - accu2), -(accu1 - a2), - sin_twiddle[(M - i) * inc]); - pDat[M + i] = accu4; - pDat[M - i] = accu3; + cplxMult(&accu3, &accu4, (accu1 - a2), (a1 - accu2), + sin_twiddle[(M - i) * inc]); + pDat[M + i] = -accu3; + pDat[M - i] = accu4; /* Create index helper variables for (4*i)*inc indexed equivalent values of * short tables. */ @@ -356,12 +354,12 @@ void dct_II( } } - cplxMultDiv2(&accu1, &accu2, tmp[M], tmp[M + 1], sin_twiddle[(M / 2) * inc]); + cplxMult(&accu1, &accu2, tmp[M], tmp[M + 1], sin_twiddle[(M / 2) * inc]); pDat[L - (M / 2)] = accu2; pDat[M / 2] = accu1; - pDat[0] = (tmp[0] >> 1) + (tmp[1] >> 1); - pDat[M] = fMult(((tmp[0] >> 1) - (tmp[1] >> 1)), + pDat[0] = tmp[0] + tmp[1]; + pDat[M] = fMult(tmp[0] - tmp[1], sin_twiddle[M * inc].v.re); /* cos((PI/(2*L))*M); */ *pDat_e += 2; diff --git a/libFDK/src/fft.cpp b/libFDK/src/fft.cpp index 4e6fdd2..c9ee784 100644 --- a/libFDK/src/fft.cpp +++ b/libFDK/src/fft.cpp @@ -170,7 +170,7 @@ amm-info@iis.fraunhofer.de /* Performs the FFT of length 2. Input vector unscaled, output vector scaled * with factor 0.5 */ -static FDK_FORCEINLINE void fft2(FIXP_DBL *RESTRICT pDat) { +static inline void fft2(FIXP_DBL *RESTRICT pDat) { FIXP_DBL r1, i1; FIXP_DBL r2, i2; @@ -196,7 +196,7 @@ static FDK_FORCEINLINE void fft2(FIXP_DBL *RESTRICT pDat) { #ifndef FUNCTION_fft3 /* Performs the FFT of length 3 according to the algorithm after winograd. */ -static FDK_FORCEINLINE void fft3(FIXP_DBL *RESTRICT pDat) { +static inline void fft3(FIXP_DBL *RESTRICT pDat) { FIXP_DBL r1, r2; FIXP_DBL s1, s2; FIXP_DBL pD; @@ -233,7 +233,7 @@ static FDK_FORCEINLINE void fft3(FIXP_DBL *RESTRICT pDat) { /* performs the FFT of length 5 according to the algorithm after winograd */ /* This version works with a prescale of 2 instead of 3 */ -static FDK_FORCEINLINE void fft5(FIXP_DBL *RESTRICT pDat) { +static inline void fft5(FIXP_DBL *RESTRICT pDat) { FIXP_DBL r1, r2, r3, r4; FIXP_DBL s1, s2, s3, s4; FIXP_DBL t; diff --git a/libFDK/src/nlc_dec.cpp b/libFDK/src/nlc_dec.cpp index 8b2f97d..3733d98 100644 --- a/libFDK/src/nlc_dec.cpp +++ b/libFDK/src/nlc_dec.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 @@ -568,12 +568,12 @@ 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, int* cdg_scheme, int ldMode) { + int num_val, PAIRING* pairing_scheme, int ldMode) { ERROR_t err = HUFFDEC_OK; + CODING_SCHEME coding_scheme = HUFF_1D; DIFF_TYPE diff_type; int i = 0; - ULONG data = 0; SCHAR pair_vec[28][2]; @@ -596,15 +596,13 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, int hufYY; /* Coding scheme */ - data = FDKreadBits(strm, 1); - *cdg_scheme = (data << PAIR_SHIFT); + coding_scheme = (CODING_SCHEME)FDKreadBits(strm, 1); - if (*cdg_scheme >> PAIR_SHIFT == HUFF_2D) { + if (coding_scheme == HUFF_2D) { if ((out_data_1 != NULL) && (out_data_2 != NULL) && (ldMode == 0)) { - data = FDKreadBits(strm, 1); - *cdg_scheme = (*cdg_scheme | data); + *pairing_scheme = (PAIRING)FDKreadBits(strm, 1); } else { - *cdg_scheme = (*cdg_scheme | FREQ_PAIR); + *pairing_scheme = FREQ_PAIR; } } @@ -613,7 +611,7 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, hufYY2 = diff_type_2; } - switch (*cdg_scheme >> PAIR_SHIFT) { + switch (coding_scheme) { case HUFF_1D: p0_flag[0] = (diff_type_1 == DIFF_FREQ); p0_flag[1] = (diff_type_2 == DIFF_FREQ); @@ -634,7 +632,7 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, case HUFF_2D: - switch (*cdg_scheme & PAIR_MASK) { + switch (*pairing_scheme) { case FREQ_PAIR: if (out_data_1 != NULL) { @@ -843,7 +841,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}; - int cdg_scheme = HUFF_1D; + PAIRING pairing = FREQ_PAIR; DIRECTION direction = BACKWARDS; switch (data_type) { @@ -959,7 +957,7 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, } /* Huffman decoding */ err = huff_decode(strm, pDataVec[0], pDataVec[1], data_type, diff_type[0], - diff_type[1], dataBands, &cdg_scheme, + diff_type[1], dataBands, &pairing, (DECODER == SAOC_DECODER)); if (err != HUFFDEC_OK) { return HUFFDEC_NOTOK; @@ -986,8 +984,8 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, } } - mixed_time_pair = (diff_type[0] != diff_type[1]) && - ((cdg_scheme & PAIR_MASK) == TIME_PAIR); + mixed_time_pair = + (diff_type[0] != diff_type[1]) && (pairing == TIME_PAIR); if (direction == BACKWARDS) { if (diff_type[0] == DIFF_FREQ) { |