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

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

Issue 1308893002: Add a base class to Wav{Reader,Writer} to access shared parameters. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add virtual destructor. Created 5 years, 3 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/common_audio/wav_file.h ('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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 const int kChunksPerSecond = 100; 57 const int kChunksPerSecond = 100;
58 const char kUsage[] = 58 const char kUsage[] =
59 "Command-line tool to run audio processing on WAV files. Accepts either\n" 59 "Command-line tool to run audio processing on WAV files. Accepts either\n"
60 "an input capture WAV file or protobuf debug dump and writes to an output\n" 60 "an input capture WAV file or protobuf debug dump and writes to an output\n"
61 "WAV file.\n" 61 "WAV file.\n"
62 "\n" 62 "\n"
63 "All components are disabled by default. If any bi-directional components\n" 63 "All components are disabled by default. If any bi-directional components\n"
64 "are enabled, only debug dump files are permitted."; 64 "are enabled, only debug dump files are permitted.";
65 65
66 // Returns a StreamConfig corresponding to wav_file if it's non-nullptr.
67 // Otherwise returns a default initialized StreamConfig.
68 StreamConfig MakeStreamConfig(const WavFile* wav_file) {
69 if (wav_file) {
70 return {wav_file->sample_rate(), wav_file->num_channels()};
71 }
72 return {};
73 }
74
66 } // namespace 75 } // namespace
67 76
68 int main(int argc, char* argv[]) { 77 int main(int argc, char* argv[]) {
69 google::SetUsageMessage(kUsage); 78 google::SetUsageMessage(kUsage);
70 google::ParseCommandLineFlags(&argc, &argv, true); 79 google::ParseCommandLineFlags(&argc, &argv, true);
71 80
72 if (!((FLAGS_i.empty()) ^ (FLAGS_dump.empty()))) { 81 if (!((FLAGS_i.empty()) ^ (FLAGS_dump.empty()))) {
73 fprintf(stderr, 82 fprintf(stderr,
74 "An input file must be specified with either -i or -dump.\n"); 83 "An input file must be specified with either -i or -dump.\n");
75 return 1; 84 return 1;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 out_rev_buf.reset(new ChannelBuffer<float>( 164 out_rev_buf.reset(new ChannelBuffer<float>(
156 rtc::CheckedDivExact(out_rev_file->sample_rate(), kChunksPerSecond), 165 rtc::CheckedDivExact(out_rev_file->sample_rate(), kChunksPerSecond),
157 out_rev_file->num_channels())); 166 out_rev_file->num_channels()));
158 out_rev_interleaved.resize(out_rev_buf->size()); 167 out_rev_interleaved.resize(out_rev_buf->size());
159 } 168 }
160 169
161 TickTime processing_start_time; 170 TickTime processing_start_time;
162 TickInterval accumulated_time; 171 TickInterval accumulated_time;
163 int num_chunks = 0; 172 int num_chunks = 0;
164 173
165 const StreamConfig input_config = { 174 const auto input_config = MakeStreamConfig(&in_file);
166 in_file.sample_rate(), in_buf.num_channels(), 175 const auto output_config = MakeStreamConfig(&out_file);
167 }; 176 const auto reverse_input_config = MakeStreamConfig(in_rev_file.get());
168 const StreamConfig output_config = { 177 const auto reverse_output_config = MakeStreamConfig(out_rev_file.get());
169 out_file.sample_rate(), out_buf.num_channels(),
170 };
171 178
172 StreamConfig reverse_input_config = {};
173 StreamConfig reverse_output_config = {};
174 if (process_reverse) {
175 reverse_input_config = {in_rev_file->sample_rate(),
176 in_rev_file->num_channels()};
177 reverse_output_config = {out_rev_file->sample_rate(),
178 out_rev_file->num_channels()};
179 }
180 while (in_file.ReadSamples(in_interleaved.size(), 179 while (in_file.ReadSamples(in_interleaved.size(),
181 &in_interleaved[0]) == in_interleaved.size()) { 180 &in_interleaved[0]) == in_interleaved.size()) {
182 // Have logs display the file time rather than wallclock time. 181 // Have logs display the file time rather than wallclock time.
183 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); 182 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond);
184 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(), 183 FloatS16ToFloat(&in_interleaved[0], in_interleaved.size(),
185 &in_interleaved[0]); 184 &in_interleaved[0]);
186 Deinterleave(&in_interleaved[0], in_buf.num_frames(), 185 Deinterleave(&in_interleaved[0], in_buf.num_frames(),
187 in_buf.num_channels(), in_buf.channels()); 186 in_buf.num_channels(), in_buf.channels());
188 if (process_reverse) { 187 if (process_reverse) {
189 in_rev_file->ReadSamples(in_rev_interleaved.size(), 188 in_rev_file->ReadSamples(in_rev_interleaved.size(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 execution_time_ms * 1.f / num_chunks); 230 execution_time_ms * 1.f / num_chunks);
232 } 231 }
233 return 0; 232 return 0;
234 } 233 }
235 234
236 } // namespace webrtc 235 } // namespace webrtc
237 236
238 int main(int argc, char* argv[]) { 237 int main(int argc, char* argv[]) {
239 return webrtc::main(argc, argv); 238 return webrtc::main(argc, argv);
240 } 239 }
OLDNEW
« no previous file with comments | « webrtc/common_audio/wav_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698