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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 if (active_render) { | 54 if (active_render) { |
55 std::copy(Y2.begin(), Y2.end(), R2->begin()); | 55 std::copy(Y2.begin(), Y2.end(), R2->begin()); |
56 } else { | 56 } else { |
57 R2->fill(0.f); | 57 R2->fill(0.f); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 // Estimates the residual echo power based on gains. | 61 // Estimates the residual echo power based on gains. |
62 void GainBasedPowerEstimate( | 62 void GainBasedPowerEstimate( |
63 size_t external_delay, | 63 size_t external_delay, |
64 const FftBuffer& X_buffer, | 64 const RenderBuffer& X_buffer, |
65 size_t blocks_since_last_saturation, | 65 size_t blocks_since_last_saturation, |
66 size_t active_render_blocks, | 66 size_t active_render_blocks, |
67 const std::array<bool, kFftLengthBy2Plus1>& bands_with_reliable_filter, | 67 const std::array<bool, kFftLengthBy2Plus1>& bands_with_reliable_filter, |
68 const std::array<float, kFftLengthBy2Plus1>& echo_path_gain, | 68 const std::array<float, kFftLengthBy2Plus1>& echo_path_gain, |
69 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, | 69 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, |
70 std::array<float, kFftLengthBy2Plus1>* R2) { | 70 std::array<float, kFftLengthBy2Plus1>* R2) { |
71 const auto& X2 = X_buffer.Spectrum(external_delay); | 71 const auto& X2 = X_buffer.Spectrum(external_delay); |
72 | 72 |
73 // Base the residual echo power on gain of the linear echo path estimate if | 73 // Base the residual echo power on gain of the linear echo path estimate if |
74 // that is reliable, otherwise use the fallback echo path estimate. Add a | 74 // that is reliable, otherwise use the fallback echo path estimate. Add a |
(...skipping 11 matching lines...) Expand all Loading... |
86 | 86 |
87 if (blocks_since_last_saturation < kSaturationLeakageBlocks) { | 87 if (blocks_since_last_saturation < kSaturationLeakageBlocks) { |
88 std::for_each(R2->begin(), R2->end(), | 88 std::for_each(R2->begin(), R2->end(), |
89 [](float& a) { a *= kSaturationLeakageFactor; }); | 89 [](float& a) { a *= kSaturationLeakageFactor; }); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 // Estimates the residual echo power based on the linear echo path. | 93 // Estimates the residual echo power based on the linear echo path. |
94 void ErleBasedPowerEstimate( | 94 void ErleBasedPowerEstimate( |
95 bool headset_detected, | 95 bool headset_detected, |
96 const FftBuffer& X_buffer, | 96 const RenderBuffer& X_buffer, |
97 bool using_subtractor_output, | 97 bool using_subtractor_output, |
98 size_t linear_filter_based_delay, | 98 size_t linear_filter_based_delay, |
99 size_t blocks_since_last_saturation, | 99 size_t blocks_since_last_saturation, |
100 bool poorly_aligned_filter, | 100 bool poorly_aligned_filter, |
101 const std::array<bool, kFftLengthBy2Plus1>& bands_with_reliable_filter, | 101 const std::array<bool, kFftLengthBy2Plus1>& bands_with_reliable_filter, |
102 const std::array<float, kFftLengthBy2Plus1>& echo_path_gain, | 102 const std::array<float, kFftLengthBy2Plus1>& echo_path_gain, |
103 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, | 103 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, |
104 const std::array<float, kFftLengthBy2Plus1>& S2_linear, | 104 const std::array<float, kFftLengthBy2Plus1>& S2_linear, |
105 const std::array<float, kFftLengthBy2Plus1>& Y2, | 105 const std::array<float, kFftLengthBy2Plus1>& Y2, |
106 const std::array<float, kFftLengthBy2Plus1>& erle, | 106 const std::array<float, kFftLengthBy2Plus1>& erle, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 ResidualEchoEstimator::ResidualEchoEstimator() { | 156 ResidualEchoEstimator::ResidualEchoEstimator() { |
157 echo_path_gain_.fill(100.f); | 157 echo_path_gain_.fill(100.f); |
158 } | 158 } |
159 | 159 |
160 ResidualEchoEstimator::~ResidualEchoEstimator() = default; | 160 ResidualEchoEstimator::~ResidualEchoEstimator() = default; |
161 | 161 |
162 void ResidualEchoEstimator::Estimate( | 162 void ResidualEchoEstimator::Estimate( |
163 bool using_subtractor_output, | 163 bool using_subtractor_output, |
164 const AecState& aec_state, | 164 const AecState& aec_state, |
165 const FftBuffer& X_buffer, | 165 const RenderBuffer& X_buffer, |
166 const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, | 166 const std::vector<std::array<float, kFftLengthBy2Plus1>>& H2, |
167 const std::array<float, kFftLengthBy2Plus1>& E2_main, | 167 const std::array<float, kFftLengthBy2Plus1>& E2_main, |
168 const std::array<float, kFftLengthBy2Plus1>& E2_shadow, | 168 const std::array<float, kFftLengthBy2Plus1>& E2_shadow, |
169 const std::array<float, kFftLengthBy2Plus1>& S2_linear, | 169 const std::array<float, kFftLengthBy2Plus1>& S2_linear, |
170 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, | 170 const std::array<float, kFftLengthBy2Plus1>& S2_fallback, |
171 const std::array<float, kFftLengthBy2Plus1>& Y2, | 171 const std::array<float, kFftLengthBy2Plus1>& Y2, |
172 std::array<float, kFftLengthBy2Plus1>* R2) { | 172 std::array<float, kFftLengthBy2Plus1>* R2) { |
173 RTC_DCHECK(R2); | 173 RTC_DCHECK(R2); |
174 const rtc::Optional<size_t>& linear_filter_based_delay = | 174 const rtc::Optional<size_t>& linear_filter_based_delay = |
175 aec_state.FilterDelay(); | 175 aec_state.FilterDelay(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 void ResidualEchoEstimator::HandleEchoPathChange( | 224 void ResidualEchoEstimator::HandleEchoPathChange( |
225 const EchoPathVariability& echo_path_variability) { | 225 const EchoPathVariability& echo_path_variability) { |
226 if (echo_path_variability.AudioPathChanged()) { | 226 if (echo_path_variability.AudioPathChanged()) { |
227 blocks_since_last_saturation_ = 0; | 227 blocks_since_last_saturation_ = 0; |
228 echo_path_gain_.fill(100.f); | 228 echo_path_gain_.fill(100.f); |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 } // namespace webrtc | 232 } // namespace webrtc |
OLD | NEW |