| OLD | NEW |
| 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 |
| 11 #include "webrtc/modules/audio_processing/rms_level.h" | 11 #include "webrtc/modules/audio_processing/rms_level.h" |
| 12 | 12 |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <numeric> | 15 #include <numeric> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/rtc_base/checks.h" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 namespace { | 20 namespace { |
| 21 static constexpr float kMaxSquaredLevel = 32768 * 32768; | 21 static constexpr float kMaxSquaredLevel = 32768 * 32768; |
| 22 // kMinLevel is the level corresponding to kMinLevelDb, that is 10^(-127/10). | 22 // kMinLevel is the level corresponding to kMinLevelDb, that is 10^(-127/10). |
| 23 static constexpr float kMinLevel = 1.995262314968883e-13f; | 23 static constexpr float kMinLevel = 1.995262314968883e-13f; |
| 24 | 24 |
| 25 // Calculates the normalized RMS value from a mean square value. The input | 25 // Calculates the normalized RMS value from a mean square value. The input |
| 26 // should be the sum of squared samples divided by the number of samples. The | 26 // should be the sum of squared samples divided by the number of samples. The |
| 27 // value will be normalized to full range before computing the RMS, wich is | 27 // value will be normalized to full range before computing the RMS, wich is |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return levels; | 98 return levels; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void RmsLevel::CheckBlockSize(size_t block_size) { | 101 void RmsLevel::CheckBlockSize(size_t block_size) { |
| 102 if (block_size_ != rtc::Optional<size_t>(block_size)) { | 102 if (block_size_ != rtc::Optional<size_t>(block_size)) { |
| 103 Reset(); | 103 Reset(); |
| 104 block_size_ = rtc::Optional<size_t>(block_size); | 104 block_size_ = rtc::Optional<size_t>(block_size); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 } // namespace webrtc | 107 } // namespace webrtc |
| OLD | NEW |