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

Side by Side Diff: webrtc/modules/audio_processing/aec3/echo_remover.cc

Issue 2722453002: Adding metrics to AEC3 (Closed)
Patch Set: Changed some of the names for the metrics Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 #include "webrtc/modules/audio_processing/aec3/echo_remover.h" 10 #include "webrtc/modules/audio_processing/aec3/echo_remover.h"
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <memory> 13 #include <memory>
14 #include <numeric> 14 #include <numeric>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/base/array_view.h" 17 #include "webrtc/base/array_view.h"
18 #include "webrtc/base/atomicops.h" 18 #include "webrtc/base/atomicops.h"
19 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" 20 #include "webrtc/modules/audio_processing/aec3/aec3_common.h"
21 #include "webrtc/modules/audio_processing/aec3/aec_state.h" 21 #include "webrtc/modules/audio_processing/aec3/aec_state.h"
22 #include "webrtc/modules/audio_processing/aec3/comfort_noise_generator.h" 22 #include "webrtc/modules/audio_processing/aec3/comfort_noise_generator.h"
23 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h" 23 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
24 #include "webrtc/modules/audio_processing/aec3/echo_remover_metrics.h"
24 #include "webrtc/modules/audio_processing/aec3/fft_buffer.h" 25 #include "webrtc/modules/audio_processing/aec3/fft_buffer.h"
25 #include "webrtc/modules/audio_processing/aec3/fft_data.h" 26 #include "webrtc/modules/audio_processing/aec3/fft_data.h"
26 #include "webrtc/modules/audio_processing/aec3/output_selector.h" 27 #include "webrtc/modules/audio_processing/aec3/output_selector.h"
27 #include "webrtc/modules/audio_processing/aec3/power_echo_model.h" 28 #include "webrtc/modules/audio_processing/aec3/power_echo_model.h"
28 #include "webrtc/modules/audio_processing/aec3/render_delay_buffer.h" 29 #include "webrtc/modules/audio_processing/aec3/render_delay_buffer.h"
29 #include "webrtc/modules/audio_processing/aec3/residual_echo_estimator.h" 30 #include "webrtc/modules/audio_processing/aec3/residual_echo_estimator.h"
30 #include "webrtc/modules/audio_processing/aec3/subtractor.h" 31 #include "webrtc/modules/audio_processing/aec3/subtractor.h"
31 #include "webrtc/modules/audio_processing/aec3/suppression_filter.h" 32 #include "webrtc/modules/audio_processing/aec3/suppression_filter.h"
32 #include "webrtc/modules/audio_processing/aec3/suppression_gain.h" 33 #include "webrtc/modules/audio_processing/aec3/suppression_gain.h"
33 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" 34 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 ComfortNoiseGenerator cng_; 84 ComfortNoiseGenerator cng_;
84 SuppressionFilter suppression_filter_; 85 SuppressionFilter suppression_filter_;
85 PowerEchoModel power_echo_model_; 86 PowerEchoModel power_echo_model_;
86 FftBuffer X_buffer_; 87 FftBuffer X_buffer_;
87 RenderSignalAnalyzer render_signal_analyzer_; 88 RenderSignalAnalyzer render_signal_analyzer_;
88 OutputSelector output_selector_; 89 OutputSelector output_selector_;
89 ResidualEchoEstimator residual_echo_estimator_; 90 ResidualEchoEstimator residual_echo_estimator_;
90 bool echo_leakage_detected_ = false; 91 bool echo_leakage_detected_ = false;
91 std::array<float, kBlockSize> x_old_; 92 std::array<float, kBlockSize> x_old_;
92 AecState aec_state_; 93 AecState aec_state_;
94 EchoRemoverMetrics metrics_;
93 95
94 RTC_DISALLOW_COPY_AND_ASSIGN(EchoRemoverImpl); 96 RTC_DISALLOW_COPY_AND_ASSIGN(EchoRemoverImpl);
95 }; 97 };
96 98
97 int EchoRemoverImpl::instance_count_ = 0; 99 int EchoRemoverImpl::instance_count_ = 0;
98 100
99 EchoRemoverImpl::EchoRemoverImpl(int sample_rate_hz) 101 EchoRemoverImpl::EchoRemoverImpl(int sample_rate_hz)
100 : fft_(), 102 : fft_(),
101 data_dumper_( 103 data_dumper_(
102 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), 104 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 cng_.Compute(aec_state_, Y2, &comfort_noise, &high_band_comfort_noise); 204 cng_.Compute(aec_state_, Y2, &comfort_noise, &high_band_comfort_noise);
203 205
204 // Detect basic doubletalk. 206 // Detect basic doubletalk.
205 const bool doubletalk = BlockPower(e_shadow) < BlockPower(e_main); 207 const bool doubletalk = BlockPower(e_shadow) < BlockPower(e_main);
206 208
207 // A choose and apply echo suppression gain. 209 // A choose and apply echo suppression gain.
208 suppression_gain_.GetGain(E2, R2, cng_.NoiseSpectrum(), 210 suppression_gain_.GetGain(E2, R2, cng_.NoiseSpectrum(),
209 doubletalk ? 0.001f : 0.0001f, &G); 211 doubletalk ? 0.001f : 0.0001f, &G);
210 suppression_filter_.ApplyGain(comfort_noise, high_band_comfort_noise, G, y); 212 suppression_filter_.ApplyGain(comfort_noise, high_band_comfort_noise, G, y);
211 213
214 // Update the metrics.
215 metrics_.Update(aec_state_, cng_.NoiseSpectrum(), G);
216
212 // Debug outputs for the purpose of development and analysis. 217 // Debug outputs for the purpose of development and analysis.
213 data_dumper_->DumpRaw("aec3_N2", cng_.NoiseSpectrum()); 218 data_dumper_->DumpRaw("aec3_N2", cng_.NoiseSpectrum());
214 data_dumper_->DumpRaw("aec3_suppressor_gain", G); 219 data_dumper_->DumpRaw("aec3_suppressor_gain", G);
215 data_dumper_->DumpWav("aec3_output", 220 data_dumper_->DumpWav("aec3_output",
216 rtc::ArrayView<const float>(&y0[0], kBlockSize), 221 rtc::ArrayView<const float>(&y0[0], kBlockSize),
217 LowestBandRate(sample_rate_hz_), 1); 222 LowestBandRate(sample_rate_hz_), 1);
218 data_dumper_->DumpRaw("aec3_using_subtractor_output", 223 data_dumper_->DumpRaw("aec3_using_subtractor_output",
219 output_selector_.UseSubtractorOutput() ? 1 : 0); 224 output_selector_.UseSubtractorOutput() ? 1 : 0);
220 data_dumper_->DumpRaw("aec3_doubletalk", doubletalk ? 1 : 0); 225 data_dumper_->DumpRaw("aec3_doubletalk", doubletalk ? 1 : 0);
221 data_dumper_->DumpRaw("aec3_E2", E2); 226 data_dumper_->DumpRaw("aec3_E2", E2);
(...skipping 22 matching lines...) Expand all
244 aec_state_.SaturatedCapture() ? 1 : 0); 249 aec_state_.SaturatedCapture() ? 1 : 0);
245 } 250 }
246 251
247 } // namespace 252 } // namespace
248 253
249 EchoRemover* EchoRemover::Create(int sample_rate_hz) { 254 EchoRemover* EchoRemover::Create(int sample_rate_hz) {
250 return new EchoRemoverImpl(sample_rate_hz); 255 return new EchoRemoverImpl(sample_rate_hz);
251 } 256 }
252 257
253 } // namespace webrtc 258 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698