OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_LIKELIHOOD_AGGREGATOR_H_ | |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_LIKELIHOOD_AGGREGATOR_H_ | |
13 | |
14 #include <deque> | |
15 #include <vector> | |
16 | |
17 namespace webrtc { | |
18 | |
19 // This class keeps a sliding window of past echo likelihood values, and can | |
20 // calculate the maximum. | |
21 class LikelihoodAggregator { | |
22 public: | |
23 explicit LikelihoodAggregator(size_t window_size_frames); | |
24 ~LikelihoodAggregator(); | |
25 | |
26 // Add a new likelihood to the buffer. This will automatically remove the | |
27 // oldest likelihood value from the buffer. | |
28 void Update(float value); | |
29 // Return the maximum likelihood value in the buffer. | |
30 float Max() const; | |
31 // Fill the buffer with zeros. | |
32 void Clear(); | |
33 | |
34 private: | |
35 // The most recent echo likelihood values are stored in a rotating buffer. | |
36 std::vector<float> recent_values_; | |
37 // Array indices of the maximum and possible future maxima. | |
38 std::deque<size_t> maximum_candidates_; | |
the sun
2017/01/13 13:55:28
I think a priority_queue may serve you better - th
ivoc
2017/01/13 14:40:36
That sounds like a good suggestion, but I rewrote
| |
39 // Where to insert the next element in the rotating buffer. | |
40 size_t insertion_index_ = 0; | |
41 }; | |
42 | |
43 } // namespace webrtc | |
44 | |
45 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_LIKELIHOOD_AGGREGATOR_H _ | |
OLD | NEW |