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

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

Issue 1234463003: Integrate Intelligibility with APM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added support for distinct reverse input/output streams. Created 5 years, 4 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 for (int i = 0; i < num_channels; ++i) { 95 for (int i = 0; i < num_channels; ++i) {
96 const T* channel = deinterleaved[i]; 96 const T* channel = deinterleaved[i];
97 int interleaved_idx = i; 97 int interleaved_idx = i;
98 for (int j = 0; j < samples_per_channel; ++j) { 98 for (int 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 // Copies audio from a single channel buffer pointed to by |mono| to each
106 // channel of |interleaved|. There must be sufficient space allocated in
107 // |interleaved| (|samples_per_channel| * |num_channels|).
108 template <typename T>
109 void UpmixMonoToInterleaved(const T* mono,
110 int num_frames,
111 int num_channels,
112 T* interleaved) {
113 int interleaved_idx = 0;
114 for (int i = 0; i < num_frames; ++i) {
115 for (int j = 0; j < num_channels; ++j) {
116 interleaved[interleaved_idx++] = mono[i];
117 }
118 }
119 }
120
105 template <typename T, typename Intermediate> 121 template <typename T, typename Intermediate>
106 void DownmixToMono(const T* const* input_channels, 122 void DownmixToMono(const T* const* input_channels,
107 int num_frames, 123 int num_frames,
108 int num_channels, 124 int num_channels,
109 T* out) { 125 T* out) {
110 for (int i = 0; i < num_frames; ++i) { 126 for (int i = 0; i < num_frames; ++i) {
111 Intermediate value = input_channels[0][i]; 127 Intermediate value = input_channels[0][i];
112 for (int j = 1; j < num_channels; ++j) { 128 for (int j = 1; j < num_channels; ++j) {
113 value += input_channels[j][i]; 129 value += input_channels[j][i];
114 } 130 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 164
149 template <> 165 template <>
150 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved, 166 void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved,
151 int num_frames, 167 int num_frames,
152 int num_channels, 168 int num_channels,
153 int16_t* deinterleaved); 169 int16_t* deinterleaved);
154 170
155 } // namespace webrtc 171 } // namespace webrtc
156 172
157 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_ 173 #endif // WEBRTC_COMMON_AUDIO_INCLUDE_AUDIO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698