| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 saturating_gain_estimator_.Initialize(); | 201 saturating_gain_estimator_.Initialize(); |
| 202 metrics_.Initialize(sample_rate_hz); | 202 metrics_.Initialize(sample_rate_hz); |
| 203 | 203 |
| 204 last_gain_ = 1.0f; | 204 last_gain_ = 1.0f; |
| 205 sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz); | 205 sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz); |
| 206 dc_forgetting_factor_ = 0.01f * sample_rate_hz / 48000.f; | 206 dc_forgetting_factor_ = 0.01f * sample_rate_hz / 48000.f; |
| 207 std::fill(dc_level_, dc_level_ + arraysize(dc_level_), 0.f); | 207 std::fill(dc_level_, dc_level_ + arraysize(dc_level_), 0.f); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void LevelController::Process(AudioBuffer* audio) { | 210 void LevelController::Process(AudioBuffer* audio) { |
| 211 RTC_DCHECK_LT(0u, audio->num_channels()); | 211 RTC_DCHECK_LT(0, audio->num_channels()); |
| 212 RTC_DCHECK_GE(2u, audio->num_channels()); | 212 RTC_DCHECK_GE(2, audio->num_channels()); |
| 213 RTC_DCHECK_NE(0.f, dc_forgetting_factor_); | 213 RTC_DCHECK_NE(0.f, dc_forgetting_factor_); |
| 214 RTC_DCHECK(sample_rate_hz_); | 214 RTC_DCHECK(sample_rate_hz_); |
| 215 data_dumper_->DumpWav("lc_input", audio->num_frames(), | 215 data_dumper_->DumpWav("lc_input", audio->num_frames(), |
| 216 audio->channels_const_f()[0], *sample_rate_hz_, 1); | 216 audio->channels_const_f()[0], *sample_rate_hz_, 1); |
| 217 | 217 |
| 218 // Remove DC level. | 218 // Remove DC level. |
| 219 for (size_t k = 0; k < audio->num_channels(); ++k) { | 219 for (size_t k = 0; k < audio->num_channels(); ++k) { |
| 220 UpdateAndRemoveDcLevel( | 220 UpdateAndRemoveDcLevel( |
| 221 dc_forgetting_factor_, &dc_level_[k], | 221 dc_forgetting_factor_, &dc_level_[k], |
| 222 rtc::ArrayView<float>(audio->channels_f()[k], audio->num_frames())); | 222 rtc::ArrayView<float>(audio->channels_f()[k], audio->num_frames())); |
| (...skipping 61 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 |