From 1b92722ad5fd85502eb408337e0a8d1edcbdcbd3 Mon Sep 17 00:00:00 2001 From: peah Date: Tue, 23 May 2017 23:44:47 -0700 Subject: [PATCH] Simplified the ERLE computation code in AEC3 BUG=webrtc:7519 Review-Url: https://codereview.webrtc.org/2901253002 Cr-Commit-Position: refs/heads/master@{#18249} --- .../modules/audio_processing/aec3/erle_estimator.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/webrtc/modules/audio_processing/aec3/erle_estimator.cc b/webrtc/modules/audio_processing/aec3/erle_estimator.cc index 2ceadd3f9e..c1394126a5 100644 --- a/webrtc/modules/audio_processing/aec3/erle_estimator.cc +++ b/webrtc/modules/audio_processing/aec3/erle_estimator.cc @@ -41,11 +41,8 @@ void ErleEstimator::Update( constexpr float kX2Min = 44015068.0f; // Update the estimates in a clamped minimum statistics manner. - size_t k = 1; - size_t band_limit = kFftLengthBy2 / 2; - float max_erle = kMaxLfErle; - for (int j = 0; j < 2; ++j) { - for (; k < band_limit; ++k) { + auto erle_update = [&](size_t start, size_t stop, float max_erle) { + for (size_t k = start; k < stop; ++k) { if (X2[k] > kX2Min && E2[k] > 0.f) { const float new_erle = Y2[k] / E2[k]; if (new_erle > erle_[k]) { @@ -55,9 +52,9 @@ void ErleEstimator::Update( } } } - band_limit = kFftLengthBy2; - max_erle = kMaxHfErle; - } + }; + erle_update(1, kFftLengthBy2 / 2, kMaxLfErle); + erle_update(kFftLengthBy2 / 2, kFftLengthBy2, kMaxHfErle); std::for_each(hold_counters_.begin(), hold_counters_.end(), [](int& a) { --a; });