diff mbox series

[FFmpeg-devel,06/20] fftools/cmdutils: rename HAS_ARG to OPT_FUNC_ARG

Message ID 20231218095722.25879-6-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
For consistent namespacing with other option flags. Also, document and
enforce that it can only be set for func-type options.
---
 fftools/cmdutils.c   |  8 +++-
 fftools/cmdutils.h   |  8 +++-
 fftools/ffmpeg_opt.c | 92 ++++++++++++++++++++++----------------------
 fftools/ffplay.c     | 14 +++----
 fftools/ffprobe.c    | 14 +++----
 fftools/opt_common.h | 14 +++----
 6 files changed, 80 insertions(+), 70 deletions(-)
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ff69cabf5..38f4f542d3 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -228,7 +228,7 @@  static int opt_has_arg(const OptionDef *o)
     if (o->type == OPT_TYPE_BOOL)
         return 0;
     if (o->type == OPT_TYPE_FUNC)
-        return !!(o->flags & HAS_ARG);
+        return !!(o->flags & OPT_FUNC_ARG);
     return 1;
 }
 
@@ -323,7 +323,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,
+        .flags      = OPT_FUNC_ARG,
         .u.func_arg = opt_default,
     };
 
@@ -481,6 +481,10 @@  static void check_options(const OptionDef *po)
     while (po->name) {
         if (po->flags & OPT_PERFILE)
             av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT));
