diff --git a/modules/audio_processing/aecm/aecm_core.cc b/modules/audio_processing/aecm/aecm_core.cc index d69dc1ce76..3d9facab4a 100644 --- a/modules/audio_processing/aecm/aecm_core.cc +++ b/modules/audio_processing/aecm/aecm_core.cc @@ -928,8 +928,14 @@ void WebRtcAecm_UpdateChannel(AecmCore* aecm, { // We need to shift down before multiplication shiftChFar = 32 - zerosCh - zerosFar; + // If zerosCh == zerosFar == 0, shiftChFar is 32. A + // right shift of 32 is undefined. To avoid that, we + // do this check. tmpU32no1 = rtc::dchecked_cast( - aecm->channelAdapt32[i] >> shiftChFar) * far_spectrum[i]; + shiftChFar >= 32 + ? 0 + : aecm->channelAdapt32[i] >> shiftChFar) * + far_spectrum[i]; } // Determine Q-domain of numerator zerosNum = WebRtcSpl_NormU32(tmpU32no1); diff --git a/modules/audio_processing/aecm/aecm_core_c.cc b/modules/audio_processing/aecm/aecm_core_c.cc index 99ddac58c2..effe04851c 100644 --- a/modules/audio_processing/aecm/aecm_core_c.cc +++ b/modules/audio_processing/aecm/aecm_core_c.cc @@ -491,7 +491,7 @@ WebRtcAecm_ProcessBlock(AecmCore* aecm, RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative. dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld; if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) { - tmp16no1 = aecm->nearFilt[i] << zeros16; + tmp16no1 = aecm->nearFilt[i] * (1 << zeros16); qDomainDiff = zeros16 - dfa_clean_q_domain_diff; tmp16no2 = ptrDfaClean[i] >> -qDomainDiff; } else {