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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 assert(false); | 74 assert(false); |
75 return false; | 75 return false; |
76 } | 76 } |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 struct AudioProcessingImpl::ApmPublicSubmodules { | 79 struct AudioProcessingImpl::ApmPublicSubmodules { |
80 ApmPublicSubmodules() | 80 ApmPublicSubmodules() |
81 : echo_cancellation(nullptr), | 81 : echo_cancellation(nullptr), |
82 echo_control_mobile(nullptr), | 82 echo_control_mobile(nullptr), |
83 gain_control(nullptr), | 83 gain_control(nullptr), |
84 high_pass_filter(nullptr), | |
85 level_estimator(nullptr), | 84 level_estimator(nullptr), |
86 noise_suppression(nullptr), | 85 noise_suppression(nullptr), |
87 voice_detection(nullptr) {} | 86 voice_detection(nullptr) {} |
88 // Accessed externally of APM without any lock acquired. | 87 // Accessed externally of APM without any lock acquired. |
89 EchoCancellationImpl* echo_cancellation; | 88 EchoCancellationImpl* echo_cancellation; |
90 EchoControlMobileImpl* echo_control_mobile; | 89 EchoControlMobileImpl* echo_control_mobile; |
91 GainControlImpl* gain_control; | 90 GainControlImpl* gain_control; |
92 HighPassFilterImpl* high_pass_filter; | 91 rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter; |
93 LevelEstimatorImpl* level_estimator; | 92 LevelEstimatorImpl* level_estimator; |
94 NoiseSuppressionImpl* noise_suppression; | 93 NoiseSuppressionImpl* noise_suppression; |
95 VoiceDetectionImpl* voice_detection; | 94 VoiceDetectionImpl* voice_detection; |
96 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc; | 95 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc; |
97 | 96 |
98 // Accessed internally from both render and capture. | 97 // Accessed internally from both render and capture. |
99 rtc::scoped_ptr<TransientSuppressor> transient_suppressor; | 98 rtc::scoped_ptr<TransientSuppressor> transient_suppressor; |
100 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 99 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
101 }; | 100 }; |
102 | 101 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 { | 235 { |
237 rtc::CritScope cs_render(&crit_render_); | 236 rtc::CritScope cs_render(&crit_render_); |
238 rtc::CritScope cs_capture(&crit_capture_); | 237 rtc::CritScope cs_capture(&crit_capture_); |
239 | 238 |
240 public_submodules_->echo_cancellation = | 239 public_submodules_->echo_cancellation = |
241 new EchoCancellationImpl(this, &crit_render_, &crit_capture_); | 240 new EchoCancellationImpl(this, &crit_render_, &crit_capture_); |
242 public_submodules_->echo_control_mobile = | 241 public_submodules_->echo_control_mobile = |
243 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); | 242 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); |
244 public_submodules_->gain_control = | 243 public_submodules_->gain_control = |
245 new GainControlImpl(this, &crit_capture_, &crit_capture_); | 244 new GainControlImpl(this, &crit_capture_, &crit_capture_); |
246 public_submodules_->high_pass_filter = | 245 public_submodules_->high_pass_filter.reset( |
247 new HighPassFilterImpl(this, &crit_capture_); | 246 new HighPassFilterImpl(&crit_capture_)); |
248 public_submodules_->level_estimator = | 247 public_submodules_->level_estimator = |
249 new LevelEstimatorImpl(this, &crit_capture_); | 248 new LevelEstimatorImpl(this, &crit_capture_); |
250 public_submodules_->noise_suppression = | 249 public_submodules_->noise_suppression = |
251 new NoiseSuppressionImpl(this, &crit_capture_); | 250 new NoiseSuppressionImpl(this, &crit_capture_); |
252 public_submodules_->voice_detection = | 251 public_submodules_->voice_detection = |
253 new VoiceDetectionImpl(this, &crit_capture_); | 252 new VoiceDetectionImpl(this, &crit_capture_); |
254 public_submodules_->gain_control_for_new_agc.reset( | 253 public_submodules_->gain_control_for_new_agc.reset( |
255 new GainControlForNewAgc(public_submodules_->gain_control)); | 254 new GainControlForNewAgc(public_submodules_->gain_control)); |
256 | 255 |
257 private_submodules_->component_list.push_back( | 256 private_submodules_->component_list.push_back( |
258 public_submodules_->echo_cancellation); | 257 public_submodules_->echo_cancellation); |
259 private_submodules_->component_list.push_back( | 258 private_submodules_->component_list.push_back( |
260 public_submodules_->echo_control_mobile); | 259 public_submodules_->echo_control_mobile); |
261 private_submodules_->component_list.push_back( | 260 private_submodules_->component_list.push_back( |
262 public_submodules_->gain_control); | 261 public_submodules_->gain_control); |
263 private_submodules_->component_list.push_back( | 262 private_submodules_->component_list.push_back( |
264 public_submodules_->high_pass_filter); | |
265 private_submodules_->component_list.push_back( | |
266 public_submodules_->level_estimator); | 263 public_submodules_->level_estimator); |
267 private_submodules_->component_list.push_back( | 264 private_submodules_->component_list.push_back( |
268 public_submodules_->noise_suppression); | 265 public_submodules_->noise_suppression); |
269 private_submodules_->component_list.push_back( | 266 private_submodules_->component_list.push_back( |
270 public_submodules_->voice_detection); | 267 public_submodules_->voice_detection); |
271 } | 268 } |
272 | 269 |
273 SetExtraOptions(config); | 270 SetExtraOptions(config); |
274 } | 271 } |
275 | 272 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 396 } |
400 | 397 |
401 InitializeExperimentalAgc(); | 398 InitializeExperimentalAgc(); |
402 | 399 |
403 InitializeTransient(); | 400 InitializeTransient(); |
404 | 401 |
405 InitializeBeamformer(); | 402 InitializeBeamformer(); |
406 | 403 |
407 InitializeIntelligibility(); | 404 InitializeIntelligibility(); |
408 | 405 |
| 406 InitializeHighPassFilter(); |
| 407 |
409 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 408 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
410 if (debug_dump_.debug_file->Open()) { | 409 if (debug_dump_.debug_file->Open()) { |
411 int err = WriteInitMessage(); | 410 int err = WriteInitMessage(); |
412 if (err != kNoError) { | 411 if (err != kNoError) { |
413 return err; | 412 return err; |
414 } | 413 } |
415 } | 414 } |
416 #endif | 415 #endif |
417 | 416 |
418 return kNoError; | 417 return kNoError; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 ca->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, | 759 ca->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, |
761 ca->num_channels()); | 760 ca->num_channels()); |
762 } | 761 } |
763 | 762 |
764 if (constants_.beamformer_enabled) { | 763 if (constants_.beamformer_enabled) { |
765 private_submodules_->beamformer->ProcessChunk(*ca->split_data_f(), | 764 private_submodules_->beamformer->ProcessChunk(*ca->split_data_f(), |
766 ca->split_data_f()); | 765 ca->split_data_f()); |
767 ca->set_num_channels(1); | 766 ca->set_num_channels(1); |
768 } | 767 } |
769 | 768 |
770 RETURN_ON_ERR(public_submodules_->high_pass_filter->ProcessCaptureAudio(ca)); | 769 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); |
771 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); | 770 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); |
772 RETURN_ON_ERR(public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca)); | 771 RETURN_ON_ERR(public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca)); |
773 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(ca)); | 772 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(ca)); |
774 | 773 |
775 if (public_submodules_->echo_control_mobile->is_enabled() && | 774 if (public_submodules_->echo_control_mobile->is_enabled() && |
776 public_submodules_->noise_suppression->is_enabled()) { | 775 public_submodules_->noise_suppression->is_enabled()) { |
777 ca->CopyLowPassToReference(); | 776 ca->CopyLowPassToReference(); |
778 } | 777 } |
779 RETURN_ON_ERR(public_submodules_->noise_suppression->ProcessCaptureAudio(ca)); | 778 RETURN_ON_ERR(public_submodules_->noise_suppression->ProcessCaptureAudio(ca)); |
780 RETURN_ON_ERR( | 779 RETURN_ON_ERR( |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 // from the returned pointer. | 1139 // from the returned pointer. |
1141 if (constants_.use_new_agc) { | 1140 if (constants_.use_new_agc) { |
1142 return public_submodules_->gain_control_for_new_agc.get(); | 1141 return public_submodules_->gain_control_for_new_agc.get(); |
1143 } | 1142 } |
1144 return public_submodules_->gain_control; | 1143 return public_submodules_->gain_control; |
1145 } | 1144 } |
1146 | 1145 |
1147 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { | 1146 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { |
1148 // Adding a lock here has no effect as it allows any access to the submodule | 1147 // Adding a lock here has no effect as it allows any access to the submodule |
1149 // from the returned pointer. | 1148 // from the returned pointer. |
1150 return public_submodules_->high_pass_filter; | 1149 return public_submodules_->high_pass_filter.get(); |
1151 } | 1150 } |
1152 | 1151 |
1153 LevelEstimator* AudioProcessingImpl::level_estimator() const { | 1152 LevelEstimator* AudioProcessingImpl::level_estimator() const { |
1154 // Adding a lock here has no effect as it allows any access to the submodule | 1153 // Adding a lock here has no effect as it allows any access to the submodule |
1155 // from the returned pointer. | 1154 // from the returned pointer. |
1156 return public_submodules_->level_estimator; | 1155 return public_submodules_->level_estimator; |
1157 } | 1156 } |
1158 | 1157 |
1159 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { | 1158 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { |
1160 // Adding a lock here has no effect as it allows any access to the submodule | 1159 // Adding a lock here has no effect as it allows any access to the submodule |
(...skipping 11 matching lines...) Expand all Loading... |
1172 if (constants_.beamformer_enabled) { | 1171 if (constants_.beamformer_enabled) { |
1173 return true; | 1172 return true; |
1174 } | 1173 } |
1175 | 1174 |
1176 int enabled_count = 0; | 1175 int enabled_count = 0; |
1177 for (auto item : private_submodules_->component_list) { | 1176 for (auto item : private_submodules_->component_list) { |
1178 if (item->is_component_enabled()) { | 1177 if (item->is_component_enabled()) { |
1179 enabled_count++; | 1178 enabled_count++; |
1180 } | 1179 } |
1181 } | 1180 } |
| 1181 if (public_submodules_->high_pass_filter->is_enabled()) { |
| 1182 enabled_count++; |
| 1183 } |
1182 | 1184 |
1183 // Data is unchanged if no components are enabled, or if only | 1185 // Data is unchanged if no components are enabled, or if only |
1184 // public_submodules_->level_estimator | 1186 // public_submodules_->level_estimator |
1185 // or public_submodules_->voice_detection is enabled. | 1187 // or public_submodules_->voice_detection is enabled. |
1186 if (enabled_count == 0) { | 1188 if (enabled_count == 0) { |
1187 return false; | 1189 return false; |
1188 } else if (enabled_count == 1) { | 1190 } else if (enabled_count == 1) { |
1189 if (public_submodules_->level_estimator->is_enabled() || | 1191 if (public_submodules_->level_estimator->is_enabled() || |
1190 public_submodules_->voice_detection->is_enabled()) { | 1192 public_submodules_->voice_detection->is_enabled()) { |
1191 return false; | 1193 return false; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 if (constants_.intelligibility_enabled) { | 1288 if (constants_.intelligibility_enabled) { |
1287 IntelligibilityEnhancer::Config config; | 1289 IntelligibilityEnhancer::Config config; |
1288 config.sample_rate_hz = capture_nonlocked_.split_rate; | 1290 config.sample_rate_hz = capture_nonlocked_.split_rate; |
1289 config.num_capture_channels = capture_.capture_audio->num_channels(); | 1291 config.num_capture_channels = capture_.capture_audio->num_channels(); |
1290 config.num_render_channels = render_.render_audio->num_channels(); | 1292 config.num_render_channels = render_.render_audio->num_channels(); |
1291 public_submodules_->intelligibility_enhancer.reset( | 1293 public_submodules_->intelligibility_enhancer.reset( |
1292 new IntelligibilityEnhancer(config)); | 1294 new IntelligibilityEnhancer(config)); |
1293 } | 1295 } |
1294 } | 1296 } |
1295 | 1297 |
| 1298 void AudioProcessingImpl::InitializeHighPassFilter() { |
| 1299 public_submodules_->high_pass_filter->Initialize(num_output_channels(), |
| 1300 proc_sample_rate_hz()); |
| 1301 } |
| 1302 |
1296 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1303 void AudioProcessingImpl::MaybeUpdateHistograms() { |
1297 static const int kMinDiffDelayMs = 60; | 1304 static const int kMinDiffDelayMs = 60; |
1298 | 1305 |
1299 if (echo_cancellation()->is_enabled()) { | 1306 if (echo_cancellation()->is_enabled()) { |
1300 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. | 1307 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. |
1301 // If a stream has echo we know that the echo_cancellation is in process. | 1308 // If a stream has echo we know that the echo_cancellation is in process. |
1302 if (capture_.stream_delay_jumps == -1 && | 1309 if (capture_.stream_delay_jumps == -1 && |
1303 echo_cancellation()->stream_has_echo()) { | 1310 echo_cancellation()->stream_has_echo()) { |
1304 capture_.stream_delay_jumps = 0; | 1311 capture_.stream_delay_jumps = 0; |
1305 } | 1312 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); | 1477 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); |
1471 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1478 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1472 | 1479 |
1473 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1480 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1474 &crit_debug_, &debug_dump_.capture)); | 1481 &crit_debug_, &debug_dump_.capture)); |
1475 return kNoError; | 1482 return kNoError; |
1476 } | 1483 } |
1477 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1484 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1478 | 1485 |
1479 } // namespace webrtc | 1486 } // namespace webrtc |
OLD | NEW |