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