1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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.
This commit is contained in:
Anton Khirnov 2023-12-17 11:47:33 +01:00
parent 66fcfc0009
commit 2f1bc3b424
3 changed files with 22 additions and 19 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);