From 46ac470d92afc21d64e3188f8256b000bd3e28ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Mon, 13 May 2019 08:41:18 +0200 Subject: [PATCH] AEC3: Remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:8671 Change-Id: Ia54cc2eb7f7235cd348a1af216beb3981fac9813 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/136580 Reviewed-by: Gustaf Ullberg Commit-Queue: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#27928} --- modules/audio_processing/aec3/BUILD.gn | 3 - .../audio_processing/aec3/skew_estimator.cc | 45 ----- .../audio_processing/aec3/skew_estimator.h | 51 ------ .../aec3/skew_estimator_unittest.cc | 157 ------------------ 4 files changed, 256 deletions(-) delete mode 100644 modules/audio_processing/aec3/skew_estimator.cc delete mode 100644 modules/audio_processing/aec3/skew_estimator.h delete mode 100644 modules/audio_processing/aec3/skew_estimator_unittest.cc diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index d41fee6531..1f69eb7722 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -104,8 +104,6 @@ rtc_static_library("aec3") { "shadow_filter_update_gain.h", "signal_dependent_erle_estimator.cc", "signal_dependent_erle_estimator.h", - "skew_estimator.cc", - "skew_estimator.h", "stationarity_estimator.cc", "stationarity_estimator.h", "subband_erle_estimator.cc", @@ -222,7 +220,6 @@ if (rtc_include_tests) { "reverb_model_estimator_unittest.cc", "shadow_filter_update_gain_unittest.cc", "signal_dependent_erle_estimator_unittest.cc", - "skew_estimator_unittest.cc", "subtractor_unittest.cc", "suppression_filter_unittest.cc", "suppression_gain_unittest.cc", diff --git a/modules/audio_processing/aec3/skew_estimator.cc b/modules/audio_processing/aec3/skew_estimator.cc deleted file mode 100644 index a2099fcd01..0000000000 --- a/modules/audio_processing/aec3/skew_estimator.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "modules/audio_processing/aec3/skew_estimator.h" - -#include - -namespace webrtc { - -SkewEstimator::SkewEstimator(size_t skew_history_size_log2) - : skew_history_size_log2_(static_cast(skew_history_size_log2)), - skew_history_(1ULL << skew_history_size_log2_, 0) {} - -SkewEstimator::~SkewEstimator() = default; - -void SkewEstimator::Reset() { - skew_ = 0; - skew_sum_ = 0; - next_index_ = 0; - sufficient_skew_stored_ = false; - std::fill(skew_history_.begin(), skew_history_.end(), 0); -} - -absl::optional SkewEstimator::GetSkewFromCapture() { - --skew_; - - skew_sum_ += skew_ - skew_history_[next_index_]; - skew_history_[next_index_] = skew_; - if (++next_index_ == skew_history_.size()) { - next_index_ = 0; - sufficient_skew_stored_ = true; - } - - const int bias = static_cast(skew_history_.size()) >> 1; - const int average = (skew_sum_ + bias) >> skew_history_size_log2_; - return sufficient_skew_stored_ ? absl::optional(average) : absl::nullopt; -} - -} // namespace webrtc diff --git a/modules/audio_processing/aec3/skew_estimator.h b/modules/audio_processing/aec3/skew_estimator.h deleted file mode 100644 index 8a457cb3d7..0000000000 --- a/modules/audio_processing/aec3/skew_estimator.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_PROCESSING_AEC3_SKEW_ESTIMATOR_H_ -#define MODULES_AUDIO_PROCESSING_AEC3_SKEW_ESTIMATOR_H_ - -#include -#include - -#include "absl/types/optional.h" -#include "rtc_base/constructor_magic.h" - -namespace webrtc { - -// Estimator of API call skew between render and capture. -class SkewEstimator { - public: - explicit SkewEstimator(size_t skew_history_size_log2); - ~SkewEstimator(); - - // Resets the estimation. - void Reset(); - - // Updates the skew data for a render call. - void LogRenderCall() { ++skew_; } - - // Updates and computes the skew at a capture call. Returns an optional which - // is non-null if a reliable skew has been found. - absl::optional GetSkewFromCapture(); - - private: - const int skew_history_size_log2_; - std::vector skew_history_; - int skew_ = 0; - int skew_sum_ = 0; - size_t next_index_ = 0; - bool sufficient_skew_stored_ = false; - - RTC_DISALLOW_COPY_AND_ASSIGN(SkewEstimator); -}; - -} // namespace webrtc - -#endif // MODULES_AUDIO_PROCESSING_AEC3_SKEW_ESTIMATOR_H_ diff --git a/modules/audio_processing/aec3/skew_estimator_unittest.cc b/modules/audio_processing/aec3/skew_estimator_unittest.cc deleted file mode 100644 index 3e8c13e23c..0000000000 --- a/modules/audio_processing/aec3/skew_estimator_unittest.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_processing/aec3/skew_estimator.h" - -#include "test/gtest.h" - -namespace webrtc { -namespace aec3 { - -// Tests that the skew ends up as it should after a skew change. -TEST(SkewEstimator, SkewChangeAdaptation) { - constexpr int kNumSkewsLog2 = 7; - constexpr int kNumSkews = 1 << kNumSkewsLog2; - - SkewEstimator estimator(kNumSkewsLog2); - - for (int k = 0; k < kNumSkews - 1; ++k) { - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_FALSE(skew); - } - - estimator.LogRenderCall(); - - absl::optional skew; - for (int k = 0; k < kNumSkews; ++k) { - estimator.LogRenderCall(); - skew = estimator.GetSkewFromCapture(); - EXPECT_TRUE(skew); - } - EXPECT_EQ(1, *skew); - - estimator.LogRenderCall(); - - for (int k = 0; k < kNumSkews; ++k) { - estimator.LogRenderCall(); - skew = estimator.GetSkewFromCapture(); - EXPECT_TRUE(skew); - } - EXPECT_EQ(2, *skew); -} - -// Tests that the skew ends up as it should for a surplus of render calls. -TEST(SkewEstimator, SkewForSurplusRender) { - constexpr int kNumSkewsLog2 = 7; - constexpr int kNumSkews = 1 << kNumSkewsLog2; - - SkewEstimator estimator(kNumSkewsLog2); - - for (int k = 0; k < kNumSkews - 1; ++k) { - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_FALSE(skew); - } - - estimator.LogRenderCall(); - - absl::optional skew; - for (int k = 0; k < kNumSkews; ++k) { - estimator.LogRenderCall(); - skew = estimator.GetSkewFromCapture(); - EXPECT_TRUE(skew); - } - EXPECT_EQ(1, *skew); -} - -// Tests that the skew ends up as it should for a surplus of capture calls. -TEST(SkewEstimator, SkewForSurplusCapture) { - constexpr int kNumSkewsLog2 = 7; - constexpr int kNumSkews = 1 << kNumSkewsLog2; - - SkewEstimator estimator(kNumSkewsLog2); - - for (int k = 0; k < kNumSkews - 1; ++k) { - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_FALSE(skew); - } - - absl::optional skew; - skew = estimator.GetSkewFromCapture(); - - for (int k = 0; k < kNumSkews; ++k) { - estimator.LogRenderCall(); - skew = estimator.GetSkewFromCapture(); - EXPECT_TRUE(skew); - } - EXPECT_EQ(-1, *skew); -} - -// Tests that the skew estimator returns a null optional when it should. -TEST(SkewEstimator, NullEstimate) { - constexpr int kNumSkewsLog2 = 4; - constexpr int kNumSkews = 1 << kNumSkewsLog2; - - SkewEstimator estimator(kNumSkewsLog2); - - for (int k = 0; k < kNumSkews - 1; ++k) { - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_FALSE(skew); - } - - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_TRUE(skew); - - estimator.Reset(); - for (int k = 0; k < kNumSkews - 1; ++k) { - estimator.LogRenderCall(); - auto skew = estimator.GetSkewFromCapture(); - EXPECT_FALSE(skew); - } -} - -// Tests that the skew estimator properly rounds the average skew. -TEST(SkewEstimator, SkewRounding) { - constexpr int kNumSkewsLog2 = 4; - constexpr int kNumSkews = 1 << kNumSkewsLog2; - - SkewEstimator estimator(kNumSkewsLog2); - - absl::optional skew; - for (int k = 0; k < kNumSkews; ++k) { - if (k == kNumSkews - 1) { - // Reverse call order once. - skew = estimator.GetSkewFromCapture(); - estimator.LogRenderCall(); - } else { - // Normal call order. - estimator.LogRenderCall(); - skew = estimator.GetSkewFromCapture(); - } - } - EXPECT_EQ(*skew, 0); - - estimator.Reset(); - for (int k = 0; k < kNumSkews; ++k) { - estimator.LogRenderCall(); - estimator.LogRenderCall(); - estimator.LogRenderCall(); - estimator.GetSkewFromCapture(); - estimator.GetSkewFromCapture(); - skew = estimator.GetSkewFromCapture(); - } - EXPECT_EQ(*skew, 1); -} -} // namespace aec3 -} // namespace webrtc