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

Unified Diff: webrtc/modules/audio_processing/echo_detector/echo_detector.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/echo_detector.h
diff --git a/webrtc/modules/audio_processing/echo_detector/echo_detector.h b/webrtc/modules/audio_processing/echo_detector/echo_detector.h
index d9c8bd5d18799c23d277c3883126759a3566f20d..1016596f3f7c06d48ed981761381026bb1161bf3 100644
--- a/webrtc/modules/audio_processing/echo_detector/echo_detector.h
+++ b/webrtc/modules/audio_processing/echo_detector/echo_detector.h
@@ -11,21 +11,60 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
-#include <stddef.h>
+#include <vector>
+
#include "webrtc/base/array_view.h"
+#include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h"
+#include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.h"
+#include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_estimator.h"
+#include "webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h"
namespace webrtc {
class EchoDetector {
public:
- EchoDetector() {}
- ~EchoDetector() {}
+ EchoDetector();
+ ~EchoDetector();
+
+ void BufferRender(rtc::ArrayView<const float> render);
+
+ void Process(rtc::ArrayView<const float> nearend);
+
+ void Initialize();
+
+ float echo_likelihood() const { return echo_likelihood_; }
+
+ private:
+ static constexpr size_t kLookbackFrames = 650;
+ // TODO(ivoc): Verify the size of this buffer.
+ static constexpr size_t kRenderBufferSize = 30;
- void BufferFarend(const rtc::ArrayView<const float>& farend);
+ // Buffer for storing the power of incoming farend buffers. This is needed for
+ // cases where calls to BufferFarend and Process are jittery.
+ CircularBuffer render_buffer_ = CircularBuffer(kRenderBufferSize);
+ // Keep track of the minimum of the size of the render buffer during the
+ // previous kRenderBufferSize updates, if this is larger than 0, it indicates
+ // clock drift and should be corrected.
+ SlidingWindowMinimum minimum_render_buffer_size_ =
+ SlidingWindowMinimum(kRenderBufferSize);
peah-webrtc 2016/10/19 14:45:26 Call constructor immediately to avoid the copy.
ivoc 2016/10/20 14:04:36 Done.
- void Process(const rtc::ArrayView<const float>& nearend);
+ // Circular buffers containing delayed versions of the power, mean and
+ // standard deviation, for calculating the delayed covariance values.
+ std::vector<float> render_power_ = std::vector<float>(kLookbackFrames);
+ std::vector<float> render_power_mean_ = std::vector<float>(kLookbackFrames);
+ std::vector<float> render_power_std_dev_ =
+ std::vector<float>(kLookbackFrames);
+ // Covariance estimates for different delay values.
+ std::vector<NormalizedCovarianceEstimator> covariance_ =
peah-webrtc 2016/10/19 14:45:26 Since the vector store several covariance estimate
ivoc 2016/10/20 14:04:36 Done.
+ std::vector<NormalizedCovarianceEstimator>(kLookbackFrames);
+ // Index where next element should be inserted in all of the above circular
+ // buffers.
+ size_t next_insertion_index_ = 0;
- void Initialize(int sample_rate_hz);
+ MeanVarianceEstimator render_variance_;
+ MeanVarianceEstimator capture_variance_;
+ // Current echo likelihood.
+ float echo_likelihood_ = 0.f;
};
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698