OLD | NEW |
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 Loading... |
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 }; |
130 while (in_file.ReadSamples(in_interleaved.size(), | 137 while (in_file.ReadSamples(in_interleaved.size(), |
131 &in_interleaved[0]) == in_interleaved.size()) { | 138 &in_interleaved[0]) == in_interleaved.size()) { |
132 // Have logs display the file time rather than wallclock time. | 139 // Have logs display the file time rather than wallclock time. |
133 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); | 140 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); |
134 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(), | 141 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(), |
135 &in_interleaved[0]); | 142 &in_interleaved[0]); |
136 Deinterleave(&in_interleaved[0], in_buf.num_frames(), | 143 Deinterleave(&in_interleaved[0], in_buf.num_frames(), |
137 in_buf.num_channels(), in_buf.channels()); | 144 in_buf.num_channels(), in_buf.channels()); |
138 | 145 |
139 if (FLAGS_perf) { | 146 if (FLAGS_perf) { |
140 processing_start_time = TickTime::Now(); | 147 processing_start_time = TickTime::Now(); |
141 } | 148 } |
142 CHECK_EQ(kNoErr, | 149 CHECK_EQ(kNoErr, ap->ProcessStream(in_buf.channels(), input_config, |
143 ap->ProcessStream(in_buf.channels(), | 150 output_config, out_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())); | |
150 if (FLAGS_perf) { | 151 if (FLAGS_perf) { |
151 accumulated_time += TickTime::Now() - processing_start_time; | 152 accumulated_time += TickTime::Now() - processing_start_time; |
152 } | 153 } |
153 | 154 |
154 Interleave(out_buf.channels(), out_buf.num_frames(), | 155 Interleave(out_buf.channels(), out_buf.num_frames(), |
155 out_buf.num_channels(), &out_interleaved[0]); | 156 out_buf.num_channels(), &out_interleaved[0]); |
156 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(), | 157 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(), |
157 &out_interleaved[0]); | 158 &out_interleaved[0]); |
158 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size()); | 159 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size()); |
159 num_chunks++; | 160 num_chunks++; |
160 } | 161 } |
161 if (FLAGS_perf) { | 162 if (FLAGS_perf) { |
162 int64_t execution_time_ms = accumulated_time.Milliseconds(); | 163 int64_t execution_time_ms = accumulated_time.Milliseconds(); |
163 printf("\nExecution time: %.3f s\nFile time: %.2f s\n" | 164 printf("\nExecution time: %.3f s\nFile time: %.2f s\n" |
164 "Time per chunk: %.3f ms\n", | 165 "Time per chunk: %.3f ms\n", |
165 execution_time_ms * 0.001f, num_chunks * 1.f / kChunksPerSecond, | 166 execution_time_ms * 0.001f, num_chunks * 1.f / kChunksPerSecond, |
166 execution_time_ms * 1.f / num_chunks); | 167 execution_time_ms * 1.f / num_chunks); |
167 } | 168 } |
168 return 0; | 169 return 0; |
169 } | 170 } |
170 | 171 |
171 } // namespace webrtc | 172 } // namespace webrtc |
172 | 173 |
173 int main(int argc, char* argv[]) { | 174 int main(int argc, char* argv[]) { |
174 return webrtc::main(argc, argv); | 175 return webrtc::main(argc, argv); |
175 } | 176 } |
OLD | NEW |