OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |