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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 audio.channels_const_f()[k] + audio.num_frames(), 0, | 52 audio.channels_const_f()[k] + audio.num_frames(), 0, |
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( |
63 audio.channels_const_f()[k], | 63 audio.channels_const_f()[k], |
64 audio.channels_const_f()[k] + audio.num_frames(), | 64 audio.channels_const_f()[k] + audio.num_frames(), |
65 [](float a, float b) { return std::abs(a) < std::abs(b); }); | 65 [](float a, float b) { return std::abs(a) < std::abs(b); }); |
66 peak_level = std::max(*channel_peak_level, peak_level); | 66 peak_level = std::max(*channel_peak_level, peak_level); |
67 } | 67 } |
68 return peak_level; | 68 return peak_level; |
69 } | 69 } |
70 | 70 |
71 const int kMetricsFrameInterval = 1000; | 71 const int kMetricsFrameInterval = 1000; |
72 | 72 |
(...skipping 211 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 |