mirror of https://github.com/mstorsjo/fdk-aac.git
Snap for 5956624 from fc8faa38d9
to rvc-release
Change-Id: I90c7f7de4ed5bb04e355e181028c850f6e95d8ad
This commit is contained in:
commit
b3ccda1719
|
@ -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
|
||||
|
@ -344,7 +344,7 @@ INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac,
|
|||
/* Overlap Add */
|
||||
x0 = -fMult(*pOvl--, pWindow[i].v.re);
|
||||
|
||||
*pOut0 += IMDCT_SCALE_DBL(x0);
|
||||
*pOut0 = fAddSaturate(*pOut0, IMDCT_SCALE_DBL(x0));
|
||||
pOut0++;
|
||||
}
|
||||
} else {
|
||||
|
@ -354,7 +354,7 @@ INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac,
|
|||
/* Overlap Add */
|
||||
x0 = fMult(*pOvl--, pWindow[i].v.re);
|
||||
|
||||
*pOut0 += IMDCT_SCALE_DBL(x0);
|
||||
*pOut0 = fAddSaturate(*pOut0, IMDCT_SCALE_DBL(x0));
|
||||
pOut0++;
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac,
|
|||
0) { /* this should only happen for ACELP -> TCX20 -> ACELP transition */
|
||||
FIXP_DBL *pOut = pOut0 - fl / 2; /* fl/2 == fac_length */
|
||||
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;
|
||||
}
|
||||
|
@ -493,9 +493,7 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
/* Div2 is compensated by table scaling */
|
||||
x = fMultDiv2(pTmp2[i], FacWindowZir[w]);
|
||||
x += fMultDiv2(pTmp1[-i - 1], FacWindowSynth[w]);
|
||||
x += pFAC_and_FAC_ZIR[i];
|
||||
pOut1[i] = x;
|
||||
|
||||
pOut1[i] = fAddSaturate(x, pFAC_and_FAC_ZIR[i]);
|
||||
w++;
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +550,7 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
|
||||
pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
|
||||
(pOut1 >= output && pOut1 < output + 1024));
|
||||
*pOut1 += IMDCT_SCALE_DBL(-x1);
|
||||
*pOut1 = fAddSaturate(*pOut1, IMDCT_SCALE_DBL(-x1));
|
||||
pOut1--;
|
||||
}
|
||||
|
||||
|
@ -578,7 +576,7 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
FIXP_DBL x = -(*pCurr--);
|
||||
/* 5) (item 4) Synthesis filter Zir component, FAC ZIR (another one). */
|
||||
if (i < f_len) {
|
||||
x += *pF++;
|
||||
x = fAddSaturate(x, *pF++);
|
||||
}
|
||||
|
||||
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
|
||||
|
@ -668,9 +666,9 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
for (i = 0; i < fl / 2; i++) {
|
||||
FIXP_DBL x0, x1;
|
||||
|
||||
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL(-x1);
|
||||
cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL_LSH1(-x1);
|
||||
pOut0++;
|
||||
pOut1--;
|
||||
}
|
||||
|
@ -680,9 +678,9 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
for (i = 0; i < fl / 2; i++) {
|
||||
FIXP_DBL x0, x1;
|
||||
|
||||
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL(x1);
|
||||
cplxMultDiv2(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
|
||||
pOut0++;
|
||||
pOut1--;
|
||||
}
|
||||
|
@ -691,9 +689,9 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
for (i = 0; i < fl / 2; i++) {
|
||||
FIXP_DBL x0, x1;
|
||||
|
||||
cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL(x1);
|
||||
cplxMultDiv2(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
|
||||
*pOut0 = IMDCT_SCALE_DBL_LSH1(x0);
|
||||
*pOut1 = IMDCT_SCALE_DBL_LSH1(x1);
|
||||
pOut0++;
|
||||
pOut1--;
|
||||
}
|
||||
|
@ -705,7 +703,7 @@ INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -130,9 +130,10 @@ void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
|
|||
for (i = 0; i < stop; i++) {
|
||||
tmp = fMultDiv2(noise[i], filt[0]); // Filt in Q-1.16
|
||||
for (j = 1; j <= len; j++) {
|
||||
tmp += fMultDiv2((noise[i - j] + noise[i + j]), filt[j]);
|
||||
tmp += fMult((noise[i - j] >> 1) + (noise[i + j] >> 1), filt[j]);
|
||||
}
|
||||
syn_out[i] = (FIXP_PCM)(IMDCT_SCALE(syn[i] - tmp));
|
||||
syn_out[i] = (FIXP_PCM)(SATURATE_SHIFT(
|
||||
(syn[i] >> 1) - (tmp >> 1), (MDCT_OUTPUT_SCALE - 1), PCM_OUT_BITS));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,17 +336,22 @@ void bass_pf_1sf_delay(
|
|||
|
||||
{
|
||||
for (i = 0; i < lg; i++) {
|
||||
/* scaled with SF_SYNTH + gain_sf + 1 */
|
||||
/* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
|
||||
* one additional shift of syn values + fMult => fMultDiv2 */
|
||||
noise_in[i] =
|
||||
(fMult(gainSGL, syn[i + i_subfr] - (syn[i + i_subfr - T] >> 1) -
|
||||
(syn[i + i_subfr + T] >> 1))) >>
|
||||
s1;
|
||||
scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
|
||||
(syn[i + i_subfr - T] >> 2) -
|
||||
(syn[i + i_subfr + T] >> 2)),
|
||||
2 - s1);
|
||||
}
|
||||
|
||||
for (i = lg; i < L_SUBFR; i++) {
|
||||
/* scaled with SF_SYNTH + gain_sf + 1 */
|
||||
/* scaled with SF_SYNTH + gain_sf + 1; composition of scalefactor 2:
|
||||
* one additional shift of syn values + fMult => fMultDiv2 */
|
||||
noise_in[i] =
|
||||
(fMult(gainSGL, syn[i + i_subfr] - syn[i + i_subfr - T])) >> s1;
|
||||
scaleValue(fMultDiv2(gainSGL, (syn[i + i_subfr] >> 1) -
|
||||
(syn[i + i_subfr - T] >> 1)),
|
||||
2 - s1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1222,7 +1228,7 @@ AAC_DECODER_ERROR CLpdChannelStream_Read(
|
|||
(INT)(samplingRate * PIT_MIN_12k8 + (FSCALE_DENOM / 2)) / FSCALE_DENOM -
|
||||
(INT)PIT_MIN_12k8;
|
||||
|
||||
if ((samplingRate < 6000) || (samplingRate > 24000)) {
|
||||
if ((samplingRate < FAC_FSCALE_MIN) || (samplingRate > FAC_FSCALE_MAX)) {
|
||||
error = AAC_DEC_PARSE_ERROR;
|
||||
goto bail;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -569,7 +569,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;
|
||||
|
@ -678,7 +678,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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -244,7 +244,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];
|
||||
|
@ -603,7 +603,7 @@ 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;
|
||||
|
|
|
@ -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
|
||||
|
@ -904,23 +904,24 @@ void sbrDecoder_calculateGainVec(FIXP_DBL **sourceBufferReal,
|
|||
}
|
||||
|
||||
if (maxVal != FL2FX_DBL(0.0f)) {
|
||||
reserve = fixMax(0, CntLeadingZeros(maxVal) - 2);
|
||||
reserve = CntLeadingZeros(maxVal) - 2;
|
||||
}
|
||||
|
||||
nrg_ov = nrg = (FIXP_DBL)0;
|
||||
if (scale_nrg_ov > -31) {
|
||||
for (i = startSample; i < overlap; i++) {
|
||||
nrg_ov += (fPow2Div2(sourceBufferReal[i][loBand] << reserve) +
|
||||
fPow2Div2(sourceBufferImag[i][loBand] << reserve)) >>
|
||||
sum_scale_ov;
|
||||
nrg_ov +=
|
||||
(fPow2Div2(scaleValue(sourceBufferReal[i][loBand], reserve)) +
|
||||
fPow2Div2(scaleValue(sourceBufferImag[i][loBand], reserve))) >>
|
||||
sum_scale_ov;
|
||||
}
|
||||
} else {
|
||||
scale_nrg_ov = 0;
|
||||
}
|
||||
if (scale_nrg > -31) {
|
||||
for (i = overlap; i < stopSample; i++) {
|
||||
nrg += (fPow2Div2(sourceBufferReal[i][loBand] << reserve) +
|
||||
fPow2Div2(sourceBufferImag[i][loBand] << reserve)) >>
|
||||
nrg += (fPow2Div2(scaleValue(sourceBufferReal[i][loBand], reserve)) +
|
||||
fPow2Div2(scaleValue(sourceBufferImag[i][loBand], reserve))) >>
|
||||
sum_scale;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -739,7 +739,8 @@ static void apply_inter_tes(FIXP_DBL **qmfReal, FIXP_DBL **qmfImag,
|
|||
fMin(DFRACT_BITS - 1, new_summand_sf - total_power_high_after_sf);
|
||||
total_power_high_after_sf = new_summand_sf;
|
||||
} else if (new_summand_sf < total_power_high_after_sf) {
|
||||
subsample_power_high[i] >>= total_power_high_after_sf - new_summand_sf;
|
||||
subsample_power_high[i] >>=
|
||||
fMin(DFRACT_BITS - 1, total_power_high_after_sf - new_summand_sf);
|
||||
}
|
||||
total_power_high_after += subsample_power_high[i] >> preShift2;
|
||||
}
|
||||
|
@ -1831,7 +1832,8 @@ static void equalizeFiltBufferExp(
|
|||
diff = (int)(nrgGain_e[band] - filtBuffer_e[band]);
|
||||
if (diff > 0) {
|
||||
filtBuffer[band] >>=
|
||||
diff; /* Compensate for the scale change by shifting the mantissa. */
|
||||
fMin(diff, DFRACT_BITS - 1); /* Compensate for the scale change by
|
||||
shifting the mantissa. */
|
||||
filtBuffer_e[band] += diff; /* New gain is bigger, use its exponent */
|
||||
} else if (diff < 0) {
|
||||
/* The buffered gains seem to be larger, but maybe there
|
||||
|
@ -1851,8 +1853,8 @@ static void equalizeFiltBufferExp(
|
|||
filtBuffer_e[band] -= reserve; /* Compensate in the exponent: */
|
||||
|
||||
/* For the remaining difference, change the new gain value */
|
||||
diff = fixMin(-(reserve + diff), DFRACT_BITS - 1);
|
||||
nrgGain[band] >>= diff;
|
||||
diff = -(reserve + diff);
|
||||
nrgGain[band] >>= fMin(diff, DFRACT_BITS - 1);
|
||||
nrgGain_e[band] += diff;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -230,6 +230,8 @@ static UCHAR getStopBand(
|
|||
}
|
||||
}
|
||||
|
||||
stopMin = fMin(stopMin, 64);
|
||||
|
||||
/*
|
||||
Choose a stop band between k1 and 64 depending on stopFreq (0..13),
|
||||
based on a logarithmic scale.
|
||||
|
@ -523,7 +525,8 @@ static FIXP_SGL calcFactorPerBand(int k_start, int k_stop, int num_bands) {
|
|||
step = FL2FXCONST_DBL(0.0f);
|
||||
}
|
||||
}
|
||||
return FX_DBL2FX_SGL(bandfactor << 1);
|
||||
return (bandfactor >= FL2FXCONST_DBL(0.5)) ? (FIXP_SGL)MAXVAL_SGL
|
||||
: FX_DBL2FX_SGL(bandfactor << 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue