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

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

Issue 2811283003: AEC3 Tuning changes (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | 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) 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 for (size_t k = 1; k < kUpperBin; ++k) { 65 for (size_t k = 1; k < kUpperBin; ++k) {
66 if (H2[delay][k] > H2[delay][0]) { 66 if (H2[delay][k] > H2[delay][0]) {
67 RTC_DCHECK_GT(H2.size(), delay); 67 RTC_DCHECK_GT(H2.size(), delay);
68 return rtc::Optional<size_t>(delay); 68 return rtc::Optional<size_t>(delay);
69 } 69 }
70 } 70 }
71 return rtc::Optional<size_t>(); 71 return rtc::Optional<size_t>();
72 } 72 }
73 73
74 constexpr int kEchoPathChangeCounterInitial = kNumBlocksPerSecond / 5; 74 constexpr int kEchoPathChangeCounterInitial = kNumBlocksPerSecond / 5;
75 constexpr int kEchoPathChangeCounterMax = 3 * kNumBlocksPerSecond; 75 constexpr int kEchoPathChangeCounterMax = 2 * kNumBlocksPerSecond;
76 76
77 } // namespace 77 } // namespace
78 78
79 int AecState::instance_count_ = 0; 79 int AecState::instance_count_ = 0;
80 80
81 AecState::AecState() 81 AecState::AecState()
82 : data_dumper_( 82 : data_dumper_(
83 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), 83 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
84 echo_path_change_counter_(kEchoPathChangeCounterInitial) {} 84 echo_path_change_counter_(kEchoPathChangeCounterInitial) {}
85 85
86 AecState::~AecState() = default; 86 AecState::~AecState() = default;
87 87
88 void AecState::HandleEchoPathChange( 88 void AecState::HandleEchoPathChange(
89 const EchoPathVariability& echo_path_variability) { 89 const EchoPathVariability& echo_path_variability) {
90 if (echo_path_variability.AudioPathChanged()) { 90 if (echo_path_variability.AudioPathChanged()) {
91 blocks_since_last_saturation_ = 0; 91 blocks_since_last_saturation_ = 0;
92 active_render_blocks_ = 0; 92 active_render_blocks_ = 0;
93 echo_path_change_counter_ = kEchoPathChangeCounterMax;
94 usable_linear_estimate_ = false; 93 usable_linear_estimate_ = false;
95 echo_leakage_detected_ = false; 94 echo_leakage_detected_ = false;
96 capture_signal_saturation_ = false; 95 capture_signal_saturation_ = false;
97 echo_saturation_ = false; 96 echo_saturation_ = false;
98 headset_detected_ = false;
99 previous_max_sample_ = 0.f; 97 previous_max_sample_ = 0.f;
100 98
101 if (echo_path_variability.delay_change) { 99 if (echo_path_variability.delay_change) {
102 force_zero_gain_counter_ = 0; 100 force_zero_gain_counter_ = 0;
103 force_zero_gain_ = true; 101 force_zero_gain_ = true;
102 echo_path_change_counter_ = kEchoPathChangeCounterMax;
103 }
104 if (echo_path_variability.gain_change) {
105 echo_path_change_counter_ = kEchoPathChangeCounterInitial;
104 } 106 }
105 } 107 }
106 } 108 }
107 109
108 void AecState::Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>& 110 void AecState::Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
109 adaptive_filter_frequency_response, 111 adaptive_filter_frequency_response,
110 const rtc::Optional<size_t>& external_delay_samples, 112 const rtc::Optional<size_t>& external_delay_samples,
111 const RenderBuffer& render_buffer, 113 const RenderBuffer& render_buffer,
112 const std::array<float, kFftLengthBy2Plus1>& E2_main, 114 const std::array<float, kFftLengthBy2Plus1>& E2_main,
113 const std::array<float, kFftLengthBy2Plus1>& Y2, 115 const std::array<float, kFftLengthBy2Plus1>& Y2,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 filter_delay_ && echo_path_change_counter_ <= 0; 164 filter_delay_ && echo_path_change_counter_ <= 0;
163 165
164 // After an amount of active render samples for which an echo should have been 166 // After an amount of active render samples for which an echo should have been
165 // detected in the capture signal if the ERL was not infinite, flag that a 167 // detected in the capture signal if the ERL was not infinite, flag that a
166 // headset is used. 168 // headset is used.
167 headset_detected_ = !external_delay_ && !filter_delay_ && 169 headset_detected_ = !external_delay_ && !filter_delay_ &&
168 active_render_blocks_ >= kEchoPathChangeConvergenceBlocks; 170 active_render_blocks_ >= kEchoPathChangeConvergenceBlocks;
169 } 171 }
170 172
171 } // namespace webrtc 173 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698