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

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

Issue 1867483003: Partial revert of "Don't always downsample to 16kHz in the reverse stream in APM" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 num_in_channels != capture_.array_geometry.size()) { 359 num_in_channels != capture_.array_geometry.size()) {
360 return kBadNumberChannelsError; 360 return kBadNumberChannelsError;
361 } 361 }
362 362
363 formats_.api_format = config; 363 formats_.api_format = config;
364 364
365 capture_nonlocked_.fwd_proc_format = StreamConfig(ClosestNativeRate(std::min( 365 capture_nonlocked_.fwd_proc_format = StreamConfig(ClosestNativeRate(std::min(
366 formats_.api_format.input_stream().sample_rate_hz(), 366 formats_.api_format.input_stream().sample_rate_hz(),
367 formats_.api_format.output_stream().sample_rate_hz()))); 367 formats_.api_format.output_stream().sample_rate_hz())));
368 368
369 int rev_proc_rate = ClosestNativeRate(std::min( 369 // We normally process the reverse stream at 16 kHz. Unless...
the sun 2016/04/06 09:34:57 nit: ClosestNativeRate() should be renamed btw, si
peah-webrtc 2016/04/06 09:36:31 True. Good point! Ok if I address that in another
370 formats_.api_format.reverse_input_stream().sample_rate_hz(), 370 int rev_proc_rate = kSampleRate16kHz;
371 formats_.api_format.reverse_output_stream().sample_rate_hz()));
372 // If the forward sample rate is 8 kHz, the reverse stream is also processed
373 // at this rate.
374 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { 371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
372 // ...the forward stream is at 8 kHz.
375 rev_proc_rate = kSampleRate8kHz; 373 rev_proc_rate = kSampleRate8kHz;
376 } else { 374 } else {
377 rev_proc_rate = std::max(rev_proc_rate, static_cast<int>(kSampleRate16kHz)); 375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() ==
376 kSampleRate32kHz) {
377 // ...or the input is at 32 kHz, in which case we use the splitting
378 // filter rather than the resampler.
379 rev_proc_rate = kSampleRate32kHz;
380 }
378 } 381 }
379 382
380 // Always downmix the reverse stream to mono for analysis. This has been 383 // Always downmix the reverse stream to mono for analysis. This has been
381 // demonstrated to work well for AEC in most practical scenarios. 384 // demonstrated to work well for AEC in most practical scenarios.
382 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1); 385 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1);
383 386
384 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz || 387 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz ||
385 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { 388 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) {
386 capture_nonlocked_.split_rate = kSampleRate16kHz; 389 capture_nonlocked_.split_rate = kSampleRate16kHz;
387 } else { 390 } else {
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 } 1144 }
1142 return false; 1145 return false;
1143 } 1146 }
1144 1147
1145 bool AudioProcessingImpl::is_rev_processed() const { 1148 bool AudioProcessingImpl::is_rev_processed() const {
1146 return constants_.intelligibility_enabled; 1149 return constants_.intelligibility_enabled;
1147 } 1150 }
1148 1151
1149 bool AudioProcessingImpl::rev_synthesis_needed() const { 1152 bool AudioProcessingImpl::rev_synthesis_needed() const {
1150 return (is_rev_processed() && 1153 return (is_rev_processed() &&
1151 is_multi_band(formats_.rev_proc_format.sample_rate_hz())); 1154 formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz);
1152 } 1155 }
1153 1156
1154 bool AudioProcessingImpl::rev_analysis_needed() const { 1157 bool AudioProcessingImpl::rev_analysis_needed() const {
1155 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) && 1158 return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz &&
1156 (is_rev_processed() || 1159 (is_rev_processed() ||
1157 public_submodules_->echo_cancellation->is_enabled() || 1160 public_submodules_->echo_cancellation->is_enabled() ||
1158 public_submodules_->echo_control_mobile->is_enabled() || 1161 public_submodules_->echo_control_mobile->is_enabled() ||
1159 public_submodules_->gain_control->is_enabled()); 1162 public_submodules_->gain_control->is_enabled());
1160 } 1163 }
1161 1164
1162 bool AudioProcessingImpl::render_check_rev_conversion_needed() const { 1165 bool AudioProcessingImpl::render_check_rev_conversion_needed() const {
1163 return rev_conversion_needed(); 1166 return rev_conversion_needed();
1164 } 1167 }
1165 1168
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1447 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1445 1448
1446 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1449 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1447 &debug_dump_.num_bytes_left_for_log_, 1450 &debug_dump_.num_bytes_left_for_log_,
1448 &crit_debug_, &debug_dump_.capture)); 1451 &crit_debug_, &debug_dump_.capture));
1449 return kNoError; 1452 return kNoError;
1450 } 1453 }
1451 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1454 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1452 1455
1453 } // namespace webrtc 1456 } // namespace webrtc
OLDNEW
« no previous file with comments | « data/audio_processing/output_data_mac.pb ('k') | webrtc/modules/audio_processing/test/audio_processing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698