aboutsummaryrefslogtreecommitdiffstats
path: root/libSBRdec/src/env_calc.cpp
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2019-10-18 14:05:11 +0200
committerJean-Michel Trivi <jmtrivi@google.com>2019-10-18 10:58:40 -0700
commit54cd15bd807a69a7d68cbb414b8a3ea4b280748f (patch)
tree5d86b3ce05b3f6a3ca651632571bd703ffc6d68d /libSBRdec/src/env_calc.cpp
parentade11a1d6f3954ded789afcdac8ef4c80f9bb2f9 (diff)
downloadfdk-aac-54cd15bd807a69a7d68cbb414b8a3ea4b280748f.tar.gz
fdk-aac-54cd15bd807a69a7d68cbb414b8a3ea4b280748f.tar.bz2
fdk-aac-54cd15bd807a69a7d68cbb414b8a3ea4b280748f.zip
Fix nrgGain_e update in equalizeFiltBufferExp(). Prevents negative shift exponents in calculateSbrEnvelope().
Bug: 131430997 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I66ad54dae0fa1d414d8b2b9a9e0b6145cce4042d
Diffstat (limited to 'libSBRdec/src/env_calc.cpp')
-rw-r--r--libSBRdec/src/env_calc.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libSBRdec/src/env_calc.cpp b/libSBRdec/src/env_calc.cpp
index c34ce96..5cfd56c 100644
--- a/libSBRdec/src/env_calc.cpp
+++ b/libSBRdec/src/env_calc.cpp
@@ -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;
}
}