Added post-adjustment of the suppression gains

This CL adds correction of the echo suppressor gain
It contains 2 changes:
-Bounds the upper value for the echo suppression gain
for bin 1 to avoid that the high-pass filter causes the
gain to be high for bin 1, which in turn may impact the
realization of any lower gains for the neighboring bins.
-Bounds the upper values for the echo suppression gains
for the higher bins to avoid any impact of the
external anti-aliasing filters.

BUG=webrtc:6018

Review-Url: https://codereview.webrtc.org/2718993002
Cr-Commit-Position: refs/heads/master@{#16854}
This commit is contained in:
peah 2017-02-27 01:15:24 -08:00 committed by Commit bot
parent fa5fdce100
commit a2376e7db6
2 changed files with 28 additions and 12 deletions

View File

@ -138,17 +138,12 @@ void SuppressionFilter::ApplyGain(
fft_.Ifft(E, &time_domain_high_band_noise);
// Scale and apply the noise to the signals.
// TODO(peah): Ensure that the high bands are properly delayed.
constexpr int kNumBandsAveragingUpperGain = kFftLengthBy2 / 4;
constexpr float kOneByNumBandsAveragingUpperGain =
1.f / kNumBandsAveragingUpperGain;
RTC_DCHECK_LT(3, suppression_gain.size());
float high_bands_gain =
std::accumulate(suppression_gain.end() - kNumBandsAveragingUpperGain,
suppression_gain.end(), 0.f) *
kOneByNumBandsAveragingUpperGain;
*std::min_element(suppression_gain.begin() + 3, suppression_gain.end());
float high_bands_noise_scaling =
0.4f * std::max(1.f - high_bands_gain * high_bands_gain, 0.f);
0.4f * std::max(1.f - high_bands_gain, 0.f);
std::transform(
(*e)[1].begin(), (*e)[1].end(), time_domain_high_band_noise.begin(),

View File

@ -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-frequency 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 on the upper-frequency gains influencing the overall achieved
// gain. TODO(peah): Update this when new anti-aliasing filters are
// implemented.
constexpr size_t kAntiAliasingImpactLimit = 64 * 0.7f;
std::for_each(gain_squared->begin() + kAntiAliasingImpactLimit,
gain_squared->end(),
[gain_squared, kAntiAliasingImpactLimit](float& a) {
a = std::min(a, (*gain_squared)[kAntiAliasingImpactLimit]);
});
(*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);
});
(*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];
(*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,