OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
11 // Commandline tool to unpack audioproc debug files. | 11 // Commandline tool to unpack audioproc debug files. |
12 // | 12 // |
13 // The debug files are dumped as protobuf blobs. For analysis, it's necessary | 13 // The debug files are dumped as protobuf blobs. For analysis, it's necessary |
14 // to unpack the file into its component parts: audio and other data. | 14 // to unpack the file into its component parts: audio and other data. |
15 | 15 |
16 #include <stdio.h> | 16 #include <stdio.h> |
17 | 17 |
18 #include "gflags/gflags.h" | 18 #include "gflags/gflags.h" |
19 #include "webrtc/audio_processing/debug.pb.h" | 19 #include "webrtc/audio_processing/debug.pb.h" |
| 20 #include "webrtc/base/format_macros.h" |
20 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" |
21 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 22 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
22 #include "webrtc/modules/audio_processing/test/test_utils.h" | 23 #include "webrtc/modules/audio_processing/test/test_utils.h" |
23 #include "webrtc/typedefs.h" | 24 #include "webrtc/typedefs.h" |
24 | 25 |
25 // TODO(andrew): unpack more of the data. | 26 // TODO(andrew): unpack more of the data. |
26 DEFINE_string(input_file, "input", "The name of the input stream file."); | 27 DEFINE_string(input_file, "input", "The name of the input stream file."); |
27 DEFINE_string(output_file, "ref_out", | 28 DEFINE_string(output_file, "ref_out", |
28 "The name of the reference output stream file."); | 29 "The name of the reference output stream file."); |
29 DEFINE_string(reverse_file, "reverse", | 30 DEFINE_string(reverse_file, "reverse", |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return 1; | 73 return 1; |
73 } | 74 } |
74 | 75 |
75 FILE* debug_file = OpenFile(argv[1], "rb"); | 76 FILE* debug_file = OpenFile(argv[1], "rb"); |
76 | 77 |
77 Event event_msg; | 78 Event event_msg; |
78 int frame_count = 0; | 79 int frame_count = 0; |
79 size_t reverse_samples_per_channel = 0; | 80 size_t reverse_samples_per_channel = 0; |
80 size_t input_samples_per_channel = 0; | 81 size_t input_samples_per_channel = 0; |
81 size_t output_samples_per_channel = 0; | 82 size_t output_samples_per_channel = 0; |
82 int num_reverse_channels = 0; | 83 size_t num_reverse_channels = 0; |
83 int num_input_channels = 0; | 84 size_t num_input_channels = 0; |
84 int num_output_channels = 0; | 85 size_t num_output_channels = 0; |
85 rtc::scoped_ptr<WavWriter> reverse_wav_file; | 86 rtc::scoped_ptr<WavWriter> reverse_wav_file; |
86 rtc::scoped_ptr<WavWriter> input_wav_file; | 87 rtc::scoped_ptr<WavWriter> input_wav_file; |
87 rtc::scoped_ptr<WavWriter> output_wav_file; | 88 rtc::scoped_ptr<WavWriter> output_wav_file; |
88 rtc::scoped_ptr<RawFile> reverse_raw_file; | 89 rtc::scoped_ptr<RawFile> reverse_raw_file; |
89 rtc::scoped_ptr<RawFile> input_raw_file; | 90 rtc::scoped_ptr<RawFile> input_raw_file; |
90 rtc::scoped_ptr<RawFile> output_raw_file; | 91 rtc::scoped_ptr<RawFile> output_raw_file; |
91 | 92 |
92 FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); | 93 FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); |
93 | 94 |
94 while (ReadMessageFromFile(debug_file, &event_msg)) { | 95 while (ReadMessageFromFile(debug_file, &event_msg)) { |
(...skipping 15 matching lines...) Expand all Loading... |
110 WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()), | 111 WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()), |
111 num_reverse_channels * reverse_samples_per_channel, | 112 num_reverse_channels * reverse_samples_per_channel, |
112 reverse_wav_file.get(), | 113 reverse_wav_file.get(), |
113 reverse_raw_file.get()); | 114 reverse_raw_file.get()); |
114 } else if (msg.channel_size() > 0) { | 115 } else if (msg.channel_size() > 0) { |
115 if (FLAGS_raw && !reverse_raw_file) { | 116 if (FLAGS_raw && !reverse_raw_file) { |
116 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float")); | 117 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float")); |
117 } | 118 } |
118 rtc::scoped_ptr<const float* []> data( | 119 rtc::scoped_ptr<const float* []> data( |
119 new const float* [num_reverse_channels]); | 120 new const float* [num_reverse_channels]); |
120 for (int i = 0; i < num_reverse_channels; ++i) { | 121 for (size_t i = 0; i < num_reverse_channels; ++i) { |
121 data[i] = reinterpret_cast<const float*>(msg.channel(i).data()); | 122 data[i] = reinterpret_cast<const float*>(msg.channel(i).data()); |
122 } | 123 } |
123 WriteFloatData(data.get(), | 124 WriteFloatData(data.get(), |
124 reverse_samples_per_channel, | 125 reverse_samples_per_channel, |
125 num_reverse_channels, | 126 num_reverse_channels, |
126 reverse_wav_file.get(), | 127 reverse_wav_file.get(), |
127 reverse_raw_file.get()); | 128 reverse_raw_file.get()); |
128 } | 129 } |
129 } else if (event_msg.type() == Event::STREAM) { | 130 } else if (event_msg.type() == Event::STREAM) { |
130 frame_count++; | 131 frame_count++; |
(...skipping 10 matching lines...) Expand all Loading... |
141 WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()), | 142 WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()), |
142 num_input_channels * input_samples_per_channel, | 143 num_input_channels * input_samples_per_channel, |
143 input_wav_file.get(), | 144 input_wav_file.get(), |
144 input_raw_file.get()); | 145 input_raw_file.get()); |
145 } else if (msg.input_channel_size() > 0) { | 146 } else if (msg.input_channel_size() > 0) { |
146 if (FLAGS_raw && !input_raw_file) { | 147 if (FLAGS_raw && !input_raw_file) { |
147 input_raw_file.reset(new RawFile(FLAGS_input_file + ".float")); | 148 input_raw_file.reset(new RawFile(FLAGS_input_file + ".float")); |
148 } | 149 } |
149 rtc::scoped_ptr<const float* []> data( | 150 rtc::scoped_ptr<const float* []> data( |
150 new const float* [num_input_channels]); | 151 new const float* [num_input_channels]); |
151 for (int i = 0; i < num_input_channels; ++i) { | 152 for (size_t i = 0; i < num_input_channels; ++i) { |
152 data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data()); | 153 data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data()); |
153 } | 154 } |
154 WriteFloatData(data.get(), | 155 WriteFloatData(data.get(), |
155 input_samples_per_channel, | 156 input_samples_per_channel, |
156 num_input_channels, | 157 num_input_channels, |
157 input_wav_file.get(), | 158 input_wav_file.get(), |
158 input_raw_file.get()); | 159 input_raw_file.get()); |
159 } | 160 } |
160 | 161 |
161 if (msg.has_output_data()) { | 162 if (msg.has_output_data()) { |
162 if (FLAGS_raw && !output_raw_file) { | 163 if (FLAGS_raw && !output_raw_file) { |
163 output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm")); | 164 output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm")); |
164 } | 165 } |
165 WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()), | 166 WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()), |
166 num_output_channels * output_samples_per_channel, | 167 num_output_channels * output_samples_per_channel, |
167 output_wav_file.get(), | 168 output_wav_file.get(), |
168 output_raw_file.get()); | 169 output_raw_file.get()); |
169 } else if (msg.output_channel_size() > 0) { | 170 } else if (msg.output_channel_size() > 0) { |
170 if (FLAGS_raw && !output_raw_file) { | 171 if (FLAGS_raw && !output_raw_file) { |
171 output_raw_file.reset(new RawFile(FLAGS_output_file + ".float")); | 172 output_raw_file.reset(new RawFile(FLAGS_output_file + ".float")); |
172 } | 173 } |
173 rtc::scoped_ptr<const float* []> data( | 174 rtc::scoped_ptr<const float* []> data( |
174 new const float* [num_output_channels]); | 175 new const float* [num_output_channels]); |
175 for (int i = 0; i < num_output_channels; ++i) { | 176 for (size_t i = 0; i < num_output_channels; ++i) { |
176 data[i] = | 177 data[i] = |
177 reinterpret_cast<const float*>(msg.output_channel(i).data()); | 178 reinterpret_cast<const float*>(msg.output_channel(i).data()); |
178 } | 179 } |
179 WriteFloatData(data.get(), | 180 WriteFloatData(data.get(), |
180 output_samples_per_channel, | 181 output_samples_per_channel, |
181 num_output_channels, | 182 num_output_channels, |
182 output_wav_file.get(), | 183 output_wav_file.get(), |
183 output_raw_file.get()); | 184 output_raw_file.get()); |
184 } | 185 } |
185 | 186 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 fprintf(settings_file, "Init at frame: %d\n", frame_count); | 262 fprintf(settings_file, "Init at frame: %d\n", frame_count); |
262 int input_sample_rate = msg.sample_rate(); | 263 int input_sample_rate = msg.sample_rate(); |
263 fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); | 264 fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); |
264 int output_sample_rate = msg.output_sample_rate(); | 265 int output_sample_rate = msg.output_sample_rate(); |
265 fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); | 266 fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); |
266 int reverse_sample_rate = msg.reverse_sample_rate(); | 267 int reverse_sample_rate = msg.reverse_sample_rate(); |
267 fprintf(settings_file, | 268 fprintf(settings_file, |
268 " Reverse sample rate: %d\n", | 269 " Reverse sample rate: %d\n", |
269 reverse_sample_rate); | 270 reverse_sample_rate); |
270 num_input_channels = msg.num_input_channels(); | 271 num_input_channels = msg.num_input_channels(); |
271 fprintf(settings_file, " Input channels: %d\n", num_input_channels); | 272 fprintf(settings_file, " Input channels: %" PRIuS "\n", |
| 273 num_input_channels); |
272 num_output_channels = msg.num_output_channels(); | 274 num_output_channels = msg.num_output_channels(); |
273 fprintf(settings_file, " Output channels: %d\n", num_output_channels); | 275 fprintf(settings_file, " Output channels: %" PRIuS "\n", |
| 276 num_output_channels); |
274 num_reverse_channels = msg.num_reverse_channels(); | 277 num_reverse_channels = msg.num_reverse_channels(); |
275 fprintf(settings_file, " Reverse channels: %d\n", num_reverse_channels); | 278 fprintf(settings_file, " Reverse channels: %" PRIuS "\n", |
| 279 num_reverse_channels); |
276 | 280 |
277 fprintf(settings_file, "\n"); | 281 fprintf(settings_file, "\n"); |
278 | 282 |
279 if (reverse_sample_rate == 0) { | 283 if (reverse_sample_rate == 0) { |
280 reverse_sample_rate = input_sample_rate; | 284 reverse_sample_rate = input_sample_rate; |
281 } | 285 } |
282 if (output_sample_rate == 0) { | 286 if (output_sample_rate == 0) { |
283 output_sample_rate = input_sample_rate; | 287 output_sample_rate = input_sample_rate; |
284 } | 288 } |
285 | 289 |
(...skipping 21 matching lines...) Expand all Loading... |
307 } | 311 } |
308 | 312 |
309 return 0; | 313 return 0; |
310 } | 314 } |
311 | 315 |
312 } // namespace webrtc | 316 } // namespace webrtc |
313 | 317 |
314 int main(int argc, char* argv[]) { | 318 int main(int argc, char* argv[]) { |
315 return webrtc::do_main(argc, argv); | 319 return webrtc::do_main(argc, argv); |
316 } | 320 } |
OLD | NEW |