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

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: 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 3840ef960133e142c33a52cd294ff7e6748467f8..f857f12f389c920b7e527ee49ea50f5af35c785d 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>>&
@@ -157,15 +154,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_ ||
@@ -175,10 +174,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);
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698