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 23 matching lines...) Expand all Loading... | |
34 } | 34 } |
35 | 35 |
36 void RemixAndResample(const int16_t* src_data, | 36 void RemixAndResample(const int16_t* src_data, |
37 size_t samples_per_channel, | 37 size_t samples_per_channel, |
38 size_t num_channels, | 38 size_t num_channels, |
39 int sample_rate_hz, | 39 int sample_rate_hz, |
40 PushResampler<int16_t>* resampler, | 40 PushResampler<int16_t>* resampler, |
41 AudioFrame* dst_frame) { | 41 AudioFrame* dst_frame) { |
42 const int16_t* audio_ptr = src_data; | 42 const int16_t* audio_ptr = src_data; |
43 size_t audio_ptr_num_channels = num_channels; | 43 size_t audio_ptr_num_channels = num_channels; |
44 int16_t mono_audio[AudioFrame::kMaxDataSizeSamples]; | 44 int16_t downsampled_audio[AudioFrame::kMaxDataSizeSamples]; |
45 | 45 |
46 // Downmix before resampling. | 46 // Downmix before resampling. |
47 if (num_channels == 2 && dst_frame->num_channels_ == 1) { | 47 if (num_channels > dst_frame->num_channels_) { |
48 AudioFrameOperations::StereoToMono(src_data, samples_per_channel, | 48 AudioFrameOperations::DownmixChannels( |
jens.nielsen
2017/02/23 16:29:18
Maybe needs some error handling here for unsupport
hlundin-webrtc
2017/02/24 09:46:36
I think this leaves the field a little too open. I
jens.nielsen
2017/02/24 14:55:49
Done.
| |
49 mono_audio); | 49 src_data, num_channels, samples_per_channel,downsampled_audio, |
50 audio_ptr = mono_audio; | 50 dst_frame->num_channels_); |
51 audio_ptr_num_channels = 1; | 51 audio_ptr = downsampled_audio; |
52 audio_ptr_num_channels = dst_frame->num_channels_; | |
52 } | 53 } |
53 | 54 |
54 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, | 55 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, |
55 audio_ptr_num_channels) == -1) { | 56 audio_ptr_num_channels) == -1) { |
56 FATAL() << "InitializeIfNeeded failed: sample_rate_hz = " << sample_rate_hz | 57 FATAL() << "InitializeIfNeeded failed: sample_rate_hz = " << sample_rate_hz |
57 << ", dst_frame->sample_rate_hz_ = " << dst_frame->sample_rate_hz_ | 58 << ", dst_frame->sample_rate_hz_ = " << dst_frame->sample_rate_hz_ |
58 << ", audio_ptr_num_channels = " << audio_ptr_num_channels; | 59 << ", audio_ptr_num_channels = " << audio_ptr_num_channels; |
59 } | 60 } |
60 | 61 |
61 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; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 int32_t temp = 0; | 109 int32_t temp = 0; |
109 for (size_t i = 0; i < source_len; ++i) { | 110 for (size_t i = 0; i < source_len; ++i) { |
110 temp = source[i] + target[i]; | 111 temp = source[i] + target[i]; |
111 target[i] = WebRtcSpl_SatW32ToW16(temp); | 112 target[i] = WebRtcSpl_SatW32ToW16(temp); |
112 } | 113 } |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 } // namespace voe | 117 } // namespace voe |
117 } // namespace webrtc | 118 } // namespace webrtc |
OLD | NEW |