Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 for (int i = 0; i < num_channels; ++i) { | 90 for (int i = 0; i < num_channels; ++i) { |
| 91 const T* channel = deinterleaved[i]; | 91 const T* channel = deinterleaved[i]; |
| 92 int interleaved_idx = i; | 92 int interleaved_idx = i; |
| 93 for (int j = 0; j < samples_per_channel; ++j) { | 93 for (int j = 0; j < samples_per_channel; ++j) { |
| 94 interleaved[interleaved_idx] = channel[j]; | 94 interleaved[interleaved_idx] = channel[j]; |
| 95 interleaved_idx += num_channels; | 95 interleaved_idx += num_channels; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Copies audio from a single channel buffer pointed to by |mono| to each | |
| 101 // channel of |interleaved|. There must be sufficient space allocated in | |
| 102 // |interleaved| (|samples_per_channel| * |num_channels|). | |
| 103 template <typename T> | |
| 104 void UpmixMonoToInterleaved(const T* mono, int samples_per_channel, | |
|
Andrew MacDonald
2015/07/29 03:52:27
Go with num_frames for new code rather than sample
ekm
2015/07/29 23:35:06
Done.
| |
| 105 int num_channels, T* interleaved) { | |
| 106 int interleaved_idx = 0; | |
| 107 for (int i = 0; i < samples_per_channel; ++i) { | |
| 108 for (int j = 0; j < num_channels; ++j) { | |
| 109 interleaved[interleaved_idx] = mono[i]; | |
|
aluebs-webrtc
2015/07/29 22:17:10
How about:
interleaved[i * num_channels + j] = mo
ekm
2015/07/29 23:35:06
I'd like to avoid the inner multiplication, though
aluebs-webrtc
2015/07/30 15:28:07
Agreed.
| |
| 110 interleaved_idx++; | |
|
Andrew MacDonald
2015/07/29 03:52:27
nit: could put the post-increment in the above lin
ekm
2015/07/29 23:35:06
Done.
| |
| 111 } | |
| 112 } | |
| 113 } | |
| 114 | |
| 100 } // namespace webrtc | 115 } // namespace webrtc |
| 101 | 116 |
| 102 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ | 117 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ |
| OLD | NEW |