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

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

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