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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 previous_masker_.fill(0.f); | 318 previous_masker_.fill(0.f); |
319 } | 319 } |
320 | 320 |
321 void SuppressionGain::GetGain( | 321 void SuppressionGain::GetGain( |
322 const std::array<float, kFftLengthBy2Plus1>& nearend_power, | 322 const std::array<float, kFftLengthBy2Plus1>& nearend_power, |
323 const std::array<float, kFftLengthBy2Plus1>& residual_echo_power, | 323 const std::array<float, kFftLengthBy2Plus1>& residual_echo_power, |
324 const std::array<float, kFftLengthBy2Plus1>& comfort_noise_power, | 324 const std::array<float, kFftLengthBy2Plus1>& comfort_noise_power, |
325 bool saturated_echo, | 325 bool saturated_echo, |
326 const std::vector<std::vector<float>>& render, | 326 const std::vector<std::vector<float>>& render, |
327 size_t num_capture_bands, | 327 size_t num_capture_bands, |
328 bool force_zero_gain, | |
328 float* high_bands_gain, | 329 float* high_bands_gain, |
329 std::array<float, kFftLengthBy2Plus1>* low_band_gain) { | 330 std::array<float, kFftLengthBy2Plus1>* low_band_gain) { |
330 RTC_DCHECK(high_bands_gain); | 331 RTC_DCHECK(high_bands_gain); |
331 RTC_DCHECK(low_band_gain); | 332 RTC_DCHECK(low_band_gain); |
332 | 333 |
333 // Choose margin to use. | 334 if (!force_zero_gain) { |
334 const float margin = saturated_echo ? 0.001f : 0.01f; | 335 // Choose margin to use. |
335 switch (optimization_) { | 336 const float margin = saturated_echo ? 0.001f : 0.01f; |
337 switch (optimization_) { | |
336 #if defined(WEBRTC_ARCH_X86_FAMILY) | 338 #if defined(WEBRTC_ARCH_X86_FAMILY) |
337 case Aec3Optimization::kSse2: | 339 case Aec3Optimization::kSse2: |
338 aec3::ComputeGains_SSE2( | 340 aec3::ComputeGains_SSE2( |
339 nearend_power, residual_echo_power, comfort_noise_power, margin, | 341 nearend_power, residual_echo_power, comfort_noise_power, margin, |
340 &previous_gain_squared_, &previous_masker_, low_band_gain); | 342 &previous_gain_squared_, &previous_masker_, low_band_gain); |
341 break; | 343 break; |
342 #endif | 344 #endif |
343 default: | 345 default: |
344 aec3::ComputeGains(nearend_power, residual_echo_power, | 346 aec3::ComputeGains(nearend_power, residual_echo_power, |
345 comfort_noise_power, margin, &previous_gain_squared_, | 347 comfort_noise_power, margin, &previous_gain_squared_, |
346 &previous_masker_, low_band_gain); | 348 &previous_masker_, low_band_gain); |
347 } | 349 } |
348 | 350 |
349 if (num_capture_bands > 1) { | 351 if (num_capture_bands > 1) { |
350 // Compute the gain for upper frequencies. | 352 // Compute the gain for upper frequencies. |
351 const float min_high_band_gain = | 353 const float min_high_band_gain = |
352 HighFrequencyGainBound(saturated_echo, render); | 354 HighFrequencyGainBound(saturated_echo, render); |
353 *high_bands_gain = | 355 *high_bands_gain = |
354 *std::min_element(low_band_gain->begin() + 32, low_band_gain->end()); | 356 *std::min_element(low_band_gain->begin() + 32, low_band_gain->end()); |
355 | 357 |
356 *high_bands_gain = std::min(*high_bands_gain, min_high_band_gain); | 358 *high_bands_gain = std::min(*high_bands_gain, min_high_band_gain); |
357 | 359 |
360 } else { | |
361 *high_bands_gain = 1.f; | |
362 } | |
358 } else { | 363 } else { |
359 *high_bands_gain = 1.f; | 364 previous_gain_squared_.fill(0.f); |
365 std::copy(comfort_noise_power.begin(), comfort_noise_power.end(), | |
366 previous_masker_.begin()); | |
367 low_band_gain->fill(0.f); | |
368 *high_bands_gain = 0.f; | |
aleloi
2017/04/10 09:35:51
I think this function will be a bit more simple if
peah-webrtc
2017/04/10 09:57:24
That is indeed a much better way to write this. Gr
| |
360 } | 369 } |
361 } | 370 } |
362 | 371 |
363 } // namespace webrtc | 372 } // namespace webrtc |
OLD | NEW |