mirror of https://git.ffmpeg.org/ffmpeg.git
cmdutils: change semantics of show_help_options() and document it.
Currently it takes a mask and value, such that options for which (flags & mask) == value. Change it to take required flags and forbidden flags instead. This is shorter and simpler to understand.
This commit is contained in:
parent
dc4c24a3d3
commit
7c5012127f
19
avconv_opt.c
19
avconv_opt.c
|
@ -1795,24 +1795,19 @@ static int show_help(const char *opt, const char *arg)
|
||||||
av_log_set_callback(log_callback_help);
|
av_log_set_callback(log_callback_help);
|
||||||
show_usage();
|
show_usage();
|
||||||
show_help_options(options, "Main options:",
|
show_help_options(options, "Main options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0);
|
0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
|
||||||
show_help_options(options, "Advanced options:",
|
show_help_options(options, "Advanced options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE,
|
OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
|
||||||
OPT_EXPERT);
|
|
||||||
show_help_options(options, "Video options:",
|
show_help_options(options, "Video options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
|
OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
|
||||||
OPT_VIDEO);
|
|
||||||
show_help_options(options, "Advanced Video options:",
|
show_help_options(options, "Advanced Video options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
|
OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
|
||||||
OPT_VIDEO | OPT_EXPERT);
|
|
||||||
show_help_options(options, "Audio options:",
|
show_help_options(options, "Audio options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
|
OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
|
||||||
OPT_AUDIO);
|
|
||||||
show_help_options(options, "Advanced Audio options:",
|
show_help_options(options, "Advanced Audio options:",
|
||||||
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
|
OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
|
||||||
OPT_AUDIO | OPT_EXPERT);
|
|
||||||
show_help_options(options, "Subtitle options:",
|
show_help_options(options, "Subtitle options:",
|
||||||
OPT_SUBTITLE, OPT_SUBTITLE);
|
OPT_SUBTITLE, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
show_help_children(avcodec_get_class(), flags);
|
show_help_children(avcodec_get_class(), flags);
|
||||||
show_help_children(avformat_get_class(), flags);
|
show_help_children(avformat_get_class(), flags);
|
||||||
|
|
6
avplay.c
6
avplay.c
|
@ -2926,10 +2926,8 @@ static int show_help(const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
av_log_set_callback(log_callback_help);
|
av_log_set_callback(log_callback_help);
|
||||||
show_usage();
|
show_usage();
|
||||||
show_help_options(options, "Main options:",
|
show_help_options(options, "Main options:", 0, OPT_EXPERT);
|
||||||
OPT_EXPERT, 0);
|
show_help_options(options, "Advanced options:", OPT_EXPERT, 0);
|
||||||
show_help_options(options, "Advanced options:",
|
|
||||||
OPT_EXPERT, OPT_EXPERT);
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
|
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
|
||||||
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
|
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
|
||||||
|
|
29
cmdutils.c
29
cmdutils.c
|
@ -113,8 +113,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
|
||||||
return us;
|
return us;
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_help_options(const OptionDef *options, const char *msg, int mask,
|
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||||
int value)
|
int rej_flags)
|
||||||
{
|
{
|
||||||
const OptionDef *po;
|
const OptionDef *po;
|
||||||
int first;
|
int first;
|
||||||
|
@ -122,18 +122,21 @@ void show_help_options(const OptionDef *options, const char *msg, int mask,
|
||||||
first = 1;
|
first = 1;
|
||||||
for (po = options; po->name != NULL; po++) {
|
for (po = options; po->name != NULL; po++) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
if ((po->flags & mask) == value) {
|
|
||||||
if (first) {
|
if (((po->flags & req_flags) != req_flags) ||
|
||||||
printf("%s\n", msg);
|
(po->flags & rej_flags))
|
||||||
first = 0;
|
continue;
|
||||||
}
|
|
||||||
av_strlcpy(buf, po->name, sizeof(buf));
|
if (first) {
|
||||||
if (po->flags & HAS_ARG) {
|
printf("%s\n", msg);
|
||||||
av_strlcat(buf, " ", sizeof(buf));
|
first = 0;
|
||||||
av_strlcat(buf, po->argname, sizeof(buf));
|
|
||||||
}
|
|
||||||
printf("-%-17s %s\n", buf, po->help);
|
|
||||||
}
|
}
|
||||||
|
av_strlcpy(buf, po->name, sizeof(buf));
|
||||||
|
if (po->flags & HAS_ARG) {
|
||||||
|
av_strlcat(buf, " ", sizeof(buf));
|
||||||
|
av_strlcat(buf, po->argname, sizeof(buf));
|
||||||
|
}
|
||||||
|
printf("-%-17s %s\n", buf, po->help);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
12
cmdutils.h
12
cmdutils.h
|
@ -153,8 +153,16 @@ typedef struct {
|
||||||
const char *argname;
|
const char *argname;
|
||||||
} OptionDef;
|
} OptionDef;
|
||||||
|
|
||||||
void show_help_options(const OptionDef *options, const char *msg, int mask,
|
/**
|
||||||
int value);
|
* Print help for all options matching specified flags.
|
||||||
|
*
|
||||||
|
* @param options a list of options
|
||||||
|
* @param msg title of this group. Only printed if at least one option matches.
|
||||||
|
* @param req_flags print only options which have all those flags set.
|
||||||
|
* @param rej_flags don't print options which have any of those flags set.
|
||||||
|
*/
|
||||||
|
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||||
|
int rej_flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show help for all options with given flags in class and all its
|
* Show help for all options with given flags in class and all its
|
||||||
|
|
Loading…
Reference in New Issue