OLD | NEW |
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 Loading... |
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 int rev_proc_rate = ClosestHigherNativeRate(std::min( | 369 // We normally process the reverse stream at 16 kHz. Unless... |
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 // 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. | |
379 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. |
380 rev_proc_rate = kSampleRate8kHz; | 373 rev_proc_rate = kSampleRate8kHz; |
381 } else { | 374 } else { |
382 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 } |
383 } | 381 } |
384 | 382 |
385 // 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 |
386 // demonstrated to work well for AEC in most practical scenarios. | 384 // demonstrated to work well for AEC in most practical scenarios. |
387 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1); | 385 formats_.rev_proc_format = StreamConfig(rev_proc_rate, 1); |
388 | 386 |
389 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz || | 387 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate32kHz || |
390 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { | 388 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { |
391 capture_nonlocked_.split_rate = kSampleRate16kHz; | 389 capture_nonlocked_.split_rate = kSampleRate16kHz; |
392 } else { | 390 } else { |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 } | 1144 } |
1147 return false; | 1145 return false; |
1148 } | 1146 } |
1149 | 1147 |
1150 bool AudioProcessingImpl::is_rev_processed() const { | 1148 bool AudioProcessingImpl::is_rev_processed() const { |
1151 return constants_.intelligibility_enabled; | 1149 return constants_.intelligibility_enabled; |
1152 } | 1150 } |
1153 | 1151 |
1154 bool AudioProcessingImpl::rev_synthesis_needed() const { | 1152 bool AudioProcessingImpl::rev_synthesis_needed() const { |
1155 return (is_rev_processed() && | 1153 return (is_rev_processed() && |
1156 is_multi_band(formats_.rev_proc_format.sample_rate_hz())); | 1154 formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz); |
1157 } | 1155 } |
1158 | 1156 |
1159 bool AudioProcessingImpl::rev_analysis_needed() const { | 1157 bool AudioProcessingImpl::rev_analysis_needed() const { |
1160 return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) && | 1158 return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz && |
1161 (is_rev_processed() || | 1159 (is_rev_processed() || |
1162 public_submodules_->echo_cancellation | 1160 public_submodules_->echo_cancellation |
1163 ->is_enabled_render_side_query() || | 1161 ->is_enabled_render_side_query() || |
1164 public_submodules_->echo_control_mobile | 1162 public_submodules_->echo_control_mobile |
1165 ->is_enabled_render_side_query() || | 1163 ->is_enabled_render_side_query() || |
1166 public_submodules_->gain_control->is_enabled_render_side_query()); | 1164 public_submodules_->gain_control->is_enabled_render_side_query()); |
1167 } | 1165 } |
1168 | 1166 |
1169 bool AudioProcessingImpl::render_check_rev_conversion_needed() const { | 1167 bool AudioProcessingImpl::render_check_rev_conversion_needed() const { |
1170 return rev_conversion_needed(); | 1168 return rev_conversion_needed(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1457 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1460 | 1458 |
1461 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1459 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1462 &debug_dump_.num_bytes_left_for_log_, | 1460 &debug_dump_.num_bytes_left_for_log_, |
1463 &crit_debug_, &debug_dump_.capture)); | 1461 &crit_debug_, &debug_dump_.capture)); |
1464 return kNoError; | 1462 return kNoError; |
1465 } | 1463 } |
1466 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1464 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1467 | 1465 |
1468 } // namespace webrtc | 1466 } // namespace webrtc |
OLD | NEW |