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

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.h

Issue 1207353002: Add new variance update option and unittests for intelligibility (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
(...skipping 25 matching lines...) Expand all
36 // as a rolling window of blocks: multiple input elements are used for 36 // as a rolling window of blocks: multiple input elements are used for
37 // one block and the history then consists of the variances of these blocks 37 // one block and the history then consists of the variances of these blocks
38 // with the same effect as kStepWindowed, but less storage, so the window 38 // with the same effect as kStepWindowed, but less storage, so the window
39 // can be longer 39 // can be longer
40 class VarianceArray { 40 class VarianceArray {
41 public: 41 public:
42 enum StepType { 42 enum StepType {
43 kStepInfinite = 0, 43 kStepInfinite = 0,
44 kStepDecaying, 44 kStepDecaying,
45 kStepWindowed, 45 kStepWindowed,
46 kStepBlocked 46 kStepBlocked,
47 kStepBlockBasedMovingAverage
47 }; 48 };
48 49
49 // Construct an instance for the given input array length (|freqs|) and 50 // Construct an instance for the given input array length (|freqs|) and
50 // computation algorithm (|type|), with the appropriate parameters. 51 // computation algorithm (|type|), with the appropriate parameters.
51 // |window_size| is the number of samples for kStepWindowed and 52 // |window_size| is the number of samples for kStepWindowed and
52 // the number of blocks for kStepBlocked. |decay| is the forgetting factor 53 // the number of blocks for kStepBlocked. |decay| is the forgetting factor
53 // for kStepDecaying. 54 // for kStepDecaying.
54 VarianceArray(int freqs, StepType type, int window_size, float decay); 55 VarianceArray(int freqs, StepType type, int window_size, float decay);
55 56
56 // Add a new data point to the series and compute the new variances. 57 // Add a new data point to the series and compute the new variances.
(...skipping 13 matching lines...) Expand all
70 const float* variance() const { return variance_.get(); } 71 const float* variance() const { return variance_.get(); }
71 72
72 // The mean value of the current set of variances. 73 // The mean value of the current set of variances.
73 float array_mean() const { return array_mean_; } 74 float array_mean() const { return array_mean_; }
74 75
75 private: 76 private:
76 void InfiniteStep(const std::complex<float>* data, bool dummy); 77 void InfiniteStep(const std::complex<float>* data, bool dummy);
77 void DecayStep(const std::complex<float>* data, bool dummy); 78 void DecayStep(const std::complex<float>* data, bool dummy);
78 void WindowedStep(const std::complex<float>* data, bool dummy); 79 void WindowedStep(const std::complex<float>* data, bool dummy);
79 void BlockedStep(const std::complex<float>* data, bool dummy); 80 void BlockedStep(const std::complex<float>* data, bool dummy);
81 void BlockBasedMovingAverage(const std::complex<float>* data, bool dummy);
80 82
81 // TODO(ekmeyerson): Switch the following running means 83 // TODO(ekmeyerson): Switch the following running means
82 // and histories from rtc::scoped_ptr to std::vector. 84 // and histories from rtc::scoped_ptr to std::vector.
83 85
84 // The current average X and X^2. 86 // The current average X and X^2.
85 rtc::scoped_ptr<std::complex<float>[]> running_mean_; 87 rtc::scoped_ptr<std::complex<float>[]> running_mean_;
86 rtc::scoped_ptr<std::complex<float>[]> running_mean_sq_; 88 rtc::scoped_ptr<std::complex<float>[]> running_mean_sq_;
87 89
88 // Average X and X^2 for the current block in kStepBlocked. 90 // Average X and X^2 for the current block in kStepBlocked.
89 rtc::scoped_ptr<std::complex<float>[]> sub_running_mean_; 91 rtc::scoped_ptr<std::complex<float>[]> sub_running_mean_;
90 rtc::scoped_ptr<std::complex<float>[]> sub_running_mean_sq_; 92 rtc::scoped_ptr<std::complex<float>[]> sub_running_mean_sq_;
91 93
92 // Sample history for the rolling window in kStepWindowed and block-wise 94 // Sample history for the rolling window in kStepWindowed and block-wise
93 // histories for kStepBlocked. 95 // histories for kStepBlocked.
94 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> history_; 96 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> history_;
95 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_; 97 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_;
96 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_sq_; 98 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_sq_;
97 99
98 // The current set of variances and sums for Welford's algorithm. 100 // The current set of variances and sums for Welford's algorithm.
99 rtc::scoped_ptr<float[]> variance_; 101 rtc::scoped_ptr<float[]> variance_;
100 rtc::scoped_ptr<float[]> conj_sum_; 102 rtc::scoped_ptr<float[]> conj_sum_;
101 103
102 const int freqs_; 104 const int freqs_;
103 const int window_size_; 105 const int window_size_;
104 const float decay_; 106 const float decay_;
105 int history_cursor_; 107 int history_cursor_;
106 int count_; 108 int count_;
107 float array_mean_; 109 float array_mean_;
110 bool buffer_full_;
108 void (VarianceArray::*step_func_)(const std::complex<float>*, bool); 111 void (VarianceArray::*step_func_)(const std::complex<float>*, bool);
109 }; 112 };
110 113
111 // Helper class for smoothing gain changes. On each applicatiion step, the 114 // Helper class for smoothing gain changes. On each applicatiion step, the
112 // currently used gains are changed towards a set of settable target gains, 115 // currently used gains are changed towards a set of settable target gains,
113 // constrained by a limit on the magnitude of the changes. 116 // constrained by a limit on the magnitude of the changes.
114 class GainApplier { 117 class GainApplier {
115 public: 118 public:
116 GainApplier(int freqs, float change_limit); 119 GainApplier(int freqs, float change_limit);
117 120
(...skipping 10 matching lines...) Expand all
128 const float change_limit_; 131 const float change_limit_;
129 rtc::scoped_ptr<float[]> target_; 132 rtc::scoped_ptr<float[]> target_;
130 rtc::scoped_ptr<float[]> current_; 133 rtc::scoped_ptr<float[]> current_;
131 }; 134 };
132 135
133 } // namespace intelligibility 136 } // namespace intelligibility
134 137
135 } // namespace webrtc 138 } // namespace webrtc
136 139
137 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS _H_ 140 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698