OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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/aec3/echo_remover_metrics.h" | 11 #include "webrtc/modules/audio_processing/aec3/echo_remover_metrics.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/safe_minmax.h" |
17 #include "webrtc/system_wrappers/include/metrics.h" | 18 #include "webrtc/system_wrappers/include/metrics.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 constexpr float kOneByMetricsCollectionBlocks = 1.f / kMetricsCollectionBlocks; | 24 constexpr float kOneByMetricsCollectionBlocks = 1.f / kMetricsCollectionBlocks; |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 int TransformDbMetricForReporting(bool negate, | 267 int TransformDbMetricForReporting(bool negate, |
267 float min_value, | 268 float min_value, |
268 float max_value, | 269 float max_value, |
269 float offset, | 270 float offset, |
270 float scaling, | 271 float scaling, |
271 float value) { | 272 float value) { |
272 float new_value = 10.f * log10(value * scaling + 1e-10f) + offset; | 273 float new_value = 10.f * log10(value * scaling + 1e-10f) + offset; |
273 if (negate) { | 274 if (negate) { |
274 new_value = -new_value; | 275 new_value = -new_value; |
275 } | 276 } |
276 return static_cast<int>(std::max(min_value, std::min(max_value, new_value))); | 277 return static_cast<int>(rtc::SafeClamp(new_value, min_value, max_value)); |
277 } | 278 } |
278 | 279 |
279 } // namespace aec3 | 280 } // namespace aec3 |
280 | 281 |
281 } // namespace webrtc | 282 } // namespace webrtc |
OLD | NEW |