Correcting the AEC3 transparent mode behavior avoid incorrect activation

This CL adds robustness to avoid the AEC3 transparent mode to be
incorrectly activated when
-there is strong near-end noise
-there is only low-level nearend activity.

Bug: webrtc:9256,chromium:841193
Change-Id: I26c2759d163914eb85dc3d863da8acbf28cbb88d
Reviewed-on: https://webrtc-review.googlesource.com/75511
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23191}
This commit is contained in:
Per Åhgren
2018-05-09 12:07:26 +02:00
committed by Commit Bot
parent ced31ba1cf
commit d18e87edd4
3 changed files with 10 additions and 5 deletions

View File

@ -19,10 +19,15 @@
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/atomicops.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
bool EnableTransparentMode() {
return !field_trial::IsEnabled("WebRTC-Aec3TransparentModeKillSwitch");
}
float ComputeGainRampupIncrease(const EchoCanceller3Config& config) {
const auto& c = config.echo_removal_control.gain_rampup;
return powf(1.f / c.first_non_zero_gain, 1.f / c.non_zero_gain_blocks);
@ -38,6 +43,7 @@ int AecState::instance_count_ = 0;
AecState::AecState(const EchoCanceller3Config& config)
: data_dumper_(
new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
allow_transparent_mode_(EnableTransparentMode()),
erle_estimator_(config.erle.min, config.erle.max_l, config.erle.max_h),
config_(config),
max_render_(config_.filter.main.length_blocks, 0.f),
@ -223,10 +229,8 @@ void AecState::Update(
transparent_mode_ =
transparent_mode_ &&
(consistent_filter_estimate_not_seen || !converged_filter_seen_);
transparent_mode_ = transparent_mode_ &&
(filter_should_have_converged_ ||
(!external_delay_seen_ &&
capture_block_counter_ > 10 * kNumBlocksPerSecond));
transparent_mode_ = transparent_mode_ && filter_should_have_converged_;
transparent_mode_ = transparent_mode_ && allow_transparent_mode_;
usable_linear_estimate_ = !echo_saturation_;
usable_linear_estimate_ =

View File

@ -142,6 +142,7 @@ class AecState {
static int instance_count_;
std::unique_ptr<ApmDataDumper> data_dumper_;
const bool allow_transparent_mode_;
ErlEstimator erl_estimator_;
ErleEstimator erle_estimator_;
size_t capture_block_counter_ = 0;

View File

@ -162,7 +162,7 @@ void Subtractor::Process(const RenderBuffer& render_buffer,
std::accumulate(e_shadow.begin(), e_shadow.end(), 0.f, sum_of_squares);
constexpr float kConvergenceThreshold = 50 * 50 * kBlockSize;
main_filter_converged_ = e2_main < 0.2 * y2 && y2 > kConvergenceThreshold;
main_filter_converged_ = e2_main < 0.5f * y2 && y2 > kConvergenceThreshold;
shadow_filter_converged_ =
e2_shadow < 0.05 * y2 && y2 > kConvergenceThreshold;
main_filter_once_converged_ =