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

Side by Side Diff: webrtc/modules/audio_processing/test/audioproc_float.cc

Issue 1253573005: Revert of Allow more than 2 input channels in AudioProcessing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/modules/audio_processing/test/audio_processing_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 in_file.num_channels()); 120 in_file.num_channels());
121 ChannelBuffer<float> out_buf( 121 ChannelBuffer<float> out_buf(
122 rtc::CheckedDivExact(out_file.sample_rate(), kChunksPerSecond), 122 rtc::CheckedDivExact(out_file.sample_rate(), kChunksPerSecond),
123 out_file.num_channels()); 123 out_file.num_channels());
124 124
125 std::vector<float> in_interleaved(in_buf.size()); 125 std::vector<float> in_interleaved(in_buf.size());
126 std::vector<float> out_interleaved(out_buf.size()); 126 std::vector<float> out_interleaved(out_buf.size());
127 TickTime processing_start_time; 127 TickTime processing_start_time;
128 TickInterval accumulated_time; 128 TickInterval accumulated_time;
129 int num_chunks = 0; 129 int num_chunks = 0;
130
131 const StreamConfig input_config = {
132 in_file.sample_rate(), in_buf.num_channels(),
133 };
134 const StreamConfig output_config = {
135 out_file.sample_rate(), out_buf.num_channels(),
136 };
137 while (in_file.ReadSamples(in_interleaved.size(), 130 while (in_file.ReadSamples(in_interleaved.size(),
138 &in_interleaved[0]) == in_interleaved.size()) { 131 &in_interleaved[0]) == in_interleaved.size()) {
139 // Have logs display the file time rather than wallclock time. 132 // Have logs display the file time rather than wallclock time.
140 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); 133 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond);
141 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(), 134 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(),
142 &in_interleaved[0]); 135 &in_interleaved[0]);
143 Deinterleave(&in_interleaved[0], in_buf.num_frames(), 136 Deinterleave(&in_interleaved[0], in_buf.num_frames(),
144 in_buf.num_channels(), in_buf.channels()); 137 in_buf.num_channels(), in_buf.channels());
145 138
146 if (FLAGS_perf) { 139 if (FLAGS_perf) {
147 processing_start_time = TickTime::Now(); 140 processing_start_time = TickTime::Now();
148 } 141 }
149 CHECK_EQ(kNoErr, ap->ProcessStream(in_buf.channels(), input_config, 142 CHECK_EQ(kNoErr,
150 output_config, out_buf.channels())); 143 ap->ProcessStream(in_buf.channels(),
144 in_buf.num_frames(),
145 in_file.sample_rate(),
146 LayoutFromChannels(in_buf.num_channels()),
147 out_file.sample_rate(),
148 LayoutFromChannels(out_buf.num_channels()),
149 out_buf.channels()));
151 if (FLAGS_perf) { 150 if (FLAGS_perf) {
152 accumulated_time += TickTime::Now() - processing_start_time; 151 accumulated_time += TickTime::Now() - processing_start_time;
153 } 152 }
154 153
155 Interleave(out_buf.channels(), out_buf.num_frames(), 154 Interleave(out_buf.channels(), out_buf.num_frames(),
156 out_buf.num_channels(), &out_interleaved[0]); 155 out_buf.num_channels(), &out_interleaved[0]);
157 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(), 156 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(),
158 &out_interleaved[0]); 157 &out_interleaved[0]);
159 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size()); 158 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size());
160 num_chunks++; 159 num_chunks++;
161 } 160 }
162 if (FLAGS_perf) { 161 if (FLAGS_perf) {
163 int64_t execution_time_ms = accumulated_time.Milliseconds(); 162 int64_t execution_time_ms = accumulated_time.Milliseconds();
164 printf("\nExecution time: %.3f s\nFile time: %.2f s\n" 163 printf("\nExecution time: %.3f s\nFile time: %.2f s\n"
165 "Time per chunk: %.3f ms\n", 164 "Time per chunk: %.3f ms\n",
166 execution_time_ms * 0.001f, num_chunks * 1.f / kChunksPerSecond, 165 execution_time_ms * 0.001f, num_chunks * 1.f / kChunksPerSecond,
167 execution_time_ms * 1.f / num_chunks); 166 execution_time_ms * 1.f / num_chunks);
168 } 167 }
169 return 0; 168 return 0;
170 } 169 }
171 170
172 } // namespace webrtc 171 } // namespace webrtc
173 172
174 int main(int argc, char* argv[]) { 173 int main(int argc, char* argv[]) {
175 return webrtc::main(argc, argv); 174 return webrtc::main(argc, argv);
176 } 175 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/audio_processing_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698