Adding parametrization of the AEC3 howling mitigation behavior

Bug: webrtc:8671,b/145243047
Change-Id: If5bcbb66b72278b901a990cb9d6e11e42c9ac592
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160781
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29930}
This commit is contained in:
Per Åhgren 2019-11-27 08:13:24 +01:00 committed by Commit Bot
parent 98e745b302
commit 17e4c58318
4 changed files with 26 additions and 4 deletions

View File

@ -234,6 +234,11 @@ bool EchoCanceller3Config::Validate(EchoCanceller3Config* config) {
1000000.f);
res = res & Limit(&c->suppressor.high_bands_suppression.max_gain_during_echo,
0.f, 1.f);
res = res & Limit(&c->suppressor.high_bands_suppression
.anti_howling_activation_threshold,
0.f, 32768.f * 32768.f);
res = res & Limit(&c->suppressor.high_bands_suppression.anti_howling_gain,
0.f, 1.f);
res = res & Limit(&c->suppressor.floor_first_increase, 0.f, 1000000.f);

View File

@ -197,6 +197,8 @@ struct RTC_EXPORT EchoCanceller3Config {
struct HighBandsSuppression {
float enr_threshold = 1.f;
float max_gain_during_echo = 1.f;
float anti_howling_activation_threshold = 25.f;
float anti_howling_gain = 0.01f;
} high_bands_suppression;
float floor_first_increase = 0.00001f;

View File

@ -349,6 +349,11 @@ void Aec3ConfigFromJsonString(absl::string_view json_string,
&cfg.suppressor.high_bands_suppression.enr_threshold);
ReadParam(subsection, "max_gain_during_echo",
&cfg.suppressor.high_bands_suppression.max_gain_during_echo);
ReadParam(subsection, "anti_howling_activation_threshold",
&cfg.suppressor.high_bands_suppression
.anti_howling_activation_threshold);
ReadParam(subsection, "anti_howling_gain",
&cfg.suppressor.high_bands_suppression.anti_howling_gain);
}
ReadParam(section, "floor_first_increase",
@ -602,7 +607,13 @@ std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
ost << "\"enr_threshold\": "
<< config.suppressor.high_bands_suppression.enr_threshold << ",";
ost << "\"max_gain_during_echo\": "
<< config.suppressor.high_bands_suppression.max_gain_during_echo;
<< config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
ost << "\"anti_howling_activation_threshold\": "
<< config.suppressor.high_bands_suppression
.anti_howling_activation_threshold
<< ",";
ost << "\"anti_howling_gain\": "
<< config.suppressor.high_bands_suppression.anti_howling_gain;
ost << "},";
ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase;
ost << "}";

View File

@ -151,14 +151,18 @@ float SuppressionGain::UpperBandsGain(
// or if the power in upper frequencies is low, do not bound the gain in the
// upper bands.
float anti_howling_gain;
constexpr float kThreshold = kBlockSize * 10.f * 10.f / 4.f;
if (high_band_energy < std::max(low_band_energy, kThreshold)) {
const float activation_threshold =
kBlockSize * config_.suppressor.high_bands_suppression
.anti_howling_activation_threshold;
if (high_band_energy < std::max(low_band_energy, activation_threshold)) {
anti_howling_gain = 1.f;
} else {
// In all other cases, bound the gain for upper frequencies.
RTC_DCHECK_LE(low_band_energy, high_band_energy);
RTC_DCHECK_NE(0.f, high_band_energy);
anti_howling_gain = 0.01f * sqrtf(low_band_energy / high_band_energy);
anti_howling_gain =
config_.suppressor.high_bands_suppression.anti_howling_gain *
sqrtf(low_band_energy / high_band_energy);
}
float gain_bound = 1.f;