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

Unified Diff: webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h

Issue 2419563003: Add algorithm for Residual Echo Detector. (Closed)
Patch Set: Added better handling of clock drift on render side. Created 4 years, 2 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/echo_detector/sliding_window_minimum.h
diff --git a/webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h b/webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h
new file mode 100644
index 0000000000000000000000000000000000000000..d114a64e6121f3176eefa0e90fab3fed1414d389
--- /dev/null
+++ b/webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 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 WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_SLIDING_WINDOW_MINIMUM_H_
+#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_SLIDING_WINDOW_MINIMUM_H_
+
+#include <vector>
+
+namespace webrtc {
+
+// This class determines the minimum value of the last entered N values in an
+// efficient way: amortized O(1). The implementation is based on the method
+// described in http://stackoverflow.com/a/17249084.
+class SlidingWindowMinimum {
+ public:
+ explicit SlidingWindowMinimum(size_t window_size);
+ SlidingWindowMinimum(SlidingWindowMinimum&& other);
+ ~SlidingWindowMinimum();
+
+ // Add a new value.
+ void AddValue(size_t new_value);
+ // Get the minimum of the previous N added values.
+ size_t GetMinimum();
+
+ private:
+ // This is a circular buffer containing the previous values.
+ std::vector<size_t> values_;
+ // This is a circular buffer containing the previous "RL" values.
+ std::vector<size_t> right_to_left_min_;
+ // For storing the previous LR value.
+ size_t left_to_right_min_;
+ // Counter for tracking how far into the window we are.
+ size_t window_index_ = 0;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_SLIDING_WINDOW_MINIMUM_H_

Powered by Google App Engine
This is Rietveld 408576698