| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void FloatToFloatS16(const float* src, size_t size, float* dest); | 65 void FloatToFloatS16(const float* src, size_t size, float* dest); |
| 66 void FloatS16ToFloat(const float* src, size_t size, float* dest); | 66 void FloatS16ToFloat(const float* src, size_t size, float* dest); |
| 67 | 67 |
| 68 // Deinterleave audio from |interleaved| to the channel buffers pointed to | 68 // Deinterleave audio from |interleaved| to the channel buffers pointed to |
| 69 // by |deinterleaved|. There must be sufficient space allocated in the | 69 // by |deinterleaved|. There must be sufficient space allocated in the |
| 70 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| | 70 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| |
| 71 // per buffer). | 71 // per buffer). |
| 72 template <typename T> | 72 template <typename T> |
| 73 void Deinterleave(const T* interleaved, | 73 void Deinterleave(const T* interleaved, |
| 74 size_t samples_per_channel, | 74 size_t samples_per_channel, |
| 75 int num_channels, | 75 size_t num_channels, |
| 76 T* const* deinterleaved) { | 76 T* const* deinterleaved) { |
| 77 for (int i = 0; i < num_channels; ++i) { | 77 for (size_t i = 0; i < num_channels; ++i) { |
| 78 T* channel = deinterleaved[i]; | 78 T* channel = deinterleaved[i]; |
| 79 int interleaved_idx = i; | 79 size_t interleaved_idx = i; |
| 80 for (size_t j = 0; j < samples_per_channel; ++j) { | 80 for (size_t j = 0; j < samples_per_channel; ++j) { |
| 81 channel[j] = interleaved[interleaved_idx]; | 81 channel[j] = interleaved[interleaved_idx]; |
| 82 interleaved_idx += num_channels; | 82 interleaved_idx += num_channels; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Interleave audio from the channel buffers pointed to by |deinterleaved| to | 87 // Interleave audio from the channel buffers pointed to by |deinterleaved| to |
| 88 // |interleaved|. There must be sufficient space allocated in |interleaved| | 88 // |interleaved|. There must be sufficient space allocated in |interleaved| |
| 89 // (|samples_per_channel| * |num_channels|). | 89 // (|samples_per_channel| * |num_channels|). |
| 90 template <typename T> | 90 template <typename T> |
| 91 void Interleave(const T* const* deinterleaved, | 91 void Interleave(const T* const* deinterleaved, |
| 92 size_t samples_per_channel, | 92 size_t samples_per_channel, |
| 93 int num_channels, | 93 size_t num_channels, |
| 94 T* interleaved) { | 94 T* interleaved) { |
| 95 for (int i = 0; i < num_channels; ++i) { | 95 for (size_t i = 0; i < num_channels; ++i) { |
| 96 const T* channel = deinterleaved[i]; | 96 const T* channel = deinterleaved[i]; |
| 97 int interleaved_idx = i; | 97 size_t interleaved_idx = i; |
| 98 for (size_t j = 0; j < samples_per_channel; ++j) { | 98 for (size_t j = 0; j < samples_per_channel; ++j) { |
| 99 interleaved[interleaved_idx] = channel[j]; | 99 interleaved[interleaved_idx] = channel[j]; |
| 100 interleaved_idx += num_channels; | 100 interleaved_idx += num_channels; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 template <typename T, typename Intermediate> | 105 template <typename T, typename Intermediate> |
| 106 void DownmixToMono(const T* const* input_channels, | 106 void DownmixToMono(const T* const* input_channels, |
| 107 size_t num_frames, | 107 size_t num_frames, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 template <> | 149 template <> |
| 150 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved, | 150 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved, |
| 151 size_t num_frames, | 151 size_t num_frames, |
| 152 int num_channels, | 152 int num_channels, |
| 153 int16_t* deinterleaved); | 153 int16_t* deinterleaved); |
| 154 | 154 |
| 155 } // namespace webrtc | 155 } // namespace webrtc |
| 156 | 156 |
| 157 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ | 157 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ |
| OLD | NEW |