aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK
diff options
context:
space:
mode:
Diffstat (limited to 'libFDK')
-rw-r--r--libFDK/include/nlc_dec.h5
-rw-r--r--libFDK/src/autocorr2nd.cpp43
-rw-r--r--libFDK/src/nlc_dec.cpp28
3 files changed, 35 insertions, 41 deletions
diff --git a/libFDK/include/nlc_dec.h b/libFDK/include/nlc_dec.h
index cca97f1..aded569 100644
--- a/libFDK/include/nlc_dec.h
+++ b/libFDK/include/nlc_dec.h
@@ -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
@@ -159,9 +159,6 @@ typedef enum {
#ifndef HUFFDEC_PARAMS
#define HUFFDEC_PARMS
-#define PAIR_SHIFT 4
-#define PAIR_MASK 0xf
-
#define MAX_ENTRIES 168
#define HANDLE_HUFF_NODE const SHORT(*)[MAX_ENTRIES][2]
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/nlc_dec.cpp b/libFDK/src/nlc_dec.cpp
index 6e98ce0..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, CODING_SCHEME* 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 = (CODING_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 = (CODING_SCHEME)(*cdg_scheme | data);
+ *pairing_scheme = (PAIRING)FDKreadBits(strm, 1);
} else {
- *cdg_scheme = (CODING_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};
- CODING_SCHEME 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) {