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

Unified Diff: webrtc/modules/audio_processing/test/unpack.cc

Issue 3005483002: Replace remaining gflags usages with rtc_base/flags (Closed)
Patch Set: Rebase Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/test/unpack.cc
diff --git a/webrtc/modules/audio_processing/test/unpack.cc b/webrtc/modules/audio_processing/test/unpack.cc
index 4c6c18dc473a8efff896e18f36cb107744667ce1..13be27981132529ec086fa58b48e9eedf3392203 100644
--- a/webrtc/modules/audio_processing/test/unpack.cc
+++ b/webrtc/modules/audio_processing/test/unpack.cc
@@ -17,9 +17,9 @@
#include <memory>
-#include "gflags/gflags.h"
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
#include "webrtc/modules/audio_processing/test/test_utils.h"
+#include "webrtc/rtc_base/flags.h"
#include "webrtc/rtc_base/format_macros.h"
#include "webrtc/rtc_base/ignore_wundef.h"
#include "webrtc/typedefs.h"
@@ -45,6 +45,7 @@ DEFINE_bool(raw, false, "Write raw data instead of a WAV file.");
DEFINE_bool(text,
false,
"Write non-audio files as text files instead of binary files.");
+DEFINE_bool(help, false, "Print this message.");
#define PRINT_CONFIG(field_name) \
if (msg.has_##field_name()) { \
@@ -70,11 +71,14 @@ int do_main(int argc, char* argv[]) {
std::string program_name = argv[0];
std::string usage = "Commandline tool to unpack audioproc debug files.\n"
"Example usage:\n" + program_name + " debug_dump.pb\n";
- google::SetUsageMessage(usage);
- google::ParseCommandLineFlags(&argc, &argv, true);
- if (argc < 2) {
- printf("%s", google::ProgramUsage());
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
+ FLAG_help || argc < 2) {
+ printf("%s", usage.c_str());
+ if (FLAG_help) {
+ rtc::FlagList::Print(nullptr, false);
+ return 0;
+ }
return 1;
}
@@ -95,7 +99,7 @@ int do_main(int argc, char* argv[]) {
std::unique_ptr<RawFile> input_raw_file;
std::unique_ptr<RawFile> output_raw_file;
- FILE* settings_file = OpenFile(FLAGS_settings_file, "wb");
+ FILE* settings_file = OpenFile(FLAG_settings_file, "wb");
while (ReadMessageFromFile(debug_file, &event_msg)) {
if (event_msg.type() == Event::REVERSE_STREAM) {
@@ -106,8 +110,9 @@ int do_main(int argc, char* argv[]) {
const ReverseStream msg = event_msg.reverse_stream();
if (msg.has_data()) {
- if (FLAGS_raw && !reverse_raw_file) {
- reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".pcm"));
+ if (FLAG_raw && !reverse_raw_file) {
+ reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
+ ".pcm"));
}
// TODO(aluebs): Replace "num_reverse_channels *
// reverse_samples_per_channel" with "msg.data().size() /
@@ -118,8 +123,9 @@ int do_main(int argc, char* argv[]) {
reverse_wav_file.get(),
reverse_raw_file.get());
} else if (msg.channel_size() > 0) {
- if (FLAGS_raw && !reverse_raw_file) {
- reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float"));
+ if (FLAG_raw && !reverse_raw_file) {
+ reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
+ ".float"));
}
std::unique_ptr<const float* []> data(
new const float* [num_reverse_channels]);
@@ -141,16 +147,18 @@ int do_main(int argc, char* argv[]) {
const Stream msg = event_msg.stream();
if (msg.has_input_data()) {
- if (FLAGS_raw && !input_raw_file) {
- input_raw_file.reset(new RawFile(FLAGS_input_file + ".pcm"));
+ if (FLAG_raw && !input_raw_file) {
+ input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
+ ".pcm"));
}
WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()),
num_input_channels * input_samples_per_channel,
input_wav_file.get(),
input_raw_file.get());
} else if (msg.input_channel_size() > 0) {
- if (FLAGS_raw && !input_raw_file) {
- input_raw_file.reset(new RawFile(FLAGS_input_file + ".float"));
+ if (FLAG_raw && !input_raw_file) {
+ input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
+ ".float"));
}
std::unique_ptr<const float* []> data(
new const float* [num_input_channels]);
@@ -165,16 +173,18 @@ int do_main(int argc, char* argv[]) {
}
if (msg.has_output_data()) {
- if (FLAGS_raw && !output_raw_file) {
- output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm"));
+ if (FLAG_raw && !output_raw_file) {
+ output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
+ ".pcm"));
}
WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()),
num_output_channels * output_samples_per_channel,
output_wav_file.get(),
output_raw_file.get());
} else if (msg.output_channel_size() > 0) {
- if (FLAGS_raw && !output_raw_file) {
- output_raw_file.reset(new RawFile(FLAGS_output_file + ".float"));
+ if (FLAG_raw && !output_raw_file) {
+ output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
+ ".float"));
}
std::unique_ptr<const float* []> data(
new const float* [num_output_channels]);
@@ -189,45 +199,45 @@ int do_main(int argc, char* argv[]) {
output_raw_file.get());
}
- if (FLAGS_full) {
+ if (FLAG_full) {
if (msg.has_delay()) {
- static FILE* delay_file = OpenFile(FLAGS_delay_file, "wb");
+ static FILE* delay_file = OpenFile(FLAG_delay_file, "wb");
int32_t delay = msg.delay();
- if (FLAGS_text) {
+ if (FLAG_text) {
fprintf(delay_file, "%d\n", delay);
} else {
- WriteData(&delay, sizeof(delay), delay_file, FLAGS_delay_file);
+ WriteData(&delay, sizeof(delay), delay_file, FLAG_delay_file);
}
}
if (msg.has_drift()) {
- static FILE* drift_file = OpenFile(FLAGS_drift_file, "wb");
+ static FILE* drift_file = OpenFile(FLAG_drift_file, "wb");
int32_t drift = msg.drift();
- if (FLAGS_text) {
+ if (FLAG_text) {
fprintf(drift_file, "%d\n", drift);
} else {
- WriteData(&drift, sizeof(drift), drift_file, FLAGS_drift_file);
+ WriteData(&drift, sizeof(drift), drift_file, FLAG_drift_file);
}
}
if (msg.has_level()) {
- static FILE* level_file = OpenFile(FLAGS_level_file, "wb");
+ static FILE* level_file = OpenFile(FLAG_level_file, "wb");
int32_t level = msg.level();
- if (FLAGS_text) {
+ if (FLAG_text) {
fprintf(level_file, "%d\n", level);
} else {
- WriteData(&level, sizeof(level), level_file, FLAGS_level_file);
+ WriteData(&level, sizeof(level), level_file, FLAG_level_file);
}
}
if (msg.has_keypress()) {
- static FILE* keypress_file = OpenFile(FLAGS_keypress_file, "wb");
+ static FILE* keypress_file = OpenFile(FLAG_keypress_file, "wb");
bool keypress = msg.keypress();
- if (FLAGS_text) {
+ if (FLAG_text) {
fprintf(keypress_file, "%d\n", keypress);
} else {
WriteData(&keypress, sizeof(keypress), keypress_file,
- FLAGS_keypress_file);
+ FLAG_keypress_file);
}
}
}
@@ -304,21 +314,21 @@ int do_main(int argc, char* argv[]) {
output_samples_per_channel =
static_cast<size_t>(output_sample_rate / 100);
- if (!FLAGS_raw) {
+ if (!FLAG_raw) {
// The WAV files need to be reset every time, because they cant change
// their sample rate or number of channels.
std::stringstream reverse_name;
- reverse_name << FLAGS_reverse_file << frame_count << ".wav";
+ reverse_name << FLAG_reverse_file << frame_count << ".wav";
reverse_wav_file.reset(new WavWriter(reverse_name.str(),
reverse_sample_rate,
num_reverse_channels));
std::stringstream input_name;
- input_name << FLAGS_input_file << frame_count << ".wav";
+ input_name << FLAG_input_file << frame_count << ".wav";
input_wav_file.reset(new WavWriter(input_name.str(),
input_sample_rate,
num_input_channels));
std::stringstream output_name;
- output_name << FLAGS_output_file << frame_count << ".wav";
+ output_name << FLAG_output_file << frame_count << ".wav";
output_wav_file.reset(new WavWriter(output_name.str(),
output_sample_rate,
num_output_channels));

Powered by Google App Engine
This is Rietveld 408576698