Fix nrgGain_e update in equalizeFiltBufferExp(). Prevents negative shift exponents in calculateSbrEnvelope().

Bug: 131430997
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: I66ad54dae0fa1d414d8b2b9a9e0b6145cce4042d
This commit is contained in:
Fraunhofer IIS FDK 2019-10-18 14:05:11 +02:00 committed by Jean-Michel Trivi
parent ade11a1d6f
commit 54cd15bd80
1 changed files with 4 additions and 3 deletions

View File

@ -1831,7 +1831,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 +1852,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;
}
}