| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 AudioProcessingImpl::AudioProcessingImpl(const Config& config) | 157 AudioProcessingImpl::AudioProcessingImpl(const Config& config) |
| 158 : AudioProcessingImpl(config, nullptr) {} | 158 : AudioProcessingImpl(config, nullptr) {} |
| 159 | 159 |
| 160 AudioProcessingImpl::AudioProcessingImpl(const Config& config, | 160 AudioProcessingImpl::AudioProcessingImpl(const Config& config, |
| 161 Beamformer<float>* beamformer) | 161 Beamformer<float>* beamformer) |
| 162 : public_submodules_(new ApmPublicSubmodules()), | 162 : public_submodules_(new ApmPublicSubmodules()), |
| 163 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 163 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
| 164 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 164 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
| 165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 166 false, | 166 false), |
| 167 #else | 167 #else |
| 168 config.Get<ExperimentalAgc>().enabled, | 168 config.Get<ExperimentalAgc>().enabled), |
| 169 #endif | 169 #endif |
| 170 config.Get<Intelligibility>().enabled), | |
| 171 | |
| 172 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 170 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 173 capture_(false, | 171 capture_(false, |
| 174 #else | 172 #else |
| 175 capture_(config.Get<ExperimentalNs>().enabled, | 173 capture_(config.Get<ExperimentalNs>().enabled, |
| 176 #endif | 174 #endif |
| 177 config.Get<Beamforming>().array_geometry, | 175 config.Get<Beamforming>().array_geometry, |
| 178 config.Get<Beamforming>().target_direction), | 176 config.Get<Beamforming>().target_direction), |
| 179 capture_nonlocked_(config.Get<Beamforming>().enabled) | 177 capture_nonlocked_(config.Get<Beamforming>().enabled, |
| 178 config.Get<Intelligibility>().enabled) |
| 180 { | 179 { |
| 181 { | 180 { |
| 182 rtc::CritScope cs_render(&crit_render_); | 181 rtc::CritScope cs_render(&crit_render_); |
| 183 rtc::CritScope cs_capture(&crit_capture_); | 182 rtc::CritScope cs_capture(&crit_capture_); |
| 184 | 183 |
| 185 public_submodules_->echo_cancellation.reset( | 184 public_submodules_->echo_cancellation.reset( |
| 186 new EchoCancellationImpl(&crit_render_, &crit_capture_)); | 185 new EchoCancellationImpl(&crit_render_, &crit_capture_)); |
| 187 public_submodules_->echo_control_mobile.reset( | 186 public_submodules_->echo_control_mobile.reset( |
| 188 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); | 187 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); |
| 189 public_submodules_->gain_control.reset( | 188 public_submodules_->gain_control.reset( |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 403 |
| 405 public_submodules_->echo_cancellation->SetExtraOptions(config); | 404 public_submodules_->echo_cancellation->SetExtraOptions(config); |
| 406 | 405 |
| 407 if (capture_.transient_suppressor_enabled != | 406 if (capture_.transient_suppressor_enabled != |
| 408 config.Get<ExperimentalNs>().enabled) { | 407 config.Get<ExperimentalNs>().enabled) { |
| 409 capture_.transient_suppressor_enabled = | 408 capture_.transient_suppressor_enabled = |
| 410 config.Get<ExperimentalNs>().enabled; | 409 config.Get<ExperimentalNs>().enabled; |
| 411 InitializeTransient(); | 410 InitializeTransient(); |
| 412 } | 411 } |
| 413 | 412 |
| 413 if(capture_nonlocked_.intelligibility_enabled != |
| 414 config.Get<Intelligibility>().enabled) { |
| 415 capture_nonlocked_.intelligibility_enabled = |
| 416 config.Get<Intelligibility>().enabled; |
| 417 InitializeIntelligibility(); |
| 418 } |
| 419 |
| 414 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 420 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 415 if (capture_nonlocked_.beamformer_enabled != | 421 if (capture_nonlocked_.beamformer_enabled != |
| 416 config.Get<Beamforming>().enabled) { | 422 config.Get<Beamforming>().enabled) { |
| 417 capture_nonlocked_.beamformer_enabled = config.Get<Beamforming>().enabled; | 423 capture_nonlocked_.beamformer_enabled = config.Get<Beamforming>().enabled; |
| 418 if (config.Get<Beamforming>().array_geometry.size() > 1) { | 424 if (config.Get<Beamforming>().array_geometry.size() > 1) { |
| 419 capture_.array_geometry = config.Get<Beamforming>().array_geometry; | 425 capture_.array_geometry = config.Get<Beamforming>().array_geometry; |
| 420 } | 426 } |
| 421 capture_.target_direction = config.Get<Beamforming>().target_direction; | 427 capture_.target_direction = config.Get<Beamforming>().target_direction; |
| 422 InitializeBeamformer(); | 428 InitializeBeamformer(); |
| 423 } | 429 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 } | 703 } |
| 698 | 704 |
| 699 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio( | 705 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio( |
| 700 ca, stream_delay_ms())); | 706 ca, stream_delay_ms())); |
| 701 | 707 |
| 702 if (public_submodules_->echo_control_mobile->is_enabled() && | 708 if (public_submodules_->echo_control_mobile->is_enabled() && |
| 703 public_submodules_->noise_suppression->is_enabled()) { | 709 public_submodules_->noise_suppression->is_enabled()) { |
| 704 ca->CopyLowPassToReference(); | 710 ca->CopyLowPassToReference(); |
| 705 } | 711 } |
| 706 public_submodules_->noise_suppression->ProcessCaptureAudio(ca); | 712 public_submodules_->noise_suppression->ProcessCaptureAudio(ca); |
| 707 if (constants_.intelligibility_enabled) { | 713 if (capture_nonlocked_.intelligibility_enabled) { |
| 708 RTC_DCHECK(public_submodules_->noise_suppression->is_enabled()); | 714 RTC_DCHECK(public_submodules_->noise_suppression->is_enabled()); |
| 709 RTC_DCHECK(public_submodules_->gain_control->is_enabled()); | 715 int gain_db = public_submodules_->gain_control->is_enabled() ? |
| 716 public_submodules_->gain_control->compression_gain_db() : |
| 717 0; |
| 710 public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate( | 718 public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate( |
| 711 public_submodules_->noise_suppression->NoiseEstimate(), | 719 public_submodules_->noise_suppression->NoiseEstimate(), gain_db); |
| 712 public_submodules_->gain_control->compression_gain_db()); | |
| 713 } | 720 } |
| 714 | 721 |
| 715 // Ensure that the stream delay was set before the call to the | 722 // Ensure that the stream delay was set before the call to the |
| 716 // AECM ProcessCaptureAudio function. | 723 // AECM ProcessCaptureAudio function. |
| 717 if (public_submodules_->echo_control_mobile->is_enabled() && | 724 if (public_submodules_->echo_control_mobile->is_enabled() && |
| 718 !was_stream_delay_set()) { | 725 !was_stream_delay_set()) { |
| 719 return AudioProcessing::kStreamParameterNotSetError; | 726 return AudioProcessing::kStreamParameterNotSetError; |
| 720 } | 727 } |
| 721 | 728 |
| 722 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( | 729 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 } | 902 } |
| 896 return kNoError; | 903 return kNoError; |
| 897 } | 904 } |
| 898 | 905 |
| 899 int AudioProcessingImpl::ProcessReverseStreamLocked() { | 906 int AudioProcessingImpl::ProcessReverseStreamLocked() { |
| 900 AudioBuffer* ra = render_.render_audio.get(); // For brevity. | 907 AudioBuffer* ra = render_.render_audio.get(); // For brevity. |
| 901 if (rev_analysis_needed()) { | 908 if (rev_analysis_needed()) { |
| 902 ra->SplitIntoFrequencyBands(); | 909 ra->SplitIntoFrequencyBands(); |
| 903 } | 910 } |
| 904 | 911 |
| 905 if (constants_.intelligibility_enabled) { | 912 if (capture_nonlocked_.intelligibility_enabled) { |
| 906 public_submodules_->intelligibility_enhancer->ProcessRenderAudio( | 913 public_submodules_->intelligibility_enhancer->ProcessRenderAudio( |
| 907 ra->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, | 914 ra->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, |
| 908 ra->num_channels()); | 915 ra->num_channels()); |
| 909 } | 916 } |
| 910 | 917 |
| 911 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessRenderAudio(ra)); | 918 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessRenderAudio(ra)); |
| 912 RETURN_ON_ERR( | 919 RETURN_ON_ERR( |
| 913 public_submodules_->echo_control_mobile->ProcessRenderAudio(ra)); | 920 public_submodules_->echo_control_mobile->ProcessRenderAudio(ra)); |
| 914 if (!constants_.use_experimental_agc) { | 921 if (!constants_.use_experimental_agc) { |
| 915 RETURN_ON_ERR(public_submodules_->gain_control->ProcessRenderAudio(ra)); | 922 RETURN_ON_ERR(public_submodules_->gain_control->ProcessRenderAudio(ra)); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 } else if (is_multi_band( | 1150 } else if (is_multi_band( |
| 1144 capture_nonlocked_.fwd_proc_format.sample_rate_hz())) { | 1151 capture_nonlocked_.fwd_proc_format.sample_rate_hz())) { |
| 1145 // Something besides public_submodules_->level_estimator is enabled, and we | 1152 // Something besides public_submodules_->level_estimator is enabled, and we |
| 1146 // have super-wb. | 1153 // have super-wb. |
| 1147 return true; | 1154 return true; |
| 1148 } | 1155 } |
| 1149 return false; | 1156 return false; |
| 1150 } | 1157 } |
| 1151 | 1158 |
| 1152 bool AudioProcessingImpl::is_rev_processed() const { | 1159 bool AudioProcessingImpl::is_rev_processed() const { |
| 1153 return constants_.intelligibility_enabled; | 1160 return capture_nonlocked_.intelligibility_enabled; |
| 1154 } | 1161 } |
| 1155 | 1162 |
| 1156 bool AudioProcessingImpl::rev_synthesis_needed() const { | 1163 bool AudioProcessingImpl::rev_synthesis_needed() const { |
| 1157 return (is_rev_processed() && | 1164 return (is_rev_processed() && |
| 1158 is_multi_band(formats_.rev_proc_format.sample_rate_hz())); | 1165 is_multi_band(formats_.rev_proc_format.sample_rate_hz())); |
| 1159 } | 1166 } |
| 1160 | 1167 |
| 1161 bool AudioProcessingImpl::rev_analysis_needed() const { | 1168 bool AudioProcessingImpl::rev_analysis_needed() const { |
| 1162 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) && | 1169 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) && |
| 1163 (is_rev_processed() || | 1170 (is_rev_processed() || |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 if (!private_submodules_->beamformer) { | 1215 if (!private_submodules_->beamformer) { |
| 1209 private_submodules_->beamformer.reset(new NonlinearBeamformer( | 1216 private_submodules_->beamformer.reset(new NonlinearBeamformer( |
| 1210 capture_.array_geometry, capture_.target_direction)); | 1217 capture_.array_geometry, capture_.target_direction)); |
| 1211 } | 1218 } |
| 1212 private_submodules_->beamformer->Initialize(kChunkSizeMs, | 1219 private_submodules_->beamformer->Initialize(kChunkSizeMs, |
| 1213 capture_nonlocked_.split_rate); | 1220 capture_nonlocked_.split_rate); |
| 1214 } | 1221 } |
| 1215 } | 1222 } |
| 1216 | 1223 |
| 1217 void AudioProcessingImpl::InitializeIntelligibility() { | 1224 void AudioProcessingImpl::InitializeIntelligibility() { |
| 1218 if (constants_.intelligibility_enabled) { | 1225 if (capture_nonlocked_.intelligibility_enabled) { |
| 1219 public_submodules_->intelligibility_enhancer.reset( | 1226 public_submodules_->intelligibility_enhancer.reset( |
| 1220 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, | 1227 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, |
| 1221 render_.render_audio->num_channels(), | 1228 render_.render_audio->num_channels(), |
| 1222 NoiseSuppressionImpl::num_noise_bins())); | 1229 NoiseSuppressionImpl::num_noise_bins())); |
| 1223 } | 1230 } |
| 1224 } | 1231 } |
| 1225 | 1232 |
| 1226 void AudioProcessingImpl::InitializeHighPassFilter() { | 1233 void AudioProcessingImpl::InitializeHighPassFilter() { |
| 1227 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), | 1234 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), |
| 1228 proc_sample_rate_hz()); | 1235 proc_sample_rate_hz()); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1468 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
| 1462 | 1469 |
| 1463 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1470 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
| 1464 &debug_dump_.num_bytes_left_for_log_, | 1471 &debug_dump_.num_bytes_left_for_log_, |
| 1465 &crit_debug_, &debug_dump_.capture)); | 1472 &crit_debug_, &debug_dump_.capture)); |
| 1466 return kNoError; | 1473 return kNoError; |
| 1467 } | 1474 } |
| 1468 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1475 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 1469 | 1476 |
| 1470 } // namespace webrtc | 1477 } // namespace webrtc |
| OLD | NEW |