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

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

Issue 2419563003: Add algorithm for Residual Echo Detector. (Closed)
Patch Set: Per's comments. 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 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 static constexpr size_t kLookbackFrames = 650;
38 // TODO(ivoc): Verify the size of this buffer.
peah-webrtc 2016/10/20 15:08:24 Do these two constants need to be in the header fi
ivoc 2016/10/21 12:21:15 Not anymore, I will move them to the cc file.
39 static constexpr size_t kRenderBufferSize = 30;
40
41 // Keep track if this is the first call to Process().
42 bool first_process_call_ = true;
43
44 // Buffer for storing the power of incoming farend buffers. This is needed for
45 // cases where calls to BufferFarend and Process are jittery.
46 CircularBuffer render_buffer_;
47 // Count how long ago it was that the size of |render_buffer_| was zero.
48 size_t render_buffer_zero_ = 0;
peah-webrtc 2016/10/20 15:08:24 I think this variable would benefit of being more
ivoc 2016/10/21 12:21:15 I changed it to frames_since_zero_buffer_size_.
49
50 // Circular buffers containing delayed versions of the power, mean and
51 // standard deviation, for calculating the delayed covariance values.
52 std::vector<float> render_power_;
53 std::vector<float> render_power_mean_;
54 std::vector<float> render_power_std_dev_;
55 // Covariance estimates for different delay values.
56 std::vector<NormalizedCovarianceEstimator> covariances_;
57 // Index where next element should be inserted in all of the above circular
58 // buffers.
59 size_t next_insertion_index_ = 0;
60
61 MeanVarianceEstimator render_statistics_;
62 MeanVarianceEstimator capture_statistics_;
63 // Current echo likelihood.
64 float echo_likelihood_ = 0.f;
29 }; 65 };
30 66
31 } // namespace webrtc 67 } // namespace webrtc
32 68
33 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ 69 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698