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

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

Issue 1777093004: Reland: Drop the 16kHz sample rate restriction on AECM and zero out higher bands (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebasing Created 4 years, 9 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #ifdef WEBRTC_ARCH_ARM_FAMILY 110 #ifdef WEBRTC_ARCH_ARM_FAMILY
111 AudioProcessing::kSampleRate32kHz}; 111 AudioProcessing::kSampleRate32kHz};
112 #else 112 #else
113 AudioProcessing::kSampleRate32kHz, 113 AudioProcessing::kSampleRate32kHz,
114 AudioProcessing::kSampleRate48kHz}; 114 AudioProcessing::kSampleRate48kHz};
115 #endif // WEBRTC_ARCH_ARM_FAMILY 115 #endif // WEBRTC_ARCH_ARM_FAMILY
116 const size_t AudioProcessing::kNumNativeSampleRates = 116 const size_t AudioProcessing::kNumNativeSampleRates =
117 arraysize(AudioProcessing::kNativeSampleRatesHz); 117 arraysize(AudioProcessing::kNativeSampleRatesHz);
118 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing:: 118 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing::
119 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1]; 119 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1];
120 const int AudioProcessing::kMaxAECMSampleRateHz = kSampleRate16kHz;
121 120
122 AudioProcessing* AudioProcessing::Create() { 121 AudioProcessing* AudioProcessing::Create() {
123 Config config; 122 Config config;
124 return Create(config, nullptr); 123 return Create(config, nullptr);
125 } 124 }
126 125
127 AudioProcessing* AudioProcessing::Create(const Config& config) { 126 AudioProcessing* AudioProcessing::Create(const Config& config) {
128 return Create(config, nullptr); 127 return Create(config, nullptr);
129 } 128 }
130 129
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return kBadNumberChannelsError; 339 return kBadNumberChannelsError;
341 } 340 }
342 341
343 if (capture_nonlocked_.beamformer_enabled && 342 if (capture_nonlocked_.beamformer_enabled &&
344 num_in_channels != capture_.array_geometry.size()) { 343 num_in_channels != capture_.array_geometry.size()) {
345 return kBadNumberChannelsError; 344 return kBadNumberChannelsError;
346 } 345 }
347 346
348 formats_.api_format = config; 347 formats_.api_format = config;
349 348
350 // We process at the closest native rate >= min(input rate, output rate)... 349 // We process at the closest native rate >= min(input rate, output rate).
351 const int min_proc_rate = 350 const int min_proc_rate =
352 std::min(formats_.api_format.input_stream().sample_rate_hz(), 351 std::min(formats_.api_format.input_stream().sample_rate_hz(),
353 formats_.api_format.output_stream().sample_rate_hz()); 352 formats_.api_format.output_stream().sample_rate_hz());
354 int fwd_proc_rate; 353 int fwd_proc_rate;
355 for (size_t i = 0; i < kNumNativeSampleRates; ++i) { 354 for (size_t i = 0; i < kNumNativeSampleRates; ++i) {
356 fwd_proc_rate = kNativeSampleRatesHz[i]; 355 fwd_proc_rate = kNativeSampleRatesHz[i];
357 if (fwd_proc_rate >= min_proc_rate) { 356 if (fwd_proc_rate >= min_proc_rate) {
358 break; 357 break;
359 } 358 }
360 } 359 }
361 // ...with one exception.
362 if (public_submodules_->echo_control_mobile->is_enabled() &&
363 min_proc_rate > kMaxAECMSampleRateHz) {
364 fwd_proc_rate = kMaxAECMSampleRateHz;
365 }
366 360
367 capture_nonlocked_.fwd_proc_format = StreamConfig(fwd_proc_rate); 361 capture_nonlocked_.fwd_proc_format = StreamConfig(fwd_proc_rate);
368 362
369 // We normally process the reverse stream at 16 kHz. Unless... 363 // We normally process the reverse stream at 16 kHz. Unless...
370 int rev_proc_rate = kSampleRate16kHz; 364 int rev_proc_rate = kSampleRate16kHz;
371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { 365 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
372 // ...the forward stream is at 8 kHz. 366 // ...the forward stream is at 8 kHz.
373 rev_proc_rate = kSampleRate8kHz; 367 rev_proc_rate = kSampleRate8kHz;
374 } else { 368 } else {
375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == 369 if (formats_.api_format.reverse_input_stream().sample_rate_hz() ==
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 return kNullPointerError; 582 return kNullPointerError;
589 } 583 }
590 // Must be a native rate. 584 // Must be a native rate.
591 if (frame->sample_rate_hz_ != kSampleRate8kHz && 585 if (frame->sample_rate_hz_ != kSampleRate8kHz &&
592 frame->sample_rate_hz_ != kSampleRate16kHz && 586 frame->sample_rate_hz_ != kSampleRate16kHz &&
593 frame->sample_rate_hz_ != kSampleRate32kHz && 587 frame->sample_rate_hz_ != kSampleRate32kHz &&
594 frame->sample_rate_hz_ != kSampleRate48kHz) { 588 frame->sample_rate_hz_ != kSampleRate48kHz) {
595 return kBadSampleRateError; 589 return kBadSampleRateError;
596 } 590 }
597 591
598 if (public_submodules_->echo_control_mobile->is_enabled() &&
599 frame->sample_rate_hz_ > kMaxAECMSampleRateHz) {
600 LOG(LS_ERROR) << "AECM only supports 16 or 8 kHz sample rates";
601 return kUnsupportedComponentError;
602 }
603
604 ProcessingConfig processing_config; 592 ProcessingConfig processing_config;
605 { 593 {
606 // Aquire lock for the access of api_format. 594 // Aquire lock for the access of api_format.
607 // The lock is released immediately due to the conditional 595 // The lock is released immediately due to the conditional
608 // reinitialization. 596 // reinitialization.
609 rtc::CritScope cs_capture(&crit_capture_); 597 rtc::CritScope cs_capture(&crit_capture_);
610 // TODO(ajm): The input and output rates and channels are currently 598 // TODO(ajm): The input and output rates and channels are currently
611 // constrained to be identical in the int16 interface. 599 // constrained to be identical in the int16 interface.
612 processing_config = formats_.api_format; 600 processing_config = formats_.api_format;
613 } 601 }
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 num_proc_channels()); 1235 num_proc_channels());
1248 } 1236 }
1249 1237
1250 void AudioProcessingImpl::InitializeGainController() { 1238 void AudioProcessingImpl::InitializeGainController() {
1251 public_submodules_->gain_control->Initialize(num_proc_channels(), 1239 public_submodules_->gain_control->Initialize(num_proc_channels(),
1252 proc_sample_rate_hz()); 1240 proc_sample_rate_hz());
1253 } 1241 }
1254 1242
1255 void AudioProcessingImpl::InitializeEchoControlMobile() { 1243 void AudioProcessingImpl::InitializeEchoControlMobile() {
1256 public_submodules_->echo_control_mobile->Initialize( 1244 public_submodules_->echo_control_mobile->Initialize(
1257 proc_sample_rate_hz(), num_reverse_channels(), num_output_channels()); 1245 proc_split_sample_rate_hz(),
1246 num_reverse_channels(),
1247 num_output_channels());
1258 } 1248 }
1259 1249
1260 void AudioProcessingImpl::InitializeLevelEstimator() { 1250 void AudioProcessingImpl::InitializeLevelEstimator() {
1261 public_submodules_->level_estimator->Initialize(); 1251 public_submodules_->level_estimator->Initialize();
1262 } 1252 }
1263 1253
1264 void AudioProcessingImpl::InitializeVoiceDetection() { 1254 void AudioProcessingImpl::InitializeVoiceDetection() {
1265 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); 1255 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
1266 } 1256 }
1267 1257
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1449 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1460 1450
1461 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1451 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1462 &debug_dump_.num_bytes_left_for_log_, 1452 &debug_dump_.num_bytes_left_for_log_,
1463 &crit_debug_, &debug_dump_.capture)); 1453 &crit_debug_, &debug_dump_.capture));
1464 return kNoError; 1454 return kNoError;
1465 } 1455 }
1466 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1456 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1467 1457
1468 } // namespace webrtc 1458 } // namespace webrtc
OLDNEW
« no previous file with comments | « data/audio_processing/output_data_fixed.pb ('k') | webrtc/modules/audio_processing/echo_control_mobile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698