OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 // Deinterleave audio from |interleaved| to the channel buffers pointed to | 83 // Deinterleave audio from |interleaved| to the channel buffers pointed to |
84 // by |deinterleaved|. There must be sufficient space allocated in the | 84 // by |deinterleaved|. There must be sufficient space allocated in the |
85 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| | 85 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| |
86 // per buffer). | 86 // per buffer). |
87 template <typename T> | 87 template <typename T> |
88 void Deinterleave(const T* interleaved, | 88 void Deinterleave(const T* interleaved, |
89 size_t samples_per_channel, | 89 size_t samples_per_channel, |
90 int num_channels, | 90 size_t num_channels, |
91 T* const* deinterleaved) { | 91 T* const* deinterleaved) { |
92 for (int i = 0; i < num_channels; ++i) { | 92 for (size_t i = 0; i < num_channels; ++i) { |
93 T* channel = deinterleaved[i]; | 93 T* channel = deinterleaved[i]; |
94 int interleaved_idx = i; | 94 size_t interleaved_idx = i; |
95 for (size_t j = 0; j < samples_per_channel; ++j) { | 95 for (size_t j = 0; j < samples_per_channel; ++j) { |
96 channel[j] = interleaved[interleaved_idx]; | 96 channel[j] = interleaved[interleaved_idx]; |
97 interleaved_idx += num_channels; | 97 interleaved_idx += num_channels; |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 // Interleave audio from the channel buffers pointed to by |deinterleaved| to | 102 // Interleave audio from the channel buffers pointed to by |deinterleaved| to |
103 // |interleaved|. There must be sufficient space allocated in |interleaved| | 103 // |interleaved|. There must be sufficient space allocated in |interleaved| |
104 // (|samples_per_channel| * |num_channels|). | 104 // (|samples_per_channel| * |num_channels|). |
105 template <typename T> | 105 template <typename T> |
106 void Interleave(const T* const* deinterleaved, | 106 void Interleave(const T* const* deinterleaved, |
107 size_t samples_per_channel, | 107 size_t samples_per_channel, |
108 int num_channels, | 108 size_t num_channels, |
109 T* interleaved) { | 109 T* interleaved) { |
110 for (int i = 0; i < num_channels; ++i) { | 110 for (size_t i = 0; i < num_channels; ++i) { |
111 const T* channel = deinterleaved[i]; | 111 const T* channel = deinterleaved[i]; |
112 int interleaved_idx = i; | 112 size_t interleaved_idx = i; |
113 for (size_t j = 0; j < samples_per_channel; ++j) { | 113 for (size_t j = 0; j < samples_per_channel; ++j) { |
114 interleaved[interleaved_idx] = channel[j]; | 114 interleaved[interleaved_idx] = channel[j]; |
115 interleaved_idx += num_channels; | 115 interleaved_idx += num_channels; |
116 } | 116 } |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 // Copies audio from a single channel buffer pointed to by |mono| to each | 120 // Copies audio from a single channel buffer pointed to by |mono| to each |
121 // channel of |interleaved|. There must be sufficient space allocated in | 121 // channel of |interleaved|. There must be sufficient space allocated in |
122 // |interleaved| (|samples_per_channel| * |num_channels|). | 122 // |interleaved| (|samples_per_channel| * |num_channels|). |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 template <> | 180 template <> |
181 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved, | 181 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved, |
182 size_t num_frames, | 182 size_t num_frames, |
183 int num_channels, | 183 int num_channels, |
184 int16_t* deinterleaved); | 184 int16_t* deinterleaved); |
185 | 185 |
186 } // namespace webrtc | 186 } // namespace webrtc |
187 | 187 |
188 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ | 188 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ |
OLD | NEW |