Index: webrtc/modules/audio_processing/aec3/suppression_gain.cc |
diff --git a/webrtc/modules/audio_processing/aec3/suppression_gain.cc b/webrtc/modules/audio_processing/aec3/suppression_gain.cc |
index 0e50292008947cbc1799d3affb5e3faf35867792..598f5d8e07cc1af156fb332182ef5e407b81f04b 100644 |
--- a/webrtc/modules/audio_processing/aec3/suppression_gain.cc |
+++ b/webrtc/modules/audio_processing/aec3/suppression_gain.cc |
@@ -325,38 +325,47 @@ void SuppressionGain::GetGain( |
bool saturated_echo, |
const std::vector<std::vector<float>>& render, |
size_t num_capture_bands, |
+ bool force_zero_gain, |
float* high_bands_gain, |
std::array<float, kFftLengthBy2Plus1>* low_band_gain) { |
RTC_DCHECK(high_bands_gain); |
RTC_DCHECK(low_band_gain); |
- // Choose margin to use. |
- const float margin = saturated_echo ? 0.001f : 0.01f; |
- switch (optimization_) { |
+ if (!force_zero_gain) { |
+ // Choose margin to use. |
+ const float margin = saturated_echo ? 0.001f : 0.01f; |
+ switch (optimization_) { |
#if defined(WEBRTC_ARCH_X86_FAMILY) |
- case Aec3Optimization::kSse2: |
- aec3::ComputeGains_SSE2( |
- nearend_power, residual_echo_power, comfort_noise_power, margin, |
- &previous_gain_squared_, &previous_masker_, low_band_gain); |
- break; |
+ case Aec3Optimization::kSse2: |
+ aec3::ComputeGains_SSE2( |
+ nearend_power, residual_echo_power, comfort_noise_power, margin, |
+ &previous_gain_squared_, &previous_masker_, low_band_gain); |
+ break; |
#endif |
- default: |
- aec3::ComputeGains(nearend_power, residual_echo_power, |
- comfort_noise_power, margin, &previous_gain_squared_, |
- &previous_masker_, low_band_gain); |
- } |
+ default: |
+ aec3::ComputeGains(nearend_power, residual_echo_power, |
+ comfort_noise_power, margin, &previous_gain_squared_, |
+ &previous_masker_, low_band_gain); |
+ } |
- if (num_capture_bands > 1) { |
- // Compute the gain for upper frequencies. |
- const float min_high_band_gain = |
- HighFrequencyGainBound(saturated_echo, render); |
- *high_bands_gain = |
- *std::min_element(low_band_gain->begin() + 32, low_band_gain->end()); |
+ if (num_capture_bands > 1) { |
+ // Compute the gain for upper frequencies. |
+ const float min_high_band_gain = |
+ HighFrequencyGainBound(saturated_echo, render); |
+ *high_bands_gain = |
+ *std::min_element(low_band_gain->begin() + 32, low_band_gain->end()); |
- *high_bands_gain = std::min(*high_bands_gain, min_high_band_gain); |
+ *high_bands_gain = std::min(*high_bands_gain, min_high_band_gain); |
+ } else { |
+ *high_bands_gain = 1.f; |
+ } |
} else { |
- *high_bands_gain = 1.f; |
+ previous_gain_squared_.fill(0.f); |
+ std::copy(comfort_noise_power.begin(), comfort_noise_power.end(), |
+ previous_masker_.begin()); |
+ low_band_gain->fill(0.f); |
+ *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
|
} |
} |