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

Side by Side Diff: webrtc/modules/audio_processing/echo_detector/echo_detector.h

Issue 2419563003: Add algorithm for Residual Echo Detector. (Closed)
Patch Set: Added comments. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
13 13
14 #include <stddef.h> 14 #include <vector>
15
15 #include "webrtc/base/array_view.h" 16 #include "webrtc/base/array_view.h"
17 #include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h"
18 #include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator. h"
19 #include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_es timator.h"
16 20
17 namespace webrtc { 21 namespace webrtc {
18 22
19 class EchoDetector { 23 class EchoDetector {
20 public: 24 public:
21 EchoDetector() {} 25 EchoDetector();
22 ~EchoDetector() {} 26 ~EchoDetector();
23 27
24 void BufferFarend(const rtc::ArrayView<const float>& farend); 28 void BufferRender(rtc::ArrayView<const float> render);
25 29
26 void Process(const rtc::ArrayView<const float>& nearend); 30 void Process(rtc::ArrayView<const float> capture);
27 31
28 void Initialize(int sample_rate_hz); 32 void Initialize();
33
34 float echo_likelihood() const { return echo_likelihood_; }
35
36 private:
37 // Keep track if the |Process| function has been previously called.
38 bool first_process_call_ = true;
39 // Buffer for storing the power of incoming farend buffers. This is needed for
40 // cases where calls to BufferFarend and Process are jittery.
41 CircularBuffer render_buffer_;
42 // Count how long ago it was that the size of |render_buffer_| was zero. This
43 // value is also reset to zero when clock drift is detected and a value from
44 // the renderbuffer is discarded, even though the buffer is not actually zero
45 // at that point. This is done to avoid repeatedly removing elements in this
46 // situation.
47 size_t frames_since_zero_buffer_size_ = 0;
48
49 // Circular buffers containing delayed versions of the power, mean and
50 // standard deviation, for calculating the delayed covariance values.
51 std::vector<float> render_power_;
52 std::vector<float> render_power_mean_;
53 std::vector<float> render_power_std_dev_;
54 // Covariance estimates for different delay values.
55 std::vector<NormalizedCovarianceEstimator> covariances_;
56 // Index where next element should be inserted in all of the above circular
57 // buffers.
58 size_t next_insertion_index_ = 0;
59
60 MeanVarianceEstimator render_statistics_;
61 MeanVarianceEstimator capture_statistics_;
62 // Current echo likelihood.
63 float echo_likelihood_ = 0.f;
29 }; 64 };
30 65
31 } // namespace webrtc 66 } // namespace webrtc
32 67
33 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ 68 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698