OLD | NEW |
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_RESIDUAL_ECHO_DETECTOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_RESIDUAL_ECHO_DETECTOR_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_RESIDUAL_ECHO_DETECTOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_RESIDUAL_ECHO_DETECTOR_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/base/array_view.h" | 16 #include "webrtc/base/array_view.h" |
17 #include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h" | 17 #include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h" |
18 #include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.
h" | 18 #include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.
h" |
| 19 #include "webrtc/modules/audio_processing/echo_detector/moving_max.h" |
19 #include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_es
timator.h" | 20 #include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_es
timator.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 class AudioBuffer; | 24 class AudioBuffer; |
24 class EchoDetector; | 25 class EchoDetector; |
25 | 26 |
26 class ResidualEchoDetector { | 27 class ResidualEchoDetector { |
27 public: | 28 public: |
28 ResidualEchoDetector(); | 29 ResidualEchoDetector(); |
(...skipping 10 matching lines...) Expand all Loading... |
39 | 40 |
40 // This function is for testing purposes only. | 41 // This function is for testing purposes only. |
41 void SetReliabilityForTest(float value) { reliability_ = value; } | 42 void SetReliabilityForTest(float value) { reliability_ = value; } |
42 | 43 |
43 static void PackRenderAudioBuffer(AudioBuffer* audio, | 44 static void PackRenderAudioBuffer(AudioBuffer* audio, |
44 std::vector<float>* packed_buffer); | 45 std::vector<float>* packed_buffer); |
45 | 46 |
46 // This function should be called while holding the capture lock. | 47 // This function should be called while holding the capture lock. |
47 float echo_likelihood() const { return echo_likelihood_; } | 48 float echo_likelihood() const { return echo_likelihood_; } |
48 | 49 |
| 50 float echo_likelihood_recent_max() const { |
| 51 return recent_likelihood_max_.max(); |
| 52 } |
| 53 |
49 private: | 54 private: |
50 // Keep track if the |Process| function has been previously called. | 55 // Keep track if the |Process| function has been previously called. |
51 bool first_process_call_ = true; | 56 bool first_process_call_ = true; |
52 // Buffer for storing the power of incoming farend buffers. This is needed for | 57 // Buffer for storing the power of incoming farend buffers. This is needed for |
53 // cases where calls to BufferFarend and Process are jittery. | 58 // cases where calls to BufferFarend and Process are jittery. |
54 CircularBuffer render_buffer_; | 59 CircularBuffer render_buffer_; |
55 // Count how long ago it was that the size of |render_buffer_| was zero. This | 60 // Count how long ago it was that the size of |render_buffer_| was zero. This |
56 // value is also reset to zero when clock drift is detected and a value from | 61 // value is also reset to zero when clock drift is detected and a value from |
57 // the renderbuffer is discarded, even though the buffer is not actually zero | 62 // the renderbuffer is discarded, even though the buffer is not actually zero |
58 // at that point. This is done to avoid repeatedly removing elements in this | 63 // at that point. This is done to avoid repeatedly removing elements in this |
(...skipping 10 matching lines...) Expand all Loading... |
69 // Index where next element should be inserted in all of the above circular | 74 // Index where next element should be inserted in all of the above circular |
70 // buffers. | 75 // buffers. |
71 size_t next_insertion_index_ = 0; | 76 size_t next_insertion_index_ = 0; |
72 | 77 |
73 MeanVarianceEstimator render_statistics_; | 78 MeanVarianceEstimator render_statistics_; |
74 MeanVarianceEstimator capture_statistics_; | 79 MeanVarianceEstimator capture_statistics_; |
75 // Current echo likelihood. | 80 // Current echo likelihood. |
76 float echo_likelihood_ = 0.f; | 81 float echo_likelihood_ = 0.f; |
77 // Reliability of the current likelihood. | 82 // Reliability of the current likelihood. |
78 float reliability_ = 0.f; | 83 float reliability_ = 0.f; |
| 84 MovingMax recent_likelihood_max_; |
79 }; | 85 }; |
80 | 86 |
81 } // namespace webrtc | 87 } // namespace webrtc |
82 | 88 |
83 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_RESIDUAL_ECHO_DETECTOR_H_ | 89 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_RESIDUAL_ECHO_DETECTOR_H_ |
OLD | NEW |