Corrected the detection of narrowband render signals

This CL corrects the bug that only looked at narrowband
render signals above 900 Hz and only assumed that the
influence of such lasted for 6 blocks, which resulted
in filter divergence and echo leakage.


Bug: webrtc:9008,chromium:821670
Change-Id: I9b2635d24b260e9d9a8c5c088ab663e03fb93c42
Reviewed-on: https://webrtc-review.googlesource.com/61800
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22434}
This commit is contained in:
Per Åhgren
2018-03-14 23:23:47 +01:00
committed by Commit Bot
parent ee205f5bba
commit 971de07713
9 changed files with 35 additions and 26 deletions

View File

@ -42,6 +42,7 @@ void IdentifySmallNarrowBandRegions(
// Identifies whether the signal has a single strong narrow-band component.
void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
int strong_peak_freeze_duration,
rtc::Optional<int>* narrow_peak_band,
size_t* narrow_peak_counter) {
const auto X2_latest = render_buffer.Spectrum(0);
@ -52,7 +53,7 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
// Compute the level around the peak.
float non_peak_power = 0.f;
for (int k = std::max(5, peak_bin - 14); k < peak_bin - 4; ++k) {
for (int k = std::max(0, peak_bin - 14); k < peak_bin - 4; ++k) {
non_peak_power = std::max(X2_latest[k], non_peak_power);
}
for (int k = peak_bin + 5;
@ -60,7 +61,7 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
non_peak_power = std::max(X2_latest[k], non_peak_power);
}
// Assess the render signal strength
// Assess the render signal strength.
const std::vector<std::vector<float>>& x_latest = render_buffer.Block(0);
auto result0 = std::minmax_element(x_latest[0].begin(), x_latest[0].end());
float max_abs = std::max(fabs(*result0.first), fabs(*result0.second));
@ -74,12 +75,14 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
}
// Detect whether the spectal peak has as strong narrowband nature.
if (peak_bin > 6 && max_abs > 100 &&
if (peak_bin > 0 && max_abs > 100 &&
X2_latest[peak_bin] > 100 * non_peak_power) {
*narrow_peak_band = peak_bin;
*narrow_peak_counter = 0;
} else {
if (*narrow_peak_band && ++(*narrow_peak_counter) > 7) {
if (*narrow_peak_band &&
++(*narrow_peak_counter) >
static_cast<size_t>(strong_peak_freeze_duration)) {
*narrow_peak_band = rtc::nullopt;
}
}
@ -87,7 +90,8 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
} // namespace
RenderSignalAnalyzer::RenderSignalAnalyzer() {
RenderSignalAnalyzer::RenderSignalAnalyzer(const EchoCanceller3Config& config)
: strong_peak_freeze_duration_(config.filter.main.length_blocks) {
narrow_band_counters_.fill(0);
}
RenderSignalAnalyzer::~RenderSignalAnalyzer() = default;
@ -100,8 +104,8 @@ void RenderSignalAnalyzer::Update(
&narrow_band_counters_);
// Identify the presence of a strong narrow band.
IdentifyStrongNarrowBandComponent(render_buffer, &narrow_peak_band_,
&narrow_peak_counter_);
IdentifyStrongNarrowBandComponent(render_buffer, strong_peak_freeze_duration_,
&narrow_peak_band_, &narrow_peak_counter_);
}
void RenderSignalAnalyzer::MaskRegionsAroundNarrowBands(