Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: webrtc/common_audio/include/audio_util.h

Issue 1227203003: Update audio code to use size_t more correctly, webrtc/common_audio/ portion. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void S16ToFloat(const int16_t* src, size_t size, float* dest); 62 void S16ToFloat(const int16_t* src, size_t size, float* dest);
63 void FloatS16ToS16(const float* src, size_t size, int16_t* dest); 63 void FloatS16ToS16(const float* src, size_t size, int16_t* dest);
64 void FloatToFloatS16(const float* src, size_t size, float* dest); 64 void FloatToFloatS16(const float* src, size_t size, float* dest);
65 void FloatS16ToFloat(const float* src, size_t size, float* dest); 65 void FloatS16ToFloat(const float* src, size_t size, float* dest);
66 66
67 // Deinterleave audio from |interleaved| to the channel buffers pointed to 67 // Deinterleave audio from |interleaved| to the channel buffers pointed to
68 // by |deinterleaved|. There must be sufficient space allocated in the 68 // by |deinterleaved|. There must be sufficient space allocated in the
69 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel| 69 // |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel|
70 // per buffer). 70 // per buffer).
71 template <typename T> 71 template <typename T>
72 void Deinterleave(const T* interleaved, int samples_per_channel, 72 void Deinterleave(const T* interleaved, size_t samples_per_channel,
73 int num_channels, T* const* deinterleaved) { 73 int num_channels, T* const* deinterleaved) {
74 for (int i = 0; i < num_channels; ++i) { 74 for (int i = 0; i < num_channels; ++i) {
75 T* channel = deinterleaved[i]; 75 T* channel = deinterleaved[i];
76 int interleaved_idx = i; 76 int interleaved_idx = i;
77 for (int j = 0; j < samples_per_channel; ++j) { 77 for (size_t j = 0; j < samples_per_channel; ++j) {
78 channel[j] = interleaved[interleaved_idx]; 78 channel[j] = interleaved[interleaved_idx];
79 interleaved_idx += num_channels; 79 interleaved_idx += num_channels;
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 // Interleave audio from the channel buffers pointed to by |deinterleaved| to 84 // Interleave audio from the channel buffers pointed to by |deinterleaved| to
85 // |interleaved|. There must be sufficient space allocated in |interleaved| 85 // |interleaved|. There must be sufficient space allocated in |interleaved|
86 // (|samples_per_channel| * |num_channels|). 86 // (|samples_per_channel| * |num_channels|).
87 template <typename T> 87 template <typename T>
88 void Interleave(const T* const* deinterleaved, int samples_per_channel, 88 void Interleave(const T* const* deinterleaved, size_t samples_per_channel,
89 int num_channels, T* interleaved) { 89 int num_channels, T* interleaved) {
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 (size_t 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 } // namespace webrtc 100 } // namespace webrtc
101 101
102 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ 102 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698