1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2025-06-05 22:39:13 +02:00

Snap for 6145313 from cee316ab3e to rvc-release

Change-Id: I642e8bbffa03f9c9e718eb115125c1e0fa852556
This commit is contained in:
android-build-team Robot
2020-01-18 04:29:58 +00:00
3 changed files with 19 additions and 28 deletions

View File

@@ -1228,7 +1228,6 @@ static void CConcealment_InterpolateBuffer(FIXP_DBL *spectrum,
int sfb, line = 0; int sfb, line = 0;
int fac_shift; int fac_shift;
int fac_mod; int fac_mod;
FIXP_DBL accu;
for (sfb = 0; sfb < sfbCnt; sfb++) { for (sfb = 0; sfb < sfbCnt; sfb++) {
fac_shift = fac_shift =
@@ -1236,15 +1235,11 @@ static void CConcealment_InterpolateBuffer(FIXP_DBL *spectrum,
fac_mod = fac_shift & 3; fac_mod = fac_shift & 3;
fac_shift = (fac_shift >> 2) + 1; fac_shift = (fac_shift >> 2) + 1;
fac_shift += *pSpecScalePrv - fixMax(*pSpecScalePrv, *pSpecScaleAct); fac_shift += *pSpecScalePrv - fixMax(*pSpecScalePrv, *pSpecScaleAct);
fac_shift = fMax(fMin(fac_shift, DFRACT_BITS - 1), -(DFRACT_BITS - 1));
for (; line < pSfbOffset[sfb + 1]; line++) { for (; line < pSfbOffset[sfb + 1]; line++) {
accu = fMult(*(spectrum + line), facMod4Table[fac_mod]); FIXP_DBL accu = fMult(*(spectrum + line), facMod4Table[fac_mod]);
if (fac_shift < 0) { *(spectrum + line) = scaleValue(accu, fac_shift);
accu >>= -fac_shift;
} else {
accu <<= fac_shift;
}
*(spectrum + line) = accu;
} }
} }
*pSpecScaleOut = fixMax(*pSpecScalePrv, *pSpecScaleAct); *pSpecScaleOut = fixMax(*pSpecScalePrv, *pSpecScaleAct);

View File

@@ -284,11 +284,14 @@ shapeBBEnv(FIXP_DBL *pHybOutputRealDry, FIXP_DBL *pHybOutputImagDry,
} }
} else { } else {
for (qs = 0; qs < cplxBands; qs++) { for (qs = 0; qs < cplxBands; qs++) {
pHybOutputRealDry[qs] = fMultDiv2(pHybOutputRealDry[qs], dryFac) << scale; pHybOutputRealDry[qs] = SATURATE_LEFT_SHIFT(
pHybOutputImagDry[qs] = fMultDiv2(pHybOutputImagDry[qs], dryFac) << scale; fMultDiv2(pHybOutputRealDry[qs], dryFac), scale, DFRACT_BITS);
pHybOutputImagDry[qs] = SATURATE_LEFT_SHIFT(
fMultDiv2(pHybOutputImagDry[qs], dryFac), scale, DFRACT_BITS);
} }
for (; qs < hybBands; qs++) { for (; qs < hybBands; qs++) {
pHybOutputRealDry[qs] = fMultDiv2(pHybOutputRealDry[qs], dryFac) << scale; pHybOutputRealDry[qs] = SATURATE_LEFT_SHIFT(
fMultDiv2(pHybOutputRealDry[qs], dryFac), scale, DFRACT_BITS);
} }
} }
} }
@@ -614,14 +617,16 @@ void SpatialDecReshapeBBEnv(spatialDec *self, const SPATIAL_BS_FRAME *frame,
fixMax(3, fixMax(dryFacSF, slotAmpSF)); /* scale is at least with 3 fixMax(3, fixMax(dryFacSF, slotAmpSF)); /* scale is at least with 3
bits to avoid overflows bits to avoid overflows
when calculating dryFac */ when calculating dryFac */
dryFac = dryFac >> (scale - dryFacSF); dryFac = dryFac >> fixMin(scale - dryFacSF, DFRACT_BITS - 1);
slotAmp_ratio = slotAmp_ratio >> (scale - slotAmpSF); slotAmp_ratio =
slotAmp_ratio >> fixMin(scale - slotAmpSF, DFRACT_BITS - 1);
/* limit dryFac */ /* limit dryFac */
dryFac = fixMax( dryFac = fixMax(
FL2FXCONST_DBL(0.25f) >> (INT)fixMin(2 * scale, DFRACT_BITS - 1), FL2FXCONST_DBL(0.25f) >> (INT)fixMin(2 * scale, DFRACT_BITS - 1),
fMult(dryFac, slotAmp_ratio) - (slotAmp_ratio >> scale) + fMult(dryFac, slotAmp_ratio) -
(dryFac >> scale)); (slotAmp_ratio >> fixMin(scale, DFRACT_BITS - 1)) +
(dryFac >> fixMin(scale, DFRACT_BITS - 1)));
dryFac = fixMin( dryFac = fixMin(
FL2FXCONST_DBL(0.50f) >> (INT)fixMin(2 * scale - 3, DFRACT_BITS - 1), FL2FXCONST_DBL(0.50f) >> (INT)fixMin(2 * scale - 3, DFRACT_BITS - 1),
dryFac); /* reduce shift bits by 3, because upper dryFac); /* reduce shift bits by 3, because upper
@@ -635,8 +640,8 @@ void SpatialDecReshapeBBEnv(spatialDec *self, const SPATIAL_BS_FRAME *frame,
/* shaping */ /* shaping */
shapeBBEnv(&self->hybOutputRealDry__FDK[ch][6], shapeBBEnv(&self->hybOutputRealDry__FDK[ch][6],
&self->hybOutputImagDry__FDK[ch][6], dryFac, scale, cplxBands, &self->hybOutputImagDry__FDK[ch][6], dryFac,
hybBands); fixMin(scale, DFRACT_BITS - 1), cplxBands, hybBands);
} }
} }
} }

View File

@@ -702,20 +702,11 @@ static void apply_inter_tes(FIXP_DBL **qmfReal, FIXP_DBL **qmfImag,
gain_sf[i] += gamma_sf + 1; /* +1 because of fMultDiv2() */ gain_sf[i] += gamma_sf + 1; /* +1 because of fMultDiv2() */
/* set gain to at least 0.2f */ /* set gain to at least 0.2f */
FIXP_DBL point_two = FL2FXCONST_DBL(0.8f); /* scaled up by 2 */
int point_two_sf = -2;
FIXP_DBL tmp = gain[i];
if (point_two_sf < gain_sf[i]) {
point_two >>= gain_sf[i] - point_two_sf;
} else {
tmp >>= point_two_sf - gain_sf[i];
}
/* limit and calculate gain[i]^2 too */ /* limit and calculate gain[i]^2 too */
FIXP_DBL gain_pow2; FIXP_DBL gain_pow2;
int gain_pow2_sf; int gain_pow2_sf;
if (tmp < point_two) {
if (fIsLessThan(gain[i], gain_sf[i], FL2FXCONST_DBL(0.2f), 0)) {
gain[i] = FL2FXCONST_DBL(0.8f); gain[i] = FL2FXCONST_DBL(0.8f);
gain_sf[i] = -2; gain_sf[i] = -2;
gain_pow2 = FL2FXCONST_DBL(0.64f); gain_pow2 = FL2FXCONST_DBL(0.64f);