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 17 matching lines...) Loading... |
28 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" | 28 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" |
29 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" | 29 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" |
30 #include "webrtc/modules/audio_processing/gain_control_impl.h" | 30 #include "webrtc/modules/audio_processing/gain_control_impl.h" |
31 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" | 31 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" |
32 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 32 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" | 33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" |
34 #endif | 34 #endif |
35 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" | 35 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" |
36 #include "webrtc/modules/audio_processing/level_estimator_impl.h" | 36 #include "webrtc/modules/audio_processing/level_estimator_impl.h" |
37 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" | 37 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" |
| 38 #include "webrtc/modules/audio_processing/residual_echo_detector.h" |
38 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" | 39 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" |
39 #include "webrtc/modules/audio_processing/voice_detection_impl.h" | 40 #include "webrtc/modules/audio_processing/voice_detection_impl.h" |
40 #include "webrtc/modules/include/module_common_types.h" | 41 #include "webrtc/modules/include/module_common_types.h" |
41 #include "webrtc/system_wrappers/include/file_wrapper.h" | 42 #include "webrtc/system_wrappers/include/file_wrapper.h" |
42 #include "webrtc/system_wrappers/include/logging.h" | 43 #include "webrtc/system_wrappers/include/logging.h" |
43 #include "webrtc/system_wrappers/include/metrics.h" | 44 #include "webrtc/system_wrappers/include/metrics.h" |
44 | 45 |
45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 46 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
46 // Files generated at build-time by the protobuf compiler. | 47 // Files generated at build-time by the protobuf compiler. |
47 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 48 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
(...skipping 82 matching lines...) Loading... |
130 | 131 |
131 // Throughout webrtc, it's assumed that success is represented by zero. | 132 // Throughout webrtc, it's assumed that success is represented by zero. |
132 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); | 133 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); |
133 | 134 |
134 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} | 135 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} |
135 | 136 |
136 bool AudioProcessingImpl::ApmSubmoduleStates::Update( | 137 bool AudioProcessingImpl::ApmSubmoduleStates::Update( |
137 bool high_pass_filter_enabled, | 138 bool high_pass_filter_enabled, |
138 bool echo_canceller_enabled, | 139 bool echo_canceller_enabled, |
139 bool mobile_echo_controller_enabled, | 140 bool mobile_echo_controller_enabled, |
| 141 bool residual_echo_detector_enabled, |
140 bool noise_suppressor_enabled, | 142 bool noise_suppressor_enabled, |
141 bool intelligibility_enhancer_enabled, | 143 bool intelligibility_enhancer_enabled, |
142 bool beamformer_enabled, | 144 bool beamformer_enabled, |
143 bool adaptive_gain_controller_enabled, | 145 bool adaptive_gain_controller_enabled, |
144 bool level_controller_enabled, | 146 bool level_controller_enabled, |
145 bool voice_activity_detector_enabled, | 147 bool voice_activity_detector_enabled, |
146 bool level_estimator_enabled, | 148 bool level_estimator_enabled, |
147 bool transient_suppressor_enabled) { | 149 bool transient_suppressor_enabled) { |
148 bool changed = false; | 150 bool changed = false; |
149 changed |= (high_pass_filter_enabled != high_pass_filter_enabled_); | 151 changed |= (high_pass_filter_enabled != high_pass_filter_enabled_); |
150 changed |= (echo_canceller_enabled != echo_canceller_enabled_); | 152 changed |= (echo_canceller_enabled != echo_canceller_enabled_); |
151 changed |= | 153 changed |= |
152 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_); | 154 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_); |
| 155 changed |= |
| 156 (residual_echo_detector_enabled != residual_echo_detector_enabled_); |
153 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_); | 157 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_); |
154 changed |= | 158 changed |= |
155 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_); | 159 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_); |
156 changed |= (beamformer_enabled != beamformer_enabled_); | 160 changed |= (beamformer_enabled != beamformer_enabled_); |
157 changed |= | 161 changed |= |
158 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); | 162 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); |
159 changed |= (level_controller_enabled != level_controller_enabled_); | 163 changed |= (level_controller_enabled != level_controller_enabled_); |
160 changed |= (level_estimator_enabled != level_estimator_enabled_); | 164 changed |= (level_estimator_enabled != level_estimator_enabled_); |
161 changed |= | 165 changed |= |
162 (voice_activity_detector_enabled != voice_activity_detector_enabled_); | 166 (voice_activity_detector_enabled != voice_activity_detector_enabled_); |
163 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_); | 167 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_); |
164 if (changed) { | 168 if (changed) { |
165 high_pass_filter_enabled_ = high_pass_filter_enabled; | 169 high_pass_filter_enabled_ = high_pass_filter_enabled; |
166 echo_canceller_enabled_ = echo_canceller_enabled; | 170 echo_canceller_enabled_ = echo_canceller_enabled; |
167 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled; | 171 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled; |
| 172 residual_echo_detector_enabled_ = residual_echo_detector_enabled; |
168 noise_suppressor_enabled_ = noise_suppressor_enabled; | 173 noise_suppressor_enabled_ = noise_suppressor_enabled; |
169 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled; | 174 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled; |
170 beamformer_enabled_ = beamformer_enabled; | 175 beamformer_enabled_ = beamformer_enabled; |
171 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; | 176 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; |
172 level_controller_enabled_ = level_controller_enabled; | 177 level_controller_enabled_ = level_controller_enabled; |
173 level_estimator_enabled_ = level_estimator_enabled; | 178 level_estimator_enabled_ = level_estimator_enabled; |
174 voice_activity_detector_enabled_ = voice_activity_detector_enabled; | 179 voice_activity_detector_enabled_ = voice_activity_detector_enabled; |
175 transient_suppressor_enabled_ = transient_suppressor_enabled; | 180 transient_suppressor_enabled_ = transient_suppressor_enabled; |
176 } | 181 } |
177 | 182 |
(...skipping 54 matching lines...) Loading... |
232 #endif | 237 #endif |
233 }; | 238 }; |
234 | 239 |
235 struct AudioProcessingImpl::ApmPrivateSubmodules { | 240 struct AudioProcessingImpl::ApmPrivateSubmodules { |
236 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) | 241 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
237 : beamformer(beamformer) {} | 242 : beamformer(beamformer) {} |
238 // Accessed internally from capture or during initialization | 243 // Accessed internally from capture or during initialization |
239 std::unique_ptr<NonlinearBeamformer> beamformer; | 244 std::unique_ptr<NonlinearBeamformer> beamformer; |
240 std::unique_ptr<AgcManagerDirect> agc_manager; | 245 std::unique_ptr<AgcManagerDirect> agc_manager; |
241 std::unique_ptr<LevelController> level_controller; | 246 std::unique_ptr<LevelController> level_controller; |
| 247 std::unique_ptr<ResidualEchoDetector> residual_echo_detector; |
242 }; | 248 }; |
243 | 249 |
244 AudioProcessing* AudioProcessing::Create() { | 250 AudioProcessing* AudioProcessing::Create() { |
245 webrtc::Config config; | 251 webrtc::Config config; |
246 return Create(config, nullptr); | 252 return Create(config, nullptr); |
247 } | 253 } |
248 | 254 |
249 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { | 255 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { |
250 return Create(config, nullptr); | 256 return Create(config, nullptr); |
251 } | 257 } |
(...skipping 45 matching lines...) Loading... |
297 new HighPassFilterImpl(&crit_capture_)); | 303 new HighPassFilterImpl(&crit_capture_)); |
298 public_submodules_->level_estimator.reset( | 304 public_submodules_->level_estimator.reset( |
299 new LevelEstimatorImpl(&crit_capture_)); | 305 new LevelEstimatorImpl(&crit_capture_)); |
300 public_submodules_->noise_suppression.reset( | 306 public_submodules_->noise_suppression.reset( |
301 new NoiseSuppressionImpl(&crit_capture_)); | 307 new NoiseSuppressionImpl(&crit_capture_)); |
302 public_submodules_->voice_detection.reset( | 308 public_submodules_->voice_detection.reset( |
303 new VoiceDetectionImpl(&crit_capture_)); | 309 new VoiceDetectionImpl(&crit_capture_)); |
304 public_submodules_->gain_control_for_experimental_agc.reset( | 310 public_submodules_->gain_control_for_experimental_agc.reset( |
305 new GainControlForExperimentalAgc( | 311 new GainControlForExperimentalAgc( |
306 public_submodules_->gain_control.get(), &crit_capture_)); | 312 public_submodules_->gain_control.get(), &crit_capture_)); |
| 313 private_submodules_->residual_echo_detector.reset( |
| 314 new ResidualEchoDetector()); |
307 | 315 |
308 // TODO(peah): Move this creation to happen only when the level controller | 316 // TODO(peah): Move this creation to happen only when the level controller |
309 // is enabled. | 317 // is enabled. |
310 private_submodules_->level_controller.reset(new LevelController()); | 318 private_submodules_->level_controller.reset(new LevelController()); |
311 } | 319 } |
312 | 320 |
313 SetExtraOptions(config); | 321 SetExtraOptions(config); |
314 } | 322 } |
315 | 323 |
316 AudioProcessingImpl::~AudioProcessingImpl() { | 324 AudioProcessingImpl::~AudioProcessingImpl() { |
(...skipping 145 matching lines...) Loading... |
462 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 470 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
463 InitializeIntelligibility(); | 471 InitializeIntelligibility(); |
464 #endif | 472 #endif |
465 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), | 473 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), |
466 proc_sample_rate_hz()); | 474 proc_sample_rate_hz()); |
467 public_submodules_->noise_suppression->Initialize(num_proc_channels(), | 475 public_submodules_->noise_suppression->Initialize(num_proc_channels(), |
468 proc_sample_rate_hz()); | 476 proc_sample_rate_hz()); |
469 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); | 477 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); |
470 public_submodules_->level_estimator->Initialize(); | 478 public_submodules_->level_estimator->Initialize(); |
471 InitializeLevelController(); | 479 InitializeLevelController(); |
| 480 InitializeResidualEchoDetector(); |
472 | 481 |
473 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 482 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
474 if (debug_dump_.debug_file->is_open()) { | 483 if (debug_dump_.debug_file->is_open()) { |
475 int err = WriteInitMessage(); | 484 int err = WriteInitMessage(); |
476 if (err != kNoError) { | 485 if (err != kNoError) { |
477 return err; | 486 return err; |
478 } | 487 } |
479 } | 488 } |
480 #endif | 489 #endif |
481 | 490 |
(...skipping 319 matching lines...) Loading... |
801 // Insert the samples into the queue. | 810 // Insert the samples into the queue. |
802 if (!agc_render_signal_queue_->Insert(&agc_render_queue_buffer_)) { | 811 if (!agc_render_signal_queue_->Insert(&agc_render_queue_buffer_)) { |
803 // The data queue is full and needs to be emptied. | 812 // The data queue is full and needs to be emptied. |
804 EmptyQueuedRenderAudio(); | 813 EmptyQueuedRenderAudio(); |
805 | 814 |
806 // Retry the insert (should always work). | 815 // Retry the insert (should always work). |
807 bool result = agc_render_signal_queue_->Insert(&agc_render_queue_buffer_); | 816 bool result = agc_render_signal_queue_->Insert(&agc_render_queue_buffer_); |
808 RTC_DCHECK(result); | 817 RTC_DCHECK(result); |
809 } | 818 } |
810 } | 819 } |
| 820 |
| 821 ResidualEchoDetector::PackRenderAudioBuffer(audio, &red_render_queue_buffer_); |
| 822 |
| 823 // Insert the samples into the queue. |
| 824 if (!red_render_signal_queue_->Insert(&red_render_queue_buffer_)) { |
| 825 // The data queue is full and needs to be emptied. |
| 826 EmptyQueuedRenderAudio(); |
| 827 |
| 828 // Retry the insert (should always work). |
| 829 bool result = red_render_signal_queue_->Insert(&red_render_queue_buffer_); |
| 830 RTC_DCHECK(result); |
| 831 } |
811 } | 832 } |
812 | 833 |
813 void AudioProcessingImpl::AllocateRenderQueue() { | 834 void AudioProcessingImpl::AllocateRenderQueue() { |
814 const size_t new_aec_render_queue_element_max_size = | 835 const size_t new_aec_render_queue_element_max_size = |
815 std::max(static_cast<size_t>(1), | 836 std::max(static_cast<size_t>(1), |
816 kMaxAllowedValuesOfSamplesPerFrame * | 837 kMaxAllowedValuesOfSamplesPerFrame * |
817 EchoCancellationImpl::NumCancellersRequired( | 838 EchoCancellationImpl::NumCancellersRequired( |
818 num_output_channels(), num_reverse_channels())); | 839 num_output_channels(), num_reverse_channels())); |
819 | 840 |
820 const size_t new_aecm_render_queue_element_max_size = | 841 const size_t new_aecm_render_queue_element_max_size = |
821 std::max(static_cast<size_t>(1), | 842 std::max(static_cast<size_t>(1), |
822 kMaxAllowedValuesOfSamplesPerFrame * | 843 kMaxAllowedValuesOfSamplesPerFrame * |
823 EchoControlMobileImpl::NumCancellersRequired( | 844 EchoControlMobileImpl::NumCancellersRequired( |
824 num_output_channels(), num_reverse_channels())); | 845 num_output_channels(), num_reverse_channels())); |
825 | 846 |
826 const size_t new_agc_render_queue_element_max_size = | 847 const size_t new_agc_render_queue_element_max_size = |
827 std::max(static_cast<size_t>(1), kMaxAllowedValuesOfSamplesPerFrame); | 848 std::max(static_cast<size_t>(1), kMaxAllowedValuesOfSamplesPerFrame); |
828 | 849 |
| 850 const size_t new_red_render_queue_element_max_size = |
| 851 std::max(static_cast<size_t>(1), kMaxAllowedValuesOfSamplesPerFrame); |
| 852 |
829 // Reallocate the queues if the queue item sizes are too small to fit the | 853 // Reallocate the queues if the queue item sizes are too small to fit the |
830 // data to put in the queues. | 854 // data to put in the queues. |
831 if (aec_render_queue_element_max_size_ < | 855 if (aec_render_queue_element_max_size_ < |
832 new_aec_render_queue_element_max_size) { | 856 new_aec_render_queue_element_max_size) { |
833 aec_render_queue_element_max_size_ = new_aec_render_queue_element_max_size; | 857 aec_render_queue_element_max_size_ = new_aec_render_queue_element_max_size; |
834 | 858 |
835 std::vector<float> template_queue_element( | 859 std::vector<float> template_queue_element( |
836 aec_render_queue_element_max_size_); | 860 aec_render_queue_element_max_size_); |
837 | 861 |
838 aec_render_signal_queue_.reset( | 862 aec_render_signal_queue_.reset( |
(...skipping 39 matching lines...) Loading... |
878 new SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>( | 902 new SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>( |
879 kMaxNumFramesToBuffer, template_queue_element, | 903 kMaxNumFramesToBuffer, template_queue_element, |
880 RenderQueueItemVerifier<int16_t>( | 904 RenderQueueItemVerifier<int16_t>( |
881 agc_render_queue_element_max_size_))); | 905 agc_render_queue_element_max_size_))); |
882 | 906 |
883 agc_render_queue_buffer_.resize(agc_render_queue_element_max_size_); | 907 agc_render_queue_buffer_.resize(agc_render_queue_element_max_size_); |
884 agc_capture_queue_buffer_.resize(agc_render_queue_element_max_size_); | 908 agc_capture_queue_buffer_.resize(agc_render_queue_element_max_size_); |
885 } else { | 909 } else { |
886 agc_render_signal_queue_->Clear(); | 910 agc_render_signal_queue_->Clear(); |
887 } | 911 } |
| 912 |
| 913 if (red_render_queue_element_max_size_ < |
| 914 new_red_render_queue_element_max_size) { |
| 915 red_render_queue_element_max_size_ = new_red_render_queue_element_max_size; |
| 916 |
| 917 std::vector<float> template_queue_element( |
| 918 red_render_queue_element_max_size_); |
| 919 |
| 920 red_render_signal_queue_.reset( |
| 921 new SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>( |
| 922 kMaxNumFramesToBuffer, template_queue_element, |
| 923 RenderQueueItemVerifier<float>( |
| 924 red_render_queue_element_max_size_))); |
| 925 |
| 926 red_render_queue_buffer_.resize(red_render_queue_element_max_size_); |
| 927 red_capture_queue_buffer_.resize(red_render_queue_element_max_size_); |
| 928 } else { |
| 929 red_render_signal_queue_->Clear(); |
| 930 } |
888 } | 931 } |
889 | 932 |
890 void AudioProcessingImpl::EmptyQueuedRenderAudio() { | 933 void AudioProcessingImpl::EmptyQueuedRenderAudio() { |
891 rtc::CritScope cs_capture(&crit_capture_); | 934 rtc::CritScope cs_capture(&crit_capture_); |
892 while (aec_render_signal_queue_->Remove(&aec_capture_queue_buffer_)) { | 935 while (aec_render_signal_queue_->Remove(&aec_capture_queue_buffer_)) { |
893 public_submodules_->echo_cancellation->ProcessRenderAudio( | 936 public_submodules_->echo_cancellation->ProcessRenderAudio( |
894 aec_capture_queue_buffer_); | 937 aec_capture_queue_buffer_); |
895 } | 938 } |
896 | 939 |
897 while (aecm_render_signal_queue_->Remove(&aecm_capture_queue_buffer_)) { | 940 while (aecm_render_signal_queue_->Remove(&aecm_capture_queue_buffer_)) { |
898 public_submodules_->echo_control_mobile->ProcessRenderAudio( | 941 public_submodules_->echo_control_mobile->ProcessRenderAudio( |
899 aecm_capture_queue_buffer_); | 942 aecm_capture_queue_buffer_); |
900 } | 943 } |
901 | 944 |
902 while (agc_render_signal_queue_->Remove(&agc_capture_queue_buffer_)) { | 945 while (agc_render_signal_queue_->Remove(&agc_capture_queue_buffer_)) { |
903 public_submodules_->gain_control->ProcessRenderAudio( | 946 public_submodules_->gain_control->ProcessRenderAudio( |
904 agc_capture_queue_buffer_); | 947 agc_capture_queue_buffer_); |
905 } | 948 } |
| 949 |
| 950 while (red_render_signal_queue_->Remove(&red_capture_queue_buffer_)) { |
| 951 private_submodules_->residual_echo_detector->AnalyzeRenderAudio( |
| 952 red_capture_queue_buffer_); |
| 953 } |
906 } | 954 } |
907 | 955 |
908 int AudioProcessingImpl::ProcessStream(AudioFrame* frame) { | 956 int AudioProcessingImpl::ProcessStream(AudioFrame* frame) { |
909 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_AudioFrame"); | 957 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_AudioFrame"); |
910 { | 958 { |
911 // Acquire the capture lock in order to safely call the function | 959 // Acquire the capture lock in order to safely call the function |
912 // that retrieves the render side data. This function accesses apm | 960 // that retrieves the render side data. This function accesses apm |
913 // getters that need the capture lock held when being called. | 961 // getters that need the capture lock held when being called. |
914 // The lock needs to be released as | 962 // The lock needs to be released as |
915 // public_submodules_->echo_control_mobile->is_enabled() aquires this lock | 963 // public_submodules_->echo_control_mobile->is_enabled() aquires this lock |
(...skipping 155 matching lines...) Loading... |
1071 // Ensure that the stream delay was set before the call to the | 1119 // Ensure that the stream delay was set before the call to the |
1072 // AECM ProcessCaptureAudio function. | 1120 // AECM ProcessCaptureAudio function. |
1073 if (public_submodules_->echo_control_mobile->is_enabled() && | 1121 if (public_submodules_->echo_control_mobile->is_enabled() && |
1074 !was_stream_delay_set()) { | 1122 !was_stream_delay_set()) { |
1075 return AudioProcessing::kStreamParameterNotSetError; | 1123 return AudioProcessing::kStreamParameterNotSetError; |
1076 } | 1124 } |
1077 | 1125 |
1078 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( | 1126 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( |
1079 capture_buffer, stream_delay_ms())); | 1127 capture_buffer, stream_delay_ms())); |
1080 | 1128 |
| 1129 if (config_.residual_echo_detector.enabled) { |
| 1130 private_submodules_->residual_echo_detector->AnalyzeCaptureAudio( |
| 1131 rtc::ArrayView<const float>( |
| 1132 capture_buffer->split_bands_const_f(0)[kBand0To8kHz], |
| 1133 capture_buffer->num_frames_per_band())); |
| 1134 } |
| 1135 |
1081 if (capture_nonlocked_.beamformer_enabled) { | 1136 if (capture_nonlocked_.beamformer_enabled) { |
1082 private_submodules_->beamformer->PostFilter(capture_buffer->split_data_f()); | 1137 private_submodules_->beamformer->PostFilter(capture_buffer->split_data_f()); |
1083 } | 1138 } |
1084 | 1139 |
1085 public_submodules_->voice_detection->ProcessCaptureAudio(capture_buffer); | 1140 public_submodules_->voice_detection->ProcessCaptureAudio(capture_buffer); |
1086 | 1141 |
1087 if (constants_.use_experimental_agc && | 1142 if (constants_.use_experimental_agc && |
1088 public_submodules_->gain_control->is_enabled() && | 1143 public_submodules_->gain_control->is_enabled() && |
1089 (!capture_nonlocked_.beamformer_enabled || | 1144 (!capture_nonlocked_.beamformer_enabled || |
1090 private_submodules_->beamformer->is_target_present())) { | 1145 private_submodules_->beamformer->is_target_present())) { |
(...skipping 355 matching lines...) Loading... |
1446 | 1501 |
1447 VoiceDetection* AudioProcessingImpl::voice_detection() const { | 1502 VoiceDetection* AudioProcessingImpl::voice_detection() const { |
1448 return public_submodules_->voice_detection.get(); | 1503 return public_submodules_->voice_detection.get(); |
1449 } | 1504 } |
1450 | 1505 |
1451 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { | 1506 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { |
1452 return submodule_states_.Update( | 1507 return submodule_states_.Update( |
1453 public_submodules_->high_pass_filter->is_enabled(), | 1508 public_submodules_->high_pass_filter->is_enabled(), |
1454 public_submodules_->echo_cancellation->is_enabled(), | 1509 public_submodules_->echo_cancellation->is_enabled(), |
1455 public_submodules_->echo_control_mobile->is_enabled(), | 1510 public_submodules_->echo_control_mobile->is_enabled(), |
| 1511 config_.residual_echo_detector.enabled, |
1456 public_submodules_->noise_suppression->is_enabled(), | 1512 public_submodules_->noise_suppression->is_enabled(), |
1457 capture_nonlocked_.intelligibility_enabled, | 1513 capture_nonlocked_.intelligibility_enabled, |
1458 capture_nonlocked_.beamformer_enabled, | 1514 capture_nonlocked_.beamformer_enabled, |
1459 public_submodules_->gain_control->is_enabled(), | 1515 public_submodules_->gain_control->is_enabled(), |
1460 capture_nonlocked_.level_controller_enabled, | 1516 capture_nonlocked_.level_controller_enabled, |
1461 public_submodules_->voice_detection->is_enabled(), | 1517 public_submodules_->voice_detection->is_enabled(), |
1462 public_submodules_->level_estimator->is_enabled(), | 1518 public_submodules_->level_estimator->is_enabled(), |
1463 capture_.transient_suppressor_enabled); | 1519 capture_.transient_suppressor_enabled); |
1464 } | 1520 } |
1465 | 1521 |
(...skipping 29 matching lines...) Loading... |
1495 render_.render_audio->num_bands(), | 1551 render_.render_audio->num_bands(), |
1496 NoiseSuppressionImpl::num_noise_bins())); | 1552 NoiseSuppressionImpl::num_noise_bins())); |
1497 } | 1553 } |
1498 #endif | 1554 #endif |
1499 } | 1555 } |
1500 | 1556 |
1501 void AudioProcessingImpl::InitializeLevelController() { | 1557 void AudioProcessingImpl::InitializeLevelController() { |
1502 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); | 1558 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); |
1503 } | 1559 } |
1504 | 1560 |
| 1561 void AudioProcessingImpl::InitializeResidualEchoDetector() { |
| 1562 private_submodules_->residual_echo_detector->Initialize(); |
| 1563 } |
| 1564 |
1505 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1565 void AudioProcessingImpl::MaybeUpdateHistograms() { |
1506 static const int kMinDiffDelayMs = 60; | 1566 static const int kMinDiffDelayMs = 60; |
1507 | 1567 |
1508 if (echo_cancellation()->is_enabled()) { | 1568 if (echo_cancellation()->is_enabled()) { |
1509 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. | 1569 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. |
1510 // If a stream has echo we know that the echo_cancellation is in process. | 1570 // If a stream has echo we know that the echo_cancellation is in process. |
1511 if (capture_.stream_delay_jumps == -1 && | 1571 if (capture_.stream_delay_jumps == -1 && |
1512 echo_cancellation()->stream_has_echo()) { | 1572 echo_cancellation()->stream_has_echo()) { |
1513 capture_.stream_delay_jumps = 0; | 1573 capture_.stream_delay_jumps = 0; |
1514 } | 1574 } |
(...skipping 218 matching lines...) Loading... |
1733 capture_processing_format(kSampleRate16kHz), | 1793 capture_processing_format(kSampleRate16kHz), |
1734 split_rate(kSampleRate16kHz) {} | 1794 split_rate(kSampleRate16kHz) {} |
1735 | 1795 |
1736 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1796 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
1737 | 1797 |
1738 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1798 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
1739 | 1799 |
1740 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1800 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
1741 | 1801 |
1742 } // namespace webrtc | 1802 } // namespace webrtc |
OLD | NEW |