Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() | 243 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() |
| 244 const { | 244 const { |
| 245 return low_cut_filter_enabled_ || echo_canceller_enabled_ || | 245 return low_cut_filter_enabled_ || echo_canceller_enabled_ || |
| 246 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || | 246 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || |
| 247 beamformer_enabled_ || adaptive_gain_controller_enabled_ || | 247 beamformer_enabled_ || adaptive_gain_controller_enabled_ || |
| 248 echo_canceller3_enabled_; | 248 echo_canceller3_enabled_; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureFullBandProcessingActive() | 251 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureFullBandProcessingActive() |
| 252 const { | 252 const { |
| 253 return level_controller_enabled_; | 253 return level_controller_enabled_ && gain_controller2_enabled_; |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() | 256 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() |
| 257 const { | 257 const { |
| 258 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || | 258 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || |
| 259 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_ || | 259 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_ || |
| 260 echo_canceller3_enabled_; | 260 echo_canceller3_enabled_; |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() | 263 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 new VoiceDetectionImpl(&crit_capture_)); | 364 new VoiceDetectionImpl(&crit_capture_)); |
| 365 public_submodules_->gain_control_for_experimental_agc.reset( | 365 public_submodules_->gain_control_for_experimental_agc.reset( |
| 366 new GainControlForExperimentalAgc( | 366 new GainControlForExperimentalAgc( |
| 367 public_submodules_->gain_control.get(), &crit_capture_)); | 367 public_submodules_->gain_control.get(), &crit_capture_)); |
| 368 private_submodules_->residual_echo_detector.reset( | 368 private_submodules_->residual_echo_detector.reset( |
| 369 new ResidualEchoDetector()); | 369 new ResidualEchoDetector()); |
| 370 | 370 |
| 371 // TODO(peah): Move this creation to happen only when the level controller | 371 // TODO(peah): Move this creation to happen only when the level controller |
| 372 // is enabled. | 372 // is enabled. |
| 373 private_submodules_->level_controller.reset(new LevelController()); | 373 private_submodules_->level_controller.reset(new LevelController()); |
| 374 | |
| 375 // TODO(alessiob): Move this creation to happen only when the gain | |
| 376 // controller is enabled. | |
|
AleBzk
2017/09/14 09:21:56
@Per: I replicated the TODO from LC, but the code
peah-webrtc
2017/09/15 07:44:25
Acknowledged.
AleBzk
2017/09/29 09:39:06
Done.
| |
| 377 private_submodules_->gain_controller2.reset(new GainController2()); | |
| 374 } | 378 } |
| 375 | 379 |
| 376 SetExtraOptions(config); | 380 SetExtraOptions(config); |
| 377 } | 381 } |
| 378 | 382 |
| 379 AudioProcessingImpl::~AudioProcessingImpl() { | 383 AudioProcessingImpl::~AudioProcessingImpl() { |
| 380 // Depends on gain_control_ and | 384 // Depends on gain_control_ and |
| 381 // public_submodules_->gain_control_for_experimental_agc. | 385 // public_submodules_->gain_control_for_experimental_agc. |
| 382 private_submodules_->agc_manager.reset(); | 386 private_submodules_->agc_manager.reset(); |
| 383 // Depends on gain_control_. | 387 // Depends on gain_control_. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 | 673 |
| 670 if (config.echo_canceller3.enabled != | 674 if (config.echo_canceller3.enabled != |
| 671 capture_nonlocked_.echo_canceller3_enabled) { | 675 capture_nonlocked_.echo_canceller3_enabled) { |
| 672 capture_nonlocked_.echo_canceller3_enabled = | 676 capture_nonlocked_.echo_canceller3_enabled = |
| 673 config_.echo_canceller3.enabled; | 677 config_.echo_canceller3.enabled; |
| 674 InitializeEchoCanceller3(); | 678 InitializeEchoCanceller3(); |
| 675 LOG(LS_INFO) << "Echo canceller 3 activated: " | 679 LOG(LS_INFO) << "Echo canceller 3 activated: " |
| 676 << capture_nonlocked_.echo_canceller3_enabled; | 680 << capture_nonlocked_.echo_canceller3_enabled; |
| 677 } | 681 } |
| 678 | 682 |
| 679 config_ok = GainController2::Validate(config_.gain_controller2); | 683 if (!GainController2::Validate(config_.gain_controller2)) { |
|
peah-webrtc
2017/09/15 07:44:25
Even though this works, I think it makes sense to
AleBzk
2017/09/29 09:39:06
Done.
| |
| 680 if (!config_ok) { | |
| 681 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl | 684 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl |
| 682 << "gain_controller2: " | 685 << "Gain Controller 2: " |
| 683 << GainController2::ToString(config_.gain_controller2) | 686 << GainController2::ToString(config_.gain_controller2) |
| 684 << std::endl | 687 << std::endl |
| 685 << "Reverting to default parameter set"; | 688 << "Reverting to default parameter set"; |
| 686 config_.gain_controller2 = AudioProcessing::Config::GainController2(); | 689 config_.gain_controller2 = AudioProcessing::Config::GainController2(); |
| 687 } | 690 } |
| 688 | 691 InitializeGainController2(); |
|
AleBzk
2017/09/14 09:21:56
@Per: every time that we call AudioProcessingImpl:
peah-webrtc
2017/09/15 07:44:25
I think so.
| |
| 689 if (config.gain_controller2.enabled != | 692 private_submodules_->gain_controller2->ApplyConfig(config_.gain_controller2); |
| 690 capture_nonlocked_.gain_controller2_enabled) { | 693 LOG(LS_INFO) << "Gain Controller 2 activated: " |
| 691 capture_nonlocked_.gain_controller2_enabled = | 694 << config_.gain_controller2.enabled; |
| 692 config_.gain_controller2.enabled; | |
| 693 InitializeGainController2(); | |
| 694 LOG(LS_INFO) << "Gain controller 2 activated: " | |
| 695 << capture_nonlocked_.gain_controller2_enabled; | |
| 696 } | |
| 697 } | 695 } |
| 698 | 696 |
| 699 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { | 697 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { |
| 700 // Run in a single-threaded manner when setting the extra options. | 698 // Run in a single-threaded manner when setting the extra options. |
| 701 rtc::CritScope cs_render(&crit_render_); | 699 rtc::CritScope cs_render(&crit_render_); |
| 702 rtc::CritScope cs_capture(&crit_capture_); | 700 rtc::CritScope cs_capture(&crit_capture_); |
| 703 | 701 |
| 704 public_submodules_->echo_cancellation->SetExtraOptions(config); | 702 public_submodules_->echo_cancellation->SetExtraOptions(config); |
| 705 | 703 |
| 706 if (capture_.transient_suppressor_enabled != | 704 if (capture_.transient_suppressor_enabled != |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 | 1261 |
| 1264 public_submodules_->transient_suppressor->Suppress( | 1262 public_submodules_->transient_suppressor->Suppress( |
| 1265 capture_buffer->channels_f()[0], capture_buffer->num_frames(), | 1263 capture_buffer->channels_f()[0], capture_buffer->num_frames(), |
| 1266 capture_buffer->num_channels(), | 1264 capture_buffer->num_channels(), |
| 1267 capture_buffer->split_bands_const_f(0)[kBand0To8kHz], | 1265 capture_buffer->split_bands_const_f(0)[kBand0To8kHz], |
| 1268 capture_buffer->num_frames_per_band(), capture_buffer->keyboard_data(), | 1266 capture_buffer->num_frames_per_band(), capture_buffer->keyboard_data(), |
| 1269 capture_buffer->num_keyboard_frames(), voice_probability, | 1267 capture_buffer->num_keyboard_frames(), voice_probability, |
| 1270 capture_.key_pressed); | 1268 capture_.key_pressed); |
| 1271 } | 1269 } |
| 1272 | 1270 |
| 1273 if (capture_nonlocked_.gain_controller2_enabled) { | 1271 if (config_.gain_controller2.enabled) { |
| 1274 private_submodules_->gain_controller2->Process(capture_buffer); | 1272 private_submodules_->gain_controller2->Process(capture_buffer); |
| 1275 } | 1273 } |
| 1276 | 1274 |
| 1277 if (capture_nonlocked_.level_controller_enabled) { | 1275 if (capture_nonlocked_.level_controller_enabled) { |
| 1278 private_submodules_->level_controller->Process(capture_buffer); | 1276 private_submodules_->level_controller->Process(capture_buffer); |
| 1279 } | 1277 } |
| 1280 | 1278 |
| 1281 // The level estimator operates on the recombined data. | 1279 // The level estimator operates on the recombined data. |
| 1282 public_submodules_->level_estimator->ProcessStream(capture_buffer); | 1280 public_submodules_->level_estimator->ProcessStream(capture_buffer); |
| 1283 | 1281 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1611 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { | 1609 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { |
| 1612 return submodule_states_.Update( | 1610 return submodule_states_.Update( |
| 1613 config_.high_pass_filter.enabled, | 1611 config_.high_pass_filter.enabled, |
| 1614 public_submodules_->echo_cancellation->is_enabled(), | 1612 public_submodules_->echo_cancellation->is_enabled(), |
| 1615 public_submodules_->echo_control_mobile->is_enabled(), | 1613 public_submodules_->echo_control_mobile->is_enabled(), |
| 1616 config_.residual_echo_detector.enabled, | 1614 config_.residual_echo_detector.enabled, |
| 1617 public_submodules_->noise_suppression->is_enabled(), | 1615 public_submodules_->noise_suppression->is_enabled(), |
| 1618 capture_nonlocked_.intelligibility_enabled, | 1616 capture_nonlocked_.intelligibility_enabled, |
| 1619 capture_nonlocked_.beamformer_enabled, | 1617 capture_nonlocked_.beamformer_enabled, |
| 1620 public_submodules_->gain_control->is_enabled(), | 1618 public_submodules_->gain_control->is_enabled(), |
| 1621 capture_nonlocked_.gain_controller2_enabled, | 1619 config_.gain_controller2.enabled, |
| 1622 capture_nonlocked_.level_controller_enabled, | 1620 capture_nonlocked_.level_controller_enabled, |
| 1623 capture_nonlocked_.echo_canceller3_enabled, | 1621 capture_nonlocked_.echo_canceller3_enabled, |
| 1624 public_submodules_->voice_detection->is_enabled(), | 1622 public_submodules_->voice_detection->is_enabled(), |
| 1625 public_submodules_->level_estimator->is_enabled(), | 1623 public_submodules_->level_estimator->is_enabled(), |
| 1626 capture_.transient_suppressor_enabled); | 1624 capture_.transient_suppressor_enabled); |
| 1627 } | 1625 } |
| 1628 | 1626 |
| 1629 | 1627 |
| 1630 void AudioProcessingImpl::InitializeTransient() { | 1628 void AudioProcessingImpl::InitializeTransient() { |
| 1631 if (capture_.transient_suppressor_enabled) { | 1629 if (capture_.transient_suppressor_enabled) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1673 void AudioProcessingImpl::InitializeEchoCanceller3() { | 1671 void AudioProcessingImpl::InitializeEchoCanceller3() { |
| 1674 if (capture_nonlocked_.echo_canceller3_enabled) { | 1672 if (capture_nonlocked_.echo_canceller3_enabled) { |
| 1675 private_submodules_->echo_canceller3.reset(new EchoCanceller3( | 1673 private_submodules_->echo_canceller3.reset(new EchoCanceller3( |
| 1676 config_.echo_canceller3, proc_sample_rate_hz(), true)); | 1674 config_.echo_canceller3, proc_sample_rate_hz(), true)); |
| 1677 } else { | 1675 } else { |
| 1678 private_submodules_->echo_canceller3.reset(); | 1676 private_submodules_->echo_canceller3.reset(); |
| 1679 } | 1677 } |
| 1680 } | 1678 } |
| 1681 | 1679 |
| 1682 void AudioProcessingImpl::InitializeGainController2() { | 1680 void AudioProcessingImpl::InitializeGainController2() { |
| 1683 if (capture_nonlocked_.gain_controller2_enabled) { | 1681 if (config_.gain_controller2.enabled) { |
| 1684 private_submodules_->gain_controller2.reset( | 1682 private_submodules_->gain_controller2->Initialize(proc_sample_rate_hz()); |
| 1685 new GainController2(proc_sample_rate_hz())); | |
| 1686 } else { | |
| 1687 private_submodules_->gain_controller2.reset(); | |
| 1688 } | 1683 } |
| 1689 } | 1684 } |
| 1690 | 1685 |
| 1691 void AudioProcessingImpl::InitializeLevelController() { | 1686 void AudioProcessingImpl::InitializeLevelController() { |
| 1692 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); | 1687 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); |
| 1693 } | 1688 } |
| 1694 | 1689 |
| 1695 void AudioProcessingImpl::InitializeResidualEchoDetector() { | 1690 void AudioProcessingImpl::InitializeResidualEchoDetector() { |
| 1696 private_submodules_->residual_echo_detector->Initialize(); | 1691 private_submodules_->residual_echo_detector->Initialize(); |
| 1697 } | 1692 } |
| 1698 | 1693 |
| 1699 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1694 void AudioProcessingImpl::MaybeUpdateHistograms() { |
| 1700 static const int kMinDiffDelayMs = 60; | 1695 static const int kMinDiffDelayMs = 60; |
| 1701 | 1696 |
| 1702 if (echo_cancellation()->is_enabled()) { | 1697 if (echo_cancellation()->is_enabled()) { |
| 1703 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. | 1698 // Activate delay_jumps_ counters if we know echo_cancellation is running. |
| 1704 // If a stream has echo we know that the echo_cancellation is in process. | 1699 // If a stream has echo we know that the echo_cancellation is in process. |
| 1705 if (capture_.stream_delay_jumps == -1 && | 1700 if (capture_.stream_delay_jumps == -1 && |
| 1706 echo_cancellation()->stream_has_echo()) { | 1701 echo_cancellation()->stream_has_echo()) { |
| 1707 capture_.stream_delay_jumps = 0; | 1702 capture_.stream_delay_jumps = 0; |
| 1708 } | 1703 } |
| 1709 if (capture_.aec_system_delay_jumps == -1 && | 1704 if (capture_.aec_system_delay_jumps == -1 && |
| 1710 echo_cancellation()->stream_has_echo()) { | 1705 echo_cancellation()->stream_has_echo()) { |
| 1711 capture_.aec_system_delay_jumps = 0; | 1706 capture_.aec_system_delay_jumps = 0; |
| 1712 } | 1707 } |
| 1713 | 1708 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1779 // descriptions for other submodules. | 1774 // descriptions for other submodules. |
| 1780 if (capture_nonlocked_.level_controller_enabled) { | 1775 if (capture_nonlocked_.level_controller_enabled) { |
| 1781 experiments_description += "LevelController;"; | 1776 experiments_description += "LevelController;"; |
| 1782 } | 1777 } |
| 1783 if (constants_.agc_clipped_level_min != kClippedLevelMin) { | 1778 if (constants_.agc_clipped_level_min != kClippedLevelMin) { |
| 1784 experiments_description += "AgcClippingLevelExperiment;"; | 1779 experiments_description += "AgcClippingLevelExperiment;"; |
| 1785 } | 1780 } |
| 1786 if (capture_nonlocked_.echo_canceller3_enabled) { | 1781 if (capture_nonlocked_.echo_canceller3_enabled) { |
| 1787 experiments_description += "EchoCanceller3;"; | 1782 experiments_description += "EchoCanceller3;"; |
| 1788 } | 1783 } |
| 1784 if (config_.gain_controller2.enabled) { | |
| 1785 experiments_description += "GainController2;"; | |
| 1786 } | |
| 1789 | 1787 |
| 1790 InternalAPMConfig apm_config; | 1788 InternalAPMConfig apm_config; |
| 1791 | 1789 |
| 1792 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled(); | 1790 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled(); |
| 1793 apm_config.aec_delay_agnostic_enabled = | 1791 apm_config.aec_delay_agnostic_enabled = |
| 1794 public_submodules_->echo_cancellation->is_delay_agnostic_enabled(); | 1792 public_submodules_->echo_cancellation->is_delay_agnostic_enabled(); |
| 1795 apm_config.aec_drift_compensation_enabled = | 1793 apm_config.aec_drift_compensation_enabled = |
| 1796 public_submodules_->echo_cancellation->is_drift_compensation_enabled(); | 1794 public_submodules_->echo_cancellation->is_drift_compensation_enabled(); |
| 1797 apm_config.aec_extended_filter_enabled = | 1795 apm_config.aec_extended_filter_enabled = |
| 1798 public_submodules_->echo_cancellation->is_extended_filter_enabled(); | 1796 public_submodules_->echo_cancellation->is_extended_filter_enabled(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1903 split_rate(kSampleRate16kHz), | 1901 split_rate(kSampleRate16kHz), |
| 1904 echo_path_gain_change(false) {} | 1902 echo_path_gain_change(false) {} |
| 1905 | 1903 |
| 1906 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1904 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
| 1907 | 1905 |
| 1908 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1906 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
| 1909 | 1907 |
| 1910 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1908 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
| 1911 | 1909 |
| 1912 } // namespace webrtc | 1910 } // namespace webrtc |
| OLD | NEW |