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

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

Issue 2974883002: Robustification of the AEC3 echo removal in the first part of the call (Closed)
Patch Set: Rebase Created 3 years, 5 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/aec_state.cc
diff --git a/webrtc/modules/audio_processing/aec3/aec_state.cc b/webrtc/modules/audio_processing/aec3/aec_state.cc
index aa389c870cfadb90d3c84034f953384fc4badfa6..ccb8639472c8f4f5c82867f79d71c300f4d5dce9 100644
--- a/webrtc/modules/audio_processing/aec3/aec_state.cc
+++ b/webrtc/modules/audio_processing/aec3/aec_state.cc
@@ -22,9 +22,6 @@
namespace webrtc {
namespace {
-constexpr size_t kEchoPathChangeConvergenceBlocks = 2 * kNumBlocksPerSecond;
-constexpr size_t kSaturationLeakageBlocks = 20;
-
// Computes delay of the adaptive filter.
rtc::Optional<size_t> EstimateFilterDelay(
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
@@ -163,15 +160,17 @@ void AecState::Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
const float max_sample = fabs(*std::max_element(
x.begin(), x.end(), [](float a, float b) { return a * a < b * b; }));
const bool saturated_echo =
- previous_max_sample_ * kFixedEchoPathGain > 1600 && SaturatedCapture();
+ previous_max_sample_ * 100 > 1600 && SaturatedCapture();
previous_max_sample_ = max_sample;
// Counts the blocks since saturation.
+ constexpr size_t kSaturationLeakageBlocks = 20;
blocks_since_last_saturation_ =
saturated_echo ? 0 : blocks_since_last_saturation_ + 1;
echo_saturation_ = blocks_since_last_saturation_ < kSaturationLeakageBlocks;
// Flag whether the linear filter estimate is usable.
+ constexpr size_t kEchoPathChangeConvergenceBlocks = 2 * kNumBlocksPerSecond;
usable_linear_estimate_ =
(!echo_saturation_) &&
(!render_received_ ||
@@ -181,10 +180,10 @@ void AecState::Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
// 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, flag that a
// headset is used.
- headset_detected_ =
- !external_delay_ && !filter_delay_ &&
- (!render_received_ ||
- blocks_with_filter_adaptation_ >= kEchoPathChangeConvergenceBlocks);
+ constexpr size_t kHeadSetDetectionBlocks = 5 * kNumBlocksPerSecond;
+ headset_detected_ = !external_delay_ && !filter_delay_ &&
+ (!render_received_ || blocks_with_filter_adaptation_ >=
+ kHeadSetDetectionBlocks);
// Update the room reverb estimate.
UpdateReverb(adaptive_filter_impulse_response);
« no previous file with comments | « webrtc/modules/audio_processing/aec3/aec3_common.h ('k') | webrtc/modules/audio_processing/aec3/residual_echo_estimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698