Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1354)

Unified Diff: webrtc/modules/audio_processing/aec3/suppression_gain.cc

Issue 2980493002: Add adaptive notch filter to remove narrowband echo components in AEC3 (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c8465eaff679807de445ad3e6c64862946be82a1..02ca3dcd888cc56afff14b216eeba910721eb180 100644
--- a/webrtc/modules/audio_processing/aec3/suppression_gain.cc
+++ b/webrtc/modules/audio_processing/aec3/suppression_gain.cc
@@ -25,6 +25,16 @@
namespace webrtc {
namespace {
+// Reduce gain to avoid narrow band echo leakage.
+void NarrowBandAttenuation(int narrow_bin,
+ std::array<float, kFftLengthBy2Plus1>* gain) {
+ const int upper_bin =
+ std::min(narrow_bin + 6, static_cast<int>(kFftLengthBy2Plus1 - 1));
+ for (int k = std::max(0, narrow_bin - 6); k <= upper_bin; ++k) {
+ (*gain)[k] = std::min((*gain)[k], 0.001f);
+ }
+}
+
// Adjust the gains according to the presence of known external filters.
void AdjustForExternalFilters(std::array<float, kFftLengthBy2Plus1>* gain) {
// Limit the low frequency gains to avoid the impact of the high-pass filter
@@ -45,6 +55,7 @@ void AdjustForExternalFilters(std::array<float, kFftLengthBy2Plus1>* gain) {
// Computes the gain to apply for the bands beyond the first band.
float UpperBandsGain(
+ const RenderSignalAnalyzer& render_signal_analyzer,
bool saturated_echo,
const std::vector<std::vector<float>>& render,
const std::array<float, kFftLengthBy2Plus1>& low_band_gain) {
@@ -53,6 +64,12 @@ float UpperBandsGain(
return 1.f;
}
+ if (render_signal_analyzer.NarrowPeakBand() &&
ivoc 2017/07/11 11:06:50 I think it makes sense to store this in a temporar
peah-webrtc 2017/07/11 11:54:18 I changed it to a separate input argument. Unfortu
+ (*render_signal_analyzer.NarrowPeakBand() >
+ static_cast<int>(kFftLengthBy2Plus1 - 10))) {
+ return 0.001f;
+ }
+
constexpr size_t kLowBandGainLimit = kFftLengthBy2 / 2;
const float gain_below_8_khz = *std::min_element(
low_band_gain.begin() + kLowBandGainLimit, low_band_gain.end());
@@ -193,6 +210,7 @@ void MaskingPower(const std::array<float, kFftLengthBy2Plus1>& nearend,
// TODO(peah): Add further optimizations, in particular for the divisions.
void SuppressionGain::LowerBandGain(
bool low_noise_render,
+ const RenderSignalAnalyzer& render_signal_analyzer,
bool saturated_echo,
const std::array<float, kFftLengthBy2Plus1>& nearend,
const std::array<float, kFftLengthBy2Plus1>& echo,
@@ -238,6 +256,9 @@ void SuppressionGain::LowerBandGain(
GainToNoAudibleEcho(low_noise_render, saturated_echo, nearend, echo, masker,
min_gain, max_gain, one_by_echo, gain);
AdjustForExternalFilters(gain);
+ if (render_signal_analyzer.NarrowPeakBand()) {
+ NarrowBandAttenuation(*render_signal_analyzer.NarrowPeakBand(), gain);
+ }
}
// Update the allowed maximum gain increase.
@@ -263,6 +284,7 @@ void SuppressionGain::GetGain(
const std::array<float, kFftLengthBy2Plus1>& nearend,
const std::array<float, kFftLengthBy2Plus1>& echo,
const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
+ const RenderSignalAnalyzer& render_signal_analyzer,
ivoc 2017/07/11 11:06:50 This object is passed around a lot, but it seems l
peah-webrtc 2017/07/11 11:54:18 Good point! I changed the code along that, but as
bool saturated_echo,
const std::vector<std::vector<float>>& render,
bool force_zero_gain,
@@ -283,11 +305,12 @@ void SuppressionGain::GetGain(
bool low_noise_render = low_render_detector_.Detect(render);
// Compute gain for the lower band.
- LowerBandGain(low_noise_render, saturated_echo, nearend, echo, comfort_noise,
- low_band_gain);
+ LowerBandGain(low_noise_render, render_signal_analyzer, saturated_echo,
+ nearend, echo, comfort_noise, low_band_gain);
// Compute the gain for the upper bands.
- *high_bands_gain = UpperBandsGain(saturated_echo, render, *low_band_gain);
+ *high_bands_gain = UpperBandsGain(render_signal_analyzer, saturated_echo,
+ render, *low_band_gain);
}
// Detects when the render signal can be considered to have low power and

Powered by Google App Engine
This is Rietveld 408576698