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

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

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

Powered by Google App Engine
This is Rietveld 408576698