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

Side by Side Diff: webrtc/modules/audio_processing/residual_echo_detector.cc

Issue 2487243002: Add UMA histogram for Echo likelihood. (Closed)
Patch Set: Initial version. Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_processing/residual_echo_detector.h" 11 #include "webrtc/modules/audio_processing/residual_echo_detector.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <numeric> 14 #include <numeric>
15 15
16 #include "webrtc/modules/audio_processing/audio_buffer.h" 16 #include "webrtc/modules/audio_processing/audio_buffer.h"
17 #include "webrtc/system_wrappers/include/metrics.h"
17 18
18 namespace { 19 namespace {
19 20
20 float Power(rtc::ArrayView<const float> input) { 21 float Power(rtc::ArrayView<const float> input) {
21 return std::inner_product(input.begin(), input.end(), input.begin(), 0.f); 22 return std::inner_product(input.begin(), input.end(), input.begin(), 0.f);
22 } 23 }
23 24
24 constexpr size_t kLookbackFrames = 650; 25 constexpr size_t kLookbackFrames = 650;
25 // TODO(ivoc): Verify the size of this buffer. 26 // TODO(ivoc): Verify the size of this buffer.
26 constexpr size_t kRenderBufferSize = 30; 27 constexpr size_t kRenderBufferSize = 30;
28 // Number of bins in the echo likelihood histogram.
29 constexpr size_t kNumberOfHistogramBins = 100;
27 30
28 } // namespace 31 } // namespace
29 32
30 namespace webrtc { 33 namespace webrtc {
31 34
32 ResidualEchoDetector::ResidualEchoDetector() 35 ResidualEchoDetector::ResidualEchoDetector()
33 : render_buffer_(kRenderBufferSize), 36 : render_buffer_(kRenderBufferSize),
34 render_power_(kLookbackFrames), 37 render_power_(kLookbackFrames),
35 render_power_mean_(kLookbackFrames), 38 render_power_mean_(kLookbackFrames),
36 render_power_std_dev_(kLookbackFrames), 39 render_power_std_dev_(kLookbackFrames),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const size_t read_index = 95 const size_t read_index =
93 (kLookbackFrames + next_insertion_index_ - delay) % kLookbackFrames; 96 (kLookbackFrames + next_insertion_index_ - delay) % kLookbackFrames;
94 RTC_DCHECK_LT(read_index, render_power_.size()); 97 RTC_DCHECK_LT(read_index, render_power_.size());
95 covariances_[delay].Update(capture_power, capture_mean, 98 covariances_[delay].Update(capture_power, capture_mean,
96 capture_std_deviation, render_power_[read_index], 99 capture_std_deviation, render_power_[read_index],
97 render_power_mean_[read_index], 100 render_power_mean_[read_index],
98 render_power_std_dev_[read_index]); 101 render_power_std_dev_[read_index]);
99 echo_likelihood_ = std::max( 102 echo_likelihood_ = std::max(
100 echo_likelihood_, covariances_[delay].normalized_cross_correlation()); 103 echo_likelihood_, covariances_[delay].normalized_cross_correlation());
101 } 104 }
105 int echo_percentage = static_cast<int>(echo_likelihood_ * 100);
106 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.ResidualEchoDetector.EchoLikelihood",
107 echo_percentage, 0, 100, kNumberOfHistogramBins);
hlundin-webrtc 2016/11/09 20:01:26 I'm not convinced that kNumberOfHistogramBins gran
ivoc 2016/11/10 15:13:47 Done.
102 108
103 // Update the next insertion index. 109 // Update the next insertion index.
104 ++next_insertion_index_; 110 ++next_insertion_index_;
105 next_insertion_index_ %= kLookbackFrames; 111 next_insertion_index_ %= kLookbackFrames;
106 } 112 }
107 113
108 void ResidualEchoDetector::Initialize() { 114 void ResidualEchoDetector::Initialize() {
109 render_buffer_.Clear(); 115 render_buffer_.Clear();
110 std::fill(render_power_.begin(), render_power_.end(), 0.f); 116 std::fill(render_power_.begin(), render_power_.end(), 0.f);
111 std::fill(render_power_mean_.begin(), render_power_mean_.end(), 0.f); 117 std::fill(render_power_mean_.begin(), render_power_mean_.end(), 0.f);
(...skipping 13 matching lines...) Expand all
125 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); 131 RTC_DCHECK_GE(160u, audio->num_frames_per_band());
126 132
127 packed_buffer->clear(); 133 packed_buffer->clear();
128 packed_buffer->insert(packed_buffer->end(), 134 packed_buffer->insert(packed_buffer->end(),
129 audio->split_bands_const_f(0)[kBand0To8kHz], 135 audio->split_bands_const_f(0)[kBand0To8kHz],
130 (audio->split_bands_const_f(0)[kBand0To8kHz] + 136 (audio->split_bands_const_f(0)[kBand0To8kHz] +
131 audio->num_frames_per_band())); 137 audio->num_frames_per_band()));
132 } 138 }
133 139
134 } // namespace webrtc 140 } // namespace webrtc
OLDNEW
« 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