vpx{enc,dec}: add --help
only output short usage to stderr on error, with --help use stdout Change-Id: I7089f3bca829817e14b14c766f4f3eaee6f54e5c
This commit is contained in:
parent
f0b4868625
commit
c5f5f4ed17
56
vpxdec.c
56
vpxdec.c
@ -47,6 +47,8 @@ struct VpxDecInputContext {
|
|||||||
struct WebmInputContext *webm_ctx;
|
struct WebmInputContext *webm_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const arg_def_t help =
|
||||||
|
ARG_DEF(NULL, "help", 0, "Show usage options and exit");
|
||||||
static const arg_def_t looparg =
|
static const arg_def_t looparg =
|
||||||
ARG_DEF(NULL, "loops", 1, "Number of times to decode the file");
|
ARG_DEF(NULL, "loops", 1, "Number of times to decode the file");
|
||||||
static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, "Codec to use");
|
static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, "Codec to use");
|
||||||
@ -98,17 +100,17 @@ static const arg_def_t framestatsarg =
|
|||||||
ARG_DEF(NULL, "framestats", 1, "Output per-frame stats (.csv format)");
|
ARG_DEF(NULL, "framestats", 1, "Output per-frame stats (.csv format)");
|
||||||
|
|
||||||
static const arg_def_t *all_args[] = {
|
static const arg_def_t *all_args[] = {
|
||||||
&codecarg, &use_yv12, &use_i420,
|
&help, &codecarg, &use_yv12,
|
||||||
&flipuvarg, &rawvideo, &noblitarg,
|
&use_i420, &flipuvarg, &rawvideo,
|
||||||
&progressarg, &limitarg, &skiparg,
|
&noblitarg, &progressarg, &limitarg,
|
||||||
&postprocarg, &summaryarg, &outputfile,
|
&skiparg, &postprocarg, &summaryarg,
|
||||||
&threadsarg, &frameparallelarg, &verbosearg,
|
&outputfile, &threadsarg, &frameparallelarg,
|
||||||
&scalearg, &fb_arg, &md5arg,
|
&verbosearg, &scalearg, &fb_arg,
|
||||||
&error_concealment, &continuearg,
|
&md5arg, &error_concealment, &continuearg,
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
&outbitdeptharg,
|
&outbitdeptharg,
|
||||||
#endif
|
#endif
|
||||||
&svcdecodingarg, &framestatsarg, NULL
|
&svcdecodingarg, &framestatsarg, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_VP8_DECODER
|
#if CONFIG_VP8_DECODER
|
||||||
@ -152,41 +154,47 @@ static INLINE int libyuv_scale(vpx_image_t *src, vpx_image_t *dst,
|
|||||||
dst->d_h, mode);
|
dst->d_h, mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
void show_help(FILE *fout, int shorthelp) {
|
||||||
void usage_exit(void) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(fout, "Usage: %s <options> filename\n\n", exec_name);
|
||||||
"Usage: %s <options> filename\n\n"
|
|
||||||
"Options:\n",
|
if (shorthelp) {
|
||||||
exec_name);
|
fprintf(fout, "Use --help to see the full list of options.\n");
|
||||||
arg_show_usage(stderr, all_args);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fout, "Options:\n");
|
||||||
|
arg_show_usage(fout, all_args);
|
||||||
#if CONFIG_VP8_DECODER
|
#if CONFIG_VP8_DECODER
|
||||||
fprintf(stderr, "\nVP8 Postprocessing Options:\n");
|
fprintf(fout, "\nVP8 Postprocessing Options:\n");
|
||||||
arg_show_usage(stderr, vp8_pp_args);
|
arg_show_usage(fout, vp8_pp_args);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr,
|
fprintf(fout,
|
||||||
"\nOutput File Patterns:\n\n"
|
"\nOutput File Patterns:\n\n"
|
||||||
" The -o argument specifies the name of the file(s) to "
|
" The -o argument specifies the name of the file(s) to "
|
||||||
"write to. If the\n argument does not include any escape "
|
"write to. If the\n argument does not include any escape "
|
||||||
"characters, the output will be\n written to a single file. "
|
"characters, the output will be\n written to a single file. "
|
||||||
"Otherwise, the filename will be calculated by\n expanding "
|
"Otherwise, the filename will be calculated by\n expanding "
|
||||||
"the following escape characters:\n");
|
"the following escape characters:\n");
|
||||||
fprintf(stderr,
|
fprintf(fout,
|
||||||
"\n\t%%w - Frame width"
|
"\n\t%%w - Frame width"
|
||||||
"\n\t%%h - Frame height"
|
"\n\t%%h - Frame height"
|
||||||
"\n\t%%<n> - Frame number, zero padded to <n> places (1..9)"
|
"\n\t%%<n> - Frame number, zero padded to <n> places (1..9)"
|
||||||
"\n\n Pattern arguments are only supported in conjunction "
|
"\n\n Pattern arguments are only supported in conjunction "
|
||||||
"with the --yv12 and\n --i420 options. If the -o option is "
|
"with the --yv12 and\n --i420 options. If the -o option is "
|
||||||
"not specified, the output will be\n directed to stdout.\n");
|
"not specified, the output will be\n directed to stdout.\n");
|
||||||
fprintf(stderr, "\nIncluded decoders:\n\n");
|
fprintf(fout, "\nIncluded decoders:\n\n");
|
||||||
|
|
||||||
for (i = 0; i < get_vpx_decoder_count(); ++i) {
|
for (i = 0; i < get_vpx_decoder_count(); ++i) {
|
||||||
const VpxInterface *const decoder = get_vpx_decoder_by_index(i);
|
const VpxInterface *const decoder = get_vpx_decoder_by_index(i);
|
||||||
fprintf(stderr, " %-6s - %s\n", decoder->name,
|
fprintf(fout, " %-6s - %s\n", decoder->name,
|
||||||
vpx_codec_iface_name(decoder->codec_interface()));
|
vpx_codec_iface_name(decoder->codec_interface()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage_exit(void) {
|
||||||
|
show_help(stderr, 1);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,7 +562,10 @@ static int main_loop(int argc, const char **argv_) {
|
|||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
arg.argv_step = 1;
|
arg.argv_step = 1;
|
||||||
|
|
||||||
if (arg_match(&arg, &codecarg, argi)) {
|
if (arg_match(&arg, &help, argi)) {
|
||||||
|
show_help(stdout, 0);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (arg_match(&arg, &codecarg, argi)) {
|
||||||
interface = get_vpx_decoder_by_name(arg.val);
|
interface = get_vpx_decoder_by_name(arg.val);
|
||||||
if (!interface)
|
if (!interface)
|
||||||
die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
|
die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
|
||||||
@ -651,6 +662,7 @@ static int main_loop(int argc, const char **argv_) {
|
|||||||
|
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
free(argv);
|
free(argv);
|
||||||
|
fprintf(stderr, "No input file specified!\n");
|
||||||
usage_exit();
|
usage_exit();
|
||||||
}
|
}
|
||||||
/* Open file */
|
/* Open file */
|
||||||
|
69
vpxenc.c
69
vpxenc.c
@ -123,6 +123,8 @@ static int fourcc_is_ivf(const char detect[4]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const arg_def_t help =
|
||||||
|
ARG_DEF(NULL, "help", 0, "Show usage options and exit");
|
||||||
static const arg_def_t debugmode =
|
static const arg_def_t debugmode =
|
||||||
ARG_DEF("D", "debug", 0, "Debug mode (makes output deterministic)");
|
ARG_DEF("D", "debug", 0, "Debug mode (makes output deterministic)");
|
||||||
static const arg_def_t outputfile =
|
static const arg_def_t outputfile =
|
||||||
@ -199,7 +201,8 @@ static const arg_def_t test16bitinternalarg = ARG_DEF(
|
|||||||
NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer");
|
NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const arg_def_t *main_args[] = { &debugmode,
|
static const arg_def_t *main_args[] = { &help,
|
||||||
|
&debugmode,
|
||||||
&outputfile,
|
&outputfile,
|
||||||
&codecarg,
|
&codecarg,
|
||||||
&passes,
|
&passes,
|
||||||
@ -549,46 +552,54 @@ static const int vp9_arg_ctrl_map[] = { VP8E_SET_CPUUSED,
|
|||||||
|
|
||||||
static const arg_def_t *no_args[] = { NULL };
|
static const arg_def_t *no_args[] = { NULL };
|
||||||
|
|
||||||
void usage_exit(void) {
|
void show_help(FILE *fout, int shorthelp) {
|
||||||
int i;
|
int i;
|
||||||
const int num_encoder = get_vpx_encoder_count();
|
const int num_encoder = get_vpx_encoder_count();
|
||||||
|
|
||||||
fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n",
|
fprintf(fout, "Usage: %s <options> -o dst_filename src_filename \n",
|
||||||
exec_name);
|
exec_name);
|
||||||
|
|
||||||
fprintf(stderr, "\nOptions:\n");
|
if (shorthelp) {
|
||||||
arg_show_usage(stderr, main_args);
|
fprintf(fout, "Use --help to see the full list of options.\n");
|
||||||
fprintf(stderr, "\nEncoder Global Options:\n");
|
return;
|
||||||
arg_show_usage(stderr, global_args);
|
}
|
||||||
fprintf(stderr, "\nRate Control Options:\n");
|
|
||||||
arg_show_usage(stderr, rc_args);
|
fprintf(fout, "\nOptions:\n");
|
||||||
fprintf(stderr, "\nTwopass Rate Control Options:\n");
|
arg_show_usage(fout, main_args);
|
||||||
arg_show_usage(stderr, rc_twopass_args);
|
fprintf(fout, "\nEncoder Global Options:\n");
|
||||||
fprintf(stderr, "\nKeyframe Placement Options:\n");
|
arg_show_usage(fout, global_args);
|
||||||
arg_show_usage(stderr, kf_args);
|
fprintf(fout, "\nRate Control Options:\n");
|
||||||
|
arg_show_usage(fout, rc_args);
|
||||||
|
fprintf(fout, "\nTwopass Rate Control Options:\n");
|
||||||
|
arg_show_usage(fout, rc_twopass_args);
|
||||||
|
fprintf(fout, "\nKeyframe Placement Options:\n");
|
||||||
|
arg_show_usage(fout, kf_args);
|
||||||
#if CONFIG_VP8_ENCODER
|
#if CONFIG_VP8_ENCODER
|
||||||
fprintf(stderr, "\nVP8 Specific Options:\n");
|
fprintf(fout, "\nVP8 Specific Options:\n");
|
||||||
arg_show_usage(stderr, vp8_args);
|
arg_show_usage(fout, vp8_args);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_VP9_ENCODER
|
#if CONFIG_VP9_ENCODER
|
||||||
fprintf(stderr, "\nVP9 Specific Options:\n");
|
fprintf(fout, "\nVP9 Specific Options:\n");
|
||||||
arg_show_usage(stderr, vp9_args);
|
arg_show_usage(fout, vp9_args);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr,
|
fprintf(fout,
|
||||||
"\nStream timebase (--timebase):\n"
|
"\nStream timebase (--timebase):\n"
|
||||||
" The desired precision of timestamps in the output, expressed\n"
|
" The desired precision of timestamps in the output, expressed\n"
|
||||||
" in fractional seconds. Default is 1/1000.\n");
|
" in fractional seconds. Default is 1/1000.\n");
|
||||||
fprintf(stderr, "\nIncluded encoders:\n\n");
|
fprintf(fout, "\nIncluded encoders:\n\n");
|
||||||
|
|
||||||
for (i = 0; i < num_encoder; ++i) {
|
for (i = 0; i < num_encoder; ++i) {
|
||||||
const VpxInterface *const encoder = get_vpx_encoder_by_index(i);
|
const VpxInterface *const encoder = get_vpx_encoder_by_index(i);
|
||||||
const char *defstr = (i == (num_encoder - 1)) ? "(default)" : "";
|
const char *defstr = (i == (num_encoder - 1)) ? "(default)" : "";
|
||||||
fprintf(stderr, " %-6s - %s %s\n", encoder->name,
|
fprintf(fout, " %-6s - %s %s\n", encoder->name,
|
||||||
vpx_codec_iface_name(encoder->codec_interface()), defstr);
|
vpx_codec_iface_name(encoder->codec_interface()), defstr);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n ");
|
fprintf(fout, "\n ");
|
||||||
fprintf(stderr, "Use --codec to switch to a non-default encoder.\n\n");
|
fprintf(fout, "Use --codec to switch to a non-default encoder.\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage_exit(void) {
|
||||||
|
show_help(stderr, 1);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,7 +914,10 @@ static void parse_global_config(struct VpxEncoderConfig *global, char **argv) {
|
|||||||
for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
|
for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
|
||||||
arg.argv_step = 1;
|
arg.argv_step = 1;
|
||||||
|
|
||||||
if (arg_match(&arg, &codecarg, argi)) {
|
if (arg_match(&arg, &help, argi)) {
|
||||||
|
show_help(stdout, 0);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (arg_match(&arg, &codecarg, argi)) {
|
||||||
global->codec = get_vpx_encoder_by_name(arg.val);
|
global->codec = get_vpx_encoder_by_name(arg.val);
|
||||||
if (!global->codec)
|
if (!global->codec)
|
||||||
die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
|
die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
|
||||||
@ -1905,8 +1919,6 @@ int main(int argc, const char **argv_) {
|
|||||||
memset(&input, 0, sizeof(input));
|
memset(&input, 0, sizeof(input));
|
||||||
exec_name = argv_[0];
|
exec_name = argv_[0];
|
||||||
|
|
||||||
if (argc < 3) usage_exit();
|
|
||||||
|
|
||||||
/* Setup default input stream settings */
|
/* Setup default input stream settings */
|
||||||
input.framerate.numerator = 30;
|
input.framerate.numerator = 30;
|
||||||
input.framerate.denominator = 1;
|
input.framerate.denominator = 1;
|
||||||
@ -1920,6 +1932,8 @@ int main(int argc, const char **argv_) {
|
|||||||
argv = argv_dup(argc - 1, argv_ + 1);
|
argv = argv_dup(argc - 1, argv_ + 1);
|
||||||
parse_global_config(&global, argv);
|
parse_global_config(&global, argv);
|
||||||
|
|
||||||
|
if (argc < 3) usage_exit();
|
||||||
|
|
||||||
switch (global.color_type) {
|
switch (global.color_type) {
|
||||||
case I420: input.fmt = VPX_IMG_FMT_I420; break;
|
case I420: input.fmt = VPX_IMG_FMT_I420; break;
|
||||||
case I422: input.fmt = VPX_IMG_FMT_I422; break;
|
case I422: input.fmt = VPX_IMG_FMT_I422; break;
|
||||||
@ -1953,7 +1967,10 @@ int main(int argc, const char **argv_) {
|
|||||||
/* Handle non-option arguments */
|
/* Handle non-option arguments */
|
||||||
input.filename = argv[0];
|
input.filename = argv[0];
|
||||||
|
|
||||||
if (!input.filename) usage_exit();
|
if (!input.filename) {
|
||||||
|
fprintf(stderr, "No input file specified!\n");
|
||||||
|
usage_exit();
|
||||||
|
}
|
||||||
|
|
||||||
/* Decide if other chroma subsamplings than 4:2:0 are supported */
|
/* Decide if other chroma subsamplings than 4:2:0 are supported */
|
||||||
if (global.codec->fourcc == VP9_FOURCC) input.only_i420 = 0;
|
if (global.codec->fourcc == VP9_FOURCC) input.only_i420 = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user