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 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "webrtc/system_wrappers/include/metrics.h" | 28 #include "webrtc/system_wrappers/include/metrics.h" |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 namespace { | 31 namespace { |
32 | 32 |
33 void UpdateAndRemoveDcLevel(float forgetting_factor, | 33 void UpdateAndRemoveDcLevel(float forgetting_factor, |
34 float* dc_level, | 34 float* dc_level, |
35 rtc::ArrayView<float> x) { | 35 rtc::ArrayView<float> x) { |
36 RTC_DCHECK(!x.empty()); | 36 RTC_DCHECK(!x.empty()); |
37 float mean = | 37 float mean = |
38 std::accumulate(x.begin(), x.end(), 0) / static_cast<float>(x.size()); | 38 std::accumulate(x.begin(), x.end(), 0.0) / static_cast<float>(x.size()); |
the sun
2016/08/24 19:41:32
Nice catch! Make it a 0.0f so we're not using doub
| |
39 *dc_level += forgetting_factor * (mean - *dc_level); | 39 *dc_level += forgetting_factor * (mean - *dc_level); |
40 | 40 |
41 for (float& v : x) { | 41 for (float& v : x) { |
42 v -= *dc_level; | 42 v -= *dc_level; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 float FrameEnergy(const AudioBuffer& audio) { | 46 float FrameEnergy(const AudioBuffer& audio) { |
47 float energy = 0.f; | 47 float energy = 0.f; |
48 for (size_t k = 0; k < audio.num_channels(); ++k) { | 48 for (size_t k = 0; k < audio.num_channels(); ++k) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 data_dumper_->DumpRaw("lc_selected_gain", 1, &last_gain_); | 221 data_dumper_->DumpRaw("lc_selected_gain", 1, &last_gain_); |
222 data_dumper_->DumpRaw("lc_noise_energy", 1, &noise_energy); | 222 data_dumper_->DumpRaw("lc_noise_energy", 1, &noise_energy); |
223 data_dumper_->DumpRaw("lc_peak_level", 1, &peak_level); | 223 data_dumper_->DumpRaw("lc_peak_level", 1, &peak_level); |
224 data_dumper_->DumpRaw("lc_saturating_gain", 1, &saturating_gain); | 224 data_dumper_->DumpRaw("lc_saturating_gain", 1, &saturating_gain); |
225 | 225 |
226 data_dumper_->DumpWav("lc_output", audio->num_frames(), | 226 data_dumper_->DumpWav("lc_output", audio->num_frames(), |
227 audio->channels_f()[0], *sample_rate_hz_, 1); | 227 audio->channels_f()[0], *sample_rate_hz_, 1); |
228 } | 228 } |
229 | 229 |
230 } // namespace webrtc | 230 } // namespace webrtc |
OLD | NEW |