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

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: Inf SNR should not fail 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 #ifdef WEBRTC_ARCH_ARM_FAMILY 115 #ifdef WEBRTC_ARCH_ARM_FAMILY
116 AudioProcessing::kSampleRate32kHz}; 116 AudioProcessing::kSampleRate32kHz};
117 #else 117 #else
118 AudioProcessing::kSampleRate32kHz, 118 AudioProcessing::kSampleRate32kHz,
119 AudioProcessing::kSampleRate48kHz}; 119 AudioProcessing::kSampleRate48kHz};
120 #endif // WEBRTC_ARCH_ARM_FAMILY 120 #endif // WEBRTC_ARCH_ARM_FAMILY
121 const size_t AudioProcessing::kNumNativeSampleRates = 121 const size_t AudioProcessing::kNumNativeSampleRates =
122 arraysize(AudioProcessing::kNativeSampleRatesHz); 122 arraysize(AudioProcessing::kNativeSampleRatesHz);
123 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing:: 123 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing::
124 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1]; 124 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1];
125 const int AudioProcessing::kMaxAECMSampleRateHz = kSampleRate16kHz;
126 125
127 AudioProcessing* AudioProcessing::Create() { 126 AudioProcessing* AudioProcessing::Create() {
128 Config config; 127 Config config;
129 return Create(config, nullptr); 128 return Create(config, nullptr);
130 } 129 }
131 130
132 AudioProcessing* AudioProcessing::Create(const Config& config) { 131 AudioProcessing* AudioProcessing::Create(const Config& config) {
133 return Create(config, nullptr); 132 return Create(config, nullptr);
134 } 133 }
135 134
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return kBadNumberChannelsError; 361 return kBadNumberChannelsError;
363 } 362 }
364 363
365 if (capture_nonlocked_.beamformer_enabled && 364 if (capture_nonlocked_.beamformer_enabled &&
366 num_in_channels != capture_.array_geometry.size()) { 365 num_in_channels != capture_.array_geometry.size()) {
367 return kBadNumberChannelsError; 366 return kBadNumberChannelsError;
368 } 367 }
369 368
370 formats_.api_format = config; 369 formats_.api_format = config;
371 370
372 // We process at the closest native rate >= min(input rate, output rate)... 371 // We process at the closest native rate >= min(input rate, output rate).
373 const int min_proc_rate = 372 const int min_proc_rate =
374 std::min(formats_.api_format.input_stream().sample_rate_hz(), 373 std::min(formats_.api_format.input_stream().sample_rate_hz(),
375 formats_.api_format.output_stream().sample_rate_hz()); 374 formats_.api_format.output_stream().sample_rate_hz());
376 int fwd_proc_rate; 375 int fwd_proc_rate;
377 for (size_t i = 0; i < kNumNativeSampleRates; ++i) { 376 for (size_t i = 0; i < kNumNativeSampleRates; ++i) {
378 fwd_proc_rate = kNativeSampleRatesHz[i]; 377 fwd_proc_rate = kNativeSampleRatesHz[i];
379 if (fwd_proc_rate >= min_proc_rate) { 378 if (fwd_proc_rate >= min_proc_rate) {
380 break; 379 break;
381 } 380 }
382 } 381 }
383 // ...with one exception.
384 if (public_submodules_->echo_control_mobile->is_enabled() &&
385 min_proc_rate > kMaxAECMSampleRateHz) {
386 fwd_proc_rate = kMaxAECMSampleRateHz;
387 }
388 382
389 capture_nonlocked_.fwd_proc_format = StreamConfig(fwd_proc_rate); 383 capture_nonlocked_.fwd_proc_format = StreamConfig(fwd_proc_rate);
390 384
391 // We normally process the reverse stream at 16 kHz. Unless... 385 // We normally process the reverse stream at 16 kHz. Unless...
392 int rev_proc_rate = kSampleRate16kHz; 386 int rev_proc_rate = kSampleRate16kHz;
393 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { 387 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
394 // ...the forward stream is at 8 kHz. 388 // ...the forward stream is at 8 kHz.
395 rev_proc_rate = kSampleRate8kHz; 389 rev_proc_rate = kSampleRate8kHz;
396 } else { 390 } else {
397 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == 391 if (formats_.api_format.reverse_input_stream().sample_rate_hz() ==
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 return kNullPointerError; 607 return kNullPointerError;
614 } 608 }
615 // Must be a native rate. 609 // Must be a native rate.
616 if (frame->sample_rate_hz_ != kSampleRate8kHz && 610 if (frame->sample_rate_hz_ != kSampleRate8kHz &&
617 frame->sample_rate_hz_ != kSampleRate16kHz && 611 frame->sample_rate_hz_ != kSampleRate16kHz &&
618 frame->sample_rate_hz_ != kSampleRate32kHz && 612 frame->sample_rate_hz_ != kSampleRate32kHz &&
619 frame->sample_rate_hz_ != kSampleRate48kHz) { 613 frame->sample_rate_hz_ != kSampleRate48kHz) {
620 return kBadSampleRateError; 614 return kBadSampleRateError;
621 } 615 }
622 616
623 if (public_submodules_->echo_control_mobile->is_enabled() &&
624 frame->sample_rate_hz_ > kMaxAECMSampleRateHz) {
625 LOG(LS_ERROR) << "AECM only supports 16 or 8 kHz sample rates";
626 return kUnsupportedComponentError;
627 }
628
629 ProcessingConfig processing_config; 617 ProcessingConfig processing_config;
630 { 618 {
631 // Aquire lock for the access of api_format. 619 // Aquire lock for the access of api_format.
632 // The lock is released immediately due to the conditional 620 // The lock is released immediately due to the conditional
633 // reinitialization. 621 // reinitialization.
634 rtc::CritScope cs_capture(&crit_capture_); 622 rtc::CritScope cs_capture(&crit_capture_);
635 // TODO(ajm): The input and output rates and channels are currently 623 // TODO(ajm): The input and output rates and channels are currently
636 // constrained to be identical in the int16 interface. 624 // constrained to be identical in the int16 interface.
637 processing_config = formats_.api_format; 625 processing_config = formats_.api_format;
638 } 626 }
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1440 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1453 1441
1454 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1442 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1455 &debug_dump_.num_bytes_left_for_log_, 1443 &debug_dump_.num_bytes_left_for_log_,
1456 &crit_debug_, &debug_dump_.capture)); 1444 &crit_debug_, &debug_dump_.capture));
1457 return kNoError; 1445 return kNoError;
1458 } 1446 }
1459 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1447 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1460 1448
1461 } // namespace webrtc 1449 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698