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

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

Issue 3003733002: Utilizing the AEC3 config struct for constants. (Closed)
Patch Set: Added comment Created 3 years, 3 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 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return rtc::Optional<size_t>(); 68 return rtc::Optional<size_t>();
69 } 69 }
70 70
71 constexpr int kEchoPathChangeCounterInitial = kNumBlocksPerSecond / 5; 71 constexpr int kEchoPathChangeCounterInitial = kNumBlocksPerSecond / 5;
72 constexpr int kEchoPathChangeCounterMax = 2 * kNumBlocksPerSecond; 72 constexpr int kEchoPathChangeCounterMax = 2 * kNumBlocksPerSecond;
73 73
74 } // namespace 74 } // namespace
75 75
76 int AecState::instance_count_ = 0; 76 int AecState::instance_count_ = 0;
77 77
78 AecState::AecState(float reverb_decay) 78 AecState::AecState(const AudioProcessing::Config::EchoCanceller3& config)
79 : data_dumper_( 79 : data_dumper_(
80 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), 80 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
81 erle_estimator_(config.param.erle.min,
82 config.param.erle.max_l,
83 config.param.erle.max_h),
81 echo_path_change_counter_(kEchoPathChangeCounterInitial), 84 echo_path_change_counter_(kEchoPathChangeCounterInitial),
82 reverb_decay_(reverb_decay) {} 85 config_(config),
86 reverb_decay_(config_.param.ep_strength.default_len) {}
83 87
84 AecState::~AecState() = default; 88 AecState::~AecState() = default;
85 89
86 void AecState::HandleEchoPathChange( 90 void AecState::HandleEchoPathChange(
87 const EchoPathVariability& echo_path_variability) { 91 const EchoPathVariability& echo_path_variability) {
88 if (echo_path_variability.AudioPathChanged()) { 92 if (echo_path_variability.AudioPathChanged()) {
89 blocks_since_last_saturation_ = 0; 93 blocks_since_last_saturation_ = 0;
90 usable_linear_estimate_ = false; 94 usable_linear_estimate_ = false;
91 echo_leakage_detected_ = false; 95 echo_leakage_detected_ = false;
92 capture_signal_saturation_ = false; 96 capture_signal_saturation_ = false;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 249
246 // If all reverb candidates have been evaluated, choose the best one as the 250 // If all reverb candidates have been evaluated, choose the best one as the
247 // reverb decay. 251 // reverb decay.
248 if (reverb_decay_to_test_ >= 0.9965f) { 252 if (reverb_decay_to_test_ >= 0.9965f) {
249 if (reverb_decay_candidate_residual_ < 0.f) { 253 if (reverb_decay_candidate_residual_ < 0.f) {
250 // Transform the decay to be in the unit of blocks. 254 // Transform the decay to be in the unit of blocks.
251 reverb_decay_ = powf(reverb_decay_candidate_, kFftLengthBy2); 255 reverb_decay_ = powf(reverb_decay_candidate_, kFftLengthBy2);
252 256
253 // Limit the estimated reverb_decay_ to the maximum one needed in practice 257 // Limit the estimated reverb_decay_ to the maximum one needed in practice
254 // to minimize the impact of incorrect estimates. 258 // to minimize the impact of incorrect estimates.
255 reverb_decay_ = std::min(0.8f, reverb_decay_); 259 reverb_decay_ =
260 std::min(config_.param.ep_strength.default_len, reverb_decay_);
256 } 261 }
257 reverb_decay_to_test_ = 0.9f; 262 reverb_decay_to_test_ = 0.9f;
258 reverb_decay_candidate_residual_ = -1.f; 263 reverb_decay_candidate_residual_ = -1.f;
259 } 264 }
260 265
261 // For noisy impulse responses, assume a fixed tail length. 266 // For noisy impulse responses, assume a fixed tail length.
262 if (tail_power > 0.0005f) { 267 if (tail_power > 0.0005f) {
263 reverb_decay_ = 0.7f; 268 reverb_decay_ = config_.param.ep_strength.default_len;
264 } 269 }
265 data_dumper_->DumpRaw("aec3_reverb_decay", reverb_decay_); 270 data_dumper_->DumpRaw("aec3_reverb_decay", reverb_decay_);
266 data_dumper_->DumpRaw("aec3_tail_power", tail_power); 271 data_dumper_->DumpRaw("aec3_tail_power", tail_power);
267 } 272 }
268 273
269 void AecState::EchoAudibility::Update(rtc::ArrayView<const float> x, 274 void AecState::EchoAudibility::Update(rtc::ArrayView<const float> x,
270 const std::array<float, kBlockSize>& s) { 275 const std::array<float, kBlockSize>& s) {
271 auto result_x = std::minmax_element(x.begin(), x.end()); 276 auto result_x = std::minmax_element(x.begin(), x.end());
272 auto result_s = std::minmax_element(s.begin(), s.end()); 277 auto result_s = std::minmax_element(s.begin(), s.end());
273 const float x_abs = 278 const float x_abs =
(...skipping 26 matching lines...) Expand all
300 max_nearend_ = e_abs; 305 max_nearend_ = e_abs;
301 max_nearend_counter_ = 0; 306 max_nearend_counter_ = 0;
302 } else { 307 } else {
303 if (++max_nearend_counter_ > 5 * kNumBlocksPerSecond) { 308 if (++max_nearend_counter_ > 5 * kNumBlocksPerSecond) {
304 max_nearend_ *= 0.995f; 309 max_nearend_ *= 0.995f;
305 } 310 }
306 } 311 }
307 } 312 }
308 313
309 } // namespace webrtc 314 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/aec_state.h ('k') | webrtc/modules/audio_processing/aec3/aec_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698