diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 7fbc405159..e8bbe696ab 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -143,6 +143,7 @@ rtc_static_library("aec3") { "../../../rtc_base:safe_minmax", "../../../rtc_base/system:arch", "../../../system_wrappers:cpu_features_api", + "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", "../utility:ooura_fft", "//third_party/abseil-cpp/absl/types:optional", diff --git a/modules/audio_processing/aec3/subband_erle_estimator.cc b/modules/audio_processing/aec3/subband_erle_estimator.cc index 730522dfdc..82f3dab86f 100644 --- a/modules/audio_processing/aec3/subband_erle_estimator.cc +++ b/modules/audio_processing/aec3/subband_erle_estimator.cc @@ -15,6 +15,7 @@ #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_minmax.h" +#include "system_wrappers/include/field_trial.h" namespace webrtc { @@ -33,11 +34,16 @@ std::array SetMaxErleBands(float max_erle_l, return max_erle; } +bool EnableMinErleDuringOnsets() { + return !field_trial::IsEnabled("WebRTC-Aec3MinErleDuringOnsetsKillSwitch"); +} + } // namespace SubbandErleEstimator::SubbandErleEstimator(const EchoCanceller3Config& config) : min_erle_(config.erle.min), - max_erle_(SetMaxErleBands(config.erle.max_l, config.erle.max_h)) { + max_erle_(SetMaxErleBands(config.erle.max_l, config.erle.max_h)), + use_min_erle_during_onsets_(EnableMinErleDuringOnsets()) { Reset(); } @@ -95,10 +101,12 @@ void SubbandErleEstimator::UpdateBands(bool onset_detection) { if (is_erle_updated[k] && !accum_spectra_.low_render_energy_[k]) { if (coming_onset_[k]) { coming_onset_[k] = false; - float alpha = new_erle[k] < erle_onsets_[k] ? 0.3f : 0.15f; - erle_onsets_[k] = rtc::SafeClamp( - erle_onsets_[k] + alpha * (new_erle[k] - erle_onsets_[k]), - min_erle_, max_erle_[k]); + if (!use_min_erle_during_onsets_) { + float alpha = new_erle[k] < erle_onsets_[k] ? 0.3f : 0.15f; + erle_onsets_[k] = rtc::SafeClamp( + erle_onsets_[k] + alpha * (new_erle[k] - erle_onsets_[k]), + min_erle_, max_erle_[k]); + } } hold_counters_[k] = kBlocksForOnsetDetection; } diff --git a/modules/audio_processing/aec3/subband_erle_estimator.h b/modules/audio_processing/aec3/subband_erle_estimator.h index c1ad4b56f4..903c6295df 100644 --- a/modules/audio_processing/aec3/subband_erle_estimator.h +++ b/modules/audio_processing/aec3/subband_erle_estimator.h @@ -66,6 +66,7 @@ class SubbandErleEstimator { const float min_erle_; const std::array max_erle_; + const bool use_min_erle_during_onsets_; AccumulatedSpectra accum_spectra_; std::array erle_; std::array erle_onsets_; diff --git a/test/fuzzers/audio_processing_configs_fuzzer.cc b/test/fuzzers/audio_processing_configs_fuzzer.cc index 333144f47f..efaeb135a4 100644 --- a/test/fuzzers/audio_processing_configs_fuzzer.cc +++ b/test/fuzzers/audio_processing_configs_fuzzer.cc @@ -28,6 +28,7 @@ namespace { const std::string kFieldTrialNames[] = { "WebRTC-Audio-Agc2ForceExtraSaturationMargin", "WebRTC-Audio-Agc2ForceInitialSaturationMargin", + "WebRTC-Aec3MinErleDuringOnsetsKillSwitch", }; std::unique_ptr CreateApm(test::FuzzDataHelper* fuzz_data,