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 RTC_DCHECK(num_channels == 2 || num_channels == 4) << "num_channels: " |
49 mono_audio); | 49 << num_channels; |
50 audio_ptr = mono_audio; | 50 RTC_DCHECK(dst_frame->num_channels_ == 1 || dst_frame->num_channels_ == 2) |
51 audio_ptr_num_channels = 1; | 51 << "dst_frame->num_channels_: " << dst_frame->num_channels_; |
| 52 |
| 53 AudioFrameOperations::DownmixChannels( |
| 54 src_data, num_channels, samples_per_channel, dst_frame->num_channels_, |
| 55 downsampled_audio); |
| 56 audio_ptr = downsampled_audio; |
| 57 audio_ptr_num_channels = dst_frame->num_channels_; |
52 } | 58 } |
53 | 59 |
54 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, | 60 if (resampler->InitializeIfNeeded(sample_rate_hz, dst_frame->sample_rate_hz_, |
55 audio_ptr_num_channels) == -1) { | 61 audio_ptr_num_channels) == -1) { |
56 FATAL() << "InitializeIfNeeded failed: sample_rate_hz = " << sample_rate_hz | 62 FATAL() << "InitializeIfNeeded failed: sample_rate_hz = " << sample_rate_hz |
57 << ", dst_frame->sample_rate_hz_ = " << dst_frame->sample_rate_hz_ | 63 << ", dst_frame->sample_rate_hz_ = " << dst_frame->sample_rate_hz_ |
58 << ", audio_ptr_num_channels = " << audio_ptr_num_channels; | 64 << ", audio_ptr_num_channels = " << audio_ptr_num_channels; |
59 } | 65 } |
60 | 66 |
61 const size_t src_length = samples_per_channel * audio_ptr_num_channels; | 67 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; | 114 int32_t temp = 0; |
109 for (size_t i = 0; i < source_len; ++i) { | 115 for (size_t i = 0; i < source_len; ++i) { |
110 temp = source[i] + target[i]; | 116 temp = source[i] + target[i]; |
111 target[i] = WebRtcSpl_SatW32ToW16(temp); | 117 target[i] = WebRtcSpl_SatW32ToW16(temp); |
112 } | 118 } |
113 } | 119 } |
114 } | 120 } |
115 | 121 |
116 } // namespace voe | 122 } // namespace voe |
117 } // namespace webrtc | 123 } // namespace webrtc |
OLD | NEW |