Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: webrtc/modules/audio_processing/level_controller/gain_selector.cc

Issue 2283793002: Revert of Added functionality for specifying the initial signal level to use for the gain estimation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 // 2) The gain does not exceed the gain that has been found 35 // 2) The gain does not exceed the gain that has been found
36 // to saturate the signal. 36 // to saturate the signal.
37 // 3) The peak level achieves the target peak level. 37 // 3) The peak level achieves the target peak level.
38 // 4) The gain is not below 1. 38 // 4) The gain is not below 1.
39 // 4) The gain is 1 if the signal has been classified as stationary 39 // 4) The gain is 1 if the signal has been classified as stationary
40 // for a long time. 40 // for a long time.
41 // 5) The gain is not above the maximum gain. 41 // 5) The gain is not above the maximum gain.
42 float GainSelector::GetNewGain(float peak_level, 42 float GainSelector::GetNewGain(float peak_level,
43 float noise_energy, 43 float noise_energy,
44 float saturating_gain, 44 float saturating_gain,
45 bool gain_jumpstart,
46 SignalClassifier::SignalType signal_type) { 45 SignalClassifier::SignalType signal_type) {
47 RTC_DCHECK_LT(0.f, peak_level); 46 RTC_DCHECK_LT(0.f, peak_level);
48 47
49 if (signal_type == SignalClassifier::SignalType::kHighlyNonStationary || 48 if (signal_type == SignalClassifier::SignalType::kHighlyNonStationary) {
50 gain_jumpstart) {
51 highly_nonstationary_signal_hold_counter_ = 100; 49 highly_nonstationary_signal_hold_counter_ = 100;
52 } else { 50 } else {
53 highly_nonstationary_signal_hold_counter_ = 51 highly_nonstationary_signal_hold_counter_ =
54 std::max(0, highly_nonstationary_signal_hold_counter_ - 1); 52 std::max(0, highly_nonstationary_signal_hold_counter_ - 1);
55 } 53 }
56 54
57 float desired_gain; 55 float desired_gain;
58 if (highly_nonstationary_signal_hold_counter_ > 0) { 56 if (highly_nonstationary_signal_hold_counter_ > 0) {
59 // Compute a desired gain that ensures that the peak level is amplified to 57 // Compute a desired gain that ensures that the peak level is amplified to
60 // the target level. 58 // the target level.
(...skipping 17 matching lines...) Expand all
78 // Limit the gain to not exceed the maximum and the saturating gains, and to 76 // Limit the gain to not exceed the maximum and the saturating gains, and to
79 // ensure that the lowest possible gain is 1. 77 // ensure that the lowest possible gain is 1.
80 gain_ = std::min(gain_, saturating_gain); 78 gain_ = std::min(gain_, saturating_gain);
81 gain_ = std::min(gain_, kMaxLcGain); 79 gain_ = std::min(gain_, kMaxLcGain);
82 gain_ = std::max(gain_, 1.f); 80 gain_ = std::max(gain_, 1.f);
83 81
84 return gain_; 82 return gain_;
85 } 83 }
86 84
87 } // namespace webrtc 85 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698