mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-01 01:17:47 +00:00
cmdutils: remove OPT_FUNC2
Make ff* tools only accept opt_* functions taking two arguments. The distinction between functions with one and two arguments is quite pointless. Simplify parse_options() code.
This commit is contained in:
parent
78046dadc3
commit
eb8bc57240
6 changed files with 148 additions and 133 deletions
35
ffplay.c
35
ffplay.c
|
@ -2817,16 +2817,17 @@ static void event_loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void opt_frame_size(const char *arg)
|
||||
static int opt_frame_size(const char *opt, const char *arg)
|
||||
{
|
||||
if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
|
||||
fprintf(stderr, "Incorrect frame size\n");
|
||||
exit(1);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
|
||||
fprintf(stderr, "Frame size must be a multiple of 2\n");
|
||||
exit(1);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int opt_width(const char *opt, const char *arg)
|
||||
|
@ -2841,18 +2842,20 @@ static int opt_height(const char *opt, const char *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void opt_format(const char *arg)
|
||||
static int opt_format(const char *opt, const char *arg)
|
||||
{
|
||||
file_iformat = av_find_input_format(arg);
|
||||
if (!file_iformat) {
|
||||
fprintf(stderr, "Unknown input format: %s\n", arg);
|
||||
exit(1);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void opt_frame_pix_fmt(const char *arg)
|
||||
static int opt_frame_pix_fmt(const char *opt, const char *arg)
|
||||
{
|
||||
frame_pix_fmt = av_get_pix_fmt(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int opt_sync(const char *opt, const char *arg)
|
||||
|
@ -2915,8 +2918,8 @@ static int opt_show_mode(const char *opt, const char *arg)
|
|||
|
||||
static const OptionDef options[] = {
|
||||
#include "cmdutils_common_opts.h"
|
||||
{ "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
|
||||
{ "y", HAS_ARG | OPT_FUNC2, {(void*)opt_height}, "force displayed height", "height" },
|
||||
{ "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
|
||||
{ "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
|
||||
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
|
||||
{ "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
|
||||
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
|
||||
|
@ -2924,16 +2927,16 @@ static const OptionDef options[] = {
|
|||
{ "ast", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_AUDIO]}, "select desired audio stream", "stream_number" },
|
||||
{ "vst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_VIDEO]}, "select desired video stream", "stream_number" },
|
||||
{ "sst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_SUBTITLE]}, "select desired subtitle stream", "stream_number" },
|
||||
{ "ss", HAS_ARG | OPT_FUNC2, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
|
||||
{ "t", HAS_ARG | OPT_FUNC2, {(void*)&opt_duration}, "play \"duration\" seconds of audio/video", "duration" },
|
||||
{ "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
|
||||
{ "t", HAS_ARG, {(void*)&opt_duration}, "play \"duration\" seconds of audio/video", "duration" },
|
||||
{ "bytes", OPT_INT | HAS_ARG, {(void*)&seek_by_bytes}, "seek by bytes 0=off 1=on -1=auto", "val" },
|
||||
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
|
||||
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
|
||||
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
|
||||
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
|
||||
{ "debug", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
|
||||
{ "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
|
||||
{ "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
|
||||
{ "vismv", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
|
||||
{ "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
|
||||
{ "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
|
||||
{ "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
|
||||
{ "drp", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts 0=off 1=on -1=auto", ""},
|
||||
|
@ -2944,8 +2947,8 @@ static const OptionDef options[] = {
|
|||
{ "idct", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&idct}, "set idct algo", "algo" },
|
||||
{ "er", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_recognition}, "set error detection threshold (0-4)", "threshold" },
|
||||
{ "ec", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_concealment}, "set error concealment options", "bit_mask" },
|
||||
{ "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
|
||||
{ "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
|
||||
{ "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
|
||||
{ "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
|
||||
{ "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" },
|
||||
{ "exitonkeydown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_keydown}, "exit on key down", "" },
|
||||
{ "exitonmousedown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_mousedown}, "exit on mouse down", "" },
|
||||
|
@ -2956,8 +2959,8 @@ static const OptionDef options[] = {
|
|||
{ "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" },
|
||||
#endif
|
||||
{ "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
|
||||
{ "showmode", HAS_ARG | OPT_FUNC2, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
|
||||
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
|
||||
{ "showmode", HAS_ARG, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
|
||||
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
|
||||
{ "i", OPT_DUMMY, {NULL}, "ffmpeg compatibility dummy option", ""},
|
||||
{ NULL, },
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue