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

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 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 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"
20 #include "webrtc/modules/audio_processing/echo_detector/sliding_window_minimum.h "
16 21
17 namespace webrtc { 22 namespace webrtc {
18 23
19 class EchoDetector { 24 class EchoDetector {
20 public: 25 public:
21 EchoDetector() {} 26 EchoDetector();
22 ~EchoDetector() {} 27 ~EchoDetector();
23 28
24 void BufferFarend(const rtc::ArrayView<const float>& farend); 29 void BufferRender(rtc::ArrayView<const float> render);
25 30
26 void Process(const rtc::ArrayView<const float>& nearend); 31 void Process(rtc::ArrayView<const float> nearend);
27 32
28 void Initialize(int sample_rate_hz); 33 void Initialize();
34
35 float echo_likelihood() const { return echo_likelihood_; }
36
37 private:
38 static constexpr size_t kLookbackFrames = 650;
39 // TODO(ivoc): Verify the size of this buffer.
40 static constexpr size_t kRenderBufferSize = 30;
41
42 // Buffer for storing the power of incoming farend buffers. This is needed for
43 // cases where calls to BufferFarend and Process are jittery.
44 CircularBuffer render_buffer_ = CircularBuffer(kRenderBufferSize);
45 // Keep track of the minimum of the size of the render buffer during the
46 // previous kRenderBufferSize updates, if this is larger than 0, it indicates
47 // clock drift and should be corrected.
48 SlidingWindowMinimum minimum_render_buffer_size_ =
49 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.
50
51 // Circular buffers containing delayed versions of the power, mean and
52 // standard deviation, for calculating the delayed covariance values.
53 std::vector<float> render_power_ = std::vector<float>(kLookbackFrames);
54 std::vector<float> render_power_mean_ = std::vector<float>(kLookbackFrames);
55 std::vector<float> render_power_std_dev_ =
56 std::vector<float>(kLookbackFrames);
57 // Covariance estimates for different delay values.
58 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.
59 std::vector<NormalizedCovarianceEstimator>(kLookbackFrames);
60 // Index where next element should be inserted in all of the above circular
61 // buffers.
62 size_t next_insertion_index_ = 0;
63
64 MeanVarianceEstimator render_variance_;
65 MeanVarianceEstimator capture_variance_;
66 // Current echo likelihood.
67 float echo_likelihood_ = 0.f;
29 }; 68 };
30 69
31 } // namespace webrtc 70 } // namespace webrtc
32 71
33 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ 72 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698