diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/modules/audio_coding/codecs/ilbc/enhancer_interface.c index f85df6d7ce..74dfebb47d 100644 --- a/modules/audio_coding/codecs/ilbc/enhancer_interface.c +++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.c @@ -202,10 +202,10 @@ size_t // (o) Estimated lag in end of in[] /* scaling */ max16 = WebRtcSpl_MaxAbsValueW16(regressor, plc_blockl + 3 - 1); - if (max16>5000) - shifts=2; - else - shifts=0; + + const int64_t max_val = plc_blockl * max16 * max16; + const int32_t factor = max_val >> 31; + shifts = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor); /* compute cross correlation */ WebRtcSpl_CrossCorrelation(corr32, target, regressor, plc_blockl, 3, shifts,