Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc

Issue 2717353002: Further tuning for AEC3 for initial echo suppression and handling of echo path changes (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
diff --git a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
index 38d5beb5fba0c4d5873bfe2ccc7db91191f2ad8f..18a07b2f5a158eb1b649e3f549e5d4da6fd93d2b 100644
--- a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
+++ b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
@@ -20,15 +20,16 @@ namespace {
constexpr float kSaturationLeakageFactor = 10.f;
constexpr size_t kSaturationLeakageBlocks = 10;
+constexpr size_t kEchoPathChangeConvergenceBlocks = 3 * 250;
// Estimates the residual echo power when there is no detection correlation
// between the render and capture signals.
void InfiniteErlPowerEstimate(
- size_t active_render_counter,
+ size_t active_render_blocks,
size_t blocks_since_last_saturation,
const std::array<float, kFftLengthBy2Plus1>& S2_fallback,
std::array<float, kFftLengthBy2Plus1>* R2) {
- if (active_render_counter > 5 * 250) {
+ if (active_render_blocks > 5 * 250) {
// After an amount of active render samples for which an echo should have
// been detected in the capture signal if the ERL was not infinite, set the
// residual echo to 0.
@@ -62,6 +63,7 @@ void GainBasedPowerEstimate(
size_t external_delay,
const FftBuffer& X_buffer,
size_t blocks_since_last_saturation,
+ size_t active_render_blocks,
const std::array<bool, kFftLengthBy2Plus1>& bands_with_reliable_filter,
const std::array<float, kFftLengthBy2Plus1>& echo_path_gain,
const std::array<float, kFftLengthBy2Plus1>& S2_fallback,
@@ -71,10 +73,17 @@ void GainBasedPowerEstimate(
// Base the residual echo power on gain of the linear echo path estimate if
// that is reliable, otherwise use the fallback echo path estimate. Add a
// leakage factor when there is saturation.
- for (size_t k = 0; k < R2->size(); ++k) {
- (*R2)[k] = bands_with_reliable_filter[k] ? echo_path_gain[k] * X2[k]
- : S2_fallback[k];
+ if (active_render_blocks > kEchoPathChangeConvergenceBlocks) {
peah-webrtc 2017/02/27 14:26:03 The filter-based echo path gain cannot be used unt
+ for (size_t k = 0; k < R2->size(); ++k) {
+ (*R2)[k] = bands_with_reliable_filter[k] ? echo_path_gain[k] * X2[k]
+ : S2_fallback[k];
+ }
+ } else {
+ for (size_t k = 0; k < R2->size(); ++k) {
+ (*R2)[k] = S2_fallback[k];
+ }
}
+
if (blocks_since_last_saturation < kSaturationLeakageBlocks) {
std::for_each(R2->begin(), R2->end(),
[](float& a) { a *= kSaturationLeakageFactor; });
@@ -145,7 +154,7 @@ void ErleBasedPowerEstimate(
} // namespace
ResidualEchoEstimator::ResidualEchoEstimator() {
- echo_path_gain_.fill(0.f);
+ echo_path_gain_.fill(100.f);
peah-webrtc 2017/02/27 14:26:03 Not important, but more appropriate.
}
ResidualEchoEstimator::~ResidualEchoEstimator() = default;
@@ -169,6 +178,10 @@ void ResidualEchoEstimator::Estimate(
if (linear_filter_based_delay) {
std::copy(H2[*linear_filter_based_delay].begin(),
H2[*linear_filter_based_delay].end(), echo_path_gain_.begin());
+ constexpr float kEchoPathGainHeadroom = 10.f;
+ std::for_each(
+ echo_path_gain_.begin(), echo_path_gain_.end(),
+ [kEchoPathGainHeadroom](float& a) { a *= kEchoPathGainHeadroom; });
peah-webrtc 2017/02/27 14:26:03 Since the filter-based frequency response of the e
}
// Counts the blocks since saturation.
@@ -178,11 +191,6 @@ void ResidualEchoEstimator::Estimate(
++blocks_since_last_saturation_;
}
- // Counts the number of active render blocks that are in a row.
peah-webrtc 2017/02/27 14:26:03 This counter was not correctly done.
- if (aec_state.ActiveRender()) {
- ++active_render_counter_;
- }
-
const auto& bands_with_reliable_filter = aec_state.BandsWithReliableFilter();
if (aec_state.UsableLinearEstimate()) {
@@ -200,16 +208,25 @@ void ResidualEchoEstimator::Estimate(
RTC_DCHECK(aec_state.ExternalDelay());
GainBasedPowerEstimate(
*aec_state.ExternalDelay(), X_buffer, blocks_since_last_saturation_,
- bands_with_reliable_filter, echo_path_gain_, S2_fallback, R2);
+ aec_state.ActiveRenderBlocks(), bands_with_reliable_filter,
+ echo_path_gain_, S2_fallback, R2);
} else if (aec_state.EchoLeakageDetected()) {
// Residual echo power when an external residual echo detection algorithm
// has deemed the echo canceller to leak echoes.
HalfDuplexPowerEstimate(aec_state.ActiveRender(), Y2, R2);
} else {
// Residual echo power when none of the other cases are fulfilled.
- InfiniteErlPowerEstimate(active_render_counter_,
+ InfiniteErlPowerEstimate(aec_state.ActiveRenderBlocks(),
blocks_since_last_saturation_, S2_fallback, R2);
}
}
+void ResidualEchoEstimator::HandleEchoPathChange(
+ const EchoPathVariability& echo_path_variability) {
+ if (echo_path_variability.AudioPathChanged()) {
+ blocks_since_last_saturation_ = 0;
+ echo_path_gain_.fill(100.f);
+ }
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698