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

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

Issue 1694423002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/test/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/test_utils.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) 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 <memory>
19
18 #include "gflags/gflags.h" 20 #include "gflags/gflags.h"
19 #include "webrtc/base/format_macros.h" 21 #include "webrtc/base/format_macros.h"
20 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/modules/audio_processing/debug.pb.h" 22 #include "webrtc/modules/audio_processing/debug.pb.h"
22 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 23 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
23 #include "webrtc/modules/audio_processing/test/test_utils.h" 24 #include "webrtc/modules/audio_processing/test/test_utils.h"
24 #include "webrtc/typedefs.h" 25 #include "webrtc/typedefs.h"
25 26
26 // TODO(andrew): unpack more of the data. 27 // TODO(andrew): unpack more of the data.
27 DEFINE_string(input_file, "input", "The name of the input stream file."); 28 DEFINE_string(input_file, "input", "The name of the input stream file.");
28 DEFINE_string(output_file, "ref_out", 29 DEFINE_string(output_file, "ref_out",
29 "The name of the reference output stream file."); 30 "The name of the reference output stream file.");
30 DEFINE_string(reverse_file, "reverse", 31 DEFINE_string(reverse_file, "reverse",
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 FILE* debug_file = OpenFile(argv[1], "rb"); 77 FILE* debug_file = OpenFile(argv[1], "rb");
77 78
78 Event event_msg; 79 Event event_msg;
79 int frame_count = 0; 80 int frame_count = 0;
80 size_t reverse_samples_per_channel = 0; 81 size_t reverse_samples_per_channel = 0;
81 size_t input_samples_per_channel = 0; 82 size_t input_samples_per_channel = 0;
82 size_t output_samples_per_channel = 0; 83 size_t output_samples_per_channel = 0;
83 size_t num_reverse_channels = 0; 84 size_t num_reverse_channels = 0;
84 size_t num_input_channels = 0; 85 size_t num_input_channels = 0;
85 size_t num_output_channels = 0; 86 size_t num_output_channels = 0;
86 rtc::scoped_ptr<WavWriter> reverse_wav_file; 87 std::unique_ptr<WavWriter> reverse_wav_file;
87 rtc::scoped_ptr<WavWriter> input_wav_file; 88 std::unique_ptr<WavWriter> input_wav_file;
88 rtc::scoped_ptr<WavWriter> output_wav_file; 89 std::unique_ptr<WavWriter> output_wav_file;
89 rtc::scoped_ptr<RawFile> reverse_raw_file; 90 std::unique_ptr<RawFile> reverse_raw_file;
90 rtc::scoped_ptr<RawFile> input_raw_file; 91 std::unique_ptr<RawFile> input_raw_file;
91 rtc::scoped_ptr<RawFile> output_raw_file; 92 std::unique_ptr<RawFile> output_raw_file;
92 93
93 FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); 94 FILE* settings_file = OpenFile(FLAGS_settings_file, "wb");
94 95
95 while (ReadMessageFromFile(debug_file, &event_msg)) { 96 while (ReadMessageFromFile(debug_file, &event_msg)) {
96 if (event_msg.type() == Event::REVERSE_STREAM) { 97 if (event_msg.type() == Event::REVERSE_STREAM) {
97 if (!event_msg.has_reverse_stream()) { 98 if (!event_msg.has_reverse_stream()) {
98 printf("Corrupt input file: ReverseStream missing.\n"); 99 printf("Corrupt input file: ReverseStream missing.\n");
99 return 1; 100 return 1;
100 } 101 }
101 102
102 const ReverseStream msg = event_msg.reverse_stream(); 103 const ReverseStream msg = event_msg.reverse_stream();
103 if (msg.has_data()) { 104 if (msg.has_data()) {
104 if (FLAGS_raw && !reverse_raw_file) { 105 if (FLAGS_raw && !reverse_raw_file) {
105 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".pcm")); 106 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".pcm"));
106 } 107 }
107 // TODO(aluebs): Replace "num_reverse_channels * 108 // TODO(aluebs): Replace "num_reverse_channels *
108 // reverse_samples_per_channel" with "msg.data().size() / 109 // reverse_samples_per_channel" with "msg.data().size() /
109 // sizeof(int16_t)" and so on when this fix in audio_processing has made 110 // sizeof(int16_t)" and so on when this fix in audio_processing has made
110 // it into stable: https://webrtc-codereview.appspot.com/15299004/ 111 // it into stable: https://webrtc-codereview.appspot.com/15299004/
111 WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()), 112 WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()),
112 num_reverse_channels * reverse_samples_per_channel, 113 num_reverse_channels * reverse_samples_per_channel,
113 reverse_wav_file.get(), 114 reverse_wav_file.get(),
114 reverse_raw_file.get()); 115 reverse_raw_file.get());
115 } else if (msg.channel_size() > 0) { 116 } else if (msg.channel_size() > 0) {
116 if (FLAGS_raw && !reverse_raw_file) { 117 if (FLAGS_raw && !reverse_raw_file) {
117 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float")); 118 reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float"));
118 } 119 }
119 rtc::scoped_ptr<const float* []> data( 120 std::unique_ptr<const float* []> data(
120 new const float* [num_reverse_channels]); 121 new const float* [num_reverse_channels]);
121 for (size_t i = 0; i < num_reverse_channels; ++i) { 122 for (size_t i = 0; i < num_reverse_channels; ++i) {
122 data[i] = reinterpret_cast<const float*>(msg.channel(i).data()); 123 data[i] = reinterpret_cast<const float*>(msg.channel(i).data());
123 } 124 }
124 WriteFloatData(data.get(), 125 WriteFloatData(data.get(),
125 reverse_samples_per_channel, 126 reverse_samples_per_channel,
126 num_reverse_channels, 127 num_reverse_channels,
127 reverse_wav_file.get(), 128 reverse_wav_file.get(),
128 reverse_raw_file.get()); 129 reverse_raw_file.get());
129 } 130 }
(...skipping 10 matching lines...) Expand all
140 input_raw_file.reset(new RawFile(FLAGS_input_file + ".pcm")); 141 input_raw_file.reset(new RawFile(FLAGS_input_file + ".pcm"));
141 } 142 }
142 WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()), 143 WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()),
143 num_input_channels * input_samples_per_channel, 144 num_input_channels * input_samples_per_channel,
144 input_wav_file.get(), 145 input_wav_file.get(),
145 input_raw_file.get()); 146 input_raw_file.get());
146 } else if (msg.input_channel_size() > 0) { 147 } else if (msg.input_channel_size() > 0) {
147 if (FLAGS_raw && !input_raw_file) { 148 if (FLAGS_raw && !input_raw_file) {
148 input_raw_file.reset(new RawFile(FLAGS_input_file + ".float")); 149 input_raw_file.reset(new RawFile(FLAGS_input_file + ".float"));
149 } 150 }
150 rtc::scoped_ptr<const float* []> data( 151 std::unique_ptr<const float* []> data(
151 new const float* [num_input_channels]); 152 new const float* [num_input_channels]);
152 for (size_t i = 0; i < num_input_channels; ++i) { 153 for (size_t i = 0; i < num_input_channels; ++i) {
153 data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data()); 154 data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data());
154 } 155 }
155 WriteFloatData(data.get(), 156 WriteFloatData(data.get(),
156 input_samples_per_channel, 157 input_samples_per_channel,
157 num_input_channels, 158 num_input_channels,
158 input_wav_file.get(), 159 input_wav_file.get(),
159 input_raw_file.get()); 160 input_raw_file.get());
160 } 161 }
161 162
162 if (msg.has_output_data()) { 163 if (msg.has_output_data()) {
163 if (FLAGS_raw && !output_raw_file) { 164 if (FLAGS_raw && !output_raw_file) {
164 output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm")); 165 output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm"));
165 } 166 }
166 WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()), 167 WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()),
167 num_output_channels * output_samples_per_channel, 168 num_output_channels * output_samples_per_channel,
168 output_wav_file.get(), 169 output_wav_file.get(),
169 output_raw_file.get()); 170 output_raw_file.get());
170 } else if (msg.output_channel_size() > 0) { 171 } else if (msg.output_channel_size() > 0) {
171 if (FLAGS_raw && !output_raw_file) { 172 if (FLAGS_raw && !output_raw_file) {
172 output_raw_file.reset(new RawFile(FLAGS_output_file + ".float")); 173 output_raw_file.reset(new RawFile(FLAGS_output_file + ".float"));
173 } 174 }
174 rtc::scoped_ptr<const float* []> data( 175 std::unique_ptr<const float* []> data(
175 new const float* [num_output_channels]); 176 new const float* [num_output_channels]);
176 for (size_t i = 0; i < num_output_channels; ++i) { 177 for (size_t i = 0; i < num_output_channels; ++i) {
177 data[i] = 178 data[i] =
178 reinterpret_cast<const float*>(msg.output_channel(i).data()); 179 reinterpret_cast<const float*>(msg.output_channel(i).data());
179 } 180 }
180 WriteFloatData(data.get(), 181 WriteFloatData(data.get(),
181 output_samples_per_channel, 182 output_samples_per_channel,
182 num_output_channels, 183 num_output_channels,
183 output_wav_file.get(), 184 output_wav_file.get(),
184 output_raw_file.get()); 185 output_raw_file.get());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 312 }
312 313
313 return 0; 314 return 0;
314 } 315 }
315 316
316 } // namespace webrtc 317 } // namespace webrtc
317 318
318 int main(int argc, char* argv[]) { 319 int main(int argc, char* argv[]) {
319 return webrtc::do_main(argc, argv); 320 return webrtc::do_main(argc, argv);
320 } 321 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698