+
+        // OPT_FUNC_ARG can only be ser for OPT_TYPE_FUNC
+        av_assert0((po->type == OPT_TYPE_FUNC) || !(po->flags & OPT_FUNC_ARG));
+
         po++;
     }
 }
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index b9ef8b5c15..d0242dc6ab 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -118,7 +118,13 @@  typedef struct OptionDef {
     const char *name;
     enum OptionType type;
     int flags;
-#define HAS_ARG         (1 << 0)
+
+/* The OPT_TYPE_FUNC option takes an argument.
+ * Must not be used with other option types, as for those it holds:
+ * - OPT_TYPE_BOOL do not take an argument
+ * - all other types do
+ */
+#define OPT_FUNC_ARG    (1 << 0)
 #define OPT_EXPERT      (1 << 2)
 #define OPT_VIDEO       (1 << 4)
 #define OPT_AUDIO       (1 << 5)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 752d5980b7..cf382759d8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1453,7 +1453,7 @@  const OptionDef options[] = {
     { "pre",                    OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
         { .off       = OFFSET(presets) },
         "preset name", "preset" },
-    { "map",                    OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "map",                    OPT_TYPE_FUNC, OPT_FUNC_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]]" },
@@ -1495,7 +1495,7 @@  const OptionDef options[] = {
     { "itsscale",               OPT_TYPE_DOUBLE, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
         { .off = OFFSET(ts_scale) },
         "set the input ts scale", "scale" },
-    { "timestamp",              OPT_TYPE_FUNC,   HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "timestamp",              OPT_TYPE_FUNC,   OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_recording_timestamp },
         "set the recording timestamp ('now' to set the current time)", "time" },
     { "metadata",               OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
@@ -1504,7 +1504,7 @@  const OptionDef options[] = {
     { "program",                OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
         { .off = OFFSET(program) },
         "add program with specified streams", "title=string:st=number..." },
-    { "dframes",                OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
+    { "dframes",                OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
         { .func_arg = opt_data_frames },
         "set the number of data frames to output", "number" },
     { "benchmark",              OPT_TYPE_BOOL, OPT_EXPERT,
@@ -1513,13 +1513,13 @@  const OptionDef options[] = {
     { "benchmark_all",          OPT_TYPE_BOOL, OPT_EXPERT,
         { &do_benchmark_all },
       "add timings for each task" },
-    { "progress",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "progress",               OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_progress },
       "write program-readable progress information", "url" },
     { "stdin",                  OPT_TYPE_BOOL, OPT_EXPERT,
         { &stdin_interaction },
       "enable or disable interaction on standard input" },
-    { "timelimit",              OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "timelimit",              OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_timelimit },
         "set max runtime in seconds in CPU user time", "limit" },
     { "dump",                   OPT_TYPE_BOOL, OPT_EXPERT,
@@ -1537,11 +1537,11 @@  const OptionDef options[] = {
     { "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",                 OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "target",                 OPT_TYPE_FUNC, OPT_FUNC_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",                  OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "vsync",                  OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_vsync },
         "set video sync method globally; deprecated, use -fps_mode", "" },
     { "frame_drop_threshold",   OPT_TYPE_FLOAT, OPT_EXPERT,
@@ -1577,7 +1577,7 @@  const OptionDef options[] = {
     { "xerror",                 OPT_TYPE_BOOL, OPT_EXPERT,
         { &exit_on_error },
         "exit on error", "error" },
-    { "abort_on",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "abort_on",               OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_abort_on },
         "abort on the specified condition flags", "flags" },
     { "copyinkf",               OPT_TYPE_BOOL, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
@@ -1595,16 +1595,16 @@  const OptionDef options[] = {
     { "q",                      OPT_TYPE_DOUBLE, OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
         { .off = OFFSET(qscale) },
         "use fixed quality scale (VBR)", "q" },
-    { "qscale",                 OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "qscale",                 OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_qscale },
         "use fixed quality scale (VBR)", "q" },
-    { "profile",                OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "profile",                OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_profile },
         "set profile", "profile" },
     { "filter",                 OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
         { .off = OFFSET(filters) },
         "set stream filtergraph", "filter_graph" },
-    { "filter_threads",         OPT_TYPE_FUNC, HAS_ARG,
+    { "filter_threads",         OPT_TYPE_FUNC, OPT_FUNC_ARG,
         { .func_arg = opt_filter_threads },
         "number of non-complex filter threads" },
     { "filter_script",          OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
@@ -1613,16 +1613,16 @@  const OptionDef options[] = {
     { "reinit_filter",          OPT_TYPE_INT, OPT_SPEC | OPT_INPUT,
         { .off = OFFSET(reinit_filters) },
         "reinit filtergraph on input parameter changes", "" },
-    { "filter_complex",         OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "filter_complex",         OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
     { "filter_complex_threads", OPT_TYPE_INT, 0,
         { &filter_complex_nbthreads },
         "number of threads for -filter_complex" },
-    { "lavfi",               OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "lavfi",               OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
-    { "filter_complex_script", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_complex_script },
         "read complex filtergraph description from a file", "filename" },
     { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
@@ -1631,10 +1631,10 @@  const OptionDef options[] = {
     { "stats",               OPT_TYPE_BOOL, 0,
         { &print_stats },
         "print progress report during encoding", },
-    { "stats_period",        OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "stats_period",        OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_stats_period },
         "set the period at which ffmpeg updates stats and -progress output", "time" },
-    { "attach",              OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
+    { "attach",              OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
         { .func_arg = opt_attach },
         "add an attachment to the output file", "filename" },
     { "dump_attachment",     OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
@@ -1684,7 +1684,7 @@  const OptionDef options[] = {
         "format of the stats written with -stats_mux_pre" },
 
     /* video options */
-    { "vframes",                    OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+    { "vframes",                    OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG  | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_video_frames },
         "set the number of video frames to output", "number" },
     { "r",                          OPT_TYPE_STRING, OPT_VIDEO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
@@ -1720,10 +1720,10 @@  const OptionDef options[] = {
     { "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_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+    { "vcodec",                     OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
         { .func_arg = opt_video_codec },
         "force video codec ('copy' to copy stream)", "codec" },
-    { "timecode",                   OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "timecode",                   OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_timecode },
         "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
     { "pass",                       OPT_TYPE_INT,    OPT_VIDEO | OPT_SPEC | OPT_OUTPUT,
@@ -1735,13 +1735,13 @@  const OptionDef options[] = {
     { "vstats",                     OPT_TYPE_FUNC,   OPT_VIDEO | OPT_EXPERT,
         { .func_arg = opt_vstats },
         "dump video coding statistics to file" },
-    { "vstats_file",                OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT,
+    { "vstats_file",                OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_vstats_file },
         "dump video coding statistics to file", "file" },
     { "vstats_version",             OPT_TYPE_INT,    OPT_VIDEO | OPT_EXPERT,
         { &vstats_version },
         "Version of the vstats format to use."},
-    { "vf",                         OPT_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "vf",                         OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_video_filters },
         "set video filters", "filter_graph" },
     { "intra_matrix",               OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
@@ -1753,7 +1753,7 @@  const OptionDef options[] = {
     { "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_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+    { "vtag",                       OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
         { .func_arg = opt_old2new },
         "force video tag/fourcc", "fourcc/tag" },
     { "fps_mode",                   OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT,
@@ -1762,13 +1762,13 @@  const OptionDef options[] = {
     { "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_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "streamid",                   OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_streamid },
         "set the value of an outfile streamid", "streamIndex:value" },
     { "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_TYPE_FUNC,   OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "b",                          OPT_TYPE_FUNC,   OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_bitrate },
         "video bitrate (please use -b:v)", "bitrate" },
     { "hwaccel",                    OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_SPEC | OPT_INPUT,
@@ -1796,10 +1796,10 @@  const OptionDef options[] = {
         "random access points" },
 
     /* audio options */
-    { "aframes",          OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+    { "aframes",          OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG  | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_audio_frames },
         "set the number of audio frames to output", "number" },
-    { "aq",               OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+    { "aq",               OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG  | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_audio_qscale },
         "set audio quality (codec-specific)", "quality", },
     { "ar",               OPT_TYPE_INT,     OPT_AUDIO | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
@@ -1811,13 +1811,13 @@  const OptionDef options[] = {
     { "an",               OPT_TYPE_BOOL,    OPT_AUDIO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
         { .off = OFFSET(audio_disable) },
         "disable audio" },
-    { "acodec",           OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+    { "acodec",           OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
         { .func_arg = opt_audio_codec },
         "force audio codec ('copy' to copy stream)", "codec" },
-    { "ab",               OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,
+    { "ab",               OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_bitrate },
         "audio bitrate (please use -b:a)", "bitrate" },
-    { "atag",             OPT_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "atag",             OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG  | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_old2new },
         "force audio tag/fourcc", "fourcc/tag" },
     { "sample_fmt",       OPT_TYPE_STRING,  OPT_AUDIO | OPT_EXPERT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT,
@@ -1829,7 +1829,7 @@  const OptionDef options[] = {
     { "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_TYPE_FUNC,    OPT_AUDIO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,
+    { "af",               OPT_TYPE_FUNC,    OPT_AUDIO | OPT_FUNC_ARG  | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_audio_filters },
         "set audio filters", "filter_graph" },
     { "guess_layout_max", OPT_TYPE_INT,     OPT_AUDIO | OPT_SPEC | OPT_EXPERT | OPT_INPUT,
@@ -1840,10 +1840,10 @@  const OptionDef options[] = {
     { "sn",     OPT_TYPE_BOOL, OPT_SUBTITLE | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
         { .off = OFFSET(subtitle_disable) },
         "disable subtitle" },
-    { "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | HAS_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
+    { "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG  | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
         { .func_arg = opt_subtitle_codec },
         "force subtitle codec ('copy' to copy stream)", "codec" },
-    { "stag",   OPT_TYPE_FUNC, OPT_SUBTITLE | HAS_ARG  | OPT_EXPERT  | OPT_PERFILE | OPT_OUTPUT,
+    { "stag",   OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG  | OPT_EXPERT  | OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_old2new }
         , "force subtitle tag/fourcc", "fourcc/tag" },
     { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT,
@@ -1860,7 +1860,7 @@  const OptionDef options[] = {
     { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
         { .off = OFFSET(mux_preload) },
         "set the initial demux-decode delay", "seconds" },
-    { "sdp_file",   OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_OUTPUT,
+    { "sdp_file",   OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
         { .func_arg = opt_sdp_file },
         "specify a file in which to print sdp information", "file" },
 
@@ -1877,23 +1877,23 @@  const OptionDef options[] = {
     { "bsf", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
         { .off = OFFSET(bitstream_filters) },
         "A comma-separated list of bitstream filters", "bitstream_filters" },
-    { "absf", OPT_TYPE_FUNC, HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "absf", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_old2new },
         "deprecated", "audio bitstream_filters" },
-    { "vbsf", OPT_TYPE_FUNC, OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "vbsf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_old2new },
         "deprecated", "video bitstream_filters" },
 
-    { "apre", OPT_TYPE_FUNC, HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "apre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_preset },
         "set the audio options to the indicated preset", "preset" },
-    { "vpre", OPT_TYPE_FUNC, OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "vpre", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_preset },
         "set the video options to the indicated preset", "preset" },
-    { "spre", OPT_TYPE_FUNC, HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "spre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_preset },
         "set the subtitle options to the indicated preset", "preset" },
-    { "fpre", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
+    { "fpre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT,
         { .func_arg = opt_preset },
         "set options from indicated preset file", "filename" },
 
@@ -1905,39 +1905,39 @@  const OptionDef options[] = {
         "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
 
     /* data codec support */
-    { "dcodec", OPT_TYPE_FUNC, HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
+    { "dcodec", OPT_TYPE_FUNC, OPT_FUNC_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_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
         { .off = OFFSET(data_disable) }, "disable data" },
 
 #if CONFIG_VAAPI
-    { "vaapi_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_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", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_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", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_init_hw_device },
         "initialise hardware device", "args" },
-    { "filter_hw_device", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_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", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
+    { "map_channel", OPT_TYPE_FUNC, OPT_FUNC_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", OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+    { "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_adrift_threshold },
         "deprecated, does nothing", "threshold" },
 #endif
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index e01b2c03de..ea5ff31393 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3617,8 +3617,8 @@  static int dummy;
 
 static const OptionDef options[] = {
     CMDUTILS_COMMON_OPTIONS
-    { "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" },
+    { "x",                  OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_width }, "force displayed width", "width" },
+    { "y",                  OPT_TYPE_FUNC, OPT_FUNC_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" },
@@ -3634,13 +3634,13 @@  static const OptionDef options[] = {
     { "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" },
+    { "f",                  OPT_TYPE_FUNC, OPT_FUNC_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" },
+    { "sync",               OPT_TYPE_FUNC, OPT_FUNC_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", "" },
@@ -3650,12 +3650,12 @@  static const OptionDef options[] = {
     { "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" },
+    { "vf",                 OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .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" },
+    { "showmode",           OPT_TYPE_FUNC, OPT_FUNC_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" },
+    { "codec",              OPT_TYPE_FUNC, OPT_FUNC_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" },
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 57e55e8a0b..f00ba48620 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4078,7 +4078,7 @@  DEFINE_OPT_SHOW_SECTION(programs,         PROGRAMS)
 
 static const OptionDef real_options[] = {
     CMDUTILS_COMMON_OPTIONS
-    { "f",                     OPT_TYPE_FUNC,  HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
+    { "f",                     OPT_TYPE_FUNC, OPT_FUNC_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},
@@ -4098,7 +4098,7 @@  static const OptionDef real_options[] = {
     { "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_entries",          OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_show_entries},
       "show a set of specified entries", "entry_list" },
 #if HAVE_THREADS
     { "show_log",              OPT_TYPE_INT,         0, { &do_show_log }, "show log" },
@@ -4113,14 +4113,14 @@  static const OptionDef real_options[] = {
     { "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_optional_fields",  OPT_TYPE_FUNC, OPT_FUNC_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"},
+    { "read_intervals",        OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
+    { "i",                     OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
+    { "o",                     OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
+    { "print_filename",        OPT_TYPE_FUNC, OPT_FUNC_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 08573eb7be..e82ada5581 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_TYPE_FUNC, OPT_EXIT | HAS_ARG, { .func_arg = show_sources },                                   \
+    { "sources"    , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG, { .func_arg = show_sources },                              \
       "list sources of the input device", "device" },                                                                   \
-    { "sinks"      , OPT_TYPE_FUNC, OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },                                     \
+    { "sinks"      , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG, { .func_arg = show_sinks },                                \
       "list sinks of the output device", "device" },                                                                    \
 
 #else
@@ -219,12 +219,12 @@  int opt_cpucount(void *optctx, const char *opt, const char *arg);
     { "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" },         \
+    { "loglevel",     OPT_TYPE_FUNC, OPT_FUNC_ARG,          { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
+    { "v",            OPT_TYPE_FUNC, OPT_FUNC_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" },     \
+    { "max_alloc",    OPT_TYPE_FUNC, OPT_FUNC_ARG,          { .func_arg = opt_max_alloc },    "set maximum size of a single allocated block", "bytes" }, \
+    { "cpuflags",     OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags },     "force specific cpu flags", "flags" },     \
+    { "cpucount",     OPT_TYPE_FUNC, OPT_FUNC_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                                                                                    \