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

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: Simplify if-statement 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(ClosestHigherNativeRate( 365 capture_nonlocked_.fwd_proc_format = StreamConfig(ClosestHigherNativeRate(
366 std::min(formats_.api_format.input_stream().sample_rate_hz(), 366 std::min(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 = ClosestHigherNativeRate(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 rev_proc_rate = is_rev_processed() ? kSampleRate32kHz : kSampleRate16kHz;
376 }
377 // If the forward sample rate is 8 kHz, the reverse stream is also processed
378 // at this rate.
371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { 379 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
372 // ...the forward stream is at 8 kHz.
373 rev_proc_rate = kSampleRate8kHz; 380 rev_proc_rate = kSampleRate8kHz;
374 } else { 381 } else {
375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == 382 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 } 383 }
382 384
383 // Always downmix the reverse stream to mono for analysis. This has been 385 // Always downmix the reverse stream to mono for analysis. This has been
384 // demonstrated to work well for AEC in most practical scenarios. 386 // demonstrated to work well for AEC in most practical scenarios.
385 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1); 387 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1);
386 388
387 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz || 389 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz ||
388 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { 390 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) {
389 capture_nonlocked_.split_rate = kSampleRate16kHz; 391 capture_nonlocked_.split_rate = kSampleRate16kHz;
390 } else { 392 } else {
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1146 }
1145 return false; 1147 return false;
1146 } 1148 }
1147 1149
1148 bool AudioProcessingImpl::is_rev_processed() const { 1150 bool AudioProcessingImpl::is_rev_processed() const {
1149 return constants_.intelligibility_enabled; 1151 return constants_.intelligibility_enabled;
1150 } 1152 }
1151 1153
1152 bool AudioProcessingImpl::rev_synthesis_needed() const { 1154 bool AudioProcessingImpl::rev_synthesis_needed() const {
1153 return (is_rev_processed() && 1155 return (is_rev_processed() &&
1154 formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz); 1156 is_multi_band(formats_.rev_proc_format.sample_rate_hz()));
1155 } 1157 }
1156 1158
1157 bool AudioProcessingImpl::rev_analysis_needed() const { 1159 bool AudioProcessingImpl::rev_analysis_needed() const {
1158 return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz && 1160 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) &&
1159 (is_rev_processed() || 1161 (is_rev_processed() ||
1160 public_submodules_->echo_cancellation 1162 public_submodules_->echo_cancellation
1161 ->is_enabled_render_side_query() || 1163 ->is_enabled_render_side_query() ||
1162 public_submodules_->echo_control_mobile 1164 public_submodules_->echo_control_mobile
1163 ->is_enabled_render_side_query() || 1165 ->is_enabled_render_side_query() ||
1164 public_submodules_->gain_control->is_enabled_render_side_query()); 1166 public_submodules_->gain_control->is_enabled_render_side_query());
1165 } 1167 }
1166 1168
1167 bool AudioProcessingImpl::render_check_rev_conversion_needed() const { 1169 bool AudioProcessingImpl::render_check_rev_conversion_needed() const {
1168 return rev_conversion_needed(); 1170 return rev_conversion_needed();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1459 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1458 1460
1459 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1461 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1460 &debug_dump_.num_bytes_left_for_log_, 1462 &debug_dump_.num_bytes_left_for_log_,
1461 &crit_debug_, &debug_dump_.capture)); 1463 &crit_debug_, &debug_dump_.capture));
1462 return kNoError; 1464 return kNoError;
1463 } 1465 }
1464 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1466 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1465 1467
1466 } // namespace webrtc 1468 } // namespace webrtc
OLDNEW
« no previous file with comments | « data/audio_processing/output_data_mac.pb ('k') | webrtc/modules/audio_processing/audio_processing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698