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

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

Issue 2967603002: Added the ability to adjust the AEC3 performance for large rooms (Closed)
Patch Set: Changes in response to reviewer commments Created 3 years, 5 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"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 std::array<float, kFftLengthBy2Plus1>* S2) { 42 std::array<float, kFftLengthBy2Plus1>* S2) {
43 for (size_t k = 0; k < E.re.size(); ++k) { 43 for (size_t k = 0; k < E.re.size(); ++k) {
44 (*S2)[k] = (Y.re[k] - E.re[k]) * (Y.re[k] - E.re[k]) + 44 (*S2)[k] = (Y.re[k] - E.re[k]) * (Y.re[k] - E.re[k]) +
45 (Y.im[k] - E.im[k]) * (Y.im[k] - E.im[k]); 45 (Y.im[k] - E.im[k]) * (Y.im[k] - E.im[k]);
46 } 46 }
47 } 47 }
48 48
49 // Class for removing the echo from the capture signal. 49 // Class for removing the echo from the capture signal.
50 class EchoRemoverImpl final : public EchoRemover { 50 class EchoRemoverImpl final : public EchoRemover {
51 public: 51 public:
52 explicit EchoRemoverImpl(int sample_rate_hz); 52 explicit EchoRemoverImpl(
53 const AudioProcessing::Config::EchoCanceller3& config,
54 int sample_rate_hz);
53 ~EchoRemoverImpl() override; 55 ~EchoRemoverImpl() override;
54 56
55 // Removes the echo from a block of samples from the capture signal. The 57 // Removes the echo from a block of samples from the capture signal. The
56 // supplied render signal is assumed to be pre-aligned with the capture 58 // supplied render signal is assumed to be pre-aligned with the capture
57 // signal. 59 // signal.
58 void ProcessCapture( 60 void ProcessCapture(
59 const rtc::Optional<size_t>& external_echo_path_delay_estimate, 61 const rtc::Optional<size_t>& external_echo_path_delay_estimate,
60 const EchoPathVariability& echo_path_variability, 62 const EchoPathVariability& echo_path_variability,
61 bool capture_signal_saturation, 63 bool capture_signal_saturation,
62 const RenderBuffer& render_buffer, 64 const RenderBuffer& render_buffer,
(...skipping 20 matching lines...) Expand all
83 ResidualEchoEstimator residual_echo_estimator_; 85 ResidualEchoEstimator residual_echo_estimator_;
84 bool echo_leakage_detected_ = false; 86 bool echo_leakage_detected_ = false;
85 AecState aec_state_; 87 AecState aec_state_;
86 EchoRemoverMetrics metrics_; 88 EchoRemoverMetrics metrics_;
87 89
88 RTC_DISALLOW_COPY_AND_ASSIGN(EchoRemoverImpl); 90 RTC_DISALLOW_COPY_AND_ASSIGN(EchoRemoverImpl);
89 }; 91 };
90 92
91 int EchoRemoverImpl::instance_count_ = 0; 93 int EchoRemoverImpl::instance_count_ = 0;
92 94
93 EchoRemoverImpl::EchoRemoverImpl(int sample_rate_hz) 95 EchoRemoverImpl::EchoRemoverImpl(
96 const AudioProcessing::Config::EchoCanceller3& config,
97 int sample_rate_hz)
94 : fft_(), 98 : fft_(),
95 data_dumper_( 99 data_dumper_(
96 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), 100 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
97 optimization_(DetectOptimization()), 101 optimization_(DetectOptimization()),
98 sample_rate_hz_(sample_rate_hz), 102 sample_rate_hz_(sample_rate_hz),
99 subtractor_(data_dumper_.get(), optimization_), 103 subtractor_(data_dumper_.get(), optimization_),
100 suppression_gain_(optimization_), 104 suppression_gain_(optimization_),
101 cng_(optimization_), 105 cng_(optimization_),
102 suppression_filter_(sample_rate_hz_) { 106 suppression_filter_(sample_rate_hz_),
107 aec_state_(config.echo_decay) {
103 RTC_DCHECK(ValidFullBandRate(sample_rate_hz)); 108 RTC_DCHECK(ValidFullBandRate(sample_rate_hz));
104 } 109 }
105 110
106 EchoRemoverImpl::~EchoRemoverImpl() = default; 111 EchoRemoverImpl::~EchoRemoverImpl() = default;
107 112
108 void EchoRemoverImpl::ProcessCapture( 113 void EchoRemoverImpl::ProcessCapture(
109 const rtc::Optional<size_t>& echo_path_delay_samples, 114 const rtc::Optional<size_t>& echo_path_delay_samples,
110 const EchoPathVariability& echo_path_variability, 115 const EchoPathVariability& echo_path_variability,
111 bool capture_signal_saturation, 116 bool capture_signal_saturation,
112 const RenderBuffer& render_buffer, 117 const RenderBuffer& render_buffer,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 aec_state_.FilterDelay() ? *aec_state_.FilterDelay() : -1); 219 aec_state_.FilterDelay() ? *aec_state_.FilterDelay() : -1);
215 data_dumper_->DumpRaw( 220 data_dumper_->DumpRaw(
216 "aec3_external_delay", 221 "aec3_external_delay",
217 aec_state_.ExternalDelay() ? *aec_state_.ExternalDelay() : -1); 222 aec_state_.ExternalDelay() ? *aec_state_.ExternalDelay() : -1);
218 data_dumper_->DumpRaw("aec3_capture_saturation", 223 data_dumper_->DumpRaw("aec3_capture_saturation",
219 aec_state_.SaturatedCapture() ? 1 : 0); 224 aec_state_.SaturatedCapture() ? 1 : 0);
220 } 225 }
221 226
222 } // namespace 227 } // namespace
223 228
224 EchoRemover* EchoRemover::Create(int sample_rate_hz) { 229 EchoRemover* EchoRemover::Create(
225 return new EchoRemoverImpl(sample_rate_hz); 230 const AudioProcessing::Config::EchoCanceller3& config,
231 int sample_rate_hz) {
232 return new EchoRemoverImpl(config, sample_rate_hz);
226 } 233 }
227 234
228 } // namespace webrtc 235 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698