| 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 |
| 11 #include "webrtc/voice_engine/utility.h" | 11 #include "webrtc/voice_engine/utility.h" |
| 12 | 12 |
| 13 #include "webrtc/base/logging.h" |
| 13 #include "webrtc/common_audio/resampler/include/push_resampler.h" | 14 #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 14 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 15 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
| 16 #include "webrtc/modules/include/module_common_types.h" | 17 #include "webrtc/modules/include/module_common_types.h" |
| 17 #include "webrtc/modules/utility/include/audio_frame_operations.h" | 18 #include "webrtc/modules/utility/include/audio_frame_operations.h" |
| 18 #include "webrtc/system_wrappers/include/logging.h" | |
| 19 #include "webrtc/voice_engine/voice_engine_defines.h" | 19 #include "webrtc/voice_engine/voice_engine_defines.h" |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 namespace voe { | 22 namespace voe { |
| 23 | 23 |
| 24 void RemixAndResample(const AudioFrame& src_frame, | 24 void RemixAndResample(const AudioFrame& src_frame, |
| 25 PushResampler<int16_t>* resampler, | 25 PushResampler<int16_t>* resampler, |
| 26 AudioFrame* dst_frame) { | 26 AudioFrame* dst_frame) { |
| 27 RemixAndResample(src_frame.data_, src_frame.samples_per_channel_, | 27 RemixAndResample(src_frame.data_, src_frame.samples_per_channel_, |
| 28 src_frame.num_channels_, src_frame.sample_rate_hz_, | 28 src_frame.num_channels_, src_frame.sample_rate_hz_, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 // Downmix before resampling. | 45 // Downmix before resampling. |
| 46 if (num_channels == 2 && dst_frame->num_channels_ == 1) { | 46 if (num_channels == 2 && dst_frame->num_channels_ == 1) { |
| 47 AudioFrameOperations::StereoToMono(src_data, samples_per_channel, | 47 AudioFrameOperations::StereoToMono(src_data, samples_per_channel, |
| 48 mono_audio); | 48 mono_audio); |
| 49 audio_ptr = mono_audio; | 49 audio_ptr = mono_audio; |
| 50 audio_ptr_num_channels = 1; | 50 audio_ptr_num_channels = 1; |
| 51 } | 51 } |
| 52 | 52 |
| 53 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, | 53 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, |
| 54 audio_ptr_num_channels) == -1) { | 54 audio_ptr_num_channels) == -1) { |
| 55 LOG_FERR3(LS_ERROR, InitializeIfNeeded, sample_rate_hz, | 55 LOG(LS_ERROR) << "InitializeIfNeeded failed: sample_rate_hz = " |
| 56 dst_frame->sample_rate_hz_, audio_ptr_num_channels); | 56 << sample_rate_hz << ", dst_frame->sample_rate_hz_ = " |
| 57 << dst_frame->sample_rate_hz_ |
| 58 << ", audio_ptr_num_channels = " << audio_ptr_num_channels; |
| 57 assert(false); | 59 assert(false); |
| 58 } | 60 } |
| 59 | 61 |
| 60 const size_t src_length = samples_per_channel * audio_ptr_num_channels; | 62 const size_t src_length = samples_per_channel * audio_ptr_num_channels; |
| 61 int out_length = resampler->Resample(audio_ptr, src_length, dst_frame->data_, | 63 int out_length = resampler->Resample(audio_ptr, src_length, dst_frame->data_, |
| 62 AudioFrame::kMaxDataSizeSamples); | 64 AudioFrame::kMaxDataSizeSamples); |
| 63 if (out_length == -1) { | 65 if (out_length == -1) { |
| 64 LOG_FERR3(LS_ERROR, Resample, audio_ptr, src_length, dst_frame->data_); | 66 LOG(LS_ERROR) << "Resample failed: audio_ptr = " << audio_ptr |
| 67 << ", src_length = " << src_length |
| 68 << ", dst_frame->data_ = " << dst_frame->data_; |
| 65 assert(false); | 69 assert(false); |
| 66 } | 70 } |
| 67 dst_frame->samples_per_channel_ = | 71 dst_frame->samples_per_channel_ = |
| 68 static_cast<size_t>(out_length / audio_ptr_num_channels); | 72 static_cast<size_t>(out_length / audio_ptr_num_channels); |
| 69 | 73 |
| 70 // Upmix after resampling. | 74 // Upmix after resampling. |
| 71 if (num_channels == 1 && dst_frame->num_channels_ == 2) { | 75 if (num_channels == 1 && dst_frame->num_channels_ == 2) { |
| 72 // The audio in dst_frame really is mono at this point; MonoToStereo will | 76 // The audio in dst_frame really is mono at this point; MonoToStereo will |
| 73 // set this back to stereo. | 77 // set this back to stereo. |
| 74 dst_frame->num_channels_ = 1; | 78 dst_frame->num_channels_ = 1; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 105 int32_t temp = 0; | 109 int32_t temp = 0; |
| 106 for (size_t i = 0; i < source_len; ++i) { | 110 for (size_t i = 0; i < source_len; ++i) { |
| 107 temp = source[i] + target[i]; | 111 temp = source[i] + target[i]; |
| 108 target[i] = WebRtcSpl_SatW32ToW16(temp); | 112 target[i] = WebRtcSpl_SatW32ToW16(temp); |
| 109 } | 113 } |
| 110 } | 114 } |
| 111 } | 115 } |
| 112 | 116 |
| 113 } // namespace voe | 117 } // namespace voe |
| 114 } // namespace webrtc | 118 } // namespace webrtc |
| OLD | NEW |