diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/modules/audio_coding/codecs/ilbc/enhancer_interface.c index fb9740eb22..71436c24dc 100644 --- a/modules/audio_coding/codecs/ilbc/enhancer_interface.c +++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.c @@ -18,6 +18,7 @@ #include "modules/audio_coding/codecs/ilbc/enhancer_interface.h" +#include #include #include "modules/audio_coding/codecs/ilbc/constants.h" @@ -203,11 +204,11 @@ size_t // (o) Estimated lag in end of in[] regressor=in+tlag-1; /* scaling */ - // Note that this is not abs-max, but it doesn't matter since we use only - // the square of it. + // Note that this is not abs-max, so we will take the absolute value below. max16 = regressor[WebRtcSpl_MaxAbsIndexW16(regressor, plc_blockl + 3 - 1)]; - - const int64_t max_val = plc_blockl * max16 * max16; + const int16_t max_target = + target[WebRtcSpl_MaxAbsIndexW16(target, plc_blockl + 3 - 1)]; + const int64_t max_val = plc_blockl * abs(max16 * max_target); const int32_t factor = max_val >> 31; shifts = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);