diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-12-17 11:47:33 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-12-22 11:39:57 +0100 |
commit | 2f1bc3b424f33069e4d870b05898aa1500f9b1ff (patch) | |
tree | 9be242e09931ff5d9fb1c9403a9af0ef8bfe14ca | |
parent | 66fcfc0009d08ac6ef95f5db4a1b6ee3ba502b8f (diff) | |
download | ffmpeg-2f1bc3b424f33069e4d870b05898aa1500f9b1ff.tar.gz |
fftools/cmdutils: include OPT_PERFILE in OPT_OFFSET
And analogously OPT_OFFSET in OPT_SPEC. Previously the inclusion would
be implicit and required all code to remember this.
-rw-r--r-- | fftools/cmdutils.c | 6 | ||||
-rw-r--r-- | fftools/cmdutils.h | 21 | ||||
-rw-r--r-- | fftools/ffmpeg_opt.c | 14 |
3 files changed, 22 insertions, 19 deletions
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 38f4f542d3..6ca2efef4a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -237,13 +237,13 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, { /* new-style options contain an offset into optctx, old-style address of * a global var*/ - void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? + void *dst = po->flags & OPT_FLAG_OFFSET ? (uint8_t *)optctx + po->u.off : po->u.dst_ptr; int *dstcount; double num; int ret; - if (po->flags & OPT_SPEC) { + if (po->flags & OPT_FLAG_SPEC) { SpecifierOpt **so = dst; char *p = strchr(opt, ':'); char *str; @@ -660,7 +660,7 @@ static int finish_group(OptionParseContext *octx, int group_idx, static int add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val) { - int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET)); + int global = !(opt->flags & OPT_PERFILE); OptionGroup *g = global ? &octx->global_opts : &octx->cur_group; int ret; diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 8e22560fc6..dc99573d80 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -135,17 +135,22 @@ typedef struct OptionDef { #define OPT_AUDIO (1 << 4) #define OPT_SUBTITLE (1 << 5) #define OPT_DATA (1 << 6) -/* The option is per-file (currently ffmpeg-only). Implied by OPT_OFFSET or - * OPT_SPEC. At least one of OPT_INPUT or OPT_OUTPUT must be set when this flag - * is in use. +/* The option is per-file (currently ffmpeg-only). At least one of OPT_INPUT or + * OPT_OUTPUT must be set when this flag is in use. */ #define OPT_PERFILE (1 << 7) -/* Option is specified as an offset in a passed optctx */ -#define OPT_OFFSET (1 << 8) -/* Option is to be stored in an array of SpecifierOpt. Implies OPT_OFFSET. + +/* Option is specified as an offset in a passed optctx. + * Always use as OPT_OFFSET in option definitions. */ +#define OPT_FLAG_OFFSET (1 << 8) +#define OPT_OFFSET (OPT_FLAG_OFFSET | OPT_PERFILE) + +/* Option is to be stored in an array of SpecifierOpt. Next element after the offset is an int containing element count in the - array. */ -#define OPT_SPEC (1 << 9) + array. + Always use as OPT_SPEC in option definitions. */ +#define OPT_FLAG_SPEC (1 << 9) +#define OPT_SPEC (OPT_FLAG_SPEC | OPT_OFFSET) /* ffmpeg-only - specifies whether an OPT_PERFILE option applies to input, * output, or both. */ #define OPT_INPUT (1 << 10) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 63c1d0ccb1..6e8de64a8e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -109,7 +109,7 @@ static void uninit_options(OptionsContext *o) while (po->name) { void *dst = (uint8_t*)o + po->u.off; - if (po->flags & OPT_SPEC) { + if (po->flags & OPT_FLAG_SPEC) { SpecifierOpt **so = dst; int i, *count = (int*)(so + 1); for (i = 0; i < *count; i++) { @@ -119,7 +119,7 @@ static void uninit_options(OptionsContext *o) } av_freep(so); *count = 0; - } else if (po->flags & OPT_OFFSET && po->type == OPT_TYPE_STRING) + } else if (po->flags & OPT_FLAG_OFFSET && po->type == OPT_TYPE_STRING) av_freep(dst); po++; } @@ -1181,8 +1181,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * void show_help_default(const char *opt, const char *arg) { - /* per-file options have at least one of those set */ - const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE; int show_advanced = 0, show_avoptions = 0; if (opt && *opt) { @@ -1209,17 +1207,17 @@ void show_help_default(const char *opt, const char *arg) show_help_options(options, "Global options (affect whole program " "instead of just one file):", - 0, per_file | OPT_EXIT | OPT_EXPERT, 0); + 0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT, 0); if (show_advanced) show_help_options(options, "Advanced global options:", OPT_EXPERT, - per_file | OPT_EXIT, 0); + OPT_PERFILE | OPT_EXIT, 0); show_help_options(options, "Per-file main options:", 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | - OPT_EXIT, per_file); + OPT_EXIT, OPT_PERFILE); if (show_advanced) show_help_options(options, "Advanced per-file options:", - OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file); + OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, OPT_PERFILE); show_help_options(options, "Video options:", OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0); |