aboutsummaryrefslogtreecommitdiffstats
path: root/libSBRdec
diff options
context:
space:
mode:
Diffstat (limited to 'libSBRdec')
-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;
}
}