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

Side by Side Diff: webrtc/modules/audio_processing/utility/mean_calculator.h

Issue 1805633006: Adding BlockMeanCalculator for AEC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
(Empty)
1 /*
2 * Copyright 2016 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_UTILITY_MEAN_CALCULATOR_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_MEAN_CALCULATOR_H_
13
14 #include <stddef.h>
15 #include <vector>
16
17 #include "webrtc/base/criticalsection.h"
peah-webrtc 2016/03/18 09:18:34 criticalsection.h should be after before construc
minyue-webrtc 2016/03/21 15:27:51 Done.
18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/optional.h"
20
21 namespace webrtc {
22
23 // MeanCalculator calculates the mean of a sample sequence of a certain length.
peah-webrtc 2016/03/18 09:18:34 I think it is better if this class is about the me
minyue-webrtc 2016/03/21 15:27:51 In statistics, sample has its own meaning, and sho
24 class MeanCalculator {
peah-webrtc 2016/03/18 09:18:34 As I said in the previous review I think you shoul
25 public:
26 explicit MeanCalculator(size_t window_length);
27
28 // Reset.
29 void Reset();
30
31 // Add one sample to the sequence.
32 void AddSample(float sample);
33
34 // Return the number of newly added samples since latest update on mean value.
35 size_t GetNumberNewSamples() const;
peah-webrtc 2016/03/18 09:18:34 What about GetNumberOfNewSamples()?
minyue-webrtc 2016/03/21 15:27:51 Done.
36
37 // Return the latest mean value.
38 float GetLatestMean() const;
39
40 private:
41 // Clear all samples added.
42 void Clear();
43
44 // Update |sum_| and |compensation_| using Kahan algorithm.
45 void KahanSum(float sample);
46
47 const size_t window_length_;
48 size_t count_;
49 float sum_;
50 float compensation_;
51 float mean_;
52
53 RTC_DISALLOW_COPY_AND_ASSIGN(MeanCalculator);
54 };
55
56 } // namespace webrtc
57
58 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_MEAN_CALCULATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698