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 |
11 #include "webrtc/modules/audio_processing/level_controller/gain_selector.h" | 11 #include "webrtc/modules/audio_processing/level_controller/gain_selector.h" |
12 | 12 |
13 #include <math.h> | 13 #include <math.h> |
14 #include <algorithm> | 14 #include <algorithm> |
15 | 15 |
| 16 #include "webrtc/base/checks.h" |
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 17 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
17 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons
tants.h" | 18 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons
tants.h" |
18 #include "webrtc/rtc_base/checks.h" | |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 GainSelector::GainSelector() { | 22 GainSelector::GainSelector() { |
23 Initialize(AudioProcessing::kSampleRate48kHz); | 23 Initialize(AudioProcessing::kSampleRate48kHz); |
24 } | 24 } |
25 | 25 |
26 void GainSelector::Initialize(int sample_rate_hz) { | 26 void GainSelector::Initialize(int sample_rate_hz) { |
27 gain_ = 1.f; | 27 gain_ = 1.f; |
28 frame_length_ = rtc::CheckedDivExact(sample_rate_hz, 100); | 28 frame_length_ = rtc::CheckedDivExact(sample_rate_hz, 100); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Limit the gain to not exceed the maximum and the saturating gains, and to | 78 // Limit the gain to not exceed the maximum and the saturating gains, and to |
79 // ensure that the lowest possible gain is 1. | 79 // ensure that the lowest possible gain is 1. |
80 gain_ = std::min(gain_, saturating_gain); | 80 gain_ = std::min(gain_, saturating_gain); |
81 gain_ = std::min(gain_, kMaxLcGain); | 81 gain_ = std::min(gain_, kMaxLcGain); |
82 gain_ = std::max(gain_, 1.f); | 82 gain_ = std::max(gain_, 1.f); |
83 | 83 |
84 return gain_; | 84 return gain_; |
85 } | 85 } |
86 | 86 |
87 } // namespace webrtc | 87 } // namespace webrtc |
OLD | NEW |