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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 for (float& v : x) { | 42 for (float& v : x) { |
43 v -= *dc_level; | 43 v -= *dc_level; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 float FrameEnergy(const AudioBuffer& audio) { | 47 float FrameEnergy(const AudioBuffer& audio) { |
48 float energy = 0.f; | 48 float energy = 0.f; |
49 for (size_t k = 0; k < audio.num_channels(); ++k) { | 49 for (size_t k = 0; k < audio.num_channels(); ++k) { |
50 float channel_energy = | 50 float channel_energy = |
51 std::accumulate(audio.channels_const_f()[k], | 51 std::accumulate(audio.channels_const_f()[k], |
52 audio.channels_const_f()[k] + audio.num_frames(), 0, | 52 audio.channels_const_f()[k] + audio.num_frames(), 0.f, |
saza WebRTC
2017/09/05 09:35:20
Good find. Fyi, aleloi@ or hlundin@ are the least
| |
53 [](float a, float b) -> float { return a + b * b; }); | 53 [](float a, float b) -> float { return a + b * b; }); |
54 energy = std::max(channel_energy, energy); | 54 energy = std::max(channel_energy, energy); |
55 } | 55 } |
56 return energy; | 56 return energy; |
57 } | 57 } |
58 | 58 |
59 float PeakLevel(const AudioBuffer& audio) { | 59 float PeakLevel(const AudioBuffer& audio) { |
60 float peak_level = 0.f; | 60 float peak_level = 0.f; |
61 for (size_t k = 0; k < audio.num_channels(); ++k) { | 61 for (size_t k = 0; k < audio.num_channels(); ++k) { |
62 auto* channel_peak_level = std::max_element( | 62 auto* channel_peak_level = std::max_element( |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 284 |
285 bool LevelController::Validate( | 285 bool LevelController::Validate( |
286 const AudioProcessing::Config::LevelController& config) { | 286 const AudioProcessing::Config::LevelController& config) { |
287 return (config.initial_peak_level_dbfs < | 287 return (config.initial_peak_level_dbfs < |
288 std::numeric_limits<float>::epsilon() && | 288 std::numeric_limits<float>::epsilon() && |
289 config.initial_peak_level_dbfs > | 289 config.initial_peak_level_dbfs > |
290 -(100.f + std::numeric_limits<float>::epsilon())); | 290 -(100.f + std::numeric_limits<float>::epsilon())); |
291 } | 291 } |
292 | 292 |
293 } // namespace webrtc | 293 } // namespace webrtc |
OLD | NEW |