Chromium Code Reviews

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

Issue 1865633005: 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: Only enable when render processing Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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 // We normally process the reverse stream at 16 kHz. Unless... 369 int rev_proc_rate = ClosestNativeRate(std::min(
370 int rev_proc_rate = kSampleRate16kHz; 370 formats_.api_format.reverse_input_stream().sample_rate_hz(),
371 formats_.api_format.reverse_output_stream().sample_rate_hz()));
372 // TODO(aluebs): Remove this restriction once we figure out why the 3-band
373 // splitting filter degrades the AEC performance.
374 if (rev_proc_rate > kSampleRate32kHz) {
375 if (is_rev_processed()) {
376 rev_proc_rate = kSampleRate32kHz;
377 } else {
378 rev_proc_rate = kSampleRate16kHz;
379 }
380 }
peah-webrtc 2016/04/22 12:36:57 I think that with the new changes this and the fol
aluebs-webrtc 2016/04/22 17:46:14 But then the separation between what is temporary
381 // If the forward sample rate is 8 kHz, the reverse stream is also processed
382 // at this rate.
371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { 383 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
372 // ...the forward stream is at 8 kHz.
373 rev_proc_rate = kSampleRate8kHz; 384 rev_proc_rate = kSampleRate8kHz;
374 } else { 385 } else {
375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == 386 rev_proc_rate = std::max(rev_proc_rate, static_cast<int>(kSampleRate16kHz));
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 }
381 } 387 }
382 388
383 // Always downmix the reverse stream to mono for analysis. This has been 389 // Always downmix the reverse stream to mono for analysis. This has been
384 // demonstrated to work well for AEC in most practical scenarios. 390 // demonstrated to work well for AEC in most practical scenarios.
385 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1); 391 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1);
386 392
387 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz || 393 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz ||
388 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { 394 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) {
389 capture_nonlocked_.split_rate = kSampleRate16kHz; 395 capture_nonlocked_.split_rate = kSampleRate16kHz;
390 } else { 396 } else {
(...skipping 753 matching lines...)
1144 } 1150 }
1145 return false; 1151 return false;
1146 } 1152 }
1147 1153
1148 bool AudioProcessingImpl::is_rev_processed() const { 1154 bool AudioProcessingImpl::is_rev_processed() const {
1149 return constants_.intelligibility_enabled; 1155 return constants_.intelligibility_enabled;
1150 } 1156 }
1151 1157
1152 bool AudioProcessingImpl::rev_synthesis_needed() const { 1158 bool AudioProcessingImpl::rev_synthesis_needed() const {
1153 return (is_rev_processed() && 1159 return (is_rev_processed() &&
1154 formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz); 1160 is_multi_band(formats_.rev_proc_format.sample_rate_hz()));
1155 } 1161 }
1156 1162
1157 bool AudioProcessingImpl::rev_analysis_needed() const { 1163 bool AudioProcessingImpl::rev_analysis_needed() const {
1158 return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz && 1164 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) &&
1159 (is_rev_processed() || 1165 (is_rev_processed() ||
1160 public_submodules_->echo_cancellation 1166 public_submodules_->echo_cancellation
1161 ->is_enabled_render_side_query() || 1167 ->is_enabled_render_side_query() ||
1162 public_submodules_->echo_control_mobile 1168 public_submodules_->echo_control_mobile
1163 ->is_enabled_render_side_query() || 1169 ->is_enabled_render_side_query() ||
1164 public_submodules_->gain_control->is_enabled_render_side_query()); 1170 public_submodules_->gain_control->is_enabled_render_side_query());
1165 } 1171 }
1166 1172
1167 bool AudioProcessingImpl::render_check_rev_conversion_needed() const { 1173 bool AudioProcessingImpl::render_check_rev_conversion_needed() const {
1168 return rev_conversion_needed(); 1174 return rev_conversion_needed();
(...skipping 280 matching lines...)
1449 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1455 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1450 1456
1451 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1457 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1452 &debug_dump_.num_bytes_left_for_log_, 1458 &debug_dump_.num_bytes_left_for_log_,
1453 &crit_debug_, &debug_dump_.capture)); 1459 &crit_debug_, &debug_dump_.capture));
1454 return kNoError; 1460 return kNoError;
1455 } 1461 }
1456 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1462 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1457 1463
1458 } // namespace webrtc 1464 } // 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