AEC3: Allow limiting dominant nearend to the non-initial phase
This CL allows control over the dominant nearend functionality so that it is not active during the initial phase, when estimates are less certain. Bug: webrtc:9906,chromium:898273 Change-Id: I5f61dac806ec3b1ebc1a3ec72f0a16d07a67f14a Reviewed-on: https://webrtc-review.googlesource.com/c/107632 Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25326}
This commit is contained in:
@ -186,6 +186,7 @@ struct RTC_EXPORT EchoCanceller3Config {
|
||||
float snr_threshold = 30.f;
|
||||
int hold_duration = 50;
|
||||
int trigger_threshold = 12;
|
||||
bool use_during_initial_phase = true;
|
||||
} dominant_nearend_detection;
|
||||
|
||||
struct HighBandsSuppression {
|
||||
|
@ -338,7 +338,7 @@ void SuppressionGain::GetGain(
|
||||
|
||||
// Update the state selection.
|
||||
dominant_nearend_detector_.Update(nearend_spectrum, residual_echo_spectrum,
|
||||
comfort_noise_spectrum);
|
||||
comfort_noise_spectrum, initial_state_);
|
||||
|
||||
// Compute gain for the lower band.
|
||||
bool low_noise_render = low_render_detector_.Detect(render);
|
||||
@ -400,12 +400,14 @@ SuppressionGain::DominantNearendDetector::DominantNearendDetector(
|
||||
enr_exit_threshold_(config.enr_exit_threshold),
|
||||
snr_threshold_(config.snr_threshold),
|
||||
hold_duration_(config.hold_duration),
|
||||
trigger_threshold_(config.trigger_threshold) {}
|
||||
trigger_threshold_(config.trigger_threshold),
|
||||
use_during_initial_phase_(config.use_during_initial_phase) {}
|
||||
|
||||
void SuppressionGain::DominantNearendDetector::Update(
|
||||
rtc::ArrayView<const float> nearend_spectrum,
|
||||
rtc::ArrayView<const float> residual_echo_spectrum,
|
||||
rtc::ArrayView<const float> comfort_noise_spectrum) {
|
||||
rtc::ArrayView<const float> comfort_noise_spectrum,
|
||||
bool initial_state) {
|
||||
auto low_frequency_energy = [](rtc::ArrayView<const float> spectrum) {
|
||||
RTC_DCHECK_LE(16, spectrum.size());
|
||||
return std::accumulate(spectrum.begin() + 1, spectrum.begin() + 16, 0.f);
|
||||
@ -416,7 +418,8 @@ void SuppressionGain::DominantNearendDetector::Update(
|
||||
|
||||
// Detect strong active nearend if the nearend is sufficiently stronger than
|
||||
// the echo and the nearend noise.
|
||||
if (ne_sum > enr_threshold_ * echo_sum &&
|
||||
if ((!initial_state || use_during_initial_phase_) &&
|
||||
ne_sum > enr_threshold_ * echo_sum &&
|
||||
ne_sum > snr_threshold_ * noise_sum) {
|
||||
if (++trigger_counter_ >= trigger_threshold_) {
|
||||
// After a period of strong active nearend activity, flag nearend mode.
|
||||
|
@ -107,7 +107,8 @@ class SuppressionGain {
|
||||
// Updates the state selection based on latest spectral estimates.
|
||||
void Update(rtc::ArrayView<const float> nearend_spectrum,
|
||||
rtc::ArrayView<const float> residual_echo_spectrum,
|
||||
rtc::ArrayView<const float> comfort_noise_spectrum);
|
||||
rtc::ArrayView<const float> comfort_noise_spectrum,
|
||||
bool initial_state);
|
||||
|
||||
private:
|
||||
const float enr_threshold_;
|
||||
@ -115,6 +116,7 @@ class SuppressionGain {
|
||||
const float snr_threshold_;
|
||||
const int hold_duration_;
|
||||
const int trigger_threshold_;
|
||||
const bool use_during_initial_phase_;
|
||||
|
||||
bool nearend_state_ = false;
|
||||
int trigger_counter_ = 0;
|
||||
|
Reference in New Issue
Block a user