Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: webrtc/modules/audio_processing/residual_echo_detector.cc

Issue 2882183004: Removed implicit divisions in the residual echo detector (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/residual_echo_detector.cc
diff --git a/webrtc/modules/audio_processing/residual_echo_detector.cc b/webrtc/modules/audio_processing/residual_echo_detector.cc
index e95e0894bfc5d8f735243c8fdd4d6673cfba349f..2162d9f76f61adb73c95197f690cc0fd5be90fdb 100644
--- a/webrtc/modules/audio_processing/residual_echo_detector.cc
+++ b/webrtc/modules/audio_processing/residual_echo_detector.cc
@@ -93,9 +93,8 @@ void ResidualEchoDetector::AnalyzeCaptureAudio(
// Update the covariance values and determine the new echo likelihood.
echo_likelihood_ = 0.f;
+ size_t read_index = next_insertion_index_;
for (size_t delay = 0; delay < covariances_.size(); ++delay) {
- const size_t read_index =
- (kLookbackFrames + next_insertion_index_ - delay) % kLookbackFrames;
RTC_DCHECK_LT(read_index, render_power_.size());
covariances_[delay].Update(capture_power, capture_mean,
capture_std_deviation, render_power_[read_index],
@@ -103,6 +102,8 @@ void ResidualEchoDetector::AnalyzeCaptureAudio(
render_power_std_dev_[read_index]);
echo_likelihood_ = std::max(
echo_likelihood_, covariances_[delay].normalized_cross_correlation());
+
+ read_index = read_index > 0 ? read_index - 1 : kLookbackFrames - 1;
}
reliability_ = (1.0f - kAlpha) * reliability_ + kAlpha * 1.0f;
echo_likelihood_ *= reliability_;
@@ -117,8 +118,9 @@ void ResidualEchoDetector::AnalyzeCaptureAudio(
recent_likelihood_max_.Update(echo_likelihood_);
// Update the next insertion index.
- ++next_insertion_index_;
- next_insertion_index_ %= kLookbackFrames;
+ next_insertion_index_ = next_insertion_index_ < (kLookbackFrames - 1)
+ ? next_insertion_index_ + 1
+ : 0;
}
void ResidualEchoDetector::Initialize() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698