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 34bb9cb3907dacfef38018bebde1ab04e67ebb36..3e81e0c1596c89fb9919b297d60640ad222df1aa 100644 |
--- a/webrtc/modules/audio_processing/aec3/suppression_gain.cc |
+++ b/webrtc/modules/audio_processing/aec3/suppression_gain.cc |
@@ -21,6 +21,25 @@ |
namespace webrtc { |
namespace { |
+void GainPostProcessing(std::array<float, kFftLengthBy2Plus1>* gain_squared) { |
+ // Limit the low frequency gains to avoid the impact of the high-pass filter |
+ // on the lower-freqyency gain influencing the overall achieved gain. |
+ (*gain_squared)[1] = std::min((*gain_squared)[1], (*gain_squared)[2]); |
+ (*gain_squared)[0] = (*gain_squared)[1]; |
+ |
+ // Limit the high frequency gains to avoid the impact of the anti-aliasing |
+ // filter filter on the upper-freqyency gains influencing the overall achieved |
hlundin-webrtc
2017/02/27 08:12:52
filter filter
hlundin-webrtc
2017/02/27 08:12:52
freqyency
peah-webrtc
2017/02/27 08:25:47
Done.
peah-webrtc
2017/02/27 08:25:47
Done.
|
+ // gain. TODO(peah): Update this when new anti-aliasing filters are |
+ // implemented. |
+ int kAntiAlisingImpactLimit = 64 * 0.7f; |
hlundin-webrtc
2017/02/27 08:12:52
Alising -> Aliasing
hlundin-webrtc
2017/02/27 08:12:52
constexpr size_t
peah-webrtc
2017/02/27 08:25:47
Done.
peah-webrtc
2017/02/27 08:25:47
Done.
|
+ std::for_each(gain_squared->begin() + kAntiAlisingImpactLimit, |
+ gain_squared->end(), |
+ [gain_squared, kAntiAlisingImpactLimit](float& a) { |
+ a = std::min(a, (*gain_squared)[kAntiAlisingImpactLimit]); |
+ }); |
+ (*gain_squared)[kFftLengthBy2] = (*gain_squared)[kFftLengthBy2Minus1]; |
+} |
+ |
constexpr int kNumIterations = 2; |
constexpr float kEchoMaskingMargin = 1.f / 10.f; |
constexpr float kBandMaskingFactor = 1.f / 2.f; |
@@ -120,8 +139,9 @@ void ComputeGains_SSE2( |
: std::min(a, b * 2.f); |
}); |
peah-webrtc
2017/02/27 07:55:23
These two lines are now moved into GainPostProcess
|
- (*gain_squared)[0] = (*gain_squared)[1]; |
- (*gain_squared)[kFftLengthBy2] = (*gain_squared)[kFftLengthBy2Minus1]; |
+ // Process the gains to avoid artefacts caused by gain realization in the |
+ // filterbank and impact of external pre-processing of the signal. |
+ GainPostProcessing(gain_squared); |
} |
std::copy(gain_squared->begin() + 1, gain_squared->end() - 1, |
@@ -231,8 +251,9 @@ void ComputeGains( |
: std::min(a, b * 2.f); |
}); |
- (*gain_squared)[0] = (*gain_squared)[1]; |
peah-webrtc
2017/02/27 07:55:23
These two lines are now moved into GainPostProcess
|
- (*gain_squared)[kFftLengthBy2] = (*gain_squared)[kFftLengthBy2Minus1]; |
+ // Process the gains to avoid artefacts caused by gain realization in the |
+ // filterbank and impact of external pre-processing of the signal. |
+ GainPostProcessing(gain_squared); |
} |
std::copy(gain_squared->begin() + 1, gain_squared->end() - 1, |