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

Unified Diff: webrtc/modules/audio_processing/aec3/matched_filter.h

Issue 2644123002: Adding full initial version of delay estimation functionality in echo canceller 3 (Closed)
Patch Set: Rebase 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/matched_filter.h
diff --git a/webrtc/modules/audio_processing/aec3/matched_filter.h b/webrtc/modules/audio_processing/aec3/matched_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e09d4b97157ccfa64f6ccf8c3e6725507276755
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec3/matched_filter.h
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_H_
+#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_H_
+
+#include <array>
+#include <memory>
+#include <vector>
+
+#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/optional.h"
+#include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
+
+namespace webrtc {
+
+class ApmDataDumper;
+
+// Produces recursively updated cross-correlation estimates for several signal
+// shifts where the intra-shift spacing is uniform.
+class MatchedFilter {
+ public:
+ // Stores properties for the lag estimate corresponding to a particular signal
+ // shift.
+ struct LagEstimate {
+ LagEstimate() = default;
+ LagEstimate(float accuracy, bool reliable, size_t lag, bool updated)
+ : accuracy(accuracy), reliable(reliable), lag(lag), updated(updated) {}
+
+ float accuracy = 0.f;
+ bool reliable = false;
+ size_t lag = 0;
+ bool updated = false;
+ };
+
+ MatchedFilter(ApmDataDumper* data_dumper,
+ size_t window_size_sub_blocks,
+ int num_matched_filters,
+ size_t alignment_shift_sub_blocks);
+
+ ~MatchedFilter();
+
+ // Updates the correlation with the values in render and capture.
+ void Update(const std::array<float, kSubBlockSize>& render,
+ const std::array<float, kSubBlockSize>& capture);
+
+ // Returns the current lag estimates.
+ rtc::ArrayView<const MatchedFilter::LagEstimate> GetLagEstimates() const {
+ return lag_estimates_;
+ }
+
+ // Returns the number of lag estimates produced using the shifted signals.
+ size_t NumLagEstimates() const { return filters_.size(); }
+
+ private:
+ // Provides buffer with a related index.
+ struct IndexedBuffer {
+ explicit IndexedBuffer(size_t size);
+ ~IndexedBuffer();
+
+ std::vector<float> data;
+ int index = 0;
+ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedBuffer);
+ };
+
+ ApmDataDumper* const data_dumper_;
+ const size_t filter_intra_lag_shift_;
+ std::vector<std::vector<float>> filters_;
+ std::vector<LagEstimate> lag_estimates_;
+ IndexedBuffer x_buffer_;
+
+ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MatchedFilter);
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_H_
« no previous file with comments | « webrtc/modules/audio_processing/aec3/echo_remover.cc ('k') | webrtc/modules/audio_processing/aec3/matched_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698