andrew@webrtc.org | b6fadb1 | 2013-04-29 17:27:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/common_audio/include/audio_util.h" |
| 12 | |
| 13 | #include "webrtc/typedefs.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | void Deinterleave(const int16_t* interleaved, int samples_per_channel, |
| 18 | int num_channels, int16_t** deinterleaved) { |
| 19 | for (int i = 0; i < num_channels; i++) { |
| 20 | int16_t* channel = deinterleaved[i]; |
| 21 | int interleaved_idx = i; |
| 22 | for (int j = 0; j < samples_per_channel; j++) { |
| 23 | channel[j] = interleaved[interleaved_idx]; |
| 24 | interleaved_idx += num_channels; |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | void Interleave(const int16_t* const* deinterleaved, int samples_per_channel, |
| 30 | int num_channels, int16_t* interleaved) { |
| 31 | for (int i = 0; i < num_channels; ++i) { |
| 32 | const int16_t* channel = deinterleaved[i]; |
| 33 | int interleaved_idx = i; |
| 34 | for (int j = 0; j < samples_per_channel; j++) { |
| 35 | interleaved[interleaved_idx] = channel[j]; |
| 36 | interleaved_idx += num_channels; |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | } // namespace webrtc |