Skip to content

Commit

Permalink
AEC3: Using a more conservative frequency response representation of …
Browse files Browse the repository at this point in the history
…the tails.

(cherry picked from commit 5eb5bb5)

Bug: chromium:1249867
Change-Id: Ic469f6226fe079c306cec6f941eeb70d6d9094f3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231682
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Original-Commit-Position: refs/heads/main@{#34966}
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232322
Cr-Commit-Position: refs/branch-heads/4638@{#1}
Cr-Branched-From: fb50179-refs/heads/main@{#34960}
  • Loading branch information
Jesús de Vicente Peña authored and WebRTC LUCI CQ committed Sep 17, 2021
1 parent fb50179 commit 494c787
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/audio/echo_canceller3_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct RTC_EXPORT EchoCanceller3Config {
bool echo_can_saturate = true;
bool bounded_erl = false;
bool erle_onset_compensation_in_dominant_nearend = false;
bool use_conservative_tail_frequency_response = false;
} ep_strength;

struct EchoAudibility {
Expand Down
6 changes: 6 additions & 0 deletions api/audio/echo_canceller3_config_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ void Aec3ConfigFromJsonString(absl::string_view json_string,
ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
ReadParam(section, "erle_onset_compensation_in_dominant_nearend",
&cfg.ep_strength.erle_onset_compensation_in_dominant_nearend);
ReadParam(section, "use_conservative_tail_frequency_response",
&cfg.ep_strength.use_conservative_tail_frequency_response);
}

if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
Expand Down Expand Up @@ -568,6 +570,10 @@ std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
<< (config.ep_strength.bounded_erl ? "true" : "false") << ",";
ost << "\"erle_onset_compensation_in_dominant_nearend\": "
<< (config.ep_strength.erle_onset_compensation_in_dominant_nearend
? "true"
: "false") << ",";
ost << "\"use_conservative_tail_frequency_response\": "
<< (config.ep_strength.use_conservative_tail_frequency_response
? "true"
: "false");
ost << "},";
Expand Down
4 changes: 4 additions & 0 deletions modules/audio_processing/aec3/echo_canceller3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ EchoCanceller3Config AdjustConfig(const EchoCanceller3Config& config) {
static_cast<float>(nearend_reverb_nearend_len.Get());
}

if (field_trial::IsEnabled("WebRTC-Aec3ConservativeTailFreqResponse")) {
adjusted_cfg.ep_strength.use_conservative_tail_frequency_response = true;
}

if (field_trial::IsEnabled("WebRTC-Aec3ShortHeadroomKillSwitch")) {
// Two blocks headroom.
adjusted_cfg.delay.delay_headroom_samples = kBlockSize * 2;
Expand Down
14 changes: 12 additions & 2 deletions modules/audio_processing/aec3/reverb_frequency_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ float AverageDecayWithinFilter(

} // namespace

ReverbFrequencyResponse::ReverbFrequencyResponse() {
tail_response_.fill(0.f);
ReverbFrequencyResponse::ReverbFrequencyResponse(
bool use_conservative_tail_frequency_response)
: use_conservative_tail_frequency_response_(
use_conservative_tail_frequency_response) {
tail_response_.fill(0.0f);
}

ReverbFrequencyResponse::~ReverbFrequencyResponse() = default;

void ReverbFrequencyResponse::Update(
Expand Down Expand Up @@ -88,6 +92,12 @@ void ReverbFrequencyResponse::Update(
tail_response_[k] = freq_resp_direct_path[k] * average_decay_;
}

if (use_conservative_tail_frequency_response_) {
for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
tail_response_[k] = std::max(freq_resp_tail[k], tail_response_[k]);
}
}

for (size_t k = 1; k < kFftLengthBy2; ++k) {
const float avg_neighbour =
0.5f * (tail_response_[k - 1] + tail_response_[k + 1]);
Expand Down
4 changes: 3 additions & 1 deletion modules/audio_processing/aec3/reverb_frequency_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace webrtc {
// Class for updating the frequency response for the reverb.
class ReverbFrequencyResponse {
public:
ReverbFrequencyResponse();
explicit ReverbFrequencyResponse(
bool use_conservative_tail_frequency_response);
~ReverbFrequencyResponse();

// Updates the frequency response estimate of the reverb.
Expand All @@ -44,6 +45,7 @@ class ReverbFrequencyResponse {
int filter_delay_blocks,
float linear_filter_quality);

const bool use_conservative_tail_frequency_response_;
float average_decay_ = 0.f;
std::array<float, kFftLengthBy2Plus1> tail_response_;
};
Expand Down
5 changes: 4 additions & 1 deletion modules/audio_processing/aec3/reverb_model_estimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ namespace webrtc {
ReverbModelEstimator::ReverbModelEstimator(const EchoCanceller3Config& config,
size_t num_capture_channels)
: reverb_decay_estimators_(num_capture_channels),
reverb_frequency_responses_(num_capture_channels) {
reverb_frequency_responses_(
num_capture_channels,
ReverbFrequencyResponse(
config.ep_strength.use_conservative_tail_frequency_response)) {
for (size_t ch = 0; ch < reverb_decay_estimators_.size(); ++ch) {
reverb_decay_estimators_[ch] =
std::make_unique<ReverbDecayEstimator>(config);
Expand Down

0 comments on commit 494c787

Please sign in to comment.