diff mbox series

[FFmpeg-devel,05/20] fftools: split off option types from other flags

Message ID 20231218095722.25879-5-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/20] fftools/ffmpeg_filter: only set framerate for video | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Dec. 18, 2023, 9:57 a.m. UTC
These values are not actually flags, as only one of them can be
meaningfully set.
---
 fftools/cmdutils.c   |  51 ++--
 fftools/cmdutils.h   |  21 +-
 fftools/ffmpeg_opt.c | 557 +++++++++++++++++++++++++------------------
 fftools/ffplay.c     | 102 ++++----
 fftools/ffprobe.c    |  76 +++---
 fftools/opt_common.h |  62 ++---
 6 files changed, 488 insertions(+), 381 deletions(-)
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index f5b3dc7346..8ff69cabf5 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -83,7 +83,7 @@  void init_dynload(void)
 #endif
 }
 
-int parse_number(const char *context, const char *numstr, int type,
+int parse_number(const char *context, const char *numstr, enum OptionType type,
                  double min, double max, double *dst)
 {
     char *tail;
@@ -93,9 +93,9 @@  int parse_number(const char *context, const char *numstr, int type,
         error = "Expected number for %s but found: %s\n";
     else if (d < min || d > max)
         error = "The value for %s was %s which is not within %f - %f\n";
-    else if (type == OPT_INT64 && (int64_t)d != d)
+    else if (type == OPT_TYPE_INT64 && (int64_t)d != d)
         error = "Expected int64 for %s but found %s\n";
-    else if (type == OPT_INT && (int)d != d)
+    else if (type == OPT_TYPE_INT && (int)d != d)
         error = "Expected int for %s but found %s\n";
     else {
         *dst = d;
@@ -225,13 +225,11 @@  static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
 
 static int opt_has_arg(const OptionDef *o)
 {
-    if (o->flags & OPT_BOOL)
+    if (o->type == OPT_TYPE_BOOL)
         return 0;
-    if (o->flags &
-        (OPT_STRING | OPT_INT  | OPT_FLOAT  | OPT_INT64 |
-         OPT_SPEC   | OPT_TIME | OPT_DOUBLE))
-        return 1;
-    return !!(o->flags & HAS_ARG);
+    if (o->type == OPT_TYPE_FUNC)
+        return !!(o->flags & HAS_ARG);
+    return 1;
 }
 
 static int write_option(void *optctx, const OptionDef *po, const char *opt,
@@ -262,46 +260,50 @@  static int write_option(void *optctx, const OptionDef *po, const char *opt,
         dst = &(*so)[*dstcount - 1].u;
     }
 
-    if (po->flags & OPT_STRING) {
+    if (po->type == OPT_TYPE_STRING) {
         char *str;
         str = av_strdup(arg);
         av_freep(dst);
         if (!str)
             return AVERROR(ENOMEM);
         *(char **)dst = str;
-    } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
-        ret = parse_number(opt, arg, OPT_INT64, INT_MIN, INT_MAX, &num);
+    } else if (po->type == OPT_TYPE_BOOL || po->type == OPT_TYPE_INT) {
+        ret = parse_number(opt, arg, OPT_TYPE_INT64, INT_MIN, INT_MAX, &num);
         if (ret < 0)
             return ret;
 
         *(int *)dst = num;
-    } else if (po->flags & OPT_INT64) {
-        ret = parse_number(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX, &num);
+    } else if (po->type == OPT_TYPE_INT64) {
+        ret = parse_number(opt, arg, OPT_TYPE_INT64, INT64_MIN, INT64_MAX, &num);
         if (ret < 0)
             return ret;
 
         *(int64_t *)dst = num;
-    } else if (po->flags & OPT_TIME) {
+    } else if (po->type == OPT_TYPE_TIME) {
         ret = av_parse_time(dst, arg, 1);
         if (ret < 0) {
             av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n",
                    opt, arg);
             return ret;
         }
-    } else if (po->flags & OPT_FLOAT) {
-        ret = parse_number(opt, arg, OPT_FLOAT, -INFINITY, INFINITY, &num);
+    } else if (po->type == OPT_TYPE_FLOAT) {
+        ret = parse_number(opt, arg, OPT_TYPE_FLOAT, -INFINITY, INFINITY, &num);
         if (ret < 0)
             return ret;
 
         *(float *)dst = num;
-    } else if (po->flags & OPT_DOUBLE) {
-        ret = parse_number(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY, &num);
+    } else if (po->type == OPT_TYPE_DOUBLE) {
+        ret = parse_number(opt, arg, OPT_TYPE_DOUBLE, -INFINITY, INFINITY, &num);
         if (ret < 0)
             return ret;
 
         *(double *)dst = num;
-    } else if (po->u.func_arg) {
-        int ret = po->u.func_arg(optctx, opt, arg);
+    } else {
+        int ret;
+
+        av_assert0(po->type == OPT_TYPE_FUNC && po->u.func_arg);
+
+        ret = po->u.func_arg(optctx, opt, arg);
         if (ret < 0) {
             av_log(NULL, AV_LOG_ERROR,
                    "Failed to set value '%s' for option '%s': %s\n",
@@ -320,6 +322,7 @@  int parse_option(void *optctx, const char *opt, const char *arg,
 {
     static const OptionDef opt_avoptions = {
         .name       = "AVOption passthrough",
+        .type       = OPT_TYPE_FUNC,
         .flags      = HAS_ARG,
         .u.func_arg = opt_default,
     };
@@ -331,9 +334,9 @@  int parse_option(void *optctx, const char *opt, const char *arg,
     if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
         /* handle 'no' bool option */
         po = find_option(options, opt + 2);
-        if ((po->name && (po->flags & OPT_BOOL)))
+        if ((po->name && po->type == OPT_TYPE_BOOL))
             arg = "0";
-    } else if (po->flags & OPT_BOOL)
+    } else if (po->type == OPT_TYPE_BOOL)
         arg = "1";
 
     if (!po->name)
@@ -814,7 +817,7 @@  do {                                                                           \
         /* boolean -nofoo options */
         if (opt[0] == 'n' && opt[1] == 'o' &&
             (po = find_option(options, opt + 2)) &&
-            po->name && po->flags & OPT_BOOL) {
+            po->name && po->type == OPT_TYPE_BOOL) {
             ret = add_opt(octx, po, opt, "0");
             if (ret < 0)
                 return ret;
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 85479f90e4..b9ef8b5c15 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -77,6 +77,17 @@  int opt_default(void *optctx, const char *opt, const char *arg);
  */
 int opt_timelimit(void *optctx, const char *opt, const char *arg);
 
+enum OptionType {
+    OPT_TYPE_FUNC,
+    OPT_TYPE_BOOL,
+    OPT_TYPE_STRING,
+    OPT_TYPE_INT,
+    OPT_TYPE_INT64,
+    OPT_TYPE_FLOAT,
+    OPT_TYPE_DOUBLE,
+    OPT_TYPE_TIME,
+};
+
 /**
  * Parse a string and return its corresponding value as a double.
  *
@@ -88,7 +99,7 @@  int opt_timelimit(void *optctx, const char *opt, const char *arg);
  * @param min the minimum valid accepted value
  * @param max the maximum valid accepted value
  */
-int parse_number(const char *context, const char *numstr, int type,
+int parse_number(const char *context, const char *numstr, enum OptionType type,
                  double min, double max, double *dst);
 
 typedef struct SpecifierOpt {
@@ -105,17 +116,13 @@  typedef struct SpecifierOpt {
 
 typedef struct OptionDef {
     const char *name;
+    enum OptionType type;
     int flags;
 #define HAS_ARG         (1 << 0)
-#define OPT_BOOL        (1 << 1)
 #define OPT_EXPERT      (1 << 2)
-#define OPT_STRING      (1 << 3)
 #define OPT_VIDEO       (1 << 4)
 #define OPT_AUDIO       (1 << 5)
-#define OPT_INT         (1 << 6)
-#define OPT_FLOAT       (1 << 7)
 #define OPT_SUBTITLE    (1 << 8)
-#define OPT_INT64       (1 << 9)
 #define OPT_EXIT        (1 << 10)
 #define OPT_DATA        (1 << 11)
 /* The option is per-file (currently ffmpeg-only).
@@ -127,8 +134,6 @@  typedef struct OptionDef {
    Next element after the offset is an int containing element count in the
    array. */
 #define OPT_SPEC        (1 << 14)
-#define OPT_TIME        (1 << 15)
-#define OPT_DOUBLE      (1 << 16)
 #define OPT_INPUT       (1 << 17)
 #define OPT_OUTPUT      (1 << 18)
      union {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index b545c42818..752d5980b7 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -105,7 +105,7 @@  static void uninit_options(OptionsContext *o)
     const OptionDef *po = options;
     int i;
 
-    /* all OPT_SPEC and OPT_STRING can be freed in generic way */
+    /* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
     while (po->name) {
         void *dst = (uint8_t*)o + po->u.off;
 
@@ -114,12 +114,12 @@  static void uninit_options(OptionsContext *o)
             int i, *count = (int*)(so + 1);
             for (i = 0; i < *count; i++) {
                 av_freep(&(*so)[i].specifier);
-                if (po->flags & OPT_STRING)
+                if (po->type == OPT_TYPE_STRING)
                     av_freep(&(*so)[i].u.str);
             }
             av_freep(so);
             *count = 0;
-        } else if (po->flags & OPT_OFFSET && po->flags & OPT_STRING)
+        } else if (po->flags & OPT_OFFSET && po->type == OPT_TYPE_STRING)
             av_freep(dst);
         po++;
     }
@@ -204,7 +204,7 @@  int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id
         int ret;
         double num;
 
-        ret = parse_number("vsync", arg, OPT_INT, VSYNC_AUTO, VSYNC_VFR, &num);
+        ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
         if (ret < 0)
             return ret;
 
@@ -1393,7 +1393,7 @@  int opt_timelimit(void *optctx, const char *opt, const char *arg)
     double lim;
     struct rlimit rl;
 
-    ret = parse_number(opt, arg, OPT_INT64, 0, INT_MAX, &lim);
+    ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
     if (ret < 0)
         return ret;
 
@@ -1426,435 +1426,534 @@  static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
 const OptionDef options[] = {
     /* main options */
     CMDUTILS_COMMON_OPTIONS
-    { "f",              OPT_STRING | OPT_OFFSET |
-                        OPT_INPUT | OPT_OUTPUT,                      { .off       = OFFSET(format) },
+    { "f",                      OPT_TYPE_STRING, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off       = OFFSET(format) },
         "force format", "fmt" },
-    { "y",              OPT_BOOL,                                    {              &file_overwrite },
+    { "y",                      OPT_TYPE_BOOL, 0,
+        {              &file_overwrite },
         "overwrite output files" },
-    { "n",              OPT_BOOL,                                    {              &no_file_overwrite },
+    { "n",                      OPT_TYPE_BOOL, 0,
+        {              &no_file_overwrite },
         "never overwrite output files" },
-    { "ignore_unknown", OPT_BOOL,                                    {              &ignore_unknown_streams },
+    { "ignore_unknown",         OPT_TYPE_BOOL, 0,
+        {              &ignore_unknown_streams },
         "Ignore unknown stream types" },
-    { "copy_unknown",   OPT_BOOL | OPT_EXPERT,                       {              &copy_unknown_streams },
+    { "copy_unknown",           OPT_TYPE_BOOL, OPT_EXPERT,
+        {              &copy_unknown_streams },
         "Copy unknown stream types" },
-    { "recast_media",   OPT_BOOL | OPT_EXPERT,                       {              &recast_media },
+    { "recast_media",           OPT_TYPE_BOOL, OPT_EXPERT,
+        {              &recast_media },
         "allow recasting stream type in order to force a decoder of different media type" },
-    { "c",              OPT_STRING | OPT_SPEC |
-                        OPT_INPUT | OPT_OUTPUT,                      { .off       = OFFSET(codec_names) },
+    { "c",                      OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off       = OFFSET(codec_names) },
         "codec name", "codec" },
-    { "codec",          OPT_STRING | OPT_SPEC |
-                        OPT_INPUT | OPT_OUTPUT,                      { .off       = OFFSET(codec_names) },
+    { "codec",                  OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off       = OFFSET(codec_names) },
         "codec name", "codec" },
-    { "pre",            OPT_STRING | OPT_SPEC |
-                        OPT_OUTPUT,                                  { .off       = OFFSET(presets) },
+    { "pre",                    OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off       = OFFSET(presets) },
         "preset name", "preset" },
-    { "map",            HAS_ARG | OPT_EXPERT | OPT_PERFILE |
-                        OPT_OUTPUT,                                  { .func_arg = opt_map },
+    { "map",                    OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_map },
         "set input stream mapping",
         "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
-    { "map_metadata",   OPT_STRING | OPT_SPEC |
-                        OPT_OUTPUT,                                  { .off       = OFFSET(metadata_map) },
+    { "map_metadata",           OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off       = OFFSET(metadata_map) },
         "set metadata information of outfile from infile",
         "outfile[,metadata]:infile[,metadata]" },
-    { "map_chapters",   OPT_INT | OPT_EXPERT | OPT_OFFSET |
-                        OPT_OUTPUT,                                  { .off = OFFSET(chapters_input_file) },
+    { "map_chapters",           OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(chapters_input_file) },
         "set chapters mapping", "input_file_index" },
-    { "t",              OPT_TIME | OPT_OFFSET |
-                        OPT_INPUT | OPT_OUTPUT,                      { .off = OFFSET(recording_time) },
+    { "t",                      OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(recording_time) },
         "record or transcode \"duration\" seconds of audio/video",
         "duration" },
-    { "to",             OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,  { .off = OFFSET(stop_time) },
+    { "to",                     OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(stop_time) },
         "record or transcode stop time", "time_stop" },
-    { "fs",             OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) },
+    { "fs",                     OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(limit_filesize) },
         "set the limit file size in bytes", "limit_size" },
-    { "ss",             OPT_TIME | OPT_OFFSET |
-                        OPT_INPUT | OPT_OUTPUT,                      { .off = OFFSET(start_time) },
+    { "ss",                     OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(start_time) },
         "set the start time offset", "time_off" },
-    { "sseof",          OPT_TIME | OPT_OFFSET |
-                        OPT_INPUT,                                   { .off = OFFSET(start_time_eof) },
+    { "sseof",                  OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT,
+        { .off = OFFSET(start_time_eof) },
         "set the start time offset relative to EOF", "time_off" },
-    { "seek_timestamp", OPT_INT | OPT_OFFSET |
-                        OPT_INPUT,                                   { .off = OFFSET(seek_timestamp) },
+    { "seek_timestamp",         OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT,
+        { .off = OFFSET(seek_timestamp) },
         "enable/disable seeking by timestamp with -ss" },
-    { "accurate_seek",  OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
-                        OPT_INPUT,                                   { .off = OFFSET(accurate_seek) },
+    { "accurate_seek",          OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(accurate_seek) },
         "enable/disable accurate seeking with -ss" },
-    { "isync",          OPT_INT | OPT_OFFSET |
-                        OPT_EXPERT | OPT_INPUT,                      { .off = OFFSET(input_sync_ref) },
+    { "isync",                  OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(input_sync_ref) },
         "Indicate the input index for sync reference", "sync ref" },
-    { "itsoffset",      OPT_TIME | OPT_OFFSET |
-                        OPT_EXPERT | OPT_INPUT,                      { .off = OFFSET(input_ts_offset) },
+    { "itsoffset",              OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(input_ts_offset) },
         "set the input ts offset", "time_off" },
-    { "itsscale",       OPT_DOUBLE | OPT_SPEC |
-                        OPT_EXPERT | OPT_INPUT,                      { .off = OFFSET(ts_scale) },
+    { "itsscale",               OPT_TYPE_DOUBLE, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(ts_scale) },
         "set the input ts scale", "scale" },
-    { "timestamp",      HAS_ARG | OPT_PERFILE | OPT_OUTPUT,          { .func_arg = opt_recording_timestamp },
+    { "timestamp",              OPT_TYPE_FUNC,   HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_recording_timestamp },
         "set the recording timestamp ('now' to set the current time)", "time" },
-    { "metadata",       OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata) },
+    { "metadata",               OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(metadata) },
         "add metadata", "string=string" },
-    { "program",        OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(program) },
+    { "program",                OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(program) },
         "add program with specified streams", "title=string:st=number..." },
-    { "dframes",        HAS_ARG | OPT_PERFILE | OPT_EXPERT |
-                        OPT_OUTPUT,                                  { .func_arg = opt_data_frames },
+    { "dframes",                OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
+        { .func_arg = opt_data_frames },
         "set the number of data frames to output", "number" },
-    { "benchmark",      OPT_BOOL | OPT_EXPERT,                       { &do_benchmark },
+    { "benchmark",              OPT_TYPE_BOOL, OPT_EXPERT,
+        { &do_benchmark },
         "add timings for benchmarking" },
-    { "benchmark_all",  OPT_BOOL | OPT_EXPERT,                       { &do_benchmark_all },
+    { "benchmark_all",          OPT_TYPE_BOOL, OPT_EXPERT,
+        { &do_benchmark_all },
       "add timings for each task" },
-    { "progress",       HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_progress },
+    { "progress",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_progress },
       "write program-readable progress information", "url" },
-    { "stdin",          OPT_BOOL | OPT_EXPERT,                       { &stdin_interaction },
+    { "stdin",                  OPT_TYPE_BOOL, OPT_EXPERT,
+        { &stdin_interaction },
       "enable or disable interaction on standard input" },
-    { "timelimit",      HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_timelimit },
+    { "timelimit",              OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_timelimit },
         "set max runtime in seconds in CPU user time", "limit" },
-    { "dump",           OPT_BOOL | OPT_EXPERT,                       { &do_pkt_dump },
+    { "dump",                   OPT_TYPE_BOOL, OPT_EXPERT,
+        { &do_pkt_dump },
         "dump each input packet" },
-    { "hex",            OPT_BOOL | OPT_EXPERT,                       { &do_hex_dump },
+    { "hex",                    OPT_TYPE_BOOL, OPT_EXPERT,
+        { &do_hex_dump },
         "when dumping packets, also dump the payload" },
-    { "re",             OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
-                        OPT_INPUT,                                   { .off = OFFSET(rate_emu) },
+    { "re",                     OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_INPUT,
+        { .off = OFFSET(rate_emu) },
         "read input at native frame rate; equivalent to -readrate 1", "" },
-    { "readrate",       OPT_FLOAT | OPT_OFFSET |
-                        OPT_EXPERT | OPT_INPUT,                      { .off = OFFSET(readrate) },
+    { "readrate",               OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(readrate) },
         "read input at specified rate", "speed" },
-    { "readrate_initial_burst", OPT_DOUBLE | OPT_OFFSET |
-                                OPT_EXPERT | OPT_INPUT,              { .off = OFFSET(readrate_initial_burst) },
+    { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(readrate_initial_burst) },
         "The initial amount of input to burst read before imposing any readrate", "seconds" },
-    { "target",         HAS_ARG | OPT_PERFILE | OPT_OUTPUT,          { .func_arg = opt_target },
+    { "target",                 OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_target },
         "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
         "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
-    { "vsync",          HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_vsync },
+    { "vsync",                  OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_vsync },
         "set video sync method globally; deprecated, use -fps_mode", "" },
-    { "frame_drop_threshold", OPT_FLOAT | OPT_EXPERT,      { &frame_drop_threshold },
+    { "frame_drop_threshold",   OPT_TYPE_FLOAT, OPT_EXPERT,
+        { &frame_drop_threshold },
         "frame drop threshold", "" },
-    { "copyts",         OPT_BOOL | OPT_EXPERT,                       { &copy_ts },
+    { "copyts",                 OPT_TYPE_BOOL, OPT_EXPERT,
+        { &copy_ts },
         "copy timestamps" },
-    { "start_at_zero",  OPT_BOOL | OPT_EXPERT,                       { &start_at_zero },
+    { "start_at_zero",          OPT_TYPE_BOOL, OPT_EXPERT,
+        { &start_at_zero },
         "shift input timestamps to start at 0 when using copyts" },
-    { "copytb",         OPT_INT | OPT_EXPERT,              { &copy_tb },
+    { "copytb",                 OPT_TYPE_INT, OPT_EXPERT,
+        { &copy_tb },
         "copy input stream time base when stream copying", "mode" },
-    { "shortest",       OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
-                        OPT_OUTPUT,                                  { .off = OFFSET(shortest) },
+    { "shortest",               OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(shortest) },
         "finish encoding within shortest input" },
-    { "shortest_buf_duration", OPT_FLOAT | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(shortest_buf_duration) },
+    { "shortest_buf_duration",  OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(shortest_buf_duration) },
         "maximum buffering duration (in seconds) for the -shortest option" },
-    { "bitexact",       OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
-                        OPT_OUTPUT | OPT_INPUT,                      { .off = OFFSET(bitexact) },
+    { "bitexact",               OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT | OPT_INPUT,
+        { .off = OFFSET(bitexact) },
         "bitexact mode" },
-    { "apad",           OPT_STRING | OPT_SPEC |
-                        OPT_OUTPUT,                                  { .off = OFFSET(apad) },
+    { "apad",                   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(apad) },
         "audio pad", "" },
-    { "dts_delta_threshold", OPT_FLOAT | OPT_EXPERT,       { &dts_delta_threshold },
+    { "dts_delta_threshold",    OPT_TYPE_FLOAT, OPT_EXPERT,
+        { &dts_delta_threshold },
         "timestamp discontinuity delta threshold", "threshold" },
-    { "dts_error_threshold", OPT_FLOAT | OPT_EXPERT,       { &dts_error_threshold },
+    { "dts_error_threshold",    OPT_TYPE_FLOAT, OPT_EXPERT,
+        { &dts_error_threshold },
         "timestamp error delta threshold", "threshold" },
-    { "xerror",         OPT_BOOL | OPT_EXPERT,                       { &exit_on_error },
+    { "xerror",                 OPT_TYPE_BOOL, OPT_EXPERT,
+        { &exit_on_error },
         "exit on error", "error" },
-    { "abort_on",       HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_abort_on },
+    { "abort_on",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_abort_on },
         "abort on the specified condition flags", "flags" },
-    { "copyinkf",       OPT_BOOL | OPT_EXPERT | OPT_SPEC |
-                        OPT_OUTPUT,                                  { .off = OFFSET(copy_initial_nonkeyframes) },
+    { "copyinkf",               OPT_TYPE_BOOL, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(copy_initial_nonkeyframes) },
         "copy initial non-keyframes" },
-    { "copypriorss",    OPT_INT | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,   { .off = OFFSET(copy_prior_start) },
+    { "copypriorss",            OPT_TYPE_INT, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(copy_prior_start) },
         "copy or discard frames before start time" },
-    { "frames",         OPT_INT64 | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(max_frames) },
+    { "frames",                 OPT_TYPE_INT64, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(max_frames) },
         "set the number of frames to output", "number" },
-    { "tag",            OPT_STRING | OPT_SPEC |
-                        OPT_EXPERT | OPT_OUTPUT | OPT_INPUT,         { .off = OFFSET(codec_tags) },
+    { "tag",                    OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT,
+        { .off = OFFSET(codec_tags) },
         "force codec tag/fourcc", "fourcc/tag" },
-    { "q",              OPT_EXPERT | OPT_DOUBLE |
-                        OPT_SPEC | OPT_OUTPUT,                       { .off = OFFSET(qscale) },
+    { "q",                      OPT_TYPE_DOUBLE, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(qscale) },
         "use fixed quality scale (VBR)", "q" },
-    { "qscale",         HAS_ARG | OPT_EXPERT | OPT_PERFILE |
-                        OPT_OUTPUT,                                  { .func_arg = opt_qscale },
+    { "qscale",                 OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_qscale },
         "use fixed quality scale (VBR)", "q" },
-    { "profile",        HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_profile },
+    { "profile",                OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_profile },
         "set profile", "profile" },
-    { "filter",         OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
+    { "filter",                 OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(filters) },
         "set stream filtergraph", "filter_graph" },
-    { "filter_threads", HAS_ARG,                                     { .func_arg = opt_filter_threads },
+    { "filter_threads",         OPT_TYPE_FUNC, HAS_ARG,
+        { .func_arg = opt_filter_threads },
         "number of non-complex filter threads" },
-    { "filter_script",  OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
+    { "filter_script",          OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(filter_scripts) },
         "read stream filtergraph description from a file", "filename" },
-    { "reinit_filter",  OPT_INT | OPT_SPEC | OPT_INPUT,    { .off = OFFSET(reinit_filters) },
+    { "reinit_filter",          OPT_TYPE_INT, OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(reinit_filters) },
         "reinit filtergraph on input parameter changes", "" },
-    { "filter_complex", HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_filter_complex },
+    { "filter_complex",         OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
-    { "filter_complex_threads", OPT_INT,                   { &filter_complex_nbthreads },
+    { "filter_complex_threads", OPT_TYPE_INT, 0,
+        { &filter_complex_nbthreads },
         "number of threads for -filter_complex" },
-    { "lavfi",          HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_filter_complex },
+    { "lavfi",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
-    { "filter_complex_script", HAS_ARG | OPT_EXPERT,                 { .func_arg = opt_filter_complex_script },
+    { "filter_complex_script", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_filter_complex_script },
         "read complex filtergraph description from a file", "filename" },
-    { "auto_conversion_filters", OPT_BOOL | OPT_EXPERT,              { &auto_conversion_filters },
+    { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
+        { &auto_conversion_filters },
         "enable automatic conversion filters globally" },
-    { "stats",          OPT_BOOL,                                    { &print_stats },
+    { "stats",               OPT_TYPE_BOOL, 0,
+        { &print_stats },
         "print progress report during encoding", },
-    { "stats_period",    HAS_ARG | OPT_EXPERT,                       { .func_arg = opt_stats_period },
+    { "stats_period",        OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_stats_period },
         "set the period at which ffmpeg updates stats and -progress output", "time" },
-    { "attach",         HAS_ARG | OPT_PERFILE | OPT_EXPERT |
-                        OPT_OUTPUT,                                  { .func_arg = opt_attach },
+    { "attach",              OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
+        { .func_arg = opt_attach },
         "add an attachment to the output file", "filename" },
-    { "dump_attachment", OPT_STRING | OPT_SPEC |
-                         OPT_EXPERT | OPT_INPUT,                     { .off = OFFSET(dump_attachment) },
+    { "dump_attachment",     OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(dump_attachment) },
         "extract an attachment into a file", "filename" },
-    { "stream_loop", OPT_INT | OPT_EXPERT | OPT_INPUT |
-                        OPT_OFFSET,                                  { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
-    { "debug_ts",       OPT_BOOL | OPT_EXPERT,                       { &debug_ts },
+    { "stream_loop",         OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
+        { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
+    { "debug_ts",            OPT_TYPE_BOOL, OPT_EXPERT,
+        { &debug_ts },
         "print timestamp debugging info" },
-    { "max_error_rate",  OPT_FLOAT,                        { &max_error_rate },
+    { "max_error_rate",      OPT_TYPE_FLOAT, 0,
+        { &max_error_rate },
         "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
-    { "discard",        OPT_STRING | OPT_SPEC |
-                        OPT_INPUT,                                   { .off = OFFSET(discard) },
+    { "discard",             OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(discard) },
         "discard", "" },
-    { "disposition",    OPT_STRING | OPT_SPEC |
-                        OPT_OUTPUT,                                  { .off = OFFSET(disposition) },
+    { "disposition",         OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(disposition) },
         "disposition", "" },
-    { "thread_queue_size", OPT_INT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
-                                                                     { .off = OFFSET(thread_queue_size) },
+    { "thread_queue_size",   OPT_TYPE_INT,  OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(thread_queue_size) },
         "set the maximum number of queued packets from the demuxer" },
-    { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT | OPT_OFFSET, { .off = OFFSET(find_stream_info) },
+    { "find_stream_info",    OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
+        { .off = OFFSET(find_stream_info) },
         "read and decode the streams to fill missing information with heuristics" },
-    { "bits_per_raw_sample", OPT_INT | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+    { "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
         { .off = OFFSET(bits_per_raw_sample) },
         "set the number of bits per raw sample", "number" },
 
-    { "stats_enc_pre",      OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(enc_stats_pre)      },
+    { "stats_enc_pre",      OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(enc_stats_pre)      },
         "write encoding stats before encoding" },
-    { "stats_enc_post",     OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(enc_stats_post)     },
+    { "stats_enc_post",     OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(enc_stats_post)     },
         "write encoding stats after encoding" },
-    { "stats_mux_pre",      OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(mux_stats)          },
+    { "stats_mux_pre",      OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(mux_stats)          },
         "write packets stats before muxing" },
-    { "stats_enc_pre_fmt",  OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(enc_stats_pre_fmt)  },
+    { "stats_enc_pre_fmt",  OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(enc_stats_pre_fmt)  },
         "format of the stats written with -stats_enc_pre" },
-    { "stats_enc_post_fmt", OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(enc_stats_post_fmt) },
+    { "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(enc_stats_post_fmt) },
         "format of the stats written with -stats_enc_post" },
-    { "stats_mux_pre_fmt",  OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_STRING, { .off = OFFSET(mux_stats_fmt)      },
+    { "stats_mux_pre_fmt",  OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(mux_stats_fmt)      },
         "format of the stats written with -stats_mux_pre" },
 
     /* video options */
-    { "vframes",      OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_video_frames },
+    { "vframes",                    OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_video_frames },
         "set the number of video frames to output", "number" },
-    { "r",            OPT_VIDEO | OPT_STRING | OPT_SPEC |
-                      OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(frame_rates) },
+    { "r",                          OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(frame_rates) },
         "set frame rate (Hz value, fraction or abbreviation)", "rate" },
-    { "fpsmax",       OPT_VIDEO | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(max_frame_rates) },
+    { "fpsmax",                     OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(max_frame_rates) },
         "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
-    { "s",            OPT_VIDEO | OPT_SUBTITLE | OPT_STRING | OPT_SPEC |
-                      OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(frame_sizes) },
+    { "s",                          OPT_TYPE_STRING, OPT_VIDEO | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(frame_sizes) },
         "set frame size (WxH or abbreviation)", "size" },
-    { "aspect",       OPT_VIDEO | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(frame_aspect_ratios) },
+    { "aspect",                     OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(frame_aspect_ratios) },
         "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
-    { "pix_fmt",      OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
-                      OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(frame_pix_fmts) },
+    { "pix_fmt",                    OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(frame_pix_fmts) },
         "set pixel format", "format" },
-    { "display_rotation", OPT_VIDEO | OPT_DOUBLE | OPT_SPEC |
-                          OPT_INPUT,                                             { .off = OFFSET(display_rotations) },
+    { "display_rotation",           OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(display_rotations) },
         "set pure counter-clockwise rotation in degrees for stream(s)",
         "angle" },
-    { "display_hflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT,              { .off = OFFSET(display_hflips) },
+    { "display_hflip",              OPT_TYPE_BOOL,   OPT_VIDEO | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(display_hflips) },
         "set display horizontal flip for stream(s) "
         "(overrides any display rotation if it is not set)"},
-    { "display_vflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT,              { .off = OFFSET(display_vflips) },
+    { "display_vflip",              OPT_TYPE_BOOL,   OPT_VIDEO | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(display_vflips) },
         "set display vertical flip for stream(s) "
         "(overrides any display rotation if it is not set)"},
-    { "vn",           OPT_VIDEO | OPT_BOOL  | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(video_disable) },
+    { "vn",                         OPT_TYPE_BOOL,   OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(video_disable) },
         "disable video" },
-    { "rc_override",  OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(rc_overrides) },
+    { "rc_override",                OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT  | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(rc_overrides) },
         "rate control override for specific intervals", "override" },
-    { "vcodec",       OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_INPUT |
-                      OPT_OUTPUT,                                                { .func_arg = opt_video_codec },
+    { "vcodec",                     OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+        { .func_arg = opt_video_codec },
         "force video codec ('copy' to copy stream)", "codec" },
-    { "timecode",     OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,            { .func_arg = opt_timecode },
+    { "timecode",                   OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_timecode },
         "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
-    { "pass",         OPT_VIDEO | OPT_SPEC | OPT_INT | OPT_OUTPUT,     { .off = OFFSET(pass) },
+    { "pass",                       OPT_TYPE_INT,    OPT_VIDEO | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(pass) },
         "select the pass number (1 to 3)", "n" },
-    { "passlogfile",  OPT_VIDEO | OPT_STRING | OPT_EXPERT | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(passlogfiles) },
+    { "passlogfile",                OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(passlogfiles) },
         "select two pass log file name prefix", "prefix" },
-    { "vstats",       OPT_VIDEO | OPT_EXPERT ,                                   { .func_arg = opt_vstats },
+    { "vstats",                     OPT_TYPE_FUNC,   OPT_VIDEO | OPT_EXPERT,
+        { .func_arg = opt_vstats },
         "dump video coding statistics to file" },
-    { "vstats_file",  OPT_VIDEO | HAS_ARG | OPT_EXPERT ,                         { .func_arg = opt_vstats_file },
+    { "vstats_file",                OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_vstats_file },
         "dump video coding statistics to file", "file" },
-    { "vstats_version",  OPT_VIDEO | OPT_INT | OPT_EXPERT ,            { &vstats_version },
+    { "vstats_version",             OPT_TYPE_INT,    OPT_VIDEO | OPT_EXPERT,
+        { &vstats_version },
         "Version of the vstats format to use."},
-    { "vf",           OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_video_filters },
+    { "vf",                         OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_video_filters },
         "set video filters", "filter_graph" },
-    { "intra_matrix", OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(intra_matrices) },
+    { "intra_matrix",               OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(intra_matrices) },
         "specify intra matrix coeffs", "matrix" },
-    { "inter_matrix", OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(inter_matrices) },
+    { "inter_matrix",               OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(inter_matrices) },
         "specify inter matrix coeffs", "matrix" },
-    { "chroma_intra_matrix", OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(chroma_intra_matrices) },
+    { "chroma_intra_matrix",        OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(chroma_intra_matrices) },
         "specify intra matrix coeffs", "matrix" },
-    { "vtag",         OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_PERFILE |
-                      OPT_INPUT | OPT_OUTPUT,                                    { .func_arg = opt_old2new },
+    { "vtag",                       OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+        { .func_arg = opt_old2new },
         "force video tag/fourcc", "fourcc/tag" },
-    { "fps_mode",     OPT_VIDEO | OPT_STRING | OPT_EXPERT |
-                      OPT_SPEC | OPT_OUTPUT,                                     { .off = OFFSET(fps_mode) },
+    { "fps_mode",                   OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(fps_mode) },
         "set framerate mode for matching video streams; overrides vsync" },
-    { "force_fps",    OPT_VIDEO | OPT_BOOL | OPT_EXPERT  | OPT_SPEC |
-                      OPT_OUTPUT,                                                { .off = OFFSET(force_fps) },
+    { "force_fps",                  OPT_TYPE_BOOL,   OPT_VIDEO | OPT_EXPERT  | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(force_fps) },
         "force the selected framerate, disable the best supported framerate selection" },
-    { "streamid",     OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
-                      OPT_OUTPUT,                                                { .func_arg = opt_streamid },
+    { "streamid",                   OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_streamid },
         "set the value of an outfile streamid", "streamIndex:value" },
-    { "force_key_frames", OPT_VIDEO | OPT_STRING | OPT_EXPERT |
-                          OPT_SPEC | OPT_OUTPUT,                                 { .off = OFFSET(forced_key_frames) },
+    { "force_key_frames",           OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(forced_key_frames) },
         "force key frames at specified timestamps", "timestamps" },
-    { "b",            OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,            { .func_arg = opt_bitrate },
+    { "b",                          OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_bitrate },
         "video bitrate (please use -b:v)", "bitrate" },
-    { "hwaccel",          OPT_VIDEO | OPT_STRING | OPT_EXPERT |
-                          OPT_SPEC | OPT_INPUT,                                  { .off = OFFSET(hwaccels) },
+    { "hwaccel",                    OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(hwaccels) },
         "use HW accelerated decoding", "hwaccel name" },
-    { "hwaccel_device",   OPT_VIDEO | OPT_STRING | OPT_EXPERT |
-                          OPT_SPEC | OPT_INPUT,                                  { .off = OFFSET(hwaccel_devices) },
+    { "hwaccel_device",             OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(hwaccel_devices) },
         "select a device for HW acceleration", "devicename" },
-    { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | OPT_EXPERT |
-                          OPT_SPEC | OPT_INPUT,                                  { .off = OFFSET(hwaccel_output_formats) },
+    { "hwaccel_output_format",      OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(hwaccel_output_formats) },
         "select output format used with HW accelerated decoding", "format" },
-    { "hwaccels",         OPT_EXIT,                                              { .func_arg = show_hwaccels },
+    { "hwaccels",                   OPT_TYPE_FUNC,   OPT_EXIT,
+        { .func_arg = show_hwaccels },
         "show available HW acceleration methods" },
-    { "autorotate",       OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_INPUT,          { .off = OFFSET(autorotate) },
+    { "autorotate",                 OPT_TYPE_BOOL,   OPT_SPEC | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(autorotate) },
         "automatically insert correct rotate filters" },
-    { "autoscale",        OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,         { .off = OFFSET(autoscale) },
+    { "autoscale",                  OPT_TYPE_BOOL,   OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(autoscale) },
         "automatically insert a scale filter at the end of the filter graph" },
-    { "fix_sub_duration_heartbeat", OPT_VIDEO | OPT_BOOL | OPT_EXPERT |
-                                    OPT_SPEC | OPT_OUTPUT,                       { .off = OFFSET(fix_sub_duration_heartbeat) },
+    { "fix_sub_duration_heartbeat", OPT_TYPE_BOOL,   OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(fix_sub_duration_heartbeat) },
         "set this video output stream to be a heartbeat stream for "
         "fix_sub_duration, according to which subtitles should be split at "
         "random access points" },
 
     /* audio options */
-    { "aframes",        OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_audio_frames },
+    { "aframes",          OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_audio_frames },
         "set the number of audio frames to output", "number" },
-    { "aq",             OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_audio_qscale },
+    { "aq",               OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_audio_qscale },
         "set audio quality (codec-specific)", "quality", },
-    { "ar",             OPT_AUDIO | OPT_INT | OPT_SPEC |
-                        OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(audio_sample_rate) },
+    { "ar",               OPT_TYPE_INT,     OPT_AUDIO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(audio_sample_rate) },
         "set audio sampling rate (in Hz)", "rate" },
-    { "ac",             OPT_AUDIO | OPT_INT | OPT_SPEC |
-                        OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(audio_channels) },
+    { "ac",               OPT_TYPE_INT,     OPT_AUDIO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(audio_channels) },
         "set number of audio channels", "channels" },
-    { "an",             OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(audio_disable) },
+    { "an",               OPT_TYPE_BOOL,    OPT_AUDIO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(audio_disable) },
         "disable audio" },
-    { "acodec",         OPT_AUDIO | HAS_ARG  | OPT_PERFILE |
-                        OPT_INPUT | OPT_OUTPUT,                                    { .func_arg = opt_audio_codec },
+    { "acodec",           OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+        { .func_arg = opt_audio_codec },
         "force audio codec ('copy' to copy stream)", "codec" },
-    { "ab",             OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,            { .func_arg = opt_bitrate },
+    { "ab",               OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_bitrate },
         "audio bitrate (please use -b:a)", "bitrate" },
-    { "atag",           OPT_AUDIO | HAS_ARG  | OPT_EXPERT | OPT_PERFILE |
-                        OPT_OUTPUT,                                                { .func_arg = opt_old2new },
+    { "atag",             OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_old2new },
         "force audio tag/fourcc", "fourcc/tag" },
-    { "sample_fmt",     OPT_AUDIO | OPT_EXPERT | OPT_SPEC |
-                        OPT_STRING | OPT_INPUT | OPT_OUTPUT,                       { .off = OFFSET(sample_fmts) },
+    { "sample_fmt",       OPT_TYPE_STRING,  OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(sample_fmts) },
         "set sample format", "format" },
-    { "channel_layout", OPT_AUDIO | OPT_EXPERT | OPT_SPEC |
-                        OPT_STRING | OPT_INPUT | OPT_OUTPUT,                       { .off = OFFSET(audio_ch_layouts) },
+    { "channel_layout",   OPT_TYPE_STRING,  OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(audio_ch_layouts) },
         "set channel layout", "layout" },
-    { "ch_layout",      OPT_AUDIO | OPT_EXPERT | OPT_SPEC |
-                        OPT_STRING | OPT_INPUT | OPT_OUTPUT,                       { .off = OFFSET(audio_ch_layouts) },
+    { "ch_layout",        OPT_TYPE_STRING,  OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(audio_ch_layouts) },
         "set channel layout", "layout" },
-    { "af",             OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_audio_filters },
+    { "af",               OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_audio_filters },
         "set audio filters", "filter_graph" },
-    { "guess_layout_max", OPT_AUDIO | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(guess_layout_max) },
+    { "guess_layout_max", OPT_TYPE_INT,     OPT_AUDIO | OPT_SPEC | OPT_EXPERT | OPT_INPUT,
+        { .off = OFFSET(guess_layout_max) },
       "set the maximum number of channels to try to guess the channel layout" },
 
     /* subtitle options */
-    { "sn",     OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(subtitle_disable) },
+    { "sn",     OPT_TYPE_BOOL, OPT_SUBTITLE | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(subtitle_disable) },
         "disable subtitle" },
-    { "scodec", OPT_SUBTITLE | HAS_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_subtitle_codec },
+    { "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | HAS_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+        { .func_arg = opt_subtitle_codec },
         "force subtitle codec ('copy' to copy stream)", "codec" },
-    { "stag",   OPT_SUBTITLE | HAS_ARG  | OPT_EXPERT  | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new }
+    { "stag",   OPT_TYPE_FUNC, OPT_SUBTITLE | HAS_ARG  | OPT_EXPERT  | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_old2new }
         , "force subtitle tag/fourcc", "fourcc/tag" },
-    { "fix_sub_duration", OPT_BOOL | OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT, { .off = OFFSET(fix_sub_duration) },
+    { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(fix_sub_duration) },
         "fix subtitles duration" },
-    { "canvas_size", OPT_SUBTITLE | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFFSET(canvas_sizes) },
+    { "canvas_size", OPT_TYPE_STRING, OPT_SUBTITLE | OPT_SPEC | OPT_INPUT,
+        { .off = OFFSET(canvas_sizes) },
         "set canvas size (WxH or abbreviation)", "size" },
 
     /* muxer options */
-    { "muxdelay",   OPT_FLOAT | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_max_delay) },
+    { "muxdelay",   OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(mux_max_delay) },
         "set the maximum demux-decode delay", "seconds" },
-    { "muxpreload", OPT_FLOAT | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_preload) },
+    { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
+        { .off = OFFSET(mux_preload) },
         "set the initial demux-decode delay", "seconds" },
-    { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file },
+    { "sdp_file",   OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_OUTPUT,
+        { .func_arg = opt_sdp_file },
         "specify a file in which to print sdp information", "file" },
 
-    { "time_base", OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(time_bases) },
+    { "time_base",     OPT_TYPE_STRING, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(time_bases) },
         "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
-    { "enc_time_base", OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(enc_time_bases) },
+    { "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
+        { .off = OFFSET(enc_time_bases) },
         "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
         "two special values are defined - "
         "0 = use frame rate (video) or sample rate (audio),"
         "-1 = match source time base", "ratio" },
 
-    { "bsf", OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
+    { "bsf", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(bitstream_filters) },
         "A comma-separated list of bitstream filters", "bitstream_filters" },
-    { "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
+    { "absf", OPT_TYPE_FUNC, HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_old2new },
         "deprecated", "audio bitstream_filters" },
-    { "vbsf", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
+    { "vbsf", OPT_TYPE_FUNC, OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_old2new },
         "deprecated", "video bitstream_filters" },
 
-    { "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,    { .func_arg = opt_preset },
+    { "apre", OPT_TYPE_FUNC, HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_preset },
         "set the audio options to the indicated preset", "preset" },
-    { "vpre", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,    { .func_arg = opt_preset },
+    { "vpre", OPT_TYPE_FUNC, OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_preset },
         "set the video options to the indicated preset", "preset" },
-    { "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
+    { "spre", OPT_TYPE_FUNC, HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_preset },
         "set the subtitle options to the indicated preset", "preset" },
-    { "fpre", HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,                { .func_arg = opt_preset },
+    { "fpre", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_preset },
         "set options from indicated preset file", "filename" },
 
-    { "max_muxing_queue_size", OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(max_muxing_queue_size) },
+    { "max_muxing_queue_size", OPT_TYPE_INT, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(max_muxing_queue_size) },
         "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
-    { "muxing_queue_data_threshold", OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(muxing_queue_data_threshold) },
+    { "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
+        { .off = OFFSET(muxing_queue_data_threshold) },
         "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
 
     /* data codec support */
-    { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec },
+    { "dcodec", OPT_TYPE_FUNC, HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
+        { .func_arg = opt_data_codec },
         "force data codec ('copy' to copy stream)", "codec" },
-    { "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
-        "disable data" },
+    { "dn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(data_disable) }, "disable data" },
 
 #if CONFIG_VAAPI
-    { "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
+    { "vaapi_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_vaapi_device },
         "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
 #endif
 
 #if CONFIG_QSV
-    { "qsv_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_qsv_device },
+    { "qsv_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_qsv_device },
         "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
 #endif
 
-    { "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device },
+    { "init_hw_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_init_hw_device },
         "initialise hardware device", "args" },
-    { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device },
+    { "filter_hw_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_filter_hw_device },
         "set hardware device used when filtering", "device" },
 
     // deprecated options
 #if FFMPEG_OPT_MAP_CHANNEL
-    { "map_channel",    HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel },
+    { "map_channel", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+        { .func_arg = opt_map_channel },
         "map an audio channel from one stream to another (deprecated)", "file.stream.channel[:syncfile.syncstream]" },
 #endif
 #if FFMPEG_OPT_ADRIFT_THRESHOLD
-    { "adrift_threshold", HAS_ARG | OPT_EXPERT,                      { .func_arg = opt_adrift_threshold },
+    { "adrift_threshold", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+        { .func_arg = opt_adrift_threshold },
         "deprecated, does nothing", "threshold" },
 #endif
 #if FFMPEG_OPT_PSNR
-    { "psnr",         OPT_VIDEO | OPT_BOOL | OPT_EXPERT,                         { &do_psnr },
+    { "psnr", OPT_TYPE_BOOL,   OPT_VIDEO | OPT_EXPERT,
+        { &do_psnr },
         "calculate PSNR of compressed frames (deprecated, use -flags +psnr)" },
 #endif
 #if FFMPEG_OPT_TOP
-    { "top",          OPT_VIDEO | OPT_EXPERT  | OPT_INT| OPT_SPEC |
-                      OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(top_field_first) },
+    { "top", OPT_TYPE_INT,     OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
+        { .off = OFFSET(top_field_first) },
         "deprecated, use the setfield video filter", "" },
 #endif
 #if FFMPEG_OPT_QPHIST
-    { "qphist",       OPT_VIDEO | OPT_EXPERT ,                        { .func_arg = opt_qphist },
+    { "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
+        { .func_arg = opt_qphist },
         "deprecated, does nothing" },
 #endif
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 3fd016ccaf..e01b2c03de 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3516,7 +3516,7 @@  static void event_loop(VideoState *cur_stream)
 static int opt_width(void *optctx, const char *opt, const char *arg)
 {
     double num;
-    int ret = parse_number(opt, arg, OPT_INT64, 1, INT_MAX, &num);
+    int ret = parse_number(opt, arg, OPT_TYPE_INT64, 1, INT_MAX, &num);
     if (ret < 0)
         return ret;
 
@@ -3527,7 +3527,7 @@  static int opt_width(void *optctx, const char *opt, const char *arg)
 static int opt_height(void *optctx, const char *opt, const char *arg)
 {
     double num;
-    int ret = parse_number(opt, arg, OPT_INT64, 1, INT_MAX, &num);
+    int ret = parse_number(opt, arg, OPT_TYPE_INT64, 1, INT_MAX, &num);
     if (ret < 0)
         return ret;
 
@@ -3568,7 +3568,7 @@  static int opt_show_mode(void *optctx, const char *opt, const char *arg)
 
     if (show_mode == SHOW_MODE_NONE) {
         double num;
-        int ret = parse_number(opt, arg, OPT_INT, 0, SHOW_MODE_NB-1, &num);
+        int ret = parse_number(opt, arg, OPT_TYPE_INT, 0, SHOW_MODE_NB-1, &num);
         if (ret < 0)
             return ret;
         show_mode = num;
@@ -3617,55 +3617,55 @@  static int dummy;
 
 static const OptionDef options[] = {
     CMDUTILS_COMMON_OPTIONS
-    { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" },
-    { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" },
-    { "fs", OPT_BOOL, { &is_full_screen }, "force full screen" },
-    { "an", OPT_BOOL, { &audio_disable }, "disable audio" },
-    { "vn", OPT_BOOL, { &video_disable }, "disable video" },
-    { "sn", OPT_BOOL, { &subtitle_disable }, "disable subtitling" },
-    { "ast", OPT_STRING | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_specifier" },
-    { "vst", OPT_STRING | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_specifier" },
-    { "sst", OPT_STRING | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_specifier" },
-    { "ss", OPT_TIME, { &start_time }, "seek to a given position in seconds", "pos" },
-    { "t",  OPT_TIME, { &duration }, "play  \"duration\" seconds of audio/video", "duration" },
-    { "bytes", OPT_INT, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" },
-    { "seek_interval", OPT_FLOAT, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" },
-    { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
-    { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
-    { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
-    { "volume", OPT_INT, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
-    { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
-    { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" },
-    { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" },
-    { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" },
-    { "drp", OPT_INT | OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""},
-    { "lowres", OPT_INT | OPT_EXPERT, { &lowres }, "", "" },
-    { "sync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" },
-    { "autoexit", OPT_BOOL | OPT_EXPERT, { &autoexit }, "exit at the end", "" },
-    { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { &exit_on_keydown }, "exit on key down", "" },
-    { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { &exit_on_mousedown }, "exit on mouse down", "" },
-    { "loop", OPT_INT | OPT_EXPERT, { &loop }, "set number of times the playback shall be looped", "loop count" },
-    { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" },
-    { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" },
-    { "window_title", OPT_STRING, { &window_title }, "set window title", "window title" },
-    { "left", OPT_INT | OPT_EXPERT, { &screen_left }, "set the x position for the left of the window", "x pos" },
-    { "top", OPT_INT | OPT_EXPERT, { &screen_top }, "set the y position for the top of the window", "y pos" },
-    { "vf", OPT_EXPERT | HAS_ARG, { .func_arg = opt_add_vfilter }, "set video filters", "filter_graph" },
-    { "af", OPT_STRING, { &afilters }, "set audio filters", "filter_graph" },
-    { "rdftspeed", OPT_INT | OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" },
-    { "showmode", HAS_ARG, { .func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
-    { "i", OPT_BOOL, { &dummy}, "read specified file", "input_file"},
-    { "codec", HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
-    { "acodec", OPT_STRING | OPT_EXPERT, {    &audio_codec_name }, "force audio decoder",    "decoder_name" },
-    { "scodec", OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
-    { "vcodec", OPT_STRING | OPT_EXPERT, {    &video_codec_name }, "force video decoder",    "decoder_name" },
-    { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" },
-    { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
+    { "x",                  OPT_TYPE_FUNC,      HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" },
+    { "y",                  OPT_TYPE_FUNC,      HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" },
+    { "fs",                 OPT_TYPE_BOOL,            0, { &is_full_screen }, "force full screen" },
+    { "an",                 OPT_TYPE_BOOL,            0, { &audio_disable }, "disable audio" },
+    { "vn",                 OPT_TYPE_BOOL,            0, { &video_disable }, "disable video" },
+    { "sn",                 OPT_TYPE_BOOL,            0, { &subtitle_disable }, "disable subtitling" },
+    { "ast",                OPT_TYPE_STRING, OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_specifier" },
+    { "vst",                OPT_TYPE_STRING, OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_specifier" },
+    { "sst",                OPT_TYPE_STRING, OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_specifier" },
+    { "ss",                 OPT_TYPE_TIME,            0, { &start_time }, "seek to a given position in seconds", "pos" },
+    { "t",                  OPT_TYPE_TIME,            0, { &duration }, "play  \"duration\" seconds of audio/video", "duration" },
+    { "bytes",              OPT_TYPE_INT,             0, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" },
+    { "seek_interval",      OPT_TYPE_FLOAT,           0, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" },
+    { "nodisp",             OPT_TYPE_BOOL,            0, { &display_disable }, "disable graphical display" },
+    { "noborder",           OPT_TYPE_BOOL,            0, { &borderless }, "borderless window" },
+    { "alwaysontop",        OPT_TYPE_BOOL,            0, { &alwaysontop }, "window always on top" },
+    { "volume",             OPT_TYPE_INT,             0, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
+    { "f",                  OPT_TYPE_FUNC,      HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
+    { "stats",              OPT_TYPE_BOOL,   OPT_EXPERT, { &show_status }, "show status", "" },
+    { "fast",               OPT_TYPE_BOOL,   OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" },
+    { "genpts",             OPT_TYPE_BOOL,   OPT_EXPERT, { &genpts }, "generate pts", "" },
+    { "drp",                OPT_TYPE_INT,    OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""},
+    { "lowres",             OPT_TYPE_INT,    OPT_EXPERT, { &lowres }, "", "" },
+    { "sync",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT, { .func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" },
+    { "autoexit",           OPT_TYPE_BOOL,   OPT_EXPERT, { &autoexit }, "exit at the end", "" },
+    { "exitonkeydown",      OPT_TYPE_BOOL,   OPT_EXPERT, { &exit_on_keydown }, "exit on key down", "" },
+    { "exitonmousedown",    OPT_TYPE_BOOL,   OPT_EXPERT, { &exit_on_mousedown }, "exit on mouse down", "" },
+    { "loop",               OPT_TYPE_INT,    OPT_EXPERT, { &loop }, "set number of times the playback shall be looped", "loop count" },
+    { "framedrop",          OPT_TYPE_BOOL,   OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" },
+    { "infbuf",             OPT_TYPE_BOOL,   OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" },
+    { "window_title",       OPT_TYPE_STRING,          0, { &window_title }, "set window title", "window title" },
+    { "left",               OPT_TYPE_INT,    OPT_EXPERT, { &screen_left }, "set the x position for the left of the window", "x pos" },
+    { "top",                OPT_TYPE_INT,    OPT_EXPERT, { &screen_top }, "set the y position for the top of the window", "y pos" },
+    { "vf",                 OPT_TYPE_FUNC,  OPT_EXPERT | HAS_ARG, { .func_arg = opt_add_vfilter }, "set video filters", "filter_graph" },
+    { "af",                 OPT_TYPE_STRING,          0, { &afilters }, "set audio filters", "filter_graph" },
+    { "rdftspeed",          OPT_TYPE_INT, OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" },
+    { "showmode",           OPT_TYPE_FUNC,      HAS_ARG, { .func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
+    { "i",                  OPT_TYPE_BOOL,            0, { &dummy}, "read specified file", "input_file"},
+    { "codec",              OPT_TYPE_FUNC,      HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
+    { "acodec",             OPT_TYPE_STRING, OPT_EXPERT, {    &audio_codec_name }, "force audio decoder",    "decoder_name" },
+    { "scodec",             OPT_TYPE_STRING, OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
+    { "vcodec",             OPT_TYPE_STRING, OPT_EXPERT, {    &video_codec_name }, "force video decoder",    "decoder_name" },
+    { "autorotate",         OPT_TYPE_BOOL,            0, { &autorotate }, "automatically rotate video", "" },
+    { "find_stream_info",   OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
         "read and decode the streams to fill missing information with heuristics" },
-    { "filter_threads", OPT_INT | OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" },
-    { "enable_vulkan", OPT_BOOL, { &enable_vulkan }, "enable vulkan renderer" },
-    { "vulkan_params", OPT_STRING | OPT_EXPERT, { &vulkan_params }, "vulkan configuration using a list of key=value pairs separated by ':'" },
-    { "hwaccel", OPT_STRING | OPT_EXPERT, { &hwaccel }, "use HW accelerated decoding" },
+    { "filter_threads",     OPT_TYPE_INT,    OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" },
+    { "enable_vulkan",      OPT_TYPE_BOOL,            0, { &enable_vulkan }, "enable vulkan renderer" },
+    { "vulkan_params",      OPT_TYPE_STRING, OPT_EXPERT, { &vulkan_params }, "vulkan configuration using a list of key=value pairs separated by ':'" },
+    { "hwaccel",            OPT_TYPE_STRING, OPT_EXPERT, { &hwaccel }, "use HW accelerated decoding" },
     { NULL, },
 };
 
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 9968603e76..57e55e8a0b 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3716,7 +3716,7 @@  static int opt_show_optional_fields(void *optctx, const char *opt, const char *a
 
     if (show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO && av_strcasecmp(arg, "auto")) {
         double num;
-        int ret = parse_number("show_optional_fields", arg, OPT_INT,
+        int ret = parse_number("show_optional_fields", arg, OPT_TYPE_INT,
                                SHOW_OPTIONAL_FIELDS_AUTO, SHOW_OPTIONAL_FIELDS_ALWAYS, &num);
         if (ret < 0)
             return ret;
@@ -4078,50 +4078,50 @@  DEFINE_OPT_SHOW_SECTION(programs,         PROGRAMS)
 
 static const OptionDef real_options[] = {
     CMDUTILS_COMMON_OPTIONS
-    { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
-    { "unit", OPT_BOOL, {&show_value_unit}, "show unit of the displayed values" },
-    { "prefix", OPT_BOOL, {&use_value_prefix}, "use SI prefixes for the displayed values" },
-    { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix},
+    { "f",                     OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
+    { "unit",                  OPT_TYPE_BOOL,        0, {&show_value_unit}, "show unit of the displayed values" },
+    { "prefix",                OPT_TYPE_BOOL,        0, {&use_value_prefix}, "use SI prefixes for the displayed values" },
+    { "byte_binary_prefix",    OPT_TYPE_BOOL,        0, {&use_byte_value_binary_prefix},
       "use binary prefixes for byte units" },
-    { "sexagesimal", OPT_BOOL,  {&use_value_sexagesimal_format},
+    { "sexagesimal",           OPT_TYPE_BOOL,        0, {&use_value_sexagesimal_format},
       "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
-    { "pretty", 0, {.func_arg = opt_pretty},
+    { "pretty",                OPT_TYPE_FUNC,        0, {.func_arg = opt_pretty},
       "prettify the format of displayed values, make it more human readable" },
-    { "output_format", OPT_STRING, { &output_format },
+    { "output_format",         OPT_TYPE_STRING,      0, { &output_format },
       "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
-    { "print_format", OPT_STRING, { &output_format }, "alias for -output_format (deprecated)" },
-    { "of", OPT_STRING, { &output_format }, "alias for -output_format", "format" },
-    { "select_streams", OPT_STRING, { &stream_specifier }, "select the specified streams", "stream_specifier" },
-    { "sections", OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
-    { "show_data",    OPT_BOOL, { &do_show_data }, "show packets data" },
-    { "show_data_hash", OPT_STRING, { &show_data_hash }, "show packets data hash" },
-    { "show_error",   0, { .func_arg = &opt_show_error },  "show probing error" },
-    { "show_format",  0, { .func_arg = &opt_show_format }, "show format/container info" },
-    { "show_frames",  0, { .func_arg = &opt_show_frames }, "show frames info" },
-    { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
+    { "print_format",          OPT_TYPE_STRING,      0, { &output_format }, "alias for -output_format (deprecated)" },
+    { "of",                    OPT_TYPE_STRING,      0, { &output_format }, "alias for -output_format", "format" },
+    { "select_streams",        OPT_TYPE_STRING,      0, { &stream_specifier }, "select the specified streams", "stream_specifier" },
+    { "sections",              OPT_TYPE_FUNC, OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
+    { "show_data",             OPT_TYPE_BOOL,        0, { &do_show_data }, "show packets data" },
+    { "show_data_hash",        OPT_TYPE_STRING,      0, { &show_data_hash }, "show packets data hash" },
+    { "show_error",            OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_error },  "show probing error" },
+    { "show_format",           OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_format }, "show format/container info" },
+    { "show_frames",           OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_frames }, "show frames info" },
+    { "show_entries",          OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_show_entries},
       "show a set of specified entries", "entry_list" },
 #if HAVE_THREADS
-    { "show_log", OPT_INT, { &do_show_log }, "show log" },
+    { "show_log",              OPT_TYPE_INT,         0, { &do_show_log }, "show log" },
 #endif
-    { "show_packets", 0, { .func_arg = &opt_show_packets }, "show packets info" },
-    { "show_programs", 0, { .func_arg = &opt_show_programs }, "show programs info" },
-    { "show_streams", 0, { .func_arg = &opt_show_streams }, "show streams info" },
-    { "show_chapters", 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
-    { "count_frames", OPT_BOOL, { &do_count_frames }, "count the number of frames per stream" },
-    { "count_packets", OPT_BOOL, { &do_count_packets }, "count the number of packets per stream" },
-    { "show_program_version",  0, { .func_arg = &opt_show_program_version },  "show ffprobe version" },
-    { "show_library_versions", 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
-    { "show_versions",         0, { .func_arg = &opt_show_versions }, "show program and library versions" },
-    { "show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
-    { "show_optional_fields", HAS_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
-    { "show_private_data", OPT_BOOL, { &show_private_data }, "show private data" },
-    { "private",           OPT_BOOL, { &show_private_data }, "same as show_private_data" },
-    { "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" },
-    { "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
-    { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
-    { "o", HAS_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
-    { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
-    { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
+    { "show_packets",          OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_packets }, "show packets info" },
+    { "show_programs",         OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_programs }, "show programs info" },
+    { "show_streams",          OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_streams }, "show streams info" },
+    { "show_chapters",         OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_chapters }, "show chapters info" },
+    { "count_frames",          OPT_TYPE_BOOL,        0, { &do_count_frames }, "count the number of frames per stream" },
+    { "count_packets",         OPT_TYPE_BOOL,        0, { &do_count_packets }, "count the number of packets per stream" },
+    { "show_program_version",  OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_program_version },  "show ffprobe version" },
+    { "show_library_versions", OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_library_versions }, "show library versions" },
+    { "show_versions",         OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_versions }, "show program and library versions" },
+    { "show_pixel_formats",    OPT_TYPE_FUNC,        0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
+    { "show_optional_fields",  OPT_TYPE_FUNC,  HAS_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
+    { "show_private_data",     OPT_TYPE_BOOL,        0, { &show_private_data }, "show private data" },
+    { "private",               OPT_TYPE_BOOL,        0, { &show_private_data }, "same as show_private_data" },
+    { "bitexact",              OPT_TYPE_BOOL,        0, {&do_bitexact}, "force bitexact output" },
+    { "read_intervals",        OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
+    { "i",                     OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
+    { "o",                     OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
+    { "print_filename",        OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
+    { "find_stream_info",      OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
         "read and decode the streams to fill missing information with heuristics" },
     { NULL, },
 };
diff --git a/fftools/opt_common.h b/fftools/opt_common.h
index ea1d16e769..08573eb7be 100644
--- a/fftools/opt_common.h
+++ b/fftools/opt_common.h
@@ -41,9 +41,9 @@  int show_sources(void *optctx, const char *opt, const char *arg);
 
 #if CONFIG_AVDEVICE
 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                \
-    { "sources"    , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },                                                  \
+    { "sources"    , OPT_TYPE_FUNC, OPT_EXIT | HAS_ARG, { .func_arg = show_sources },                                   \
       "list sources of the input device", "device" },                                                                   \
-    { "sinks"      , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },                                                    \
+    { "sinks"      , OPT_TYPE_FUNC, OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },                                     \
       "list sinks of the output device", "device" },                                                                    \
 
 #else
@@ -197,35 +197,35 @@  int opt_cpuflags(void *optctx, const char *opt, const char *arg);
 int opt_cpucount(void *optctx, const char *opt, const char *arg);
 
 #define CMDUTILS_COMMON_OPTIONS                                                                                         \
-    { "L",           OPT_EXIT,             { .func_arg = show_license },     "show license" },                          \
-    { "h",           OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
-    { "?",           OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
-    { "help",        OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
-    { "-help",       OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
-    { "version",     OPT_EXIT,             { .func_arg = show_version },     "show version" },                          \
-    { "buildconf",   OPT_EXIT,             { .func_arg = show_buildconf },   "show build configuration" },              \
-    { "formats",     OPT_EXIT,             { .func_arg = show_formats },     "show available formats" },                \
-    { "muxers",      OPT_EXIT,             { .func_arg = show_muxers },      "show available muxers" },                 \
-    { "demuxers",    OPT_EXIT,             { .func_arg = show_demuxers },    "show available demuxers" },               \
-    { "devices",     OPT_EXIT,             { .func_arg = show_devices },     "show available devices" },                \
-    { "codecs",      OPT_EXIT,             { .func_arg = show_codecs },      "show available codecs" },                 \
-    { "decoders",    OPT_EXIT,             { .func_arg = show_decoders },    "show available decoders" },               \
-    { "encoders",    OPT_EXIT,             { .func_arg = show_encoders },    "show available encoders" },               \
-    { "bsfs",        OPT_EXIT,             { .func_arg = show_bsfs },        "show available bit stream filters" },     \
-    { "protocols",   OPT_EXIT,             { .func_arg = show_protocols },   "show available protocols" },              \
-    { "filters",     OPT_EXIT,             { .func_arg = show_filters },     "show available filters" },                \
-    { "pix_fmts",    OPT_EXIT,             { .func_arg = show_pix_fmts },    "show available pixel formats" },          \
-    { "layouts",     OPT_EXIT,             { .func_arg = show_layouts },     "show standard channel layouts" },         \
-    { "sample_fmts", OPT_EXIT,             { .func_arg = show_sample_fmts }, "show available audio sample formats" },   \
-    { "dispositions", OPT_EXIT,            { .func_arg = show_dispositions}, "show available stream dispositions" },    \
-    { "colors",      OPT_EXIT,             { .func_arg = show_colors },      "show available color names" },            \
-    { "loglevel",    HAS_ARG,              { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
-    { "v",           HAS_ARG,              { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
-    { "report",      0,                    { .func_arg = opt_report },       "generate a report" },                     \
-    { "max_alloc",   HAS_ARG,              { .func_arg = opt_max_alloc },    "set maximum size of a single allocated block", "bytes" }, \
-    { "cpuflags",    HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags },     "force specific cpu flags", "flags" },     \
-    { "cpucount",    HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount },     "force specific cpu count", "count" },     \
-    { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner},     "do not show program banner", "hide_banner" },          \
+    { "L",            OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_license },     "show license" },                          \
+    { "h",            OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_help },        "show help", "topic" },                    \
+    { "?",            OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_help },        "show help", "topic" },                    \
+    { "help",         OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_help },        "show help", "topic" },                    \
+    { "-help",        OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_help },        "show help", "topic" },                    \
+    { "version",      OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_version },     "show version" },                          \
+    { "buildconf",    OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_buildconf },   "show build configuration" },              \
+    { "formats",      OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_formats },     "show available formats" },                \
+    { "muxers",       OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_muxers },      "show available muxers" },                 \
+    { "demuxers",     OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_demuxers },    "show available demuxers" },               \
+    { "devices",      OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_devices },     "show available devices" },                \
+    { "codecs",       OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_codecs },      "show available codecs" },                 \
+    { "decoders",     OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_decoders },    "show available decoders" },               \
+    { "encoders",     OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_encoders },    "show available encoders" },               \
+    { "bsfs",         OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_bsfs },        "show available bit stream filters" },     \
+    { "protocols",    OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_protocols },   "show available protocols" },              \
+    { "filters",      OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_filters },     "show available filters" },                \
+    { "pix_fmts",     OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_pix_fmts },    "show available pixel formats" },          \
+    { "layouts",      OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_layouts },     "show standard channel layouts" },         \
+    { "sample_fmts",  OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_sample_fmts }, "show available audio sample formats" },   \
+    { "dispositions", OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_dispositions}, "show available stream dispositions" },    \
+    { "colors",       OPT_TYPE_FUNC, OPT_EXIT,              { .func_arg = show_colors },      "show available color names" },            \
+    { "loglevel",     OPT_TYPE_FUNC, HAS_ARG,               { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
+    { "v",            OPT_TYPE_FUNC, HAS_ARG,               { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
+    { "report",       OPT_TYPE_FUNC, 0,                     { .func_arg = opt_report },       "generate a report" },                     \
+    { "max_alloc",    OPT_TYPE_FUNC, HAS_ARG,               { .func_arg = opt_max_alloc },    "set maximum size of a single allocated block", "bytes" }, \
+    { "cpuflags",     OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,  { .func_arg = opt_cpuflags },     "force specific cpu flags", "flags" },     \
+    { "cpucount",     OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,  { .func_arg = opt_cpucount },     "force specific cpu count", "count" },     \
+    { "hide_banner",  OPT_TYPE_BOOL, OPT_EXPERT,            {&hide_banner},                   "do not show program banner", "hide_banner" }, \
     CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                    \
 
 #endif /* FFTOOLS_OPT_COMMON_H */