Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1494593004: Make VoiceDetection not a ProcessingComponent. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 private: 143 private:
144 GainControl* real_gain_control_; 144 GainControl* real_gain_control_;
145 int volume_; 145 int volume_;
146 }; 146 };
147 147
148 struct AudioProcessingImpl::ApmPublicSubmodules { 148 struct AudioProcessingImpl::ApmPublicSubmodules {
149 ApmPublicSubmodules() 149 ApmPublicSubmodules()
150 : echo_cancellation(nullptr), 150 : echo_cancellation(nullptr),
151 echo_control_mobile(nullptr), 151 echo_control_mobile(nullptr),
152 gain_control(nullptr), 152 gain_control(nullptr) {}
153 voice_detection(nullptr) {}
154 // Accessed externally of APM without any lock acquired. 153 // Accessed externally of APM without any lock acquired.
155 EchoCancellationImpl* echo_cancellation; 154 EchoCancellationImpl* echo_cancellation;
156 EchoControlMobileImpl* echo_control_mobile; 155 EchoControlMobileImpl* echo_control_mobile;
157 GainControlImpl* gain_control; 156 GainControlImpl* gain_control;
158 rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter; 157 rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter;
159 rtc::scoped_ptr<LevelEstimatorImpl> level_estimator; 158 rtc::scoped_ptr<LevelEstimatorImpl> level_estimator;
160 rtc::scoped_ptr<NoiseSuppressionImpl> noise_suppression; 159 rtc::scoped_ptr<NoiseSuppressionImpl> noise_suppression;
161 VoiceDetectionImpl* voice_detection; 160 rtc::scoped_ptr<VoiceDetectionImpl> voice_detection;
162 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc; 161 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc;
163 162
164 // Accessed internally from both render and capture. 163 // Accessed internally from both render and capture.
165 rtc::scoped_ptr<TransientSuppressor> transient_suppressor; 164 rtc::scoped_ptr<TransientSuppressor> transient_suppressor;
166 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer; 165 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer;
167 }; 166 };
168 167
169 struct AudioProcessingImpl::ApmPrivateSubmodules { 168 struct AudioProcessingImpl::ApmPrivateSubmodules {
170 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer) 169 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer)
171 : beamformer(beamformer) {} 170 : beamformer(beamformer) {}
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 public_submodules_->echo_control_mobile = 238 public_submodules_->echo_control_mobile =
240 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); 239 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_);
241 public_submodules_->gain_control = 240 public_submodules_->gain_control =
242 new GainControlImpl(this, &crit_capture_, &crit_capture_); 241 new GainControlImpl(this, &crit_capture_, &crit_capture_);
243 public_submodules_->high_pass_filter.reset( 242 public_submodules_->high_pass_filter.reset(
244 new HighPassFilterImpl(&crit_capture_)); 243 new HighPassFilterImpl(&crit_capture_));
245 public_submodules_->level_estimator.reset( 244 public_submodules_->level_estimator.reset(
246 new LevelEstimatorImpl(&crit_capture_)); 245 new LevelEstimatorImpl(&crit_capture_));
247 public_submodules_->noise_suppression.reset( 246 public_submodules_->noise_suppression.reset(
248 new NoiseSuppressionImpl(&crit_capture_)); 247 new NoiseSuppressionImpl(&crit_capture_));
249 public_submodules_->voice_detection = 248 public_submodules_->voice_detection.reset(
250 new VoiceDetectionImpl(this, &crit_capture_); 249 new VoiceDetectionImpl(&crit_capture_));
251 public_submodules_->gain_control_for_new_agc.reset( 250 public_submodules_->gain_control_for_new_agc.reset(
252 new GainControlForNewAgc(public_submodules_->gain_control)); 251 new GainControlForNewAgc(public_submodules_->gain_control));
253 252
254 private_submodules_->component_list.push_back( 253 private_submodules_->component_list.push_back(
255 public_submodules_->echo_cancellation); 254 public_submodules_->echo_cancellation);
256 private_submodules_->component_list.push_back( 255 private_submodules_->component_list.push_back(
257 public_submodules_->echo_control_mobile); 256 public_submodules_->echo_control_mobile);
258 private_submodules_->component_list.push_back( 257 private_submodules_->component_list.push_back(
259 public_submodules_->gain_control); 258 public_submodules_->gain_control);
260 private_submodules_->component_list.push_back(
261 public_submodules_->voice_detection);
262 } 259 }
263 260
264 SetExtraOptions(config); 261 SetExtraOptions(config);
265 } 262 }
266 263
267 AudioProcessingImpl::~AudioProcessingImpl() { 264 AudioProcessingImpl::~AudioProcessingImpl() {
268 // Depends on gain_control_ and 265 // Depends on gain_control_ and
269 // public_submodules_->gain_control_for_new_agc. 266 // public_submodules_->gain_control_for_new_agc.
270 private_submodules_->agc_manager.reset(); 267 private_submodules_->agc_manager.reset();
271 // Depends on gain_control_. 268 // Depends on gain_control_.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 386 }
390 } 387 }
391 388
392 InitializeExperimentalAgc(); 389 InitializeExperimentalAgc();
393 InitializeTransient(); 390 InitializeTransient();
394 InitializeBeamformer(); 391 InitializeBeamformer();
395 InitializeIntelligibility(); 392 InitializeIntelligibility();
396 InitializeHighPassFilter(); 393 InitializeHighPassFilter();
397 InitializeNoiseSuppression(); 394 InitializeNoiseSuppression();
398 InitializeLevelEstimator(); 395 InitializeLevelEstimator();
396 InitializeVoiceDetection();
399 397
400 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 398 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
401 if (debug_dump_.debug_file->Open()) { 399 if (debug_dump_.debug_file->Open()) {
402 int err = WriteInitMessage(); 400 int err = WriteInitMessage();
403 if (err != kNoError) { 401 if (err != kNoError) {
404 return err; 402 return err;
405 } 403 }
406 } 404 }
407 #endif 405 #endif
408 406
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); 767 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca);
770 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(ca)); 768 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(ca));
771 769
772 if (public_submodules_->echo_control_mobile->is_enabled() && 770 if (public_submodules_->echo_control_mobile->is_enabled() &&
773 public_submodules_->noise_suppression->is_enabled()) { 771 public_submodules_->noise_suppression->is_enabled()) {
774 ca->CopyLowPassToReference(); 772 ca->CopyLowPassToReference();
775 } 773 }
776 public_submodules_->noise_suppression->ProcessCaptureAudio(ca); 774 public_submodules_->noise_suppression->ProcessCaptureAudio(ca);
777 RETURN_ON_ERR( 775 RETURN_ON_ERR(
778 public_submodules_->echo_control_mobile->ProcessCaptureAudio(ca)); 776 public_submodules_->echo_control_mobile->ProcessCaptureAudio(ca));
779 RETURN_ON_ERR(public_submodules_->voice_detection->ProcessCaptureAudio(ca)); 777 public_submodules_->voice_detection->ProcessCaptureAudio(ca);
780 778
781 if (constants_.use_new_agc && 779 if (constants_.use_new_agc &&
782 public_submodules_->gain_control->is_enabled() && 780 public_submodules_->gain_control->is_enabled() &&
783 (!constants_.beamformer_enabled || 781 (!constants_.beamformer_enabled ||
784 private_submodules_->beamformer->is_target_present())) { 782 private_submodules_->beamformer->is_target_present())) {
785 private_submodules_->agc_manager->Process( 783 private_submodules_->agc_manager->Process(
786 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), 784 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(),
787 capture_nonlocked_.split_rate); 785 capture_nonlocked_.split_rate);
788 } 786 }
789 RETURN_ON_ERR(public_submodules_->gain_control->ProcessCaptureAudio(ca)); 787 RETURN_ON_ERR(public_submodules_->gain_control->ProcessCaptureAudio(ca));
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1153
1156 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { 1154 NoiseSuppression* AudioProcessingImpl::noise_suppression() const {
1157 // Adding a lock here has no effect as it allows any access to the submodule 1155 // Adding a lock here has no effect as it allows any access to the submodule
1158 // from the returned pointer. 1156 // from the returned pointer.
1159 return public_submodules_->noise_suppression.get(); 1157 return public_submodules_->noise_suppression.get();
1160 } 1158 }
1161 1159
1162 VoiceDetection* AudioProcessingImpl::voice_detection() const { 1160 VoiceDetection* AudioProcessingImpl::voice_detection() const {
1163 // Adding a lock here has no effect as it allows any access to the submodule 1161 // Adding a lock here has no effect as it allows any access to the submodule
1164 // from the returned pointer. 1162 // from the returned pointer.
1165 return public_submodules_->voice_detection; 1163 return public_submodules_->voice_detection.get();
1166 } 1164 }
1167 1165
1168 bool AudioProcessingImpl::is_data_processed() const { 1166 bool AudioProcessingImpl::is_data_processed() const {
1169 if (constants_.beamformer_enabled) { 1167 if (constants_.beamformer_enabled) {
1170 return true; 1168 return true;
1171 } 1169 }
1172 1170
1173 int enabled_count = 0; 1171 int enabled_count = 0;
1174 for (auto item : private_submodules_->component_list) { 1172 for (auto item : private_submodules_->component_list) {
1175 if (item->is_component_enabled()) { 1173 if (item->is_component_enabled()) {
1176 enabled_count++; 1174 enabled_count++;
1177 } 1175 }
1178 } 1176 }
1179 if (public_submodules_->high_pass_filter->is_enabled()) { 1177 if (public_submodules_->high_pass_filter->is_enabled()) {
1180 enabled_count++; 1178 enabled_count++;
1181 } 1179 }
1182 if (public_submodules_->noise_suppression->is_enabled()) { 1180 if (public_submodules_->noise_suppression->is_enabled()) {
1183 enabled_count++; 1181 enabled_count++;
1184 } 1182 }
1185 if (public_submodules_->level_estimator->is_enabled()) { 1183 if (public_submodules_->level_estimator->is_enabled()) {
1186 enabled_count++; 1184 enabled_count++;
1187 } 1185 }
1186 if (public_submodules_->voice_detection->is_enabled()) {
1187 enabled_count++;
1188 }
1188 1189
1189 // Data is unchanged if no components are enabled, or if only 1190 // Data is unchanged if no components are enabled, or if only
1190 // public_submodules_->level_estimator 1191 // public_submodules_->level_estimator
1191 // or public_submodules_->voice_detection is enabled. 1192 // or public_submodules_->voice_detection is enabled.
1192 if (enabled_count == 0) { 1193 if (enabled_count == 0) {
1193 return false; 1194 return false;
1194 } else if (enabled_count == 1) { 1195 } else if (enabled_count == 1) {
1195 if (public_submodules_->level_estimator->is_enabled() || 1196 if (public_submodules_->level_estimator->is_enabled() ||
1196 public_submodules_->voice_detection->is_enabled()) { 1197 public_submodules_->voice_detection->is_enabled()) {
1197 return false; 1198 return false;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1307
1307 void AudioProcessingImpl::InitializeNoiseSuppression() { 1308 void AudioProcessingImpl::InitializeNoiseSuppression() {
1308 public_submodules_->noise_suppression->Initialize(num_output_channels(), 1309 public_submodules_->noise_suppression->Initialize(num_output_channels(),
1309 proc_sample_rate_hz()); 1310 proc_sample_rate_hz());
1310 } 1311 }
1311 1312
1312 void AudioProcessingImpl::InitializeLevelEstimator() { 1313 void AudioProcessingImpl::InitializeLevelEstimator() {
1313 public_submodules_->level_estimator->Initialize(); 1314 public_submodules_->level_estimator->Initialize();
1314 } 1315 }
1315 1316
1317 void AudioProcessingImpl::InitializeVoiceDetection() {
1318 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
1319 }
1320
1316 void AudioProcessingImpl::MaybeUpdateHistograms() { 1321 void AudioProcessingImpl::MaybeUpdateHistograms() {
1317 static const int kMinDiffDelayMs = 60; 1322 static const int kMinDiffDelayMs = 60;
1318 1323
1319 if (echo_cancellation()->is_enabled()) { 1324 if (echo_cancellation()->is_enabled()) {
1320 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. 1325 // Activate delay_jumps_ counters if we know echo_cancellation is runnning.
1321 // If a stream has echo we know that the echo_cancellation is in process. 1326 // If a stream has echo we know that the echo_cancellation is in process.
1322 if (capture_.stream_delay_jumps == -1 && 1327 if (capture_.stream_delay_jumps == -1 &&
1323 echo_cancellation()->stream_has_echo()) { 1328 echo_cancellation()->stream_has_echo()) {
1324 capture_.stream_delay_jumps = 0; 1329 capture_.stream_delay_jumps = 0;
1325 } 1330 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); 1495 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG);
1491 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1496 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1492 1497
1493 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1498 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1494 &crit_debug_, &debug_dump_.capture)); 1499 &crit_debug_, &debug_dump_.capture));
1495 return kNoError; 1500 return kNoError;
1496 } 1501 }
1497 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1502 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1498 1503
1499 } // namespace webrtc 1504 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | webrtc/modules/audio_processing/voice_detection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698