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

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

Issue 1952123003: Surface the IntelligibilityEnhancer on MediaConstraints (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change to use MediaConstraints Created 4 years, 7 months 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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();
tommi 2016/05/11 06:06:48 Don't you need to check first if the value is true
aluebs-webrtc 2016/05/11 21:22:05 The check if the value is true is done inside Init
tommi 2016/05/12 07:06:38 OK. It is confusing that if the value is false, we
aluebs-webrtc 2016/05/13 02:04:38 The older components (that use to inherit from Pro
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
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 RTC_DCHECK(public_submodules_->gain_control->is_enabled());
710 public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate( 716 public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate(
711 public_submodules_->noise_suppression->NoiseEstimate(), 717 public_submodules_->noise_suppression->NoiseEstimate(),
712 public_submodules_->gain_control->compression_gain_db()); 718 public_submodules_->gain_control->compression_gain_db());
713 } 719 }
714 720
715 // Ensure that the stream delay was set before the call to the 721 // Ensure that the stream delay was set before the call to the
716 // AECM ProcessCaptureAudio function. 722 // AECM ProcessCaptureAudio function.
717 if (public_submodules_->echo_control_mobile->is_enabled() && 723 if (public_submodules_->echo_control_mobile->is_enabled() &&
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } 901 }
896 return kNoError; 902 return kNoError;
897 } 903 }
898 904
899 int AudioProcessingImpl::ProcessReverseStreamLocked() { 905 int AudioProcessingImpl::ProcessReverseStreamLocked() {
900 AudioBuffer* ra = render_.render_audio.get(); // For brevity. 906 AudioBuffer* ra = render_.render_audio.get(); // For brevity.
901 if (rev_analysis_needed()) { 907 if (rev_analysis_needed()) {
902 ra->SplitIntoFrequencyBands(); 908 ra->SplitIntoFrequencyBands();
903 } 909 }
904 910
905 if (constants_.intelligibility_enabled) { 911 if (capture_nonlocked_.intelligibility_enabled) {
906 public_submodules_->intelligibility_enhancer->ProcessRenderAudio( 912 public_submodules_->intelligibility_enhancer->ProcessRenderAudio(
907 ra->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate, 913 ra->split_channels_f(kBand0To8kHz), capture_nonlocked_.split_rate,
908 ra->num_channels()); 914 ra->num_channels());
909 } 915 }
910 916
911 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessRenderAudio(ra)); 917 RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessRenderAudio(ra));
912 RETURN_ON_ERR( 918 RETURN_ON_ERR(
913 public_submodules_->echo_control_mobile->ProcessRenderAudio(ra)); 919 public_submodules_->echo_control_mobile->ProcessRenderAudio(ra));
914 if (!constants_.use_experimental_agc) { 920 if (!constants_.use_experimental_agc) {
915 RETURN_ON_ERR(public_submodules_->gain_control->ProcessRenderAudio(ra)); 921 RETURN_ON_ERR(public_submodules_->gain_control->ProcessRenderAudio(ra));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 } else if (is_multi_band( 1149 } else if (is_multi_band(
1144 capture_nonlocked_.fwd_proc_format.sample_rate_hz())) { 1150 capture_nonlocked_.fwd_proc_format.sample_rate_hz())) {
1145 // Something besides public_submodules_->level_estimator is enabled, and we 1151 // Something besides public_submodules_->level_estimator is enabled, and we
1146 // have super-wb. 1152 // have super-wb.
1147 return true; 1153 return true;
1148 } 1154 }
1149 return false; 1155 return false;
1150 } 1156 }
1151 1157
1152 bool AudioProcessingImpl::is_rev_processed() const { 1158 bool AudioProcessingImpl::is_rev_processed() const {
1153 return constants_.intelligibility_enabled; 1159 return capture_nonlocked_.intelligibility_enabled;
1154 } 1160 }
1155 1161
1156 bool AudioProcessingImpl::rev_synthesis_needed() const { 1162 bool AudioProcessingImpl::rev_synthesis_needed() const {
1157 return (is_rev_processed() && 1163 return (is_rev_processed() &&
1158 is_multi_band(formats_.rev_proc_format.sample_rate_hz())); 1164 is_multi_band(formats_.rev_proc_format.sample_rate_hz()));
1159 } 1165 }
1160 1166
1161 bool AudioProcessingImpl::rev_analysis_needed() const { 1167 bool AudioProcessingImpl::rev_analysis_needed() const {
1162 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) && 1168 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) &&
1163 (is_rev_processed() || 1169 (is_rev_processed() ||
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 if (!private_submodules_->beamformer) { 1214 if (!private_submodules_->beamformer) {
1209 private_submodules_->beamformer.reset(new NonlinearBeamformer( 1215 private_submodules_->beamformer.reset(new NonlinearBeamformer(
1210 capture_.array_geometry, capture_.target_direction)); 1216 capture_.array_geometry, capture_.target_direction));
1211 } 1217 }
1212 private_submodules_->beamformer->Initialize(kChunkSizeMs, 1218 private_submodules_->beamformer->Initialize(kChunkSizeMs,
1213 capture_nonlocked_.split_rate); 1219 capture_nonlocked_.split_rate);
1214 } 1220 }
1215 } 1221 }
1216 1222
1217 void AudioProcessingImpl::InitializeIntelligibility() { 1223 void AudioProcessingImpl::InitializeIntelligibility() {
1218 if (constants_.intelligibility_enabled) { 1224 if (capture_nonlocked_.intelligibility_enabled) {
tommi 2016/05/12 07:06:38 This should be a dcheck and the function should do
aluebs-webrtc 2016/05/13 02:04:38 Please see explanation above.
1219 public_submodules_->intelligibility_enhancer.reset( 1225 public_submodules_->intelligibility_enhancer.reset(
1220 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, 1226 new IntelligibilityEnhancer(capture_nonlocked_.split_rate,
1221 render_.render_audio->num_channels(), 1227 render_.render_audio->num_channels(),
1222 NoiseSuppressionImpl::num_noise_bins())); 1228 NoiseSuppressionImpl::num_noise_bins()));
1223 } 1229 }
1224 } 1230 }
1225 1231
1226 void AudioProcessingImpl::InitializeHighPassFilter() { 1232 void AudioProcessingImpl::InitializeHighPassFilter() {
1227 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), 1233 public_submodules_->high_pass_filter->Initialize(num_proc_channels(),
1228 proc_sample_rate_hz()); 1234 proc_sample_rate_hz());
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1467 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1462 1468
1463 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1469 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1464 &debug_dump_.num_bytes_left_for_log_, 1470 &debug_dump_.num_bytes_left_for_log_,
1465 &crit_debug_, &debug_dump_.capture)); 1471 &crit_debug_, &debug_dump_.capture));
1466 return kNoError; 1472 return kNoError;
1467 } 1473 }
1468 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1474 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1469 1475
1470 } // namespace webrtc 1476 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698