options: change option macros and all option declarations

Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with

   {"name", ...

followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.

I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.

Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.

Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.

In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
This commit is contained in:
wm4 2020-03-14 21:28:01 +01:00
parent cdd6eb0994
commit 26f4f18c06
78 changed files with 1608 additions and 1601 deletions

View File

@ -113,7 +113,7 @@ options/options.h, options/options.c
link them to the option parser. For example, an entry like this may be
typical:
OPT_SUBSTRUCT("", demux_opts, demux_conf, 0),
{"", OPT_SUBSTRUCT(demux_opts, demux_conf)},
This directs the option access code to include all options in demux_conf
into the global option list, with no prefix (""), and as part of the

View File

@ -63,10 +63,10 @@ struct ad_lavc_params {
const struct m_sub_options ad_lavc_conf = {
.opts = (const m_option_t[]) {
OPT_FLOATRANGE("ac3drc", ac3drc, 0, 0, 6),
OPT_FLAG("downmix", downmix, 0),
OPT_INTRANGE("threads", threads, 0, 0, 16),
OPT_KEYVALUELIST("o", avopts, 0),
{"ac3drc", OPT_FLOAT(ac3drc), M_RANGE(0, 6)},
{"downmix", OPT_FLAG(downmix)},
{"threads", OPT_INT(threads), M_RANGE(0, 16)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.size = sizeof(struct ad_lavc_params),

View File

@ -128,12 +128,12 @@ const struct mp_user_filter_entry af_format = {
.description = "Force audio format",
.priv_size = sizeof(struct f_opts),
.options = (const struct m_option[]) {
OPT_AUDIOFORMAT("format", in_format, 0),
OPT_INTRANGE("srate", in_srate, 0, 1000, 8*48000),
OPT_CHANNELS("channels", in_channels, 0, .min = 1),
OPT_INTRANGE("out-srate", out_srate, 0, 1000, 8*48000),
OPT_CHANNELS("out-channels", out_channels, 0, .min = 1),
OPT_FLAG("fail", fail, 0),
{"format", OPT_AUDIOFORMAT(in_format)},
{"srate", OPT_INT(in_srate), M_RANGE(1000, 8*48000)},
{"channels", OPT_CHANNELS(in_channels), .min = 1},
{"out-srate", OPT_INT(out_srate), M_RANGE(1000, 8*48000)},
{"out-channels", OPT_CHANNELS(out_channels), .min = 1},
{"fail", OPT_FLAG(fail)},
{0}
},
},

View File

@ -375,12 +375,12 @@ const struct mp_user_filter_entry af_lavcac3enc = {
.encoder = "ac3",
},
.options = (const struct m_option[]) {
OPT_FLAG("tospdif", add_iec61937_header, 0),
OPT_CHOICE_OR_INT("bitrate", bit_rate, 0, 32, 640,
({"auto", 0}, {"default", 0})),
OPT_INTRANGE("minch", min_channel_num, 0, 2, 6),
OPT_STRING("encoder", encoder, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{"tospdif", OPT_FLAG(add_iec61937_header)},
{"bitrate", OPT_CHOICE(bit_rate,
{"auto", 0}, {"default", 0}), M_RANGE(32, 640)},
{"minch", OPT_INT(min_channel_num), M_RANGE(2, 6)},
{"encoder", OPT_STRING(encoder)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
},

View File

@ -333,35 +333,35 @@ const struct mp_user_filter_entry af_rubberband = {
.channels = RubberBandOptionChannelsTogether,
},
.options = (const struct m_option[]) {
OPT_CHOICE("transients", transients, 0,
({"crisp", RubberBandOptionTransientsCrisp},
{"mixed", RubberBandOptionTransientsMixed},
{"smooth", RubberBandOptionTransientsSmooth})),
OPT_CHOICE("detector", detector, 0,
({"compound", RubberBandOptionDetectorCompound},
{"percussive", RubberBandOptionDetectorPercussive},
{"soft", RubberBandOptionDetectorSoft})),
OPT_CHOICE("phase", phase, 0,
({"laminar", RubberBandOptionPhaseLaminar},
{"independent", RubberBandOptionPhaseIndependent})),
OPT_CHOICE("window", window, 0,
({"standard", RubberBandOptionWindowStandard},
{"short", RubberBandOptionWindowShort},
{"long", RubberBandOptionWindowLong})),
OPT_CHOICE("smoothing", smoothing, 0,
({"off", RubberBandOptionSmoothingOff},
{"on", RubberBandOptionSmoothingOn})),
OPT_CHOICE("formant", formant, 0,
({"shifted", RubberBandOptionFormantShifted},
{"preserved", RubberBandOptionFormantPreserved})),
OPT_CHOICE("pitch", pitch, 0,
({"quality", RubberBandOptionPitchHighQuality},
{"speed", RubberBandOptionPitchHighSpeed},
{"consistency", RubberBandOptionPitchHighConsistency})),
OPT_CHOICE("channels", channels, 0,
({"apart", RubberBandOptionChannelsApart},
{"together", RubberBandOptionChannelsTogether})),
OPT_DOUBLE("pitch-scale", scale, 0, .min = 0.01, .max = 100),
{"transients", OPT_CHOICE(transients,
{"crisp", RubberBandOptionTransientsCrisp},
{"mixed", RubberBandOptionTransientsMixed},
{"smooth", RubberBandOptionTransientsSmooth})},
{"detector", OPT_CHOICE(detector,
{"compound", RubberBandOptionDetectorCompound},
{"percussive", RubberBandOptionDetectorPercussive},
{"soft", RubberBandOptionDetectorSoft})},
{"phase", OPT_CHOICE(phase,
{"laminar", RubberBandOptionPhaseLaminar},
{"independent", RubberBandOptionPhaseIndependent})},
{"window", OPT_CHOICE(window,
{"standard", RubberBandOptionWindowStandard},
{"short", RubberBandOptionWindowShort},
{"long", RubberBandOptionWindowLong})},
{"smoothing", OPT_CHOICE(smoothing,
{"off", RubberBandOptionSmoothingOff},
{"on", RubberBandOptionSmoothingOn})},
{"formant", OPT_CHOICE(formant,
{"shifted", RubberBandOptionFormantShifted},
{"preserved", RubberBandOptionFormantPreserved})},
{"pitch", OPT_CHOICE(pitch,
{"quality", RubberBandOptionPitchHighQuality},
{"speed", RubberBandOptionPitchHighSpeed},
{"consistency", RubberBandOptionPitchHighConsistency})},
{"channels", OPT_CHOICE(channels,
{"apart", RubberBandOptionChannelsApart},
{"together", RubberBandOptionChannelsTogether})},
{"pitch-scale", OPT_DOUBLE(scale), M_RANGE(0.01, 100)},
{0}
},
},

View File

@ -609,15 +609,15 @@ const struct mp_user_filter_entry af_scaletempo = {
.scale_nominal = 1.0,
},
.options = (const struct m_option[]) {
OPT_FLOAT("scale", scale_nominal, 0, .min = 0.01, .max = DBL_MAX),
OPT_FLOAT("stride", ms_stride, 0, .min = 0.01, .max = DBL_MAX),
OPT_FLOAT("overlap", percent_overlap, 0, .min = 0, .max = 1),
OPT_FLOAT("search", ms_search, 0, .min = 0, .max = DBL_MAX),
OPT_CHOICE("speed", speed_opt, 0,
({"pitch", SCALE_PITCH},
{"tempo", SCALE_TEMPO},
{"none", 0},
{"both", SCALE_TEMPO | SCALE_PITCH})),
{"scale", OPT_FLOAT(scale_nominal), M_RANGE(0.01, DBL_MAX)},
{"stride", OPT_FLOAT(ms_stride), M_RANGE(0.01, DBL_MAX)},
{"overlap", OPT_FLOAT(percent_overlap), M_RANGE(0, 1)},
{"search", OPT_FLOAT(ms_search), M_RANGE(0, DBL_MAX)},
{"speed", OPT_CHOICE(speed_opt,
{"pitch", SCALE_PITCH},
{"tempo", SCALE_TEMPO},
{"none", 0},
{"both", SCALE_TEMPO | SCALE_PITCH})},
{0}
},
},

View File

@ -136,11 +136,12 @@ static const struct m_obj_list ao_obj_list = {
#define OPT_BASE_STRUCT struct ao_opts
const struct m_sub_options ao_conf = {
.opts = (const struct m_option[]) {
OPT_SETTINGSLIST("ao", audio_driver_list, UPDATE_AUDIO, &ao_obj_list, ),
OPT_STRING("audio-device", audio_device, UPDATE_AUDIO),
OPT_STRING("audio-client-name", audio_client_name, UPDATE_AUDIO),
OPT_DOUBLE("audio-buffer", audio_buffer,
UPDATE_AUDIO, .min = 0, .max = 10),
{"ao", OPT_SETTINGSLIST(audio_driver_list, &ao_obj_list),
.flags = UPDATE_AUDIO},
{"audio-device", OPT_STRING(audio_device), .flags = UPDATE_AUDIO},
{"audio-client-name", OPT_STRING(audio_client_name), .flags = UPDATE_AUDIO},
{"audio-buffer", OPT_DOUBLE(audio_buffer),
.flags = UPDATE_AUDIO, M_RANGE(0, 10)},
{0}
},
.size = sizeof(OPT_BASE_STRUCT),

View File

@ -67,14 +67,14 @@ struct ao_alsa_opts {
#define OPT_BASE_STRUCT struct ao_alsa_opts
static const struct m_sub_options ao_alsa_conf = {
.opts = (const struct m_option[]) {
OPT_FLAG("alsa-resample", resample, 0),
OPT_STRING("alsa-mixer-device", mixer_device, 0),
OPT_STRING("alsa-mixer-name", mixer_name, 0),
OPT_INTRANGE("alsa-mixer-index", mixer_index, 0, 0, 99),
OPT_FLAG("alsa-non-interleaved", ni, 0),
OPT_FLAG("alsa-ignore-chmap", ignore_chmap, 0),
OPT_INTRANGE("alsa-buffer-time", buffer_time, 0, 0, INT_MAX),
OPT_INTRANGE("alsa-periods", frags, 0, 0, INT_MAX),
{"alsa-resample", OPT_FLAG(resample)},
{"alsa-mixer-device", OPT_STRING(mixer_device)},
{"alsa-mixer-name", OPT_STRING(mixer_name)},
{"alsa-mixer-index", OPT_INT(mixer_index), M_RANGE(0, 99)},
{"alsa-non-interleaved", OPT_FLAG(ni)},
{"alsa-ignore-chmap", OPT_FLAG(ignore_chmap)},
{"alsa-buffer-time", OPT_INT(buffer_time), M_RANGE(0, INT_MAX)},
{"alsa-periods", OPT_INT(frags), M_RANGE(0, INT_MAX)},
{0}
},
.defaults = &(const struct ao_alsa_opts) {

View File

@ -709,8 +709,8 @@ const struct ao_driver audio_out_audiotrack = {
.resume = start,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
OPT_FLAG("pcm-float", cfg_pcm_float, 0),
OPT_INT("session-id", cfg_session_id, 0),
{"pcm-float", OPT_FLAG(cfg_pcm_float)},
{"session-id", OPT_INT(cfg_session_id)},
{0}
},
.options_prefix = "audiotrack",

View File

@ -423,7 +423,7 @@ const struct ao_driver audio_out_coreaudio = {
.list_devs = ca_get_device_list,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]){
OPT_FLAG("change-physical-format", change_physical_format, 0),
{"change-physical-format", OPT_FLAG(change_physical_format)},
{0}
},
.options_prefix = "coreaudio",

View File

@ -465,7 +465,7 @@ const struct ao_driver audio_out_coreaudio_exclusive = {
.changed_mixing = false,
},
.options = (const struct m_option[]){
OPT_FLAG("spdif-hack", spdif_hack, 0),
{"spdif-hack", OPT_FLAG(spdif_hack)},
{0}
},
.options_prefix = "coreaudio",

View File

@ -55,12 +55,12 @@ struct jack_opts {
#define OPT_BASE_STRUCT struct jack_opts
static const struct m_sub_options ao_jack_conf = {
.opts = (const struct m_option[]){
OPT_STRING("jack-port", port, 0),
OPT_STRING("jack-name", client_name, 0),
OPT_FLAG("jack-autostart", autostart, 0),
OPT_FLAG("jack-connect", connect, 0),
OPT_CHOICE("jack-std-channel-layout", stdlayout, 0,
({"waveext", 0}, {"any", 1})),
{"jack-port", OPT_STRING(port)},
{"jack-name", OPT_STRING(client_name)},
{"jack-autostart", OPT_FLAG(autostart)},
{"jack-connect", OPT_FLAG(connect)},
{"jack-std-channel-layout", OPT_CHOICE(stdlayout,
{"waveext", 0}, {"any", 1})},
{0}
},
.defaults = &(const struct jack_opts) {

View File

@ -237,15 +237,15 @@ const struct ao_driver audio_out_null = {
.speed = 1,
},
.options = (const struct m_option[]) {
OPT_FLAG("untimed", untimed, 0),
OPT_FLOATRANGE("buffer", bufferlen, 0, 0, 100),
OPT_INTRANGE("outburst", outburst, 0, 1, 100000),
OPT_FLOATRANGE("speed", speed, 0, 0, 10000),
OPT_FLOATRANGE("latency", latency_sec, 0, 0, 100),
OPT_FLAG("broken-eof", broken_eof, 0),
OPT_FLAG("broken-delay", broken_delay, 0),
OPT_CHANNELS("channel-layouts", channel_layouts, 0),
OPT_AUDIOFORMAT("format", format, 0),
{"untimed", OPT_FLAG(untimed)},
{"buffer", OPT_FLOAT(bufferlen), M_RANGE(0, 100)},
{"outburst", OPT_INT(outburst), M_RANGE(1, 100000)},
{"speed", OPT_FLOAT(speed), M_RANGE(0, 10000)},
{"latency", OPT_FLOAT(latency_sec), M_RANGE(0, 100)},
{"broken-eof", OPT_FLAG(broken_eof)},
{"broken-delay", OPT_FLAG(broken_delay)},
{"channel-layouts", OPT_CHANNELS(channel_layouts)},
{"format", OPT_AUDIOFORMAT(format)},
{0}
},
.options_prefix = "ao-null",

View File

@ -428,9 +428,9 @@ const struct ao_driver audio_out_openal = {
.direct_channels = 0,
},
.options = (const struct m_option[]) {
OPT_INTRANGE("num-buffers", num_buffers, 0, 2, MAX_BUF),
OPT_INTRANGE("num-samples", num_samples, 0, 256, MAX_SAMPLES),
OPT_FLAG("direct-channels", direct_channels, 0),
{"num-buffers", OPT_INT(num_buffers), M_RANGE(2, MAX_BUF)},
{"num-samples", OPT_INT(num_samples), M_RANGE(256, MAX_SAMPLES)},
{"direct-channels", OPT_FLAG(direct_channels)},
{0}
},
.options_prefix = "openal",

View File

@ -254,8 +254,10 @@ const struct ao_driver audio_out_opensles = {
.buffer_size_in_ms = 250,
},
.options = (const struct m_option[]) {
OPT_INTRANGE("frames-per-enqueue", frames_per_enqueue, 0, 1, 96000),
OPT_INTRANGE("buffer-size-in-ms", buffer_size_in_ms, 0, 0, 500),
{"frames-per-enqueue", OPT_INT(frames_per_enqueue),
M_RANGE(1, 96000)},
{"buffer-size-in-ms", OPT_INT(buffer_size_in_ms),
M_RANGE(0, 500)},
{0}
},
.options_prefix = "opensles",

View File

@ -649,8 +649,8 @@ const struct ao_driver audio_out_oss = {
.oss_mixer_device = PATH_DEV_MIXER,
},
.options = (const struct m_option[]) {
OPT_STRING("mixer-device", oss_mixer_device, M_OPT_FILE),
OPT_STRING("mixer-channel", cfg_oss_mixer_channel, 0),
{"mixer-device", OPT_STRING(oss_mixer_device), .flags = M_OPT_FILE},
{"mixer-channel", OPT_STRING(cfg_oss_mixer_channel)},
{0}
},
.options_prefix = "oss",

View File

@ -221,9 +221,9 @@ const struct ao_driver audio_out_pcm = {
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) { .waveheader = 1 },
.options = (const struct m_option[]) {
OPT_STRING("file", outputfilename, M_OPT_FILE),
OPT_FLAG("waveheader", waveheader, 0),
OPT_FLAG("append", append, 0),
{"file", OPT_STRING(outputfilename), .flags = M_OPT_FILE},
{"waveheader", OPT_FLAG(waveheader)},
{"append", OPT_FLAG(append)},
{0}
},
.options_prefix = "ao-pcm",

View File

@ -837,10 +837,11 @@ const struct ao_driver audio_out_pulse = {
.cfg_buffer = 100,
},
.options = (const struct m_option[]) {
OPT_STRING("host", cfg_host, 0),
OPT_CHOICE_OR_INT("buffer", cfg_buffer, 0, 1, 2000, ({"native", 0})),
OPT_FLAG("latency-hacks", cfg_latency_hacks, 0),
OPT_FLAG("allow-suspended", cfg_allow_suspended, 0),
{"host", OPT_STRING(cfg_host)},
{"buffer", OPT_CHOICE(cfg_buffer, {"native", 0}),
M_RANGE(1, 2000)},
{"latency-hacks", OPT_FLAG(cfg_latency_hacks)},
{"allow-suspended", OPT_FLAG(cfg_allow_suspended)},
{0}
},
.options_prefix = "pulse",

View File

@ -210,7 +210,7 @@ const struct ao_driver audio_out_sdl = {
.buflen = 0, // use SDL default
},
.options = (const struct m_option[]) {
OPT_FLOAT("buflen", buflen, 0),
{"buflen", OPT_FLOAT(buflen)},
{0}
},
.options_prefix = "sdl",

View File

@ -77,32 +77,32 @@ struct mux_stream {
#define OPT_BASE_STRUCT struct encode_opts
const struct m_sub_options encode_config = {
.opts = (const m_option_t[]) {
OPT_STRING("o", file, CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE),
OPT_STRING("of", format, 0),
OPT_KEYVALUELIST("ofopts", fopts, M_OPT_HAVE_HELP),
OPT_STRING("ovc", vcodec, 0),
OPT_KEYVALUELIST("ovcopts", vopts, M_OPT_HAVE_HELP),
OPT_STRING("oac", acodec, 0),
OPT_KEYVALUELIST("oacopts", aopts, M_OPT_HAVE_HELP),
OPT_FLOATRANGE("ovoffset", voffset, 0, -1000000.0, 1000000.0,
.deprecation_message = "--audio-delay (once unbroken)"),
OPT_FLOATRANGE("oaoffset", aoffset, 0, -1000000.0, 1000000.0,
.deprecation_message = "--audio-delay (once unbroken)"),
OPT_FLAG("orawts", rawts, 0),
OPT_FLAG("ovfirst", video_first, 0,
.deprecation_message = "no replacement"),
OPT_FLAG("oafirst", audio_first, 0,
.deprecation_message = "no replacement"),
OPT_FLAG("ocopy-metadata", copy_metadata, 0),
OPT_KEYVALUELIST("oset-metadata", set_metadata, 0),
OPT_STRINGLIST("oremove-metadata", remove_metadata, 0),
{"o", OPT_STRING(file), .flags = CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE},
{"of", OPT_STRING(format)},
{"ofopts", OPT_KEYVALUELIST(fopts), .flags = M_OPT_HAVE_HELP},
{"ovc", OPT_STRING(vcodec)},
{"ovcopts", OPT_KEYVALUELIST(vopts), .flags = M_OPT_HAVE_HELP},
{"oac", OPT_STRING(acodec)},
{"oacopts", OPT_KEYVALUELIST(aopts), .flags = M_OPT_HAVE_HELP},
{"ovoffset", OPT_FLOAT(voffset), M_RANGE(-1000000.0, 1000000.0),
.deprecation_message = "--audio-delay (once unbroken)"},
{"oaoffset", OPT_FLOAT(aoffset), M_RANGE(-1000000.0, 1000000.0),
.deprecation_message = "--audio-delay (once unbroken)"},
{"orawts", OPT_FLAG(rawts)},
{"ovfirst", OPT_FLAG(video_first),
.deprecation_message = "no replacement"},
{"oafirst", OPT_FLAG(audio_first),
.deprecation_message = "no replacement"},
{"ocopy-metadata", OPT_FLAG(copy_metadata)},
{"oset-metadata", OPT_KEYVALUELIST(set_metadata)},
{"oremove-metadata", OPT_STRINGLIST(remove_metadata)},
OPT_REMOVED("ocopyts", "ocopyts is now the default"),
OPT_REMOVED("oneverdrop", "no replacement"),
OPT_REMOVED("oharddup", "use --vf-add=fps=VALUE"),
OPT_REMOVED("ofps", "no replacement (use --vf-add=fps=VALUE for CFR)"),
OPT_REMOVED("oautofps", "no replacement"),
OPT_REMOVED("omaxfps", "no replacement"),
{"ocopyts", OPT_REMOVED("ocopyts is now the default")},
{"oneverdrop", OPT_REMOVED("no replacement")},
{"oharddup", OPT_REMOVED("use --vf-add=fps=VALUE")},
{"ofps", OPT_REMOVED("no replacement (use --vf-add=fps=VALUE for CFR)")},
{"oautofps", OPT_REMOVED("no replacement")},
{"omaxfps", OPT_REMOVED("no replacement")},
{0}
},
.size = sizeof(struct encode_opts),

View File

@ -40,9 +40,10 @@ struct demux_cache_opts {
const struct m_sub_options demux_cache_conf = {
.opts = (const struct m_option[]){
OPT_STRING("cache-dir", cache_dir, M_OPT_FILE),
OPT_CHOICE("cache-unlink-files", unlink_files, 0,
({"immediate", 2}, {"whendone", 1}, {"no", 0})),
{"cache-dir", OPT_STRING(cache_dir), .flags = M_OPT_FILE},
{"cache-unlink-files", OPT_CHOICE(unlink_files,
{"immediate", 2}, {"whendone", 1}, {"no", 0}),
},
{0}
},
.size = sizeof(struct demux_cache_opts),

View File

@ -112,35 +112,38 @@ static bool get_demux_sub_opts(int index, const struct m_sub_options **sub);
const struct m_sub_options demux_conf = {
.opts = (const struct m_option[]){
OPT_CHOICE("cache", enable_cache, 0,
({"no", 0}, {"auto", -1}, {"yes", 1})),
OPT_FLAG("cache-on-disk", disk_cache, 0),
OPT_DOUBLE("demuxer-readahead-secs", min_secs, 0,
.min = 0, .max = DBL_MAX),
{"cache", OPT_CHOICE(enable_cache,
{"no", 0}, {"auto", -1}, {"yes", 1})},
{"cache-on-disk", OPT_FLAG(disk_cache)},
{"demuxer-readahead-secs", OPT_DOUBLE(min_secs), M_RANGE(0, DBL_MAX)},
// (The MAX_BYTES sizes may not be accurate because the max field is
// of double type.)
OPT_BYTE_SIZE("demuxer-max-bytes", max_bytes, 0, 0, MAX_BYTES),
OPT_BYTE_SIZE("demuxer-max-back-bytes", max_bytes_bw, 0, 0, MAX_BYTES),
OPT_FLAG("demuxer-donate-buffer", donate_fw, 0),
OPT_FLAG("force-seekable", force_seekable, 0),
OPT_DOUBLE("cache-secs", min_secs_cache, 0, .min = 0, .max = DBL_MAX,
.deprecation_message = "will use unlimited time"),
OPT_FLAG("access-references", access_references, 0),
OPT_CHOICE("demuxer-seekable-cache", seekable_cache, 0,
({"auto", -1}, {"no", 0}, {"yes", 1})),
OPT_FLAG("sub-create-cc-track", create_ccs, 0),
OPT_STRING("stream-record", record_file, 0),
OPT_CHOICE_OR_INT("video-backward-overlap", video_back_preroll, 0, 0,
1024, ({"auto", -1})),
OPT_CHOICE_OR_INT("audio-backward-overlap", audio_back_preroll, 0, 0,
1024, ({"auto", -1})),
OPT_INTRANGE("video-backward-batch", back_batch[STREAM_VIDEO], 0, 0, 1024),
OPT_INTRANGE("audio-backward-batch", back_batch[STREAM_AUDIO], 0, 0, 1024),
OPT_DOUBLE("demuxer-backward-playback-step", back_seek_size, 0,
.min = 0, .max = DBL_MAX),
OPT_STRING("metadata-codepage", meta_cp, 0),
OPT_FLAG("demuxer-force-retry-on-eof", force_retry_eof, 0,
.deprecation_message = "temporary debug option, no replacement"),
{"demuxer-max-bytes", OPT_BYTE_SIZE(max_bytes),
M_RANGE(0, MAX_BYTES)},
{"demuxer-max-back-bytes", OPT_BYTE_SIZE(max_bytes_bw),
M_RANGE(0, MAX_BYTES)},
{"demuxer-donate-buffer", OPT_FLAG(donate_fw)},
{"force-seekable", OPT_FLAG(force_seekable)},
{"cache-secs", OPT_DOUBLE(min_secs_cache), M_RANGE(0, DBL_MAX),
.deprecation_message = "will use unlimited time"},
{"access-references", OPT_FLAG(access_references)},
{"demuxer-seekable-cache", OPT_CHOICE(seekable_cache,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"sub-create-cc-track", OPT_FLAG(create_ccs)},
{"stream-record", OPT_STRING(record_file)},
{"video-backward-overlap", OPT_CHOICE(video_back_preroll, {"auto", -1}),
M_RANGE(0, 1024)},
{"audio-backward-overlap", OPT_CHOICE(audio_back_preroll, {"auto", -1}),
M_RANGE(0, 1024)},
{"video-backward-batch", OPT_INT(back_batch[STREAM_VIDEO]),
M_RANGE(0, 1024)},
{"audio-backward-batch", OPT_INT(back_batch[STREAM_AUDIO]),
M_RANGE(0, 1024)},
{"demuxer-backward-playback-step", OPT_DOUBLE(back_seek_size),
M_RANGE(0, DBL_MAX)},
{"metadata-codepage", OPT_STRING(meta_cp)},
{"demuxer-force-retry-on-eof", OPT_FLAG(force_retry_eof),
.deprecation_message = "temporary debug option, no replacement"},
{0}
},
.size = sizeof(struct demux_opts),

View File

@ -49,7 +49,7 @@ struct demux_cue_opts {
const struct m_sub_options demux_cue_conf = {
.opts = (const m_option_t[]) {
OPT_STRING("codepage", cue_cp, 0),
{"codepage", OPT_STRING(cue_cp)},
{0}
},
.size = sizeof(struct demux_cue_opts),

View File

@ -84,30 +84,29 @@ struct demux_lavf_opts {
const struct m_sub_options demux_lavf_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("demuxer-lavf-probesize", probesize, 0, 32, INT_MAX),
OPT_CHOICE("demuxer-lavf-probe-info", probeinfo, 0,
({"no", 0}, {"yes", 1}, {"auto", -1}, {"nostreams", -2})),
OPT_STRING("demuxer-lavf-format", format, 0),
OPT_FLOATRANGE("demuxer-lavf-analyzeduration", analyzeduration, 0,
0, 3600),
OPT_INTRANGE("demuxer-lavf-buffersize", buffersize, 0, 1,
10 * 1024 * 1024, OPTDEF_INT(BIO_BUFFER_SIZE)),
OPT_FLAG("demuxer-lavf-allow-mimetype", allow_mimetype, 0),
OPT_INTRANGE("demuxer-lavf-probescore", probescore, 0,
1, AVPROBE_SCORE_MAX),
OPT_FLAG("demuxer-lavf-hacks", hacks, 0),
OPT_KEYVALUELIST("demuxer-lavf-o", avopts, 0),
OPT_STRING("sub-codepage", sub_cp, 0),
OPT_CHOICE("rtsp-transport", rtsp_transport, 0,
({"lavf", 0},
{"udp", 1},
{"tcp", 2},
{"http", 3},
{"udp_multicast", 4}
)),
OPT_CHOICE("demuxer-lavf-linearize-timestamps", linearize_ts, 0,
({"no", 0}, {"auto", -1}, {"yes", 1})),
OPT_FLAG("demuxer-lavf-propagate-opts", propagate_opts, 0),
{"demuxer-lavf-probesize", OPT_INT(probesize), M_RANGE(32, INT_MAX)},
{"demuxer-lavf-probe-info", OPT_CHOICE(probeinfo,
{"no", 0}, {"yes", 1}, {"auto", -1}, {"nostreams", -2})},
{"demuxer-lavf-format", OPT_STRING(format)},
{"demuxer-lavf-analyzeduration", OPT_FLOAT(analyzeduration),
M_RANGE(0, 3600)},
{"demuxer-lavf-buffersize", OPT_INT(buffersize),
M_RANGE(1, 10 * 1024 * 1024), OPTDEF_INT(BIO_BUFFER_SIZE)},
{"demuxer-lavf-allow-mimetype", OPT_FLAG(allow_mimetype)},
{"demuxer-lavf-probescore", OPT_INT(probescore),
M_RANGE(1, AVPROBE_SCORE_MAX)},
{"demuxer-lavf-hacks", OPT_FLAG(hacks)},
{"demuxer-lavf-o", OPT_KEYVALUELIST(avopts)},
{"sub-codepage", OPT_STRING(sub_cp)},
{"rtsp-transport", OPT_CHOICE(rtsp_transport,
{"lavf", 0},
{"udp", 1},
{"tcp", 2},
{"http", 3},
{"udp_multicast", 4})},
{"demuxer-lavf-linearize-timestamps", OPT_CHOICE(linearize_ts,
{"no", 0}, {"auto", -1}, {"yes", 1})},
{"demuxer-lavf-propagate-opts", OPT_FLAG(propagate_opts)},
{0}
},
.size = sizeof(struct demux_lavf_opts),

View File

@ -112,7 +112,7 @@ const struct demuxer_desc demuxer_desc_libarchive = {
.open = open_file,
.options = &(const struct m_sub_options){
.opts = (const struct m_option[]) {
OPT_FLAG("rar-list-all-volumes", rar_list_all_volumes, 0),
{"rar-list-all-volumes", OPT_FLAG(rar_list_all_volumes)},
{0}
},
.size = sizeof(OPT_BASE_STRUCT),

View File

@ -229,15 +229,15 @@ struct demux_mkv_opts {
const struct m_sub_options demux_mkv_conf = {
.opts = (const m_option_t[]) {
OPT_CHOICE("subtitle-preroll", subtitle_preroll, 0,
({"no", 0}, {"yes", 1}, {"index", 2})),
OPT_DOUBLE("subtitle-preroll-secs", subtitle_preroll_secs, 0,
.min = 0, .max = DBL_MAX),
OPT_DOUBLE("subtitle-preroll-secs-index", subtitle_preroll_secs_index, 0,
.min = 0, .max = DBL_MAX),
OPT_CHOICE("probe-video-duration", probe_duration, 0,
({"no", 0}, {"yes", 1}, {"full", 2})),
OPT_FLAG("probe-start-time", probe_start_time, 0),
{"subtitle-preroll", OPT_CHOICE(subtitle_preroll,
{"no", 0}, {"yes", 1}, {"index", 2})},
{"subtitle-preroll-secs", OPT_DOUBLE(subtitle_preroll_secs),
M_RANGE(0, DBL_MAX)},
{"subtitle-preroll-secs-index", OPT_DOUBLE(subtitle_preroll_secs_index),
M_RANGE(0, DBL_MAX)},
{"probe-video-duration", OPT_CHOICE(probe_duration,
{"no", 0}, {"yes", 1}, {"full", 2})},
{"probe-start-time", OPT_FLAG(probe_start_time)},
{0}
},
.size = sizeof(struct demux_mkv_opts),

View File

@ -54,27 +54,27 @@ struct demux_rawaudio_opts {
#define OPT_BASE_STRUCT struct demux_rawaudio_opts
const struct m_sub_options demux_rawaudio_conf = {
.opts = (const m_option_t[]) {
OPT_CHANNELS("channels", channels, 0, .min = 1),
OPT_INTRANGE("rate", samplerate, 0, 1000, 8 * 48000),
OPT_CHOICE("format", aformat, 0,
({"u8", PCM(0, 0, 8, 0)},
{"s8", PCM(1, 0, 8, 0)},
{"u16le", PCM(0, 0, 16, 0)}, {"u16be", PCM(0, 0, 16, 1)},
{"s16le", PCM(1, 0, 16, 0)}, {"s16be", PCM(1, 0, 16, 1)},
{"u24le", PCM(0, 0, 24, 0)}, {"u24be", PCM(0, 0, 24, 1)},
{"s24le", PCM(1, 0, 24, 0)}, {"s24be", PCM(1, 0, 24, 1)},
{"u32le", PCM(0, 0, 32, 0)}, {"u32be", PCM(0, 0, 32, 1)},
{"s32le", PCM(1, 0, 32, 0)}, {"s32be", PCM(1, 0, 32, 1)},
{"floatle", PCM(0, 1, 32, 0)}, {"floatbe", PCM(0, 1, 32, 1)},
{"doublele",PCM(0, 1, 64, 0)}, {"doublebe", PCM(0, 1, 64, 1)},
{"u16", PCM(0, 0, 16, NE)},
{"s16", PCM(1, 0, 16, NE)},
{"u24", PCM(0, 0, 24, NE)},
{"s24", PCM(1, 0, 24, NE)},
{"u32", PCM(0, 0, 32, NE)},
{"s32", PCM(1, 0, 32, NE)},
{"float", PCM(0, 1, 32, NE)},
{"double", PCM(0, 1, 64, NE)})),
{"channels", OPT_CHANNELS(channels), .min = 1},
{"rate", OPT_INT(samplerate), M_RANGE(1000, 8 * 48000)},
{"format", OPT_CHOICE(aformat,
{"u8", PCM(0, 0, 8, 0)},
{"s8", PCM(1, 0, 8, 0)},
{"u16le", PCM(0, 0, 16, 0)}, {"u16be", PCM(0, 0, 16, 1)},
{"s16le", PCM(1, 0, 16, 0)}, {"s16be", PCM(1, 0, 16, 1)},
{"u24le", PCM(0, 0, 24, 0)}, {"u24be", PCM(0, 0, 24, 1)},
{"s24le", PCM(1, 0, 24, 0)}, {"s24be", PCM(1, 0, 24, 1)},
{"u32le", PCM(0, 0, 32, 0)}, {"u32be", PCM(0, 0, 32, 1)},
{"s32le", PCM(1, 0, 32, 0)}, {"s32be", PCM(1, 0, 32, 1)},
{"floatle", PCM(0, 1, 32, 0)}, {"floatbe", PCM(0, 1, 32, 1)},
{"doublele",PCM(0, 1, 64, 0)}, {"doublebe", PCM(0, 1, 64, 1)},
{"u16", PCM(0, 0, 16, NE)},
{"s16", PCM(1, 0, 16, NE)},
{"u24", PCM(0, 0, 24, NE)},
{"s24", PCM(1, 0, 24, NE)},
{"u32", PCM(0, 0, 32, NE)},
{"s32", PCM(1, 0, 32, NE)},
{"float", PCM(0, 1, 32, NE)},
{"double", PCM(0, 1, 64, NE)})},
{0}
},
.size = sizeof(struct demux_rawaudio_opts),
@ -107,13 +107,13 @@ struct demux_rawvideo_opts {
#define OPT_BASE_STRUCT struct demux_rawvideo_opts
const struct m_sub_options demux_rawvideo_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("w", width, 0, 1, 8192),
OPT_INTRANGE("h", height, 0, 1, 8192),
OPT_GENERAL(int, "format", vformat, 0, .type = &m_option_type_fourcc),
OPT_IMAGEFORMAT("mp-format", mp_format, 0),
OPT_STRING("codec", codec, 0),
OPT_FLOATRANGE("fps", fps, 0, 0.001, 1000),
OPT_INTRANGE("size", imgsize, 0, 1, 8192 * 8192 * 4),
{"w", OPT_INT(width), M_RANGE(1, 8192)},
{"h", OPT_INT(height), M_RANGE(1, 8192)},
{"format", OPT_FOURCC(vformat)},
{"mp-format", OPT_IMAGEFORMAT(mp_format)},
{"codec", OPT_STRING(codec)},
{"fps", OPT_FLOAT(fps), M_RANGE(0.001, 1000)},
{"size", OPT_INT(imgsize), M_RANGE(1, 8192 * 8192 * 4)},
{0}
},
.size = sizeof(struct demux_rawvideo_opts),

View File

@ -63,10 +63,10 @@ struct dec_queue_opts {
#define OPT_BASE_STRUCT struct dec_queue_opts
static const struct m_option dec_queue_opts_list[] = {
OPT_FLAG("enable", use_queue, 0),
OPT_DOUBLE("max-secs", max_duration, 0, .min = 0, .max = DBL_MAX),
OPT_BYTE_SIZE("max-bytes", max_bytes, 0, 0, (size_t)-1),
OPT_INT64("max-samples", max_samples, 0, .min = 0, .max = DBL_MAX),
{"enable", OPT_FLAG(use_queue)},
{"max-secs", OPT_DOUBLE(max_duration), M_RANGE(0, DBL_MAX)},
{"max-bytes", OPT_BYTE_SIZE(max_bytes), M_RANGE(0, (size_t)-1)},
{"max-samples", OPT_INT64(max_samples), M_RANGE(0, DBL_MAX)},
{0}
};
@ -115,21 +115,24 @@ static int decoder_list_opt(struct mp_log *log, const m_option_t *opt,
const struct m_sub_options dec_wrapper_conf = {
.opts = (const struct m_option[]){
OPT_FLAG("correct-pts", correct_pts, 0),
OPT_DOUBLE("fps", force_fps, 0, .min = 0, .max = DBL_MAX),
OPT_STRING_VALIDATE("ad", audio_decoders, 0, decoder_list_opt),
OPT_STRING_VALIDATE("vd", video_decoders, 0, decoder_list_opt),
OPT_STRING_VALIDATE("audio-spdif", audio_spdif, 0, decoder_list_opt),
OPT_CHOICE_OR_INT("video-rotate", video_rotate, UPDATE_IMGPAR, 0, 359,
({"no", -1})),
OPT_ASPECT("video-aspect-override", movie_aspect,
UPDATE_IMGPAR, .min = -1, .max = 10),
OPT_CHOICE("video-aspect-method", aspect_method, UPDATE_IMGPAR,
({"bitstream", 1}, {"container", 2})),
OPT_SUBSTRUCT("vd-queue", vdec_queue_opts, vdec_queue_conf, 0),
OPT_SUBSTRUCT("ad-queue", adec_queue_opts, adec_queue_conf, 0),
OPT_BYTE_SIZE("video-reversal-buffer", video_reverse_size, 0, 0, (size_t)-1),
OPT_BYTE_SIZE("audio-reversal-buffer", audio_reverse_size, 0, 0, (size_t)-1),
{"correct-pts", OPT_FLAG(correct_pts)},
{"fps", OPT_DOUBLE(force_fps), M_RANGE(0, DBL_MAX)},
{"ad", OPT_STRING_VALIDATE(audio_decoders, decoder_list_opt)},
{"vd", OPT_STRING_VALIDATE(video_decoders, decoder_list_opt)},
{"audio-spdif", OPT_STRING_VALIDATE(audio_spdif, decoder_list_opt)},
{"video-rotate", OPT_CHOICE(video_rotate, {"no", -1}),
.flags = UPDATE_IMGPAR, M_RANGE(0, 359)},
{"video-aspect-override", OPT_ASPECT(movie_aspect),
.flags = UPDATE_IMGPAR, M_RANGE(-1, 10)},
{"video-aspect-method", OPT_CHOICE(aspect_method,
{"bitstream", 1}, {"container", 2}),
.flags = UPDATE_IMGPAR},
{"vd-queue", OPT_SUBSTRUCT(vdec_queue_opts, vdec_queue_conf)},
{"ad-queue", OPT_SUBSTRUCT(adec_queue_opts, adec_queue_conf)},
{"video-reversal-buffer", OPT_BYTE_SIZE(video_reverse_size),
M_RANGE(0, (size_t)-1)},
{"audio-reversal-buffer", OPT_BYTE_SIZE(audio_reverse_size),
M_RANGE(0, (size_t)-1)},
{0}
},
.size = sizeof(struct dec_wrapper_opts),

View File

@ -1091,9 +1091,9 @@ const struct mp_user_filter_entry af_lavfi = {
.name = "lavfi",
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const m_option_t[]){
OPT_STRING("graph", graph, 0),
OPT_FLAG("fix-pts", fix_pts, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{"graph", OPT_STRING(graph)},
{"fix-pts", OPT_FLAG(fix_pts)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.priv_defaults = &(const OPT_BASE_STRUCT){
@ -1110,9 +1110,9 @@ const struct mp_user_filter_entry af_lavfi_bridge = {
.name = "lavfi-bridge",
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const m_option_t[]){
OPT_STRING("name", filter_name, 0),
OPT_KEYVALUELIST("opts", filter_opts, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{"name", OPT_STRING(filter_name)},
{"opts", OPT_KEYVALUELIST(filter_opts)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.priv_defaults = &(const OPT_BASE_STRUCT){
@ -1130,8 +1130,8 @@ const struct mp_user_filter_entry vf_lavfi = {
.name = "lavfi",
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const m_option_t[]){
OPT_STRING("graph", graph, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{"graph", OPT_STRING(graph)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.priv_defaults = &(const OPT_BASE_STRUCT){
@ -1148,9 +1148,9 @@ const struct mp_user_filter_entry vf_lavfi_bridge = {
.name = "lavfi-bridge",
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const m_option_t[]){
OPT_STRING("name", filter_name, 0),
OPT_KEYVALUELIST("opts", filter_opts, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{"name", OPT_STRING(filter_name)},
{"opts", OPT_KEYVALUELIST(filter_opts)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.priv_defaults = &(const OPT_BASE_STRUCT){

View File

@ -71,14 +71,13 @@ struct priv {
#define OPT_BASE_STRUCT struct mp_resample_opts
const struct m_sub_options resample_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("audio-resample-filter-size", filter_size, 0, 0, 32),
OPT_INTRANGE("audio-resample-phase-shift", phase_shift, 0, 0, 30),
OPT_FLAG("audio-resample-linear", linear, 0),
OPT_DOUBLE("audio-resample-cutoff", cutoff, 0,
.min = 0, .max = 1),
OPT_FLAG("audio-normalize-downmix", normalize, 0),
OPT_DOUBLE("audio-resample-max-output-size", max_output_frame_size, 0),
OPT_KEYVALUELIST("audio-swresample-o", avopts, 0),
{"audio-resample-filter-size", OPT_INT(filter_size), M_RANGE(0, 32)},
{"audio-resample-phase-shift", OPT_INT(phase_shift), M_RANGE(0, 30)},
{"audio-resample-linear", OPT_FLAG(linear)},
{"audio-resample-cutoff", OPT_DOUBLE(cutoff), M_RANGE(0, 1)},
{"audio-normalize-downmix", OPT_FLAG(normalize)},
{"audio-resample-max-output-size", OPT_DOUBLE(max_output_frame_size)},
{"audio-swresample-o", OPT_KEYVALUELIST(avopts)},
{0}
},
.size = sizeof(struct mp_resample_opts),

View File

@ -152,7 +152,4 @@ struct mp_cmd *mp_cmd_clone(struct mp_cmd *cmd);
extern const struct m_option_type m_option_type_cycle_dir;
#define OPT_CYCLEDIR(...) \
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_cycle_dir)
#endif

View File

@ -183,26 +183,27 @@ struct input_opts {
const struct m_sub_options input_config = {
.opts = (const m_option_t[]) {
OPT_STRING("input-conf", config_file, M_OPT_FILE),
OPT_INT("input-ar-delay", ar_delay, 0),
OPT_INT("input-ar-rate", ar_rate, 0),
OPT_PRINT("input-keylist", mp_print_key_list),
OPT_PRINT("input-cmdlist", mp_print_cmd_list),
OPT_FLAG("input-default-bindings", default_bindings, 0),
OPT_FLAG("input-test", test, 0),
OPT_INTRANGE("input-doubleclick-time", doubleclick_time, 0, 0, 1000),
OPT_FLAG("input-right-alt-gr", use_alt_gr, 0),
OPT_INTRANGE("input-key-fifo-size", key_fifo_size, 0, 2, 65000),
OPT_FLAG("input-cursor", enable_mouse_movements, 0),
OPT_FLAG("input-vo-keyboard", vo_key_input, 0),
OPT_FLAG("input-media-keys", use_media_keys, 0),
{"input-conf", OPT_STRING(config_file), .flags = M_OPT_FILE},
{"input-ar-delay", OPT_INT(ar_delay)},
{"input-ar-rate", OPT_INT(ar_rate)},
{"input-keylist", OPT_PRINT(mp_print_key_list)},
{"input-cmdlist", OPT_PRINT(mp_print_cmd_list)},
{"input-default-bindings", OPT_FLAG(default_bindings)},
{"input-test", OPT_FLAG(test)},
{"input-doubleclick-time", OPT_INT(doubleclick_time),
M_RANGE(0, 1000)},
{"input-right-alt-gr", OPT_FLAG(use_alt_gr)},
{"input-key-fifo-size", OPT_INT(key_fifo_size), M_RANGE(2, 65000)},
{"input-cursor", OPT_FLAG(enable_mouse_movements)},
{"input-vo-keyboard", OPT_FLAG(vo_key_input)},
{"input-media-keys", OPT_FLAG(use_media_keys)},
#if HAVE_SDL2_GAMEPAD
OPT_FLAG("input-gamepad", use_gamepad, 0),
{"input-gamepad", OPT_FLAG(use_gamepad)},
#endif
OPT_FLAG("window-dragging", allow_win_drag, 0),
OPT_REPLACED("input-x11-keyboard", "input-vo-keyboard"),
{"window-dragging", OPT_FLAG(allow_win_drag)},
{"input-x11-keyboard", OPT_REPLACED("input-vo-keyboard")},
#if HAVE_COCOA
OPT_REMOVED("input-appleremote", "replaced by MediaPlayer support"),
{"input-appleremote", OPT_REMOVED("replaced by MediaPlayer support")},
#endif
{0}
},

View File

@ -371,6 +371,7 @@ struct m_option {
// Float types use [DBL_MIN, DBL_MAX], though by setting min or max to
// -/+INFINITY, the range can be extended to INFINITY. (This part is buggy
// for "float".)
// Preferably use M_RANGE() to set these fields.
// Some types will abuse the min or max field for unrelated things.
double min, max;
@ -569,6 +570,9 @@ extern const char m_option_path_separator;
(offsetof(type, member) + (0 && MP_EXPECT_TYPE(expected_member_type*, \
&((type*)0)->member)))
#define OPT_TYPED_FIELD(type_, c_type, field) \
.type = &type_, \
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, field, c_type)
#define OPTION_LIST_SEPARATOR ','
@ -578,185 +582,147 @@ extern const char m_option_path_separator;
#define OPTDEF_FLOAT(f) .defval = (void *)&(const float){f}
#define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d}
#define OPT_GENERAL(ctype, optname, varname, flagv, ...) \
{.name = optname, .flags = flagv, \
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, varname, ctype), \
__VA_ARGS__}
#define M_RANGE(a, b) .min = (a), .max = (b)
#define OPT_GENERAL_NOTYPE(optname, varname, flagv, ...) \
{.name = optname, .flags = flagv, \
.offset = offsetof(OPT_BASE_STRUCT, varname), \
__VA_ARGS__}
#define OPT_BOOL(field) \
OPT_TYPED_FIELD(m_option_type_bool, bool, field)
#define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__
#define OPT_FLAG(field) \
OPT_TYPED_FIELD(m_option_type_flag, int, field)
#define OPTF_BOOL(field) \
.type = &m_option_type_bool, \
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, field, bool),
#define OPT_INT(field) \
OPT_TYPED_FIELD(m_option_type_int, int, field)
/* The OPT_SOMETHING->OPT_SOMETHING_ kind of redirection exists to
* make the code fully standard-conforming: the C standard requires that
* __VA_ARGS__ has at least one argument (though GCC for example would accept
* 0). Thus the first OPT_SOMETHING is a wrapper which just adds one
* argument to ensure __VA_ARGS__ is not empty when calling the next macro.
*/
#define OPT_INT64(field) \
OPT_TYPED_FIELD(m_option_type_int64, int64_t, field)
// Note: new code should use OPTF_BOOL instead
#define OPT_FLAG(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_flag)
#define OPT_FLOAT(field) \
OPT_TYPED_FIELD(m_option_type_float, float, field)
#define OPT_STRINGLIST(...) \
OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_string_list)
#define OPT_DOUBLE(field) \
OPT_TYPED_FIELD(m_option_type_double, double, field)
#define OPT_KEYVALUELIST(...) \
OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_keyvalue_list)
#define OPT_STRING(field) \
OPT_TYPED_FIELD(m_option_type_string, char*, field)
#define OPT_PATHLIST(...) \
OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_string_list,\
.priv = (void *)&m_option_path_separator)
#define OPT_STRINGLIST(field) \
OPT_TYPED_FIELD(m_option_type_string_list, char**, field)
#define OPT_INT(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_int)
#define OPT_KEYVALUELIST(field) \
OPT_TYPED_FIELD(m_option_type_keyvalue_list, char**, field)
#define OPT_INT64(...) \
OPT_GENERAL(int64_t, __VA_ARGS__, .type = &m_option_type_int64)
#define OPT_PATHLIST(field) \
OPT_TYPED_FIELD(m_option_type_string_list, char**, field), \
.priv = (void *)&m_option_path_separator
#define OPT_RANGE_(ctype, optname, varname, flags, minval, maxval, ...) \
OPT_GENERAL(ctype, optname, varname, flags, \
.min = minval, .max = maxval, __VA_ARGS__)
#define OPT_TIME(field) \
OPT_TYPED_FIELD(m_option_type_time, double, field)
#define OPT_INTRANGE(...) \
OPT_RANGE_(int, __VA_ARGS__, .type = &m_option_type_int)
#define OPT_REL_TIME(field) \
OPT_TYPED_FIELD(m_option_type_rel_time, struct m_rel_time, field)
#define OPT_FLOATRANGE(...) \
OPT_RANGE_(float, __VA_ARGS__, .type = &m_option_type_float)
#define OPT_COLOR(field) \
OPT_TYPED_FIELD(m_option_type_color, struct m_color, field)
#define OPT_DOUBLERANGE(...) \
OPT_RANGE_(double, __VA_ARGS__, .type = &m_option_type_double)
#define OPT_BYTE_SIZE(field) \
OPT_TYPED_FIELD(m_option_type_byte_size, int64_t, field)
#define OPT_FLOAT(...) \
OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_float)
#define OPT_GEOMETRY(field) \
OPT_TYPED_FIELD(m_option_type_geometry, struct m_geometry, field)
#define OPT_DOUBLE(...) \
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_double)
#define OPT_SIZE_BOX(field) \
OPT_TYPED_FIELD(m_option_type_size_box, struct m_geometry, field)
#define OPT_STRING(...) \
OPT_GENERAL(char*, __VA_ARGS__, .type = &m_option_type_string)
#define OPT_TRACKCHOICE(field) \
OPT_CHOICE(field, {"no", -2}, {"auto", -1}), \
M_RANGE(0, 8190)
#define OPT_SETTINGSLIST(optname, varname, flags, objlist, ...) \
OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \
.type = &m_option_type_obj_settings_list, \
.priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist), \
__VA_ARGS__)
#define OPT_MSGLEVELS(field) \
OPT_TYPED_FIELD(m_option_type_msglevels, char **, field)
#define OPT_IMAGEFORMAT(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_imgfmt)
#define OPT_ASPECT(field) \
OPT_TYPED_FIELD(m_option_type_aspect, float, field)
#define OPT_AUDIOFORMAT(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt)
#define OPT_IMAGEFORMAT(field) \
OPT_TYPED_FIELD(m_option_type_imgfmt, int, field)
#define OPT_AUDIOFORMAT(field) \
OPT_TYPED_FIELD(m_option_type_afmt, int, field)
// If .min==1, then passing auto is disallowed, but "" is still accepted, and
// limit channel list to 1 item.
#define OPT_CHANNELS(...) \
OPT_GENERAL(struct m_channels, __VA_ARGS__, .type = &m_option_type_channels)
#define OPT_CHANNELS(field) \
OPT_TYPED_FIELD(m_option_type_channels, struct m_channels, field)
#define M_CHOICES(choices) \
.priv = (void *)&(const struct m_opt_choice_alternatives[]){ \
OPT_HELPER_REMOVEPAREN choices, {NULL}}
#define OPT_STRING_VALIDATE(field, validate_fn) \
OPT_TYPED_FIELD(m_option_type_string, char*, field), \
.priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn)
#define M_CHOICES(...) \
.priv = (void *)&(const struct m_opt_choice_alternatives[]){ __VA_ARGS__, {0}}
#define OPT_CHOICE(...) \
OPT_CHOICE_(__VA_ARGS__, .type = &m_option_type_choice)
#define OPT_CHOICE_(optname, varname, flags, choices, ...) \
OPT_GENERAL(int, optname, varname, flags, M_CHOICES(choices), __VA_ARGS__)
// Variant which takes a pointer to struct m_opt_choice_alternatives directly
#define OPT_CHOICE_C(optname, varname, flags, choices, ...) \
OPT_GENERAL(int, optname, varname, flags, .priv = (void *) \
MP_EXPECT_TYPE(const struct m_opt_choice_alternatives*, choices), \
.type = &m_option_type_choice, __VA_ARGS__)
#define OPT_CHOICE_C(field, choices) \
OPT_TYPED_FIELD(m_option_type_choice, int, field), \
.priv = (void *)MP_EXPECT_TYPE(const struct m_opt_choice_alternatives*, choices)
#define OPT_FLAGS(...) \
OPT_CHOICE_(__VA_ARGS__, .type = &m_option_type_flags)
// Variant where you pass a struct m_opt_choice_alternatives initializer
#define OPT_CHOICE(field, ...) \
OPT_TYPED_FIELD(m_option_type_choice, int, field), \
M_CHOICES(__VA_ARGS__)
// Union of choices and an int range. The choice values can be included in the
// int range, or be completely separate - both works.
#define OPT_CHOICE_OR_INT_(optname, varname, flags, minval, maxval, choices, ...) \
OPT_GENERAL(int, optname, varname, flags, \
.min = minval, .max = maxval, \
M_CHOICES(choices), __VA_ARGS__)
#define OPT_CHOICE_OR_INT(...) \
OPT_CHOICE_OR_INT_(__VA_ARGS__, .type = &m_option_type_choice)
#define OPT_FLAGS(field, ...) \
OPT_TYPED_FIELD(m_option_type_flags, int, field), \
M_CHOICES(__VA_ARGS__)
#define OPT_TIME(...) \
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_time)
#define OPT_SETTINGSLIST(field, objlist) \
OPT_TYPED_FIELD(m_option_type_obj_settings_list, m_obj_settings_t*, field), \
.priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist)
#define OPT_REL_TIME(...) \
OPT_GENERAL(struct m_rel_time, __VA_ARGS__, .type = &m_option_type_rel_time)
#define OPT_FOURCC(field) \
OPT_TYPED_FIELD(m_option_type_fourcc, int, field)
#define OPT_COLOR(...) \
OPT_GENERAL(struct m_color, __VA_ARGS__, .type = &m_option_type_color)
#define OPT_BYTE_SIZE(...) \
OPT_RANGE_(int64_t, __VA_ARGS__, .type = &m_option_type_byte_size)
#define OPT_GEOMETRY(...) \
OPT_GENERAL(struct m_geometry, __VA_ARGS__, .type = &m_option_type_geometry)
#define OPT_SIZE_BOX(...) \
OPT_GENERAL(struct m_geometry, __VA_ARGS__, .type = &m_option_type_size_box)
#define OPT_TRACKCHOICE(name, var, ...) \
OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1}), \
## __VA_ARGS__)
#define OPT_ASPECT(...) \
OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_aspect)
#define OPT_STRING_VALIDATE_(optname, varname, flags, validate_fn, ...) \
OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \
.priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn))
#define OPT_STRING_VALIDATE(...) \
OPT_STRING_VALIDATE_(__VA_ARGS__, .type = &m_option_type_string)
#define OPT_PRINT(optname, fn) \
{.name = optname, \
.flags = M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
.type = &m_option_type_print_fn, \
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
.offset = -1}
#define OPT_CYCLEDIR(field) \
OPT_TYPED_FIELD(m_option_type_cycle_dir, double, field)
// subconf must have the type struct m_sub_options.
// All sub-options are prefixed with "name-" and are added to the current
// (containing) option list.
// If name is "", add the sub-options directly instead.
// varname refers to the field, that must be a pointer to a field described by
// "field" refers to the field, that must be a pointer to a field described by
// the subconf struct.
#define OPT_SUBSTRUCT(name, varname, subconf, flagv) \
OPT_GENERAL_NOTYPE(name, varname, flagv, \
.type = &m_option_type_subconfig, \
.priv = (void*)&subconf)
#define OPT_SUBSTRUCT(field, subconf) \
.offset = offsetof(OPT_BASE_STRUCT, field), \
.type = &m_option_type_subconfig, .priv = (void*)&subconf
// Provide a another name for the option.
#define OPT_ALIAS(optname, newname) \
{.name = optname, .type = &m_option_type_alias, .priv = newname, \
.offset = -1}
// Non-fields
#define OPT_ALIAS(newname) \
.type = &m_option_type_alias, .priv = newname, .offset = -1
// If "--optname" was removed, but "--newname" has the same semantics.
// It will be redirected, and a warning will be printed on first use.
#define OPT_REPLACED_MSG(optname, newname, msg) \
{.name = optname, .type = &m_option_type_alias, .priv = newname, \
.deprecation_message = (msg), .offset = -1}
#define OPT_REPLACED_MSG(newname, msg) \
.type = &m_option_type_alias, .priv = newname, \
.deprecation_message = (msg), .offset = -1
// Same, with a generic deprecation message.
#define OPT_REPLACED(optname, newname) OPT_REPLACED_MSG(optname, newname, "")
#define OPT_REPLACED(newname) OPT_REPLACED_MSG(newname, "")
// Alias, resolved on the CLI/config file/profile parser level only.
#define OPT_CLI_ALIAS(optname, newname) \
{.name = optname, .type = &m_option_type_cli_alias, .priv = newname, \
.flags = M_OPT_NOPROP, .offset = -1}
#define OPT_CLI_ALIAS(newname) \
.type = &m_option_type_cli_alias, .priv = newname, \
.flags = M_OPT_NOPROP, .offset = -1
// "--optname" doesn't exist, but inform the user about a replacement with msg.
#define OPT_REMOVED(optname, msg) \
{.name = optname, .type = &m_option_type_removed, .priv = msg, \
.deprecation_message = "", .flags = M_OPT_NOPROP, .offset = -1}
#define OPT_REMOVED(msg) \
.type = &m_option_type_removed, .priv = msg, \
.deprecation_message = "", .flags = M_OPT_NOPROP, .offset = -1
#define OPT_PRINT(fn) \
.flags = M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
.type = &m_option_type_print_fn, \
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
.offset = -1
#endif /* MPLAYER_M_OPTION_H */

File diff suppressed because it is too large Load Diff

View File

@ -44,30 +44,30 @@
#define OPT_BASE_STRUCT struct macos_opts
const struct m_sub_options macos_conf = {
.opts = (const struct m_option[]) {
OPT_CHOICE("macos-title-bar-appearance", macos_title_bar_appearance, 0,
({"auto", 0}, {"aqua", 1}, {"darkAqua", 2},
{"vibrantLight", 3}, {"vibrantDark", 4},
{"aquaHighContrast", 5}, {"darkAquaHighContrast", 6},
{"vibrantLightHighContrast", 7},
{"vibrantDarkHighContrast", 8})),
OPT_CHOICE("macos-title-bar-material", macos_title_bar_material, 0,
({"titlebar", 0}, {"selection", 1}, {"menu", 2},
{"popover", 3}, {"sidebar", 4}, {"headerView", 5},
{"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8},
{"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11},
{"underWindowBackground", 12}, {"underPageBackground", 13},
{"dark", 14}, {"light", 15}, {"mediumLight", 16},
{"ultraDark", 17})),
OPT_COLOR("macos-title-bar-color", macos_title_bar_color, 0),
OPT_CHOICE_OR_INT("macos-fs-animation-duration",
macos_fs_animation_duration, 0, 0, 1000,
({"default", -1})),
OPT_FLAG("macos-force-dedicated-gpu", macos_force_dedicated_gpu, 0),
OPT_CHOICE("cocoa-cb-sw-renderer", cocoa_cb_sw_renderer, 0,
({"auto", -1}, {"no", 0}, {"yes", 1})),
OPT_FLAG("cocoa-cb-10bit-context", cocoa_cb_10bit_context, 0),
OPT_REMOVED("macos-title-bar-style", "Split into --macos-title-bar-appearance "
"and --macos-title-bar-material"),
{"macos-title-bar-appearance", OPT_CHOICE(macos_title_bar_appearance,
{"auto", 0}, {"aqua", 1}, {"darkAqua", 2},
{"vibrantLight", 3}, {"vibrantDark", 4},
{"aquaHighContrast", 5}, {"darkAquaHighContrast", 6},
{"vibrantLightHighContrast", 7},
{"vibrantDarkHighContrast", 8})},
{"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material,
{"titlebar", 0}, {"selection", 1}, {"menu", 2},
{"popover", 3}, {"sidebar", 4}, {"headerView", 5},
{"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8},
{"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11},
{"underWindowBackground", 12}, {"underPageBackground", 13},
{"dark", 14}, {"light", 15}, {"mediumLight", 16},
{"ultraDark", 17})},
{"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)},
{"macos-fs-animation-duration",
OPT_CHOICE(macos_fs_animation_duration, {"default", -1}),
M_RANGE(0, 1000)},
{"macos-force-dedicated-gpu", OPT_FLAG(macos_force_dedicated_gpu)},
{"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"cocoa-cb-10bit-context", OPT_FLAG(cocoa_cb_10bit_context)},
{"macos-title-bar-style", OPT_REMOVED("Split into --macos-title-bar-appearance "
"and --macos-title-bar-material")},
{0}
},
.size = sizeof(struct macos_opts),

View File

@ -5592,30 +5592,32 @@ const struct mp_cmd_def mp_cmds[] = {
{ "seek", cmd_seek,
{
OPT_TIME("target", v.d, 0),
OPT_FLAGS("flags", v.i, 0,
({"relative", 4|0}, {"-", 4|0},
{"absolute-percent", 4|1},
{"absolute", 4|2},
{"relative-percent", 4|3},
{"keyframes", 32|8},
{"exact", 32|16}),
OPTDEF_INT(4|0)),
{"target", OPT_TIME(v.d)},
{"flags", OPT_FLAGS(v.i,
{"relative", 4|0}, {"-", 4|0},
{"absolute-percent", 4|1},
{"absolute", 4|2},
{"relative-percent", 4|3},
{"keyframes", 32|8},
{"exact", 32|16}),
OPTDEF_INT(4|0)},
// backwards compatibility only
OPT_CHOICE("legacy", v.i, MP_CMD_OPT_ARG,
({"unused", 0}, {"default-precise", 0},
{"keyframes", 32|8},
{"exact", 32|16})),
{"legacy", OPT_CHOICE(v.i,
{"unused", 0}, {"default-precise", 0},
{"keyframes", 32|8},
{"exact", 32|16}),
.flags = MP_CMD_OPT_ARG},
},
.allow_auto_repeat = true,
.scalable = true,
},
{ "revert-seek", cmd_revert_seek,
{OPT_FLAGS("flags", v.i, MP_CMD_OPT_ARG, ({"mark", 1}))},
{ {"flags", OPT_FLAGS(v.i, {"mark", 1}), .flags = MP_CMD_OPT_ARG} },
},
{ "quit", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) },
{ "quit", cmd_quit, { {"code", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG} },
.priv = &(const bool){0} },
{ "quit-watch-later", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) },
{ "quit-watch-later", cmd_quit, { {"code", OPT_INT(v.i),
.flags = MP_CMD_OPT_ARG} },
.priv = &(const bool){1} },
{ "stop", cmd_stop, },
{ "frame-step", cmd_frame_step, .allow_auto_repeat = true,
@ -5623,44 +5625,52 @@ const struct mp_cmd_def mp_cmds[] = {
{ "frame-back-step", cmd_frame_back_step, .allow_auto_repeat = true },
{ "playlist-next", cmd_playlist_next_prev,
{
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0},
{"force", 1})),
{"flags", OPT_CHOICE(v.i,
{"weak", 0},
{"force", 1}),
.flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){1},
},
{ "playlist-prev", cmd_playlist_next_prev,
{
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0},
{"force", 1})),
{"flags", OPT_CHOICE(v.i,
{"weak", 0},
{"force", 1}),
.flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){-1},
},
{ "playlist-shuffle", cmd_playlist_shuffle, },
{ "playlist-unshuffle", cmd_playlist_unshuffle, },
{ "sub-step", cmd_sub_step_seek, { OPT_INT("skip", v.i, 0) },
{ "sub-step", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} },
.allow_auto_repeat = true, .priv = &(const bool){true} },
{ "sub-seek", cmd_sub_step_seek, { OPT_INT("skip", v.i, 0) },
{ "sub-seek", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} },
.allow_auto_repeat = true, .priv = &(const bool){false} },
{ "print-text", cmd_print_text, { OPT_STRING("text", v.s, 0) },
{ "print-text", cmd_print_text, { {"text", OPT_STRING(v.s)} },
.is_noisy = true, .allow_auto_repeat = true },
{ "show-text", cmd_show_text, { OPT_STRING("text", v.s, 0),
OPT_INT("duration", v.i, 0, OPTDEF_INT(-1)),
OPT_INT("level", v.i, MP_CMD_OPT_ARG), },
{ "show-text", cmd_show_text,
{
{"text", OPT_STRING(v.s)},
{"duration", OPT_INT(v.i), OPTDEF_INT(-1)},
{"level", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG},
},
.is_noisy = true, .allow_auto_repeat = true},
{ "expand-text", cmd_expand_text, { OPT_STRING("text", v.s, 0) },
{ "expand-text", cmd_expand_text, { {"text", OPT_STRING(v.s)} },
.is_noisy = true },
{ "expand-path", cmd_expand_path, { OPT_STRING("text", v.s, 0) },
{ "expand-path", cmd_expand_path, { {"text", OPT_STRING(v.s)} },
.is_noisy = true },
{ "show-progress", cmd_show_progress, .allow_auto_repeat = true,
.is_noisy = true },
{ "sub-add", cmd_track_add,
{
OPT_STRING("url", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"select", 0}, {"auto", 1}, {"cached", 2})),
OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
{"url", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i,
{"select", 0}, {"auto", 1}, {"cached", 2}),
.flags = MP_CMD_OPT_ARG},
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_SUB},
.spawn_thread = true,
@ -5669,11 +5679,12 @@ const struct mp_cmd_def mp_cmds[] = {
},
{ "audio-add", cmd_track_add,
{
OPT_STRING("url", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"select", 0}, {"auto", 1}, {"cached", 2})),
OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
{"url", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i,
{"select", 0}, {"auto", 1}, {"cached", 2}),
.flags = MP_CMD_OPT_ARG},
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_AUDIO},
.spawn_thread = true,
@ -5682,11 +5693,11 @@ const struct mp_cmd_def mp_cmds[] = {
},
{ "video-add", cmd_track_add,
{
OPT_STRING("url", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"select", 0}, {"auto", 1}, {"cached", 2})),
OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
{"url", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i, {"select", 0}, {"auto", 1}, {"cached", 2}),
.flags = MP_CMD_OPT_ARG},
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_VIDEO},
.spawn_thread = true,
@ -5694,26 +5705,26 @@ const struct mp_cmd_def mp_cmds[] = {
.abort_on_playback_end = true,
},
{ "sub-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "sub-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_SUB}, },
{ "audio-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "audio-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_AUDIO}, },
{ "video-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "video-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_VIDEO}, },
{ "sub-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "sub-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_SUB},
.spawn_thread = true,
.can_abort = true,
.abort_on_playback_end = true,
},
{ "audio-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "audio-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_AUDIO},
.spawn_thread = true,
.can_abort = true,
.abort_on_playback_end = true,
},
{ "video-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
{ "video-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_VIDEO},
.spawn_thread = true,
.can_abort = true,
@ -5722,9 +5733,10 @@ const struct mp_cmd_def mp_cmds[] = {
{ "rescan-external-files", cmd_rescan_external_files,
{
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"keep-selection", 1},
{"reselect", 0})),
{"flags", OPT_CHOICE(v.i,
{"keep-selection", 1},
{"reselect", 0}),
.flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
.can_abort = true,
@ -5733,121 +5745,126 @@ const struct mp_cmd_def mp_cmds[] = {
{ "screenshot", cmd_screenshot,
{
OPT_FLAGS("flags", v.i, 0,
({"video", 4|0}, {"-", 4|0},
{"window", 4|1},
{"subtitles", 4|2},
{"each-frame", 8}),
OPTDEF_INT(4|2)),
{"flags", OPT_FLAGS(v.i,
{"video", 4|0}, {"-", 4|0},
{"window", 4|1},
{"subtitles", 4|2},
{"each-frame", 8}),
OPTDEF_INT(4|2)},
// backwards compatibility
OPT_CHOICE("legacy", v.i, MP_CMD_OPT_ARG,
({"unused", 0}, {"single", 0},
{"each-frame", 8})),
{"legacy", OPT_CHOICE(v.i,
{"unused", 0}, {"single", 0},
{"each-frame", 8}),
.flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
},
{ "screenshot-to-file", cmd_screenshot_to_file,
{
OPT_STRING("filename", v.s, 0),
OPT_CHOICE("flags", v.i, 0,
({"video", 0},
{"window", 1},
{"subtitles", 2}),
OPTDEF_INT(2)),
{"filename", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i,
{"video", 0},
{"window", 1},
{"subtitles", 2}),
OPTDEF_INT(2)},
},
.spawn_thread = true,
},
{ "screenshot-raw", cmd_screenshot_raw,
{
OPT_CHOICE("flags", v.i, 0,
({"video", 0},
{"window", 1},
{"subtitles", 2}),
OPTDEF_INT(2)),
{"flags", OPT_CHOICE(v.i,
{"video", 0},
{"window", 1},
{"subtitles", 2}),
OPTDEF_INT(2)},
},
},
{ "loadfile", cmd_loadfile,
{
OPT_STRING("url", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"replace", 0},
{"append", 1},
{"append-play", 2})),
OPT_KEYVALUELIST("options", v.str_list, MP_CMD_OPT_ARG),
{"url", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i,
{"replace", 0},
{"append", 1},
{"append-play", 2}),
.flags = MP_CMD_OPT_ARG},
{"options", OPT_KEYVALUELIST(v.str_list), .flags = MP_CMD_OPT_ARG},
},
},
{ "loadlist", cmd_loadlist, { OPT_STRING("url", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"replace", 0}, {"append", 1})), },
{ "loadlist", cmd_loadlist,
{
{"url", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i, {"replace", 0}, {"append", 1}),
.flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
.can_abort = true,
},
{ "playlist-clear", cmd_playlist_clear },
{ "playlist-remove", cmd_playlist_remove,
{OPT_CHOICE_OR_INT("index", v.i, MP_CMD_OPT_ARG, 0, INT_MAX,
({"current", -1}))},
},
{ "playlist-move", cmd_playlist_move, { OPT_INT("index1", v.i, 0),
OPT_INT("index2", v.i, 0), }},
{ "run", cmd_run, { OPT_STRING("command", v.s, 0),
OPT_STRING("args", v.s, 0), },
{ "playlist-remove", cmd_playlist_remove, {
{"index", OPT_CHOICE(v.i, {"current", -1}),
.flags = MP_CMD_OPT_ARG, M_RANGE(0, INT_MAX)}, }},
{ "playlist-move", cmd_playlist_move, { {"index1", OPT_INT(v.i)},
{"index2", OPT_INT(v.i)}, }},
{ "run", cmd_run, { {"command", OPT_STRING(v.s)},
{"args", OPT_STRING(v.s)}, },
.vararg = true,
},
{ "subprocess", cmd_subprocess,
{
OPT_STRINGLIST("args", v.str_list, 0),
OPT_FLAG("playback_only", v.i, 0, OPTDEF_INT(1)),
OPT_BYTE_SIZE("capture_size", v.i64, 0, 0, INT_MAX,
OPTDEF_INT64(64 * 1024 * 1024)),
OPT_FLAG("capture_stdout", v.i, MP_CMD_OPT_ARG),
OPT_FLAG("capture_stderr", v.i, MP_CMD_OPT_ARG),
{"args", OPT_STRINGLIST(v.str_list)},
{"playback_only", OPT_FLAG(v.i), OPTDEF_INT(1)},
{"capture_size", OPT_BYTE_SIZE(v.i64), M_RANGE(0, INT_MAX),
OPTDEF_INT64(64 * 1024 * 1024)},
{"capture_stdout", OPT_FLAG(v.i), .flags = MP_CMD_OPT_ARG},
{"capture_stderr", OPT_FLAG(v.i), .flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
.can_abort = true,
},
{ "set", cmd_set, {OPT_STRING("name", v.s, 0), OPT_STRING("value", v.s, 0)}},
{ "change-list", cmd_change_list, { OPT_STRING("name", v.s, 0),
OPT_STRING("operation", v.s, 0),
OPT_STRING("value", v.s, 0) }},
{ "add", cmd_add_cycle, { OPT_STRING("name", v.s, 0),
OPT_DOUBLE("value", v.d, 0, OPTDEF_DOUBLE(1)), },
{ "set", cmd_set, {{"name", OPT_STRING(v.s)}, {"value", OPT_STRING(v.s)}}},
{ "change-list", cmd_change_list, { {"name", OPT_STRING(v.s)},
{"operation", OPT_STRING(v.s)},
{"value", OPT_STRING(v.s)} }},
{ "add", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
{"value", OPT_DOUBLE(v.d), OPTDEF_DOUBLE(1)}, },
.allow_auto_repeat = true,
.scalable = true,
},
{ "cycle", cmd_add_cycle, { OPT_STRING("name", v.s, 0),
OPT_CYCLEDIR("value", v.d, 0, OPTDEF_DOUBLE(1)), },
{ "cycle", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
{"value", OPT_CYCLEDIR(v.d), OPTDEF_DOUBLE(1)}, },
.allow_auto_repeat = true,
.scalable = true,
.priv = "",
},
{ "multiply", cmd_multiply, { OPT_STRING("name", v.s, 0),
OPT_DOUBLE("value", v.d, 0)},
{ "multiply", cmd_multiply, { {"name", OPT_STRING(v.s)},
{"value", OPT_DOUBLE(v.d)}},
.allow_auto_repeat = true},
{ "cycle-values", cmd_cycle_values, { OPT_STRING("arg0", v.s, 0),
OPT_STRING("arg1", v.s, 0),
OPT_STRING("argN", v.s, 0), },
{ "cycle-values", cmd_cycle_values, { {"arg0", OPT_STRING(v.s)},
{"arg1", OPT_STRING(v.s)},
{"argN", OPT_STRING(v.s)}, },
.vararg = true},
{ "enable-section", cmd_enable_input_section,
{
OPT_STRING("name", v.s, 0),
OPT_FLAGS("flags", v.i, MP_CMD_OPT_ARG,
({"default", 0},
{"exclusive", MP_INPUT_EXCLUSIVE},
{"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
{"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING})),
{"name", OPT_STRING(v.s)},
{"flags", OPT_FLAGS(v.i,
{"default", 0},
{"exclusive", MP_INPUT_EXCLUSIVE},
{"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
{"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING}),
.flags = MP_CMD_OPT_ARG},
}
},
{ "disable-section", cmd_disable_input_section,
{OPT_STRING("name", v.s, 0) }},
{{"name", OPT_STRING(v.s)} }},
{ "define-section", cmd_define_input_section,
{
OPT_STRING("name", v.s, 0),
OPT_STRING("contents", v.s, 0),
OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
({"default", 0}, {"force", 1})),
{"name", OPT_STRING(v.s)},
{"contents", OPT_STRING(v.s)},
{"flags", OPT_CHOICE(v.i, {"default", 0}, {"force", 1}),
.flags = MP_CMD_OPT_ARG},
},
},
@ -5855,89 +5872,87 @@ const struct mp_cmd_def mp_cmds[] = {
{ "drop-buffers", cmd_drop_buffers, },
{ "af", cmd_filter, { OPT_STRING("operation", v.s, 0),
OPT_STRING("value", v.s, 0), },
{ "af", cmd_filter, { {"operation", OPT_STRING(v.s)},
{"value", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_AUDIO} },
{ "vf", cmd_filter, { OPT_STRING("operation", v.s, 0),
OPT_STRING("value", v.s, 0), },
{ "vf", cmd_filter, { {"operation", OPT_STRING(v.s)},
{"value", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_VIDEO} },
{ "af-command", cmd_filter_command, { OPT_STRING("label", v.s, 0),
OPT_STRING("command", v.s, 0),
OPT_STRING("argument", v.s, 0), },
{ "af-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
{"command", OPT_STRING(v.s)},
{"argument", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_AUDIO} },
{ "vf-command", cmd_filter_command, { OPT_STRING("label", v.s, 0),
OPT_STRING("command", v.s, 0),
OPT_STRING("argument", v.s, 0), },
{ "vf-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
{"command", OPT_STRING(v.s)},
{"argument", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_VIDEO} },
{ "ao-reload", cmd_ao_reload },
{ "script-binding", cmd_script_binding, { OPT_STRING("name", v.s, 0) },
{ "script-binding", cmd_script_binding, { {"name", OPT_STRING(v.s)} },
.allow_auto_repeat = true, .on_updown = true},
{ "script-message", cmd_script_message, { OPT_STRING("args", v.s, 0) },
{ "script-message", cmd_script_message, { {"args", OPT_STRING(v.s)} },
.vararg = true },
{ "script-message-to", cmd_script_message_to, { OPT_STRING("target", v.s, 0),
OPT_STRING("args", v.s, 0) },
{ "script-message-to", cmd_script_message_to, { {"target", OPT_STRING(v.s)},
{"args", OPT_STRING(v.s)} },
.vararg = true },
{ "overlay-add", cmd_overlay_add, { OPT_INT("id", v.i, 0),
OPT_INT("x", v.i, 0),
OPT_INT("y", v.i, 0),
OPT_STRING("file", v.s, 0),
OPT_INT("offset", v.i, 0),
OPT_STRING("fmt", v.s, 0),
OPT_INT("w", v.i, 0),
OPT_INT("h", v.i, 0),
OPT_INT("stride", v.i, 0), }},
{ "overlay-remove", cmd_overlay_remove, { OPT_INT("id", v.i, 0) } },
{ "overlay-add", cmd_overlay_add, { {"id", OPT_INT(v.i)},
{"x", OPT_INT(v.i)},
{"y", OPT_INT(v.i)},
{"file", OPT_STRING(v.s)},
{"offset", OPT_INT(v.i)},
{"fmt", OPT_STRING(v.s)},
{"w", OPT_INT(v.i)},
{"h", OPT_INT(v.i)},
{"stride", OPT_INT(v.i)}, }},
{ "overlay-remove", cmd_overlay_remove, { {"id", OPT_INT(v.i)} } },
{ "osd-overlay", cmd_osd_overlay,
{
OPT_INT64("id", v.i64, 0),
OPT_CHOICE("format", v.i, 0, ({"none", 0},
{"ass-events", 1})),
OPT_STRING("data", v.s, 0),
OPT_INT("res_x", v.i, 0, OPTDEF_INT(0)),
OPT_INT("res_y", v.i, 0, OPTDEF_INT(720)),
OPT_INT("z", v.i, 0, OPTDEF_INT(0)),
OPT_FLAG("hidden", v.i, 0, OPTDEF_INT(0)),
OPT_FLAG("compute_bounds", v.i, 0, OPTDEF_INT(0)),
{"id", OPT_INT64(v.i64)},
{"format", OPT_CHOICE(v.i, {"none", 0}, {"ass-events", 1})},
{"data", OPT_STRING(v.s)},
{"res_x", OPT_INT(v.i), OPTDEF_INT(0)},
{"res_y", OPT_INT(v.i), OPTDEF_INT(720)},
{"z", OPT_INT(v.i), OPTDEF_INT(0)},
{"hidden", OPT_FLAG(v.i), OPTDEF_INT(0)},
{"compute_bounds", OPT_FLAG(v.i), OPTDEF_INT(0)},
},
.is_noisy = true,
},
{ "write-watch-later-config", cmd_write_watch_later_config },
{ "mouse", cmd_mouse, { OPT_INT("x", v.i, 0),
OPT_INT("y", v.i, 0),
OPT_INT("button", v.i, 0, OPTDEF_INT(-1)),
OPT_CHOICE("mode", v.i, MP_CMD_OPT_ARG,
({"single", 0}, {"double", 1})), }},
{ "keybind", cmd_key_bind, { OPT_STRING("name", v.s, 0),
OPT_STRING("cmd", v.s, 0) }},
{ "keypress", cmd_key, { OPT_STRING("name", v.s, 0) },
{ "mouse", cmd_mouse, { {"x", OPT_INT(v.i)},
{"y", OPT_INT(v.i)},
{"button", OPT_INT(v.i), OPTDEF_INT(-1)},
{"mode", OPT_CHOICE(v.i,
{"single", 0}, {"double", 1}),
.flags = MP_CMD_OPT_ARG}}},
{ "keybind", cmd_key_bind, { {"name", OPT_STRING(v.s)},
{"cmd", OPT_STRING(v.s)} }},
{ "keypress", cmd_key, { {"name", OPT_STRING(v.s)} },
.priv = &(const int){0}},
{ "keydown", cmd_key, { OPT_STRING("name", v.s, 0) },
{ "keydown", cmd_key, { {"name", OPT_STRING(v.s)} },
.priv = &(const int){MP_KEY_STATE_DOWN}},
{ "keyup", cmd_key, { OPT_STRING("name", v.s, MP_CMD_OPT_ARG) },
{ "keyup", cmd_key, { {"name", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG} },
.priv = &(const int){MP_KEY_STATE_UP}},
{ "apply-profile", cmd_apply_profile, {OPT_STRING("name", v.s, 0)} },
{ "apply-profile", cmd_apply_profile, {{"name", OPT_STRING(v.s)}} },
{ "load-script", cmd_load_script, {OPT_STRING("filename", v.s, 0)} },
{ "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
{ "dump-cache", cmd_dump_cache, { OPT_TIME("start", v.d, 0,
.min = MP_NOPTS_VALUE),
OPT_TIME("end", v.d, 0,
.min = MP_NOPTS_VALUE),
OPT_STRING("filename", v.s, 0) },
{ "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d), .min = MP_NOPTS_VALUE},
{"end", OPT_TIME(v.d), .min = MP_NOPTS_VALUE},
{"filename", OPT_STRING(v.s)} },
.exec_async = true,
.can_abort = true,
},
{ "ab-loop-dump-cache", cmd_dump_cache_ab, { OPT_STRING("filename", v.s, 0) },
{ "ab-loop-dump-cache", cmd_dump_cache_ab, { {"filename", OPT_STRING(v.s)} },
.exec_async = true,
.can_abort = true,
},

View File

@ -106,9 +106,9 @@ struct stream_opts {
const struct m_sub_options stream_conf = {
.opts = (const struct m_option[]){
OPT_BYTE_SIZE("stream-buffer-size", buffer_size, 0,
STREAM_MIN_BUFFER_SIZE, 512 * 1024 * 1024),
OPT_FLAG("load-unsafe-playlists", load_unsafe_playlists, 0),
{"stream-buffer-size", OPT_BYTE_SIZE(buffer_size),
M_RANGE(STREAM_MIN_BUFFER_SIZE, 512 * 1024 * 1024)},
{"load-unsafe-playlists", OPT_FLAG(load_unsafe_playlists)},
{0}
},
.size = sizeof(struct stream_opts),

View File

@ -76,17 +76,17 @@ typedef struct cdda_params {
#define OPT_BASE_STRUCT struct cdda_params
const struct m_sub_options stream_cdda_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("speed", speed, 0, 1, 100),
OPT_INTRANGE("paranoia", paranoia_mode, 0, 0, 2),
OPT_INTRANGE("sector-size", sector_size, 0, 1, 100),
OPT_INTRANGE("overlap", search_overlap, 0, 0, 75),
OPT_INT("toc-bias", toc_bias, 0),
OPT_INT("toc-offset", toc_offset, 0),
OPT_FLAG("skip", skip, 0),
OPT_INT("span-a", span[0], 0),
OPT_INT("span-b", span[1], 0),
OPT_FLAG("cdtext", cdtext, 0),
OPT_REMOVED("span", "use span-a/span-b"),
{"speed", OPT_INT(speed), M_RANGE(1, 100)},
{"paranoia", OPT_INT(paranoia_mode), M_RANGE(0, 2)},
{"sector-size", OPT_INT(sector_size), M_RANGE(1, 100)},
{"overlap", OPT_INT(search_overlap), M_RANGE(0, 75)},
{"toc-bias", OPT_INT(toc_bias)},
{"toc-offset", OPT_INT(toc_offset)},
{"skip", OPT_FLAG(skip)},
{"span-a", OPT_INT(span[0])},
{"span-b", OPT_INT(span[1])},
{"cdtext", OPT_FLAG(cdtext)},
{"span", OPT_REMOVED("use span-a/span-b")},
{0}
},
.size = sizeof(struct cdda_params),

View File

@ -73,13 +73,13 @@ static pthread_mutex_t global_dvb_state_lock = PTHREAD_MUTEX_INITIALIZER;
const struct m_sub_options stream_dvb_conf = {
.opts = (const m_option_t[]) {
OPT_STRING("prog", cfg_prog, UPDATE_DVB_PROG),
OPT_INTRANGE("card", cfg_devno, 0, 0, MAX_ADAPTERS-1),
OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30),
OPT_STRING("file", cfg_file, M_OPT_FILE),
OPT_FLAG("full-transponder", cfg_full_transponder, 0),
OPT_INT("channel-switch-offset", cfg_channel_switch_offset,
UPDATE_DVB_PROG),
{"prog", OPT_STRING(cfg_prog), .flags = UPDATE_DVB_PROG},
{"card", OPT_INT(cfg_devno), M_RANGE(0, MAX_ADAPTERS-1)},
{"timeout", OPT_INT(cfg_timeout), M_RANGE(1, 30)},
{"file", OPT_STRING(cfg_file), .flags = M_OPT_FILE},
{"full-transponder", OPT_FLAG(cfg_full_transponder)},
{"channel-switch-offset", OPT_INT(cfg_channel_switch_offset),
.flags = UPDATE_DVB_PROG},
{0}
},
.size = sizeof(dvb_opts_t),

View File

@ -52,18 +52,18 @@ struct stream_lavf_params {
const struct m_sub_options stream_lavf_conf = {
.opts = (const m_option_t[]) {
OPT_KEYVALUELIST("stream-lavf-o", avopts, 0),
OPT_STRINGLIST("http-header-fields", http_header_fields, 0),
OPT_STRING("user-agent", useragent, 0),
OPT_STRING("referrer", referrer, 0),
OPT_FLAG("cookies", cookies_enabled, 0),
OPT_STRING("cookies-file", cookies_file, M_OPT_FILE),
OPT_FLAG("tls-verify", tls_verify, 0),
OPT_STRING("tls-ca-file", tls_ca_file, M_OPT_FILE),
OPT_STRING("tls-cert-file", tls_cert_file, M_OPT_FILE),
OPT_STRING("tls-key-file", tls_key_file, M_OPT_FILE),
OPT_DOUBLE("network-timeout", timeout, 0, .min = 0, .max = DBL_MAX),
OPT_STRING("http-proxy", http_proxy, 0),
{"stream-lavf-o", OPT_KEYVALUELIST(avopts)},
{"http-header-fields", OPT_STRINGLIST(http_header_fields)},
{"user-agent", OPT_STRING(useragent)},
{"referrer", OPT_STRING(referrer)},
{"cookies", OPT_FLAG(cookies_enabled)},
{"cookies-file", OPT_STRING(cookies_file), .flags = M_OPT_FILE},
{"tls-verify", OPT_FLAG(tls_verify)},
{"tls-ca-file", OPT_STRING(tls_ca_file), .flags = M_OPT_FILE},
{"tls-cert-file", OPT_STRING(tls_cert_file), .flags = M_OPT_FILE},
{"tls-key-file", OPT_STRING(tls_key_file), .flags = M_OPT_FILE},
{"network-timeout", OPT_DOUBLE(timeout), M_RANGE(0, DBL_MAX)},
{"http-proxy", OPT_STRING(http_proxy)},
{0}
},
.size = sizeof(struct stream_lavf_params),

View File

@ -44,28 +44,28 @@
#define OPT_BASE_STRUCT struct osd_style_opts
static const m_option_t style_opts[] = {
OPT_STRING("font", font, 0),
OPT_FLOATRANGE("font-size", font_size, 0, 1, 9000),
OPT_COLOR("color", color, 0),
OPT_COLOR("border-color", border_color, 0),
OPT_COLOR("shadow-color", shadow_color, 0),
OPT_COLOR("back-color", back_color, 0),
OPT_FLOAT("border-size", border_size, 0),
OPT_FLOAT("shadow-offset", shadow_offset, 0),
OPT_FLOATRANGE("spacing", spacing, 0, -10, 10),
OPT_INTRANGE("margin-x", margin_x, 0, 0, 300),
OPT_INTRANGE("margin-y", margin_y, 0, 0, 600),
OPT_CHOICE("align-x", align_x, 0,
({"left", -1}, {"center", 0}, {"right", +1})),
OPT_CHOICE("align-y", align_y, 0,
({"top", -1}, {"center", 0}, {"bottom", +1})),
OPT_FLOATRANGE("blur", blur, 0, 0, 20),
OPT_FLAG("bold", bold, 0),
OPT_FLAG("italic", italic, 0),
OPT_CHOICE("justify", justify, 0,
({"auto", 0}, {"left", 1}, {"center", 2}, {"right", 3})),
OPT_CHOICE("font-provider", font_provider, 0,
({"auto", 0}, {"none", 1}, {"fontconfig", 2})),
{"font", OPT_STRING(font)},
{"font-size", OPT_FLOAT(font_size), M_RANGE(1, 9000)},
{"color", OPT_COLOR(color)},
{"border-color", OPT_COLOR(border_color)},
{"shadow-color", OPT_COLOR(shadow_color)},
{"back-color", OPT_COLOR(back_color)},
{"border-size", OPT_FLOAT(border_size)},
{"shadow-offset", OPT_FLOAT(shadow_offset)},
{"spacing", OPT_FLOAT(spacing), M_RANGE(-10, 10)},
{"margin-x", OPT_INT(margin_x), M_RANGE(0, 300)},
{"margin-y", OPT_INT(margin_y), M_RANGE(0, 600)},
{"align-x", OPT_CHOICE(align_x,
{"left", -1}, {"center", 0}, {"right", +1})},
{"align-y", OPT_CHOICE(align_y,
{"top", -1}, {"center", 0}, {"bottom", +1})},
{"blur", OPT_FLOAT(blur), M_RANGE(0, 20)},
{"bold", OPT_FLAG(bold)},
{"italic", OPT_FLAG(italic)},
{"justify", OPT_CHOICE(justify,
{"auto", 0}, {"left", 1}, {"center", 2}, {"right", 3})},
{"font-provider", OPT_CHOICE(font_provider,
{"auto", 0}, {"none", 1}, {"fontconfig", 2})},
{0}
};

View File

@ -821,13 +821,18 @@ bool mp_colorspace_equal(struct mp_colorspace c1, struct mp_colorspace c2)
const struct m_sub_options mp_csp_equalizer_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("brightness", values[MP_CSP_EQ_BRIGHTNESS], 0, -100, 100),
OPT_INTRANGE("saturation", values[MP_CSP_EQ_SATURATION], 0, -100, 100),
OPT_INTRANGE("contrast", values[MP_CSP_EQ_CONTRAST], 0, -100, 100),
OPT_INTRANGE("hue", values[MP_CSP_EQ_HUE], 0, -100, 100),
OPT_INTRANGE("gamma", values[MP_CSP_EQ_GAMMA], 0, -100, 100),
OPT_CHOICE_C("video-output-levels", values[MP_CSP_EQ_OUTPUT_LEVELS], 0,
mp_csp_levels_names),
{"brightness", OPT_INT(values[MP_CSP_EQ_BRIGHTNESS]),
M_RANGE(-100, 100)},
{"saturation", OPT_INT(values[MP_CSP_EQ_SATURATION]),
M_RANGE(-100, 100)},
{"contrast", OPT_INT(values[MP_CSP_EQ_CONTRAST]),
M_RANGE(-100, 100)},
{"hue", OPT_INT(values[MP_CSP_EQ_HUE]),
M_RANGE(-100, 100)},
{"gamma", OPT_INT(values[MP_CSP_EQ_GAMMA]),
M_RANGE(-100, 100)},
{"video-output-levels",
OPT_CHOICE_C(values[MP_CSP_EQ_OUTPUT_LEVELS], mp_csp_levels_names)},
{0}
},
.size = sizeof(struct mp_csp_equalizer_opts),

View File

@ -99,32 +99,29 @@ static const struct m_opt_choice_alternatives discard_names[] = {
{"all", AVDISCARD_ALL},
{0}
};
#define OPT_DISCARD(name, field, flags) \
OPT_GENERAL(int, name, field, flags, .type = CONF_TYPE_CHOICE, \
.priv = (void *)discard_names)
#define OPT_DISCARD(field) OPT_CHOICE_C(field, discard_names)
const struct m_sub_options vd_lavc_conf = {
.opts = (const m_option_t[]){
OPT_FLAG("vd-lavc-fast", fast, 0),
OPT_FLAG("vd-lavc-show-all", show_all, 0),
OPT_DISCARD("vd-lavc-skiploopfilter", skip_loop_filter, 0),
OPT_DISCARD("vd-lavc-skipidct", skip_idct, 0),
OPT_DISCARD("vd-lavc-skipframe", skip_frame, 0),
OPT_DISCARD("vd-lavc-framedrop", framedrop, 0),
OPT_INT("vd-lavc-threads", threads, 0, .min = 0, .max = DBL_MAX),
OPT_FLAG("vd-lavc-bitexact", bitexact, 0),
OPT_FLAG("vd-lavc-assume-old-x264", old_x264, 0),
OPT_FLAG("vd-lavc-check-hw-profile", check_hw_profile, 0),
OPT_CHOICE_OR_INT("vd-lavc-software-fallback", software_fallback,
0, 1, INT_MAX, ({"no", INT_MAX}, {"yes", 1})),
OPT_KEYVALUELIST("vd-lavc-o", avopts, 0),
OPT_FLAG("vd-lavc-dr", dr, 0),
OPT_STRING_VALIDATE("hwdec", hwdec_api,
M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC,
hwdec_validate_opt),
OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
OPT_IMAGEFORMAT("hwdec-image-format", hwdec_image_format, 0, .min = -1),
OPT_INTRANGE("hwdec-extra-frames", hwdec_extra_frames, 0, 0, 256),
{"vd-lavc-fast", OPT_FLAG(fast)},
{"vd-lavc-show-all", OPT_FLAG(show_all)},
{"vd-lavc-skiploopfilter", OPT_DISCARD(skip_loop_filter)},
{"vd-lavc-skipidct", OPT_DISCARD(skip_idct)},
{"vd-lavc-skipframe", OPT_DISCARD(skip_frame)},
{"vd-lavc-framedrop", OPT_DISCARD(framedrop)},
{"vd-lavc-threads", OPT_INT(threads), M_RANGE(0, DBL_MAX)},
{"vd-lavc-bitexact", OPT_FLAG(bitexact)},
{"vd-lavc-assume-old-x264", OPT_FLAG(old_x264)},
{"vd-lavc-check-hw-profile", OPT_FLAG(check_hw_profile)},
{"vd-lavc-software-fallback", OPT_CHOICE(software_fallback,
{"no", INT_MAX}, {"yes", 1}), M_RANGE(1, INT_MAX)},
{"vd-lavc-o", OPT_KEYVALUELIST(avopts)},
{"vd-lavc-dr", OPT_FLAG(dr)},
{"hwdec", OPT_STRING_VALIDATE(hwdec_api, hwdec_validate_opt),
.flags = M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC},
{"hwdec-codecs", OPT_STRING(hwdec_codecs)},
{"hwdec-image-format", OPT_IMAGEFORMAT(hwdec_image_format), .min = -1},
{"hwdec-extra-frames", OPT_INT(hwdec_extra_frames), M_RANGE(0, 256)},
{0}
},
.size = sizeof(struct vd_lavc_params),

View File

@ -476,15 +476,15 @@ fail:
#define OPT_BASE_STRUCT struct opts
static const m_option_t vf_opts_fields[] = {
OPT_FLAG("deint", deint_enabled, 0),
OPT_FLAG("interlaced-only", interlaced_only, 0),
OPT_CHOICE("mode", mode, 0,
({"blend", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND},
{"bob", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB},
{"adaptive", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE},
{"mocomp", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION},
{"ivctc", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE},
{"none", 0})),
{"deint", OPT_FLAG(deint_enabled)},
{"interlaced-only", OPT_FLAG(interlaced_only)},
{"mode", OPT_CHOICE(mode,
{"blend", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND},
{"bob", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB},
{"adaptive", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE},
{"mocomp", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION},
{"ivctc", D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE},
{"none", 0})},
{0}
};

View File

@ -45,9 +45,9 @@ const struct m_opt_choice_alternatives type_names[] = {
#define OPT_BASE_STRUCT struct f_opts
static const struct m_option f_opts_list[] = {
OPT_CHOICE_C("type", type, 0, type_names),
OPT_FLAG("clear-on-query", clear, 0),
OPT_FLAG("print", print, 0),
{"type", OPT_CHOICE_C(type, type_names)},
{"clear-on-query", OPT_FLAG(clear)},
{"print", OPT_FLAG(print)},
{0}
};

View File

@ -183,24 +183,24 @@ static struct mp_filter *vf_format_create(struct mp_filter *parent, void *option
#define OPT_BASE_STRUCT struct vf_format_opts
static const m_option_t vf_opts_fields[] = {
OPT_IMAGEFORMAT("fmt", fmt, 0),
OPT_CHOICE_C("colormatrix", colormatrix, 0, mp_csp_names),
OPT_CHOICE_C("colorlevels", colorlevels, 0, mp_csp_levels_names),
OPT_CHOICE_C("primaries", primaries, 0, mp_csp_prim_names),
OPT_CHOICE_C("gamma", gamma, 0, mp_csp_trc_names),
OPT_FLOAT("sig-peak", sig_peak, 0),
OPT_CHOICE_C("light", light, 0, mp_csp_light_names),
OPT_CHOICE_C("chroma-location", chroma_location, 0, mp_chroma_names),
OPT_CHOICE_C("stereo-in", stereo_in, 0, mp_stereo3d_names),
OPT_INTRANGE("rotate", rotate, 0, -1, 359),
OPT_INT("w", w, 0),
OPT_INT("h", h, 0),
OPT_INT("dw", dw, 0),
OPT_INT("dh", dh, 0),
OPT_DOUBLE("dar", dar, 0),
OPT_FLAG("convert", convert, 0),
OPT_REMOVED("outputlevels", "use the --video-output-levels global option"),
OPT_REMOVED("peak", "use sig-peak instead (changed value scale!)"),
{"fmt", OPT_IMAGEFORMAT(fmt)},
{"colormatrix", OPT_CHOICE_C(colormatrix, mp_csp_names)},
{"colorlevels", OPT_CHOICE_C(colorlevels, mp_csp_levels_names)},
{"primaries", OPT_CHOICE_C(primaries, mp_csp_prim_names)},
{"gamma", OPT_CHOICE_C(gamma, mp_csp_trc_names)},
{"sig-peak", OPT_FLOAT(sig_peak)},
{"light", OPT_CHOICE_C(light, mp_csp_light_names)},
{"chroma-location", OPT_CHOICE_C(chroma_location, mp_chroma_names)},
{"stereo-in", OPT_CHOICE_C(stereo_in, mp_stereo3d_names)},
{"rotate", OPT_INT(rotate), M_RANGE(-1, 359)},
{"w", OPT_INT(w)},
{"h", OPT_INT(h)},
{"dw", OPT_INT(dw)},
{"dh", OPT_INT(dh)},
{"dar", OPT_DOUBLE(dar)},
{"convert", OPT_FLAG(convert)},
{"outputlevels", OPT_REMOVED("use the --video-output-levels global option")},
{"peak", OPT_REMOVED("use sig-peak instead (changed value scale!)")},
{0}
};

View File

@ -363,8 +363,8 @@ const struct mp_user_filter_entry vf_gpu = {
.name = "gpu",
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const struct m_option[]){
OPT_INT("w", w, 0),
OPT_INT("h", h, 0),
{"w", OPT_INT(w)},
{"h", OPT_INT(h)},
{0}
},
},

View File

@ -147,8 +147,8 @@ static struct mp_filter *vf_sub_create(struct mp_filter *parent, void *options)
#define OPT_BASE_STRUCT struct vf_sub_opts
static const m_option_t vf_opts_fields[] = {
OPT_INTRANGE("bottom-margin", bottom_margin, 0, 0, 2000),
OPT_INTRANGE("top-margin", top_margin, 0, 0, 2000),
{"bottom-margin", OPT_INT(bottom_margin), M_RANGE(0, 2000)},
{"top-margin", OPT_INT(top_margin), M_RANGE(0, 2000)},
{0}
};

View File

@ -800,10 +800,11 @@ error:
#define OPT_BASE_STRUCT struct vapoursynth_opts
static const m_option_t vf_opts_fields[] = {
OPT_STRING("file", file, M_OPT_FILE),
OPT_INTRANGE("buffered-frames", maxbuffer, 0, 1, 9999, OPTDEF_INT(4)),
OPT_CHOICE_OR_INT("concurrent-frames", maxrequests, 0, 1, 99,
({"auto", -1}), OPTDEF_INT(-1)),
{"file", OPT_STRING(file), .flags = M_OPT_FILE},
{"buffered-frames", OPT_INT(maxbuffer), M_RANGE(1, 9999),
OPTDEF_INT(4)},
{"concurrent-frames", OPT_CHOICE(maxrequests, {"auto", -1}),
M_RANGE(1, 99), OPTDEF_INT(-1)},
{0}
};

View File

@ -471,17 +471,17 @@ error:
#define OPT_BASE_STRUCT struct opts
static const m_option_t vf_opts_fields[] = {
OPT_CHOICE("deint", deint_type, 0,
// The values >=0 must match with deint_algorithm[].
({"auto", -1},
{"no", 0},
{"first-field", 1},
{"bob", 2},
{"weave", 3},
{"motion-adaptive", 4},
{"motion-compensated", 5})),
OPT_FLAG("interlaced-only", interlaced_only, 0),
OPT_FLAG("reversal-bug", reversal_bug, 0),
{"deint", OPT_CHOICE(deint_type,
// The values >=0 must match with deint_algorithm[].
{"auto", -1},
{"no", 0},
{"first-field", 1},
{"bob", 2},
{"weave", 3},
{"motion-adaptive", 4},
{"motion-compensated", 5})},
{"interlaced-only", OPT_FLAG(interlaced_only)},
{"reversal-bug", OPT_FLAG(reversal_bug)},
{0}
};

View File

@ -168,19 +168,19 @@ error:
#define OPT_BASE_STRUCT struct opts
static const m_option_t vf_opts_fields[] = {
OPT_CHOICE("deint-mode", opts.deint, 0,
({"first-field", 1},
{"bob", 2},
{"temporal", 3},
{"temporal-spatial", 4}),
OPTDEF_INT(3)),
OPT_FLAG("deint", deint_enabled, 0),
OPT_FLAG("chroma-deint", opts.chroma_deint, 0, OPTDEF_INT(1)),
OPT_FLAG("pullup", opts.pullup, 0),
OPT_FLOATRANGE("denoise", opts.denoise, 0, 0, 1),
OPT_FLOATRANGE("sharpen", opts.sharpen, 0, -1, 1),
OPT_INTRANGE("hqscaling", opts.hqscaling, 0, 0, 9),
OPT_FLAG("interlaced-only", interlaced_only, 0),
{"deint-mode", OPT_CHOICE(opts.deint,
{"first-field", 1},
{"bob", 2},
{"temporal", 3},
{"temporal-spatial", 4}),
OPTDEF_INT(3)},
{"deint", OPT_FLAG(deint_enabled)},
{"chroma-deint", OPT_FLAG(opts.chroma_deint), OPTDEF_INT(1)},
{"pullup", OPT_FLAG(opts.pullup)},
{"denoise", OPT_FLOAT(opts.denoise), M_RANGE(0, 1)},
{"sharpen", OPT_FLOAT(opts.sharpen), M_RANGE(-1, 1)},
{"hqscaling", OPT_INT(opts.hqscaling), M_RANGE(0, 9)},
{"interlaced-only", OPT_FLAG(interlaced_only)},
{0}
};

View File

@ -65,16 +65,16 @@ const struct m_opt_choice_alternatives mp_image_writer_formats[] = {
#define OPT_BASE_STRUCT struct image_writer_opts
const struct m_option image_writer_opts[] = {
OPT_CHOICE_C("format", format, 0, mp_image_writer_formats),
OPT_INTRANGE("jpeg-quality", jpeg_quality, 0, 0, 100),
OPT_FLAG("jpeg-source-chroma", jpeg_source_chroma, 0),
OPT_INTRANGE("png-compression", png_compression, 0, 0, 9),
OPT_INTRANGE("png-filter", png_filter, 0, 0, 5),
OPT_FLAG("webp-lossless", webp_lossless, 0),
OPT_INTRANGE("webp-quality", webp_quality, 0, 0, 100),
OPT_INTRANGE("webp-compression", webp_compression, 0, 0, 6),
OPT_FLAG("high-bit-depth", high_bit_depth, 0),
OPT_FLAG("tag-colorspace", tag_csp, 0),
{"format", OPT_CHOICE_C(format, mp_image_writer_formats)},
{"jpeg-quality", OPT_INT(jpeg_quality), M_RANGE(0, 100)},
{"jpeg-source-chroma", OPT_FLAG(jpeg_source_chroma)},
{"png-compression", OPT_INT(png_compression), M_RANGE(0, 9)},
{"png-filter", OPT_INT(png_filter), M_RANGE(0, 5)},
{"webp-lossless", OPT_FLAG(webp_lossless)},
{"webp-quality", OPT_INT(webp_quality), M_RANGE(0, 100)},
{"webp-compression", OPT_INT(webp_compression), M_RANGE(0, 6)},
{"high-bit-depth", OPT_FLAG(high_bit_depth)},
{"tag-colorspace", OPT_FLAG(tag_csp)},
{0},
};

View File

@ -31,7 +31,8 @@ struct android_opts {
#define OPT_BASE_STRUCT struct android_opts
const struct m_sub_options android_conf = {
.opts = (const struct m_option[]) {
OPT_SIZE_BOX("android-surface-size", surface_size, UPDATE_VO_RESIZE),
{"android-surface-size", OPT_SIZE_BOX(surface_size),
.flags = UPDATE_VO_RESIZE},
{0}
},
.size = sizeof(struct android_opts),

View File

@ -43,36 +43,36 @@ struct d3d11_opts {
#define OPT_BASE_STRUCT struct d3d11_opts
const struct m_sub_options d3d11_conf = {
.opts = (const struct m_option[]) {
OPT_CHOICE("d3d11-warp", warp, 0,
({"auto", -1},
{"no", 0},
{"yes", 1})),
OPT_CHOICE("d3d11-feature-level", feature_level, 0,
({"12_1", D3D_FEATURE_LEVEL_12_1},
{"12_0", D3D_FEATURE_LEVEL_12_0},
{"11_1", D3D_FEATURE_LEVEL_11_1},
{"11_0", D3D_FEATURE_LEVEL_11_0},
{"10_1", D3D_FEATURE_LEVEL_10_1},
{"10_0", D3D_FEATURE_LEVEL_10_0},
{"9_3", D3D_FEATURE_LEVEL_9_3},
{"9_2", D3D_FEATURE_LEVEL_9_2},
{"9_1", D3D_FEATURE_LEVEL_9_1})),
OPT_FLAG("d3d11-flip", flip, 0),
OPT_INTRANGE("d3d11-sync-interval", sync_interval, 0, 0, 4),
OPT_STRING_VALIDATE("d3d11-adapter", adapter_name, 0,
d3d11_validate_adapter),
OPT_CHOICE("d3d11-output-format", output_format, 0,
({"auto", DXGI_FORMAT_UNKNOWN},
{"rgba8", DXGI_FORMAT_R8G8B8A8_UNORM},
{"bgra8", DXGI_FORMAT_B8G8R8A8_UNORM},
{"rgb10_a2", DXGI_FORMAT_R10G10B10A2_UNORM},
{"rgba16f", DXGI_FORMAT_R16G16B16A16_FLOAT})),
OPT_CHOICE("d3d11-output-csp", color_space, 0,
({"auto", -1},
{"srgb", DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709},
{"linear", DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709},
{"pq", DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020},
{"bt.2020", DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020})),
{"d3d11-warp", OPT_CHOICE(warp,
{"auto", -1},
{"no", 0},
{"yes", 1})},
{"d3d11-feature-level", OPT_CHOICE(feature_level,
{"12_1", D3D_FEATURE_LEVEL_12_1},
{"12_0", D3D_FEATURE_LEVEL_12_0},
{"11_1", D3D_FEATURE_LEVEL_11_1},
{"11_0", D3D_FEATURE_LEVEL_11_0},
{"10_1", D3D_FEATURE_LEVEL_10_1},
{"10_0", D3D_FEATURE_LEVEL_10_0},
{"9_3", D3D_FEATURE_LEVEL_9_3},
{"9_2", D3D_FEATURE_LEVEL_9_2},
{"9_1", D3D_FEATURE_LEVEL_9_1})},
{"d3d11-flip", OPT_FLAG(flip)},
{"d3d11-sync-interval", OPT_INT(sync_interval), M_RANGE(0, 4)},
{"d3d11-adapter", OPT_STRING_VALIDATE(adapter_name,
d3d11_validate_adapter)},
{"d3d11-output-format", OPT_CHOICE(output_format,
{"auto", DXGI_FORMAT_UNKNOWN},
{"rgba8", DXGI_FORMAT_R8G8B8A8_UNORM},
{"bgra8", DXGI_FORMAT_B8G8R8A8_UNORM},
{"rgb10_a2", DXGI_FORMAT_R10G10B10A2_UNORM},
{"rgba16f", DXGI_FORMAT_R16G16B16A16_FLOAT})},
{"d3d11-output-csp", OPT_CHOICE(color_space,
{"auto", -1},
{"srgb", DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709},
{"linear", DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709},
{"pq", DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020},
{"bt.2020", DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020})},
{0}
},
.defaults = &(const struct d3d11_opts) {

View File

@ -36,7 +36,7 @@ struct d3d11va_opts {
#define OPT_BASE_STRUCT struct d3d11va_opts
const struct m_sub_options d3d11va_conf = {
.opts = (const struct m_option[]) {
OPT_FLAG("d3d11va-zero-copy", zero_copy, 0),
{"d3d11va-zero-copy", OPT_FLAG(zero_copy)},
{0}
},
.defaults = &(const struct d3d11va_opts) {

View File

@ -64,27 +64,27 @@ static double mode_get_Hz(const drmModeModeInfo *mode);
#define OPT_BASE_STRUCT struct drm_opts
const struct m_sub_options drm_conf = {
.opts = (const struct m_option[]) {
OPT_STRING_VALIDATE("drm-connector", drm_connector_spec,
0, drm_validate_connector_opt),
OPT_STRING_VALIDATE("drm-mode", drm_mode_spec,
0, drm_validate_mode_opt),
OPT_CHOICE("drm-atomic", drm_atomic, 0,
({"no", 0},
{"auto", 1})),
OPT_CHOICE_OR_INT("drm-draw-plane", drm_draw_plane, 0, 0, INT_MAX,
({"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
OPT_CHOICE_OR_INT("drm-drmprime-video-plane", drm_drmprime_video_plane, 0, 0, INT_MAX,
({"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
OPT_CHOICE("drm-format", drm_format, 0,
({"xrgb8888", DRM_OPTS_FORMAT_XRGB8888},
{"xrgb2101010", DRM_OPTS_FORMAT_XRGB2101010})),
OPT_SIZE_BOX("drm-draw-surface-size", drm_draw_surface_size, 0),
{"drm-connector", OPT_STRING_VALIDATE(drm_connector_spec,
drm_validate_connector_opt)},
{"drm-mode", OPT_STRING_VALIDATE(drm_mode_spec,
drm_validate_mode_opt)},
{"drm-atomic", OPT_CHOICE(drm_atomic, {"no", 0}, {"auto", 1})},
{"drm-draw-plane", OPT_CHOICE(drm_draw_plane,
{"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE}),
M_RANGE(0, INT_MAX)},
{"drm-drmprime-video-plane", OPT_CHOICE(drm_drmprime_video_plane,
{"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE}),
M_RANGE(0, INT_MAX)},
{"drm-format", OPT_CHOICE(drm_format,
{"xrgb8888", DRM_OPTS_FORMAT_XRGB8888},
{"xrgb2101010", DRM_OPTS_FORMAT_XRGB2101010})},
{"drm-draw-surface-size", OPT_SIZE_BOX(drm_draw_surface_size)},
OPT_REPLACED("drm-osd-plane-id", "drm-draw-plane"),
OPT_REPLACED("drm-video-plane-id", "drm-drmprime-video-plane"),
OPT_REPLACED("drm-osd-size", "drm-draw-surface-size"),
{"drm-osd-plane-id", OPT_REPLACED("drm-draw-plane")},
{"drm-video-plane-id", OPT_REPLACED("drm-drmprime-video-plane")},
{"drm-osd-size", OPT_REPLACED("drm-draw-surface-size")},
{0},
},
.defaults = &(const struct drm_opts) {

View File

@ -78,16 +78,16 @@ static int validate_3dlut_size_opt(struct mp_log *log, const m_option_t *opt,
#define OPT_BASE_STRUCT struct mp_icc_opts
const struct m_sub_options mp_icc_conf = {
.opts = (const m_option_t[]) {
OPT_FLAG("use-embedded-icc-profile", use_embedded, 0),
OPT_STRING("icc-profile", profile, M_OPT_FILE),
OPT_FLAG("icc-profile-auto", profile_auto, 0),
OPT_STRING("icc-cache-dir", cache_dir, M_OPT_FILE),
OPT_INT("icc-intent", intent, 0),
OPT_CHOICE_OR_INT("icc-contrast", contrast, 0, 0, 1000000, ({"inf", -1})),
OPT_STRING_VALIDATE("icc-3dlut-size", size_str, 0, validate_3dlut_size_opt),
OPT_REPLACED("3dlut-size", "icc-3dlut-size"),
OPT_REMOVED("icc-cache", "see icc-cache-dir"),
{"use-embedded-icc-profile", OPT_FLAG(use_embedded)},
{"icc-profile", OPT_STRING(profile), .flags = M_OPT_FILE},
{"icc-profile-auto", OPT_FLAG(profile_auto)},
{"icc-cache-dir", OPT_STRING(cache_dir), .flags = M_OPT_FILE},
{"icc-intent", OPT_INT(intent)},
{"icc-contrast", OPT_CHOICE(contrast, {"inf", -1}),
M_RANGE(0, 1000000)},
{"icc-3dlut-size", OPT_STRING_VALIDATE(size_str, validate_3dlut_size_opt)},
{"3dlut-size", OPT_REPLACED("icc-3dlut-size")},
{"icc-cache", OPT_REMOVED("see icc-cache-dir")},
{0}
},
.size = sizeof(struct mp_icc_opts),

View File

@ -33,7 +33,7 @@ struct spirv_opts {
#define OPT_BASE_STRUCT struct spirv_opts
const struct m_sub_options spirv_conf = {
.opts = (const struct m_option[]) {
OPT_CHOICE_C("spirv-compiler", compiler, 0, compiler_choices),
{"spirv-compiler", OPT_CHOICE_C(compiler, compiler_choices)},
{0}
},
.size = sizeof(struct spirv_opts),

View File

@ -346,119 +346,123 @@ static int validate_error_diffusion_opt(struct mp_log *log, const m_option_t *op
#define OPT_BASE_STRUCT struct gl_video_opts
// Use for options which use NAN for defaults.
#define OPT_FLOATDEF(name, var, flags) \
OPT_FLOAT(name, var, (flags) | M_OPT_DEFAULT_NAN)
#define OPT_FLOATDEF(field) \
OPT_FLOAT(field), \
.flags = M_OPT_DEFAULT_NAN
#define SCALER_OPTS(n, i) \
OPT_STRING_VALIDATE(n, scaler[i].kernel.name, 0, validate_scaler_opt), \
OPT_FLOATDEF(n"-param1", scaler[i].kernel.params[0], 0), \
OPT_FLOATDEF(n"-param2", scaler[i].kernel.params[1], 0), \
OPT_FLOAT(n"-blur", scaler[i].kernel.blur, 0), \
OPT_FLOATRANGE(n"-cutoff", scaler[i].cutoff, 0, 0.0, 1.0), \
OPT_FLOATRANGE(n"-taper", scaler[i].kernel.taper, 0, 0.0, 1.0), \
OPT_FLOATDEF(n"-wparam", scaler[i].window.params[0], 0), \
OPT_FLOAT(n"-wblur", scaler[i].window.blur, 0), \
OPT_FLOATRANGE(n"-wtaper", scaler[i].window.taper, 0, 0.0, 1.0), \
OPT_FLOATRANGE(n"-clamp", scaler[i].clamp, 0, 0.0, 1.0), \
OPT_FLOATRANGE(n"-radius", scaler[i].radius, 0, 0.5, 16.0), \
OPT_FLOATRANGE(n"-antiring", scaler[i].antiring, 0, 0.0, 1.0), \
OPT_STRING_VALIDATE(n"-window", scaler[i].window.name, 0, validate_window_opt)
{n, OPT_STRING_VALIDATE(scaler[i].kernel.name, validate_scaler_opt)}, \
{n"-param1", OPT_FLOATDEF(scaler[i].kernel.params[0])}, \
{n"-param2", OPT_FLOATDEF(scaler[i].kernel.params[1])}, \
{n"-blur", OPT_FLOAT(scaler[i].kernel.blur)}, \
{n"-cutoff", OPT_FLOAT(scaler[i].cutoff), M_RANGE(0.0, 1.0)}, \
{n"-taper", OPT_FLOAT(scaler[i].kernel.taper), M_RANGE(0.0, 1.0)}, \
{n"-wparam", OPT_FLOATDEF(scaler[i].window.params[0])}, \
{n"-wblur", OPT_FLOAT(scaler[i].window.blur)}, \
{n"-wtaper", OPT_FLOAT(scaler[i].window.taper), M_RANGE(0.0, 1.0)}, \
{n"-clamp", OPT_FLOAT(scaler[i].clamp), M_RANGE(0.0, 1.0)}, \
{n"-radius", OPT_FLOAT(scaler[i].radius), M_RANGE(0.5, 16.0)}, \
{n"-antiring", OPT_FLOAT(scaler[i].antiring), M_RANGE(0.0, 1.0)}, \
{n"-window", OPT_STRING_VALIDATE(scaler[i].window.name, validate_window_opt)}
const struct m_sub_options gl_video_conf = {
.opts = (const m_option_t[]) {
OPT_CHOICE("gpu-dumb-mode", dumb_mode, 0,
({"auto", 0}, {"yes", 1}, {"no", -1})),
OPT_FLOATRANGE("gamma-factor", gamma, 0, 0.1, 2.0),
OPT_FLAG("gamma-auto", gamma_auto, 0),
OPT_CHOICE_C("target-prim", target_prim, 0, mp_csp_prim_names),
OPT_CHOICE_C("target-trc", target_trc, 0, mp_csp_trc_names),
OPT_CHOICE_OR_INT("target-peak", target_peak, 0, 10, 10000,
({"auto", 0})),
OPT_CHOICE("tone-mapping", tone_map.curve, 0,
({"clip", TONE_MAPPING_CLIP},
{"mobius", TONE_MAPPING_MOBIUS},
{"reinhard", TONE_MAPPING_REINHARD},
{"hable", TONE_MAPPING_HABLE},
{"gamma", TONE_MAPPING_GAMMA},
{"linear", TONE_MAPPING_LINEAR})),
OPT_CHOICE("hdr-compute-peak", tone_map.compute_peak, 0,
({"auto", 0},
{"yes", 1},
{"no", -1})),
OPT_FLOATRANGE("hdr-peak-decay-rate", tone_map.decay_rate, 0, 1.0, 1000.0),
OPT_FLOATRANGE("hdr-scene-threshold-low",
tone_map.scene_threshold_low, 0, 0, 20.0),
OPT_FLOATRANGE("hdr-scene-threshold-high",
tone_map.scene_threshold_high, 0, 0, 20.0),
OPT_FLOATDEF("tone-mapping-param", tone_map.curve_param, 0),
OPT_FLOATRANGE("tone-mapping-max-boost", tone_map.max_boost, 0, 1.0, 10.0),
OPT_FLOAT("tone-mapping-desaturate", tone_map.desat, 0),
OPT_FLOATRANGE("tone-mapping-desaturate-exponent",
tone_map.desat_exp, 0, 0.0, 20.0),
OPT_FLAG("gamut-warning", tone_map.gamut_warning, 0),
OPT_FLAG("opengl-pbo", pbo, 0),
{"gpu-dumb-mode", OPT_CHOICE(dumb_mode,
{"auto", 0}, {"yes", 1}, {"no", -1})},
{"gamma-factor", OPT_FLOAT(gamma), M_RANGE(0.1, 2.0)},
{"gamma-auto", OPT_FLAG(gamma_auto)},
{"target-prim", OPT_CHOICE_C(target_prim, mp_csp_prim_names)},
{"target-trc", OPT_CHOICE_C(target_trc, mp_csp_trc_names)},
{"target-peak", OPT_CHOICE(target_peak, {"auto", 0}),
M_RANGE(10, 10000)},
{"tone-mapping", OPT_CHOICE(tone_map.curve,
{"clip", TONE_MAPPING_CLIP},
{"mobius", TONE_MAPPING_MOBIUS},
{"reinhard", TONE_MAPPING_REINHARD},
{"hable", TONE_MAPPING_HABLE},
{"gamma", TONE_MAPPING_GAMMA},
{"linear", TONE_MAPPING_LINEAR})},
{"hdr-compute-peak", OPT_CHOICE(tone_map.compute_peak,
{"auto", 0},
{"yes", 1},
{"no", -1})},
{"hdr-peak-decay-rate", OPT_FLOAT(tone_map.decay_rate),
M_RANGE(1.0, 1000.0)},
{"hdr-scene-threshold-low", OPT_FLOAT(tone_map.scene_threshold_low),
M_RANGE(0, 20.0)},
{"hdr-scene-threshold-high", OPT_FLOAT(tone_map.scene_threshold_high),
M_RANGE(0, 20.0)},
{"tone-mapping-param", OPT_FLOATDEF(tone_map.curve_param)},
{"tone-mapping-max-boost", OPT_FLOAT(tone_map.max_boost),
M_RANGE(1.0, 10.0)},
{"tone-mapping-desaturate", OPT_FLOAT(tone_map.desat)},
{"tone-mapping-desaturate-exponent", OPT_FLOAT(tone_map.desat_exp),
M_RANGE(0.0, 20.0)},
{"gamut-warning", OPT_FLAG(tone_map.gamut_warning)},
{"opengl-pbo", OPT_FLAG(pbo)},
SCALER_OPTS("scale", SCALER_SCALE),
SCALER_OPTS("dscale", SCALER_DSCALE),
SCALER_OPTS("cscale", SCALER_CSCALE),
SCALER_OPTS("tscale", SCALER_TSCALE),
OPT_INTRANGE("scaler-lut-size", scaler_lut_size, 0, 4, 10),
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
OPT_FLAG("correct-downscaling", correct_downscaling, 0),
OPT_FLAG("linear-downscaling", linear_downscaling, 0),
OPT_FLAG("linear-upscaling", linear_upscaling, 0),
OPT_FLAG("sigmoid-upscaling", sigmoid_upscaling, 0),
OPT_FLOATRANGE("sigmoid-center", sigmoid_center, 0, 0.0, 1.0),
OPT_FLOATRANGE("sigmoid-slope", sigmoid_slope, 0, 1.0, 20.0),
OPT_STRING("fbo-format", fbo_format, 0),
OPT_CHOICE_OR_INT("dither-depth", dither_depth, 0, -1, 16,
({"no", -1}, {"auto", 0})),
OPT_CHOICE("dither", dither_algo, 0,
({"fruit", DITHER_FRUIT},
{"ordered", DITHER_ORDERED},
{"error-diffusion", DITHER_ERROR_DIFFUSION},
{"no", DITHER_NONE})),
OPT_INTRANGE("dither-size-fruit", dither_size, 0, 2, 8),
OPT_FLAG("temporal-dither", temporal_dither, 0),
OPT_INTRANGE("temporal-dither-period", temporal_dither_period, 0, 1, 128),
OPT_STRING_VALIDATE("error-diffusion", error_diffusion, 0,
validate_error_diffusion_opt),
OPT_CHOICE("alpha", alpha_mode, 0,
({"no", ALPHA_NO},
{"yes", ALPHA_YES},
{"blend", ALPHA_BLEND},
{"blend-tiles", ALPHA_BLEND_TILES})),
OPT_FLAG("opengl-rectangle-textures", use_rectangle, 0),
OPT_COLOR("background", background, 0),
OPT_FLAG("interpolation", interpolation, 0),
OPT_FLOAT("interpolation-threshold", interpolation_threshold, 0),
OPT_CHOICE("blend-subtitles", blend_subs, 0,
({"no", BLEND_SUBS_NO},
{"yes", BLEND_SUBS_YES},
{"video", BLEND_SUBS_VIDEO})),
OPT_PATHLIST("glsl-shaders", user_shaders, M_OPT_FILE),
OPT_CLI_ALIAS("glsl-shader", "glsl-shaders-append"),
OPT_FLAG("deband", deband, 0),
OPT_SUBSTRUCT("deband", deband_opts, deband_conf, 0),
OPT_FLOAT("sharpen", unsharp, 0),
OPT_INTRANGE("gpu-tex-pad-x", tex_pad_x, 0, 0, 4096),
OPT_INTRANGE("gpu-tex-pad-y", tex_pad_y, 0, 0, 4096),
OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0),
OPT_STRING("gpu-shader-cache-dir", shader_cache_dir, M_OPT_FILE),
OPT_STRING_VALIDATE("gpu-hwdec-interop", hwdec_interop, 0,
ra_hwdec_validate_opt),
OPT_REPLACED("opengl-hwdec-interop", "gpu-hwdec-interop"),
OPT_REPLACED("hwdec-preload", "opengl-hwdec-interop"),
OPT_REPLACED("hdr-tone-mapping", "tone-mapping"),
OPT_REPLACED("opengl-shaders", "glsl-shaders"),
OPT_REPLACED("opengl-shader", "glsl-shader"),
OPT_REPLACED("opengl-shader-cache-dir", "gpu-shader-cache-dir"),
OPT_REPLACED("opengl-tex-pad-x", "gpu-tex-pad-x"),
OPT_REPLACED("opengl-tex-pad-y", "gpu-tex-pad-y"),
OPT_REPLACED("opengl-fbo-format", "fbo-format"),
OPT_REPLACED("opengl-dumb-mode", "gpu-dumb-mode"),
OPT_REPLACED("opengl-gamma", "gamma-factor"),
OPT_REMOVED("linear-scaling", "Split into --linear-upscaling and "
"--linear-downscaling"),
{"scaler-lut-size", OPT_INT(scaler_lut_size), M_RANGE(4, 10)},
{"scaler-resizes-only", OPT_FLAG(scaler_resizes_only)},
{"correct-downscaling", OPT_FLAG(correct_downscaling)},
{"linear-downscaling", OPT_FLAG(linear_downscaling)},
{"linear-upscaling", OPT_FLAG(linear_upscaling)},
{"sigmoid-upscaling", OPT_FLAG(sigmoid_upscaling)},
{"sigmoid-center", OPT_FLOAT(sigmoid_center), M_RANGE(0.0, 1.0)},
{"sigmoid-slope", OPT_FLOAT(sigmoid_slope), M_RANGE(1.0, 20.0)},
{"fbo-format", OPT_STRING(fbo_format)},
{"dither-depth", OPT_CHOICE(dither_depth, {"no", -1}, {"auto", 0}),
M_RANGE(-1, 16)},
{"dither", OPT_CHOICE(dither_algo,
{"fruit", DITHER_FRUIT},
{"ordered", DITHER_ORDERED},
{"error-diffusion", DITHER_ERROR_DIFFUSION},
{"no", DITHER_NONE})},
{"dither-size-fruit", OPT_INT(dither_size), M_RANGE(2, 8)},
{"temporal-dither", OPT_FLAG(temporal_dither)},
{"temporal-dither-period", OPT_INT(temporal_dither_period),
M_RANGE(1, 128)},
{"error-diffusion",
OPT_STRING_VALIDATE(error_diffusion, validate_error_diffusion_opt)},
{"alpha", OPT_CHOICE(alpha_mode,
{"no", ALPHA_NO},
{"yes", ALPHA_YES},
{"blend", ALPHA_BLEND},
{"blend-tiles", ALPHA_BLEND_TILES})},
{"opengl-rectangle-textures", OPT_FLAG(use_rectangle)},
{"background", OPT_COLOR(background)},
{"interpolation", OPT_FLAG(interpolation)},
{"interpolation-threshold", OPT_FLOAT(interpolation_threshold)},
{"blend-subtitles", OPT_CHOICE(blend_subs,
{"no", BLEND_SUBS_NO},
{"yes", BLEND_SUBS_YES},
{"video", BLEND_SUBS_VIDEO})},
{"glsl-shaders", OPT_PATHLIST(user_shaders), .flags = M_OPT_FILE},
{"glsl-shader", OPT_CLI_ALIAS("glsl-shaders-append")},
{"deband", OPT_FLAG(deband)},
{"deband", OPT_SUBSTRUCT(deband_opts, deband_conf)},
{"sharpen", OPT_FLOAT(unsharp)},
{"gpu-tex-pad-x", OPT_INT(tex_pad_x), M_RANGE(0, 4096)},
{"gpu-tex-pad-y", OPT_INT(tex_pad_y), M_RANGE(0, 4096)},
{"", OPT_SUBSTRUCT(icc_opts, mp_icc_conf)},
{"gpu-shader-cache-dir", OPT_STRING(shader_cache_dir), .flags = M_OPT_FILE},
{"gpu-hwdec-interop",
OPT_STRING_VALIDATE(hwdec_interop, ra_hwdec_validate_opt)},
{"opengl-hwdec-interop", OPT_REPLACED("gpu-hwdec-interop")},
{"hwdec-preload", OPT_REPLACED("opengl-hwdec-interop")},
{"hdr-tone-mapping", OPT_REPLACED("tone-mapping")},
{"opengl-shaders", OPT_REPLACED("glsl-shaders")},
{"opengl-shader", OPT_REPLACED("glsl-shader")},
{"opengl-shader-cache-dir", OPT_REPLACED("gpu-shader-cache-dir")},
{"opengl-tex-pad-x", OPT_REPLACED("gpu-tex-pad-x")},
{"opengl-tex-pad-y", OPT_REPLACED("gpu-tex-pad-y")},
{"opengl-fbo-format", OPT_REPLACED("fbo-format")},
{"opengl-dumb-mode", OPT_REPLACED("gpu-dumb-mode")},
{"opengl-gamma", OPT_REPLACED("gamma-factor")},
{"linear-scaling", OPT_REMOVED("Split into --linear-upscaling and "
"--linear-downscaling")},
{0}
},
.size = sizeof(struct gl_video_opts),

View File

@ -882,10 +882,10 @@ const struct deband_opts deband_opts_def = {
#define OPT_BASE_STRUCT struct deband_opts
const struct m_sub_options deband_conf = {
.opts = (const m_option_t[]) {
OPT_INTRANGE("iterations", iterations, 0, 1, 16),
OPT_FLOATRANGE("threshold", threshold, 0, 0.0, 4096.0),
OPT_FLOATRANGE("range", range, 0, 1.0, 64.0),
OPT_FLOATRANGE("grain", grain, 0, 0.0, 4096.0),
{"iterations", OPT_INT(iterations), M_RANGE(1, 16)},
{"threshold", OPT_FLOAT(threshold), M_RANGE(0.0, 4096.0)},
{"range", OPT_FLOAT(range), M_RANGE(1.0, 64.0)},
{"grain", OPT_FLOAT(grain), M_RANGE(0.0, 4096.0)},
{0}
},
.size = sizeof(struct deband_opts),

View File

@ -59,21 +59,20 @@ struct opengl_opts {
#define OPT_BASE_STRUCT struct opengl_opts
const struct m_sub_options opengl_conf = {
.opts = (const struct m_option[]) {
OPT_FLAG("opengl-glfinish", use_glfinish, 0),
OPT_FLAG("opengl-waitvsync", waitvsync, 0),
OPT_INT("opengl-swapinterval", swapinterval, 0),
OPT_INT("opengl-check-pattern-a", vsync_pattern[0], 0),
OPT_INT("opengl-check-pattern-b", vsync_pattern[1], 0),
OPT_INT("opengl-restrict", restrict_version, 0),
OPT_CHOICE("opengl-es", gles_mode, 0,
({"auto", GLES_AUTO}, {"yes", GLES_YES}, {"no", GLES_NO})),
OPT_CHOICE("opengl-early-flush", early_flush, 0,
({"no", FLUSH_NO}, {"yes", FLUSH_YES}, {"auto", FLUSH_AUTO})),
OPT_REPLACED("opengl-debug", "gpu-debug"),
OPT_REPLACED("opengl-sw", "gpu-sw"),
OPT_REPLACED("opengl-vsync-fences", "swapchain-depth"),
OPT_REPLACED("opengl-backend", "gpu-context"),
{"opengl-glfinish", OPT_FLAG(use_glfinish)},
{"opengl-waitvsync", OPT_FLAG(waitvsync)},
{"opengl-swapinterval", OPT_INT(swapinterval)},
{"opengl-check-pattern-a", OPT_INT(vsync_pattern[0])},
{"opengl-check-pattern-b", OPT_INT(vsync_pattern[1])},
{"opengl-restrict", OPT_INT(restrict_version)},
{"opengl-es", OPT_CHOICE(gles_mode,
{"auto", GLES_AUTO}, {"yes", GLES_YES}, {"no", GLES_NO})},
{"opengl-early-flush", OPT_CHOICE(early_flush,
{"no", FLUSH_NO}, {"yes", FLUSH_YES}, {"auto", FLUSH_AUTO})},
{"opengl-debug", OPT_REPLACED("gpu-debug")},
{"opengl-sw", OPT_REPLACED("gpu-sw")},
{"opengl-vsync-fences", OPT_REPLACED("swapchain-depth")},
{"opengl-backend", OPT_REPLACED("gpu-context")},
{0},
},
.defaults = &(const struct opengl_opts) {

View File

@ -59,26 +59,26 @@ struct angle_opts {
#define OPT_BASE_STRUCT struct angle_opts
const struct m_sub_options angle_conf = {
.opts = (const struct m_option[]) {
OPT_CHOICE("angle-renderer", renderer, 0,
({"auto", RENDERER_AUTO},
{"d3d9", RENDERER_D3D9},
{"d3d11", RENDERER_D3D11})),
OPT_CHOICE("angle-d3d11-warp", d3d11_warp, 0,
({"auto", -1},
{"no", 0},
{"yes", 1})),
OPT_CHOICE("angle-d3d11-feature-level", d3d11_feature_level, 0,
({"11_0", D3D_FEATURE_LEVEL_11_0},
{"10_1", D3D_FEATURE_LEVEL_10_1},
{"10_0", D3D_FEATURE_LEVEL_10_0},
{"9_3", D3D_FEATURE_LEVEL_9_3})),
OPT_CHOICE("angle-egl-windowing", egl_windowing, 0,
({"auto", -1},
{"no", 0},
{"yes", 1})),
OPT_FLAG("angle-flip", flip, 0),
OPT_REPLACED("angle-max-frame-latency", "swapchain-depth"),
OPT_REMOVED("angle-swapchain-length", "controlled by --swapchain-depth"),
{"angle-renderer", OPT_CHOICE(renderer,
{"auto", RENDERER_AUTO},
{"d3d9", RENDERER_D3D9},
{"d3d11", RENDERER_D3D11})},
{"angle-d3d11-warp", OPT_CHOICE(d3d11_warp,
{"auto", -1},
{"no", 0},
{"yes", 1})},
{"angle-d3d11-feature-level", OPT_CHOICE(d3d11_feature_level,
{"11_0", D3D_FEATURE_LEVEL_11_0},
{"10_1", D3D_FEATURE_LEVEL_10_1},
{"10_0", D3D_FEATURE_LEVEL_10_0},
{"9_3", D3D_FEATURE_LEVEL_9_3})},
{"angle-egl-windowing", OPT_CHOICE(egl_windowing,
{"auto", -1},
{"no", 0},
{"yes", 1})},
{"angle-flip", OPT_FLAG(flip)},
{"angle-max-frame-latency", OPT_REPLACED("swapchain-depth")},
{"angle-swapchain-length", OPT_REMOVED("controlled by --swapchain-depth")},
{0}
},
.defaults = &(const struct angle_opts) {

View File

@ -28,7 +28,7 @@ struct cocoa_opts {
#define OPT_BASE_STRUCT struct cocoa_opts
const struct m_sub_options cocoa_conf = {
.opts = (const struct m_option[]) {
OPT_REPLACED("cocoa-force-dedicated-gpu", "macos-force-dedicated-gpu"),
{"cocoa-force-dedicated-gpu", OPT_REPLACED("macos-force-dedicated-gpu")},
{0}
},
.size = sizeof(struct cocoa_opts),

View File

@ -1684,21 +1684,21 @@ static void draw_osd(struct vo *vo)
#define OPT_BASE_STRUCT d3d_priv
static const struct m_option opts[] = {
OPT_FLAG("prefer-stretchrect", opt_prefer_stretchrect, 0),
OPT_FLAG("disable-textures", opt_disable_textures, 0),
OPT_FLAG("disable-stretchrect", opt_disable_stretchrect, 0),
OPT_FLAG("disable-shaders", opt_disable_shaders, 0),
OPT_FLAG("only-8bit", opt_only_8bit, 0),
OPT_FLAG("force-power-of-2", opt_force_power_of_2, 0),
OPT_FLAG("disable-texture-align", opt_disable_texture_align, 0),
OPT_CHOICE("texture-memory", opt_texture_memory, 0,
({"default", 0},
{"managed", 1},
{"default-pool", 2},
{"default-pool-shadow", 3},
{"scratch", 4})),
OPT_FLAG("swap-discard", opt_swap_discard, 0),
OPT_FLAG("exact-backbuffer", opt_exact_backbuffer, 0),
{"prefer-stretchrect", OPT_FLAG(opt_prefer_stretchrect)},
{"disable-textures", OPT_FLAG(opt_disable_textures)},
{"disable-stretchrect", OPT_FLAG(opt_disable_stretchrect)},
{"disable-shaders", OPT_FLAG(opt_disable_shaders)},
{"only-8bit", OPT_FLAG(opt_only_8bit)},
{"force-power-of-2", OPT_FLAG(opt_force_power_of_2)},
{"disable-texture-align", OPT_FLAG(opt_disable_texture_align)},
{"texture-memory", OPT_CHOICE(opt_texture_memory,
{"default", 0},
{"managed", 1},
{"default-pool", 2},
{"default-pool-shadow", 3},
{"scratch", 4})},
{"swap-discard", OPT_FLAG(opt_swap_discard)},
{"exact-backbuffer", OPT_FLAG(opt_exact_backbuffer)},
{0}
};

View File

@ -311,10 +311,10 @@ err_out:
#define OPT_BASE_STRUCT struct gpu_priv
static const m_option_t options[] = {
OPT_STRING_VALIDATE("gpu-context", context_name, 0, ra_ctx_validate_context),
OPT_STRING_VALIDATE("gpu-api", context_type, 0, ra_ctx_validate_api),
OPT_FLAG("gpu-debug", opts.debug, 0),
OPT_FLAG("gpu-sw", opts.allow_sw, 0),
{"gpu-context", OPT_STRING_VALIDATE(context_name, ra_ctx_validate_context)},
{"gpu-api", OPT_STRING_VALIDATE(context_type, ra_ctx_validate_api)},
{"gpu-debug", OPT_FLAG(opts.debug)},
{"gpu-sw", OPT_FLAG(opts.allow_sw)},
{0}
};

View File

@ -56,8 +56,8 @@ struct vo_image_opts {
static const struct m_sub_options vo_image_conf = {
.opts = (const struct m_option[]) {
OPT_SUBSTRUCT("vo-image", opts, image_writer_conf, 0),
OPT_STRING("vo-image-outdir", outdir, M_OPT_FILE),
{"vo-image", OPT_SUBSTRUCT(opts, image_writer_conf)},
{"vo-image-outdir", OPT_STRING(outdir), .flags = M_OPT_FILE},
{0},
},
.size = sizeof(struct vo_image_opts),

View File

@ -98,7 +98,7 @@ const struct vo_driver video_out_null = {
.uninit = uninit,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
OPT_DOUBLE("fps", cfg_fps, 0, .min = 0, .max = 10000),
{"fps", OPT_DOUBLE(cfg_fps), M_RANGE(0, 10000)},
{0},
},
.options_prefix = "vo-null",

View File

@ -889,10 +889,10 @@ fail:
#define OPT_BASE_STRUCT struct priv
static const struct m_option options[] = {
OPT_INT("display", display_nr, 0),
OPT_INT("layer", layer, 0, OPTDEF_INT(-10)),
OPT_FLAG("background", background, 0),
OPT_FLAG("osd", enable_osd, 0, OPTDEF_INT(1)),
{"display", OPT_INT(display_nr)},
{"layer", OPT_INT(layer), OPTDEF_INT(-10)},
{"background", OPT_FLAG(background)},
{"osd", OPT_FLAG(enable_osd), OPTDEF_INT(1)},
{0},
};

View File

@ -980,9 +980,9 @@ const struct vo_driver video_out_sdl = {
.screensaver_enabled = false,
},
.options = (const struct m_option []){
OPT_FLAG("sw", allow_sw, 0),
OPT_FLAG("switch-mode", switch_mode, 0),
OPT_FLAG("vsync", vsync, 0),
{"sw", OPT_FLAG(allow_sw)},
{"switch-mode", OPT_FLAG(switch_mode)},
{"vsync", OPT_FLAG(vsync)},
{NULL}
},
.preinit = preinit,

View File

@ -58,12 +58,12 @@ struct vo_tct_opts {
#define OPT_BASE_STRUCT struct vo_tct_opts
static const struct m_sub_options vo_tct_conf = {
.opts = (const m_option_t[]) {
OPT_CHOICE("vo-tct-algo", algo, 0,
({"plain", ALGO_PLAIN},
{"half-blocks", ALGO_HALF_BLOCKS})),
OPT_INT("vo-tct-width", width, 0),
OPT_INT("vo-tct-height", height, 0),
OPT_FLAG("vo-tct-256", term256, 0),
{"vo-tct-algo", OPT_CHOICE(algo,
{"plain", ALGO_PLAIN},
{"half-blocks", ALGO_HALF_BLOCKS})},
{"vo-tct-width", OPT_INT(width)},
{"vo-tct-height", OPT_INT(height)},
{"vo-tct-256", OPT_FLAG(term256)},
{0}
},
.defaults = &(const struct vo_tct_opts) {

View File

@ -897,12 +897,12 @@ const struct vo_driver video_out_vaapi = {
.scaling = VA_FILTER_SCALING_DEFAULT,
},
.options = (const struct m_option[]) {
OPT_CHOICE("scaling", scaling, 0,
({"default", VA_FILTER_SCALING_DEFAULT},
{"fast", VA_FILTER_SCALING_FAST},
{"hq", VA_FILTER_SCALING_HQ},
{"nla", VA_FILTER_SCALING_NL_ANAMORPHIC})),
OPT_FLAG("scaled-osd", force_scaled_osd, 0),
{"scaling", OPT_CHOICE(scaling,
{"default", VA_FILTER_SCALING_DEFAULT},
{"fast", VA_FILTER_SCALING_FAST},
{"hq", VA_FILTER_SCALING_HQ},
{"nla", VA_FILTER_SCALING_NL_ANAMORPHIC})},
{"scaled-osd", OPT_FLAG(force_scaled_osd)},
{0}
},
.options_prefix = "vo-vaapi",

View File

@ -1115,26 +1115,24 @@ const struct vo_driver video_out_vdpau = {
.uninit = uninit,
.priv_size = sizeof(struct vdpctx),
.options = (const struct m_option []){
OPT_INTRANGE("deint", deint, 0, -4, 4),
OPT_FLAG("chroma-deint", chroma_deint, 0, OPTDEF_INT(1)),
OPT_FLAG("pullup", pullup, 0),
OPT_FLOATRANGE("denoise", denoise, 0, 0, 1),
OPT_FLOATRANGE("sharpen", sharpen, 0, -1, 1),
OPT_INTRANGE("hqscaling", hqscaling, 0, 0, 9),
OPT_FLOAT("fps", user_fps, 0),
OPT_FLAG("composite-detect", composite_detect, 0, OPTDEF_INT(1)),
OPT_INT("queuetime-windowed", flip_offset_window, 0, OPTDEF_INT(50)),
OPT_INT("queuetime-fs", flip_offset_fs, 0, OPTDEF_INT(50)),
OPT_INTRANGE("output-surfaces", num_output_surfaces, 0,
2, MAX_OUTPUT_SURFACES, OPTDEF_INT(3)),
OPT_COLOR("colorkey", colorkey, 0,
.defval = &(const struct m_color) {
.r = 2, .g = 5, .b = 7, .a = 255,
}),
OPT_FLAG("force-yuv", force_yuv, 0),
OPT_REPLACED("queuetime_windowed", "queuetime-windowed"),
OPT_REPLACED("queuetime_fs", "queuetime-fs"),
OPT_REPLACED("output_surfaces", "output-surfaces"),
{"deint", OPT_INT(deint), M_RANGE(-4, 4)},
{"chroma-deint", OPT_FLAG(chroma_deint), OPTDEF_INT(1)},
{"pullup", OPT_FLAG(pullup)},
{"denoise", OPT_FLOAT(denoise), M_RANGE(0, 1)},
{"sharpen", OPT_FLOAT(sharpen), M_RANGE(-1, 1)},
{"hqscaling", OPT_INT(hqscaling), M_RANGE(0, 9)},
{"fps", OPT_FLOAT(user_fps)},
{"composite-detect", OPT_FLAG(composite_detect), OPTDEF_INT(1)},
{"queuetime-windowed", OPT_INT(flip_offset_window), OPTDEF_INT(50)},
{"queuetime-fs", OPT_INT(flip_offset_fs), OPTDEF_INT(50)},
{"output-surfaces", OPT_INT(num_output_surfaces),
M_RANGE(2, MAX_OUTPUT_SURFACES), OPTDEF_INT(3)},
{"colorkey", OPT_COLOR(colorkey),
.defval = &(const struct m_color){.r = 2, .g = 5, .b = 7, .a = 255}},
{"force-yuv", OPT_FLAG(force_yuv)},
{"queuetime_windowed", OPT_REPLACED("queuetime-windowed")},
{"queuetime_fs", OPT_REPLACED("queuetime-fs")},
{"output_surfaces", OPT_REPLACED("output-surfaces")},
{NULL},
},
.options_prefix = "vo-vdpau",

View File

@ -898,20 +898,20 @@ const struct vo_driver video_out_xv = {
.cfg_buffers = 2,
},
.options = (const struct m_option[]) {
OPT_INT("port", xv_port, 0, .min = 0, .max = DBL_MAX),
OPT_INT("adaptor", cfg_xv_adaptor, 0, .min = -1, .max = DBL_MAX),
OPT_CHOICE("ck", xv_ck_info.source, 0,
({"use", CK_SRC_USE},
{"set", CK_SRC_SET},
{"cur", CK_SRC_CUR})),
OPT_CHOICE("ck-method", xv_ck_info.method, 0,
({"none", CK_METHOD_NONE},
{"bg", CK_METHOD_BACKGROUND},
{"man", CK_METHOD_MANUALFILL},
{"auto", CK_METHOD_AUTOPAINT})),
OPT_INT("colorkey", colorkey, 0),
OPT_INTRANGE("buffers", cfg_buffers, 0, 1, MAX_BUFFERS),
OPT_REMOVED("no-colorkey", "use ck-method=none instead"),
{"port", OPT_INT(xv_port), M_RANGE(0, DBL_MAX)},
{"adaptor", OPT_INT(cfg_xv_adaptor), M_RANGE(-1, DBL_MAX)},
{"ck", OPT_CHOICE(xv_ck_info.source,
{"use", CK_SRC_USE},
{"set", CK_SRC_SET},
{"cur", CK_SRC_CUR})},
{"ck-method", OPT_CHOICE(xv_ck_info.method,
{"none", CK_METHOD_NONE},
{"bg", CK_METHOD_BACKGROUND},
{"man", CK_METHOD_MANUALFILL},
{"auto", CK_METHOD_AUTOPAINT})},
{"colorkey", OPT_INT(colorkey)},
{"buffers", OPT_INT(cfg_buffers), M_RANGE(1, MAX_BUFFERS)},
{"no-colorkey", OPT_REMOVED("use ck-method=none instead")},
{0}
},
.options_prefix = "xv",

View File

@ -87,16 +87,16 @@ done:
#define OPT_BASE_STRUCT struct vulkan_opts
const struct m_sub_options vulkan_conf = {
.opts = (const struct m_option[]) {
OPT_STRING_VALIDATE("vulkan-device", device, 0, vk_validate_dev),
OPT_CHOICE("vulkan-swap-mode", swap_mode, 0,
({"auto", -1},
{"fifo", VK_PRESENT_MODE_FIFO_KHR},
{"fifo-relaxed", VK_PRESENT_MODE_FIFO_RELAXED_KHR},
{"mailbox", VK_PRESENT_MODE_MAILBOX_KHR},
{"immediate", VK_PRESENT_MODE_IMMEDIATE_KHR})),
OPT_INTRANGE("vulkan-queue-count", queue_count, 0, 1, 8),
OPT_FLAG("vulkan-async-transfer", async_transfer, 0),
OPT_FLAG("vulkan-async-compute", async_compute, 0),
{"vulkan-device", OPT_STRING_VALIDATE(device, vk_validate_dev)},
{"vulkan-swap-mode", OPT_CHOICE(swap_mode,
{"auto", -1},
{"fifo", VK_PRESENT_MODE_FIFO_KHR},
{"fifo-relaxed", VK_PRESENT_MODE_FIFO_RELAXED_KHR},
{"mailbox", VK_PRESENT_MODE_MAILBOX_KHR},
{"immediate", VK_PRESENT_MODE_IMMEDIATE_KHR})},
{"vulkan-queue-count", OPT_INT(queue_count), M_RANGE(1, 8)},
{"vulkan-async-transfer", OPT_FLAG(async_transfer)},
{"vulkan-async-compute", OPT_FLAG(async_compute)},
{0}
},
.size = sizeof(struct vulkan_opts),

View File

@ -45,9 +45,11 @@
#define OPT_BASE_STRUCT struct wayland_opts
const struct m_sub_options wayland_conf = {
.opts = (const struct m_option[]) {
OPT_FLAG("wayland-disable-vsync", disable_vsync, 0),
OPT_INTRANGE("wayland-edge-pixels-pointer", edge_pixels_pointer, 10, 0, INT_MAX),
OPT_INTRANGE("wayland-edge-pixels-touch", edge_pixels_touch, 64, 0, INT_MAX),
{"wayland-disable-vsync", OPT_FLAG(disable_vsync)},
{"wayland-edge-pixels-pointer", OPT_INT(edge_pixels_pointer),
M_RANGE(0, INT_MAX)},
{"wayland-edge-pixels-touch", OPT_INT(edge_pixels_touch),
M_RANGE(0, INT_MAX)},
{0},
},
.size = sizeof(struct wayland_opts),

View File

@ -57,27 +57,27 @@ struct sws_opts {
#define OPT_BASE_STRUCT struct sws_opts
const struct m_sub_options sws_conf = {
.opts = (const m_option_t[]) {
OPT_CHOICE("scaler", scaler, 0,
({"fast-bilinear", SWS_FAST_BILINEAR},
{"bilinear", SWS_BILINEAR},
{"bicubic", SWS_BICUBIC},
{"x", SWS_X},
{"point", SWS_POINT},
{"area", SWS_AREA},
{"bicublin", SWS_BICUBLIN},
{"gauss", SWS_GAUSS},
{"sinc", SWS_SINC},
{"lanczos", SWS_LANCZOS},
{"spline", SWS_SPLINE})),
OPT_FLOATRANGE("lgb", lum_gblur, 0, 0, 100.0),
OPT_FLOATRANGE("cgb", chr_gblur, 0, 0, 100.0),
OPT_INT("cvs", chr_vshift, 0),
OPT_INT("chs", chr_hshift, 0),
OPT_FLOATRANGE("ls", lum_sharpen, 0, -100.0, 100.0),
OPT_FLOATRANGE("cs", chr_sharpen, 0, -100.0, 100.0),
OPT_FLAG("fast", fast, 0),
OPT_FLAG("bitexact", bitexact, 0),
OPT_FLAG("allow-zimg", zimg, 0),
{"scaler", OPT_CHOICE(scaler,
{"fast-bilinear", SWS_FAST_BILINEAR},
{"bilinear", SWS_BILINEAR},
{"bicubic", SWS_BICUBIC},
{"x", SWS_X},
{"point", SWS_POINT},
{"area", SWS_AREA},
{"bicublin", SWS_BICUBLIN},
{"gauss", SWS_GAUSS},
{"sinc", SWS_SINC},
{"lanczos", SWS_LANCZOS},
{"spline", SWS_SPLINE})},
{"lgb", OPT_FLOAT(lum_gblur), M_RANGE(0, 100.0)},
{"cgb", OPT_FLOAT(chr_gblur), M_RANGE(0, 100.0)},
{"cvs", OPT_INT(chr_vshift)},
{"chs", OPT_INT(chr_hshift)},
{"ls", OPT_FLOAT(lum_sharpen), M_RANGE(-100.0, 100.0)},
{"cs", OPT_FLOAT(chr_sharpen), M_RANGE(-100.0, 100.0)},
{"fast", OPT_FLAG(fast)},
{"bitexact", OPT_FLAG(bitexact)},
{"allow-zimg", OPT_FLAG(zimg)},
{0}
},
.size = sizeof(struct sws_opts),

View File

@ -38,7 +38,7 @@ struct vaapi_opts {
#define OPT_BASE_STRUCT struct vaapi_opts
const struct m_sub_options vaapi_conf = {
.opts = (const struct m_option[]) {
OPT_STRING("device", path, 0),
{"device", OPT_STRING(path)},
{0},
},
.defaults = &(const struct vaapi_opts) {

View File

@ -39,24 +39,23 @@ static const struct m_opt_choice_alternatives mp_zimg_scalers[] = {
{0}
};
#define OPT_PARAM(name, var, flags) \
OPT_DOUBLE(name, var, (flags) | M_OPT_DEFAULT_NAN)
#define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN
#define OPT_BASE_STRUCT struct zimg_opts
const struct m_sub_options zimg_conf = {
.opts = (struct m_option[]) {
OPT_CHOICE_C("scaler", scaler, 0, mp_zimg_scalers),
OPT_PARAM("scaler-param-a", scaler_params[0], 0),
OPT_PARAM("scaler-param-b", scaler_params[1], 0),
OPT_CHOICE_C("scaler-chroma", scaler_chroma, 0, mp_zimg_scalers),
OPT_PARAM("scaler-chroma-param-a", scaler_chroma_params[0], 0),
OPT_PARAM("scaler-chroma-param-b", scaler_chroma_params[1], 0),
OPT_CHOICE("dither", dither, 0,
({"no", ZIMG_DITHER_NONE},
{"ordered", ZIMG_DITHER_ORDERED},
{"random", ZIMG_DITHER_RANDOM},
{"error-diffusion", ZIMG_DITHER_ERROR_DIFFUSION})),
OPT_FLAG("fast", fast, 0),
{"scaler", OPT_CHOICE_C(scaler, mp_zimg_scalers)},
{"scaler-param-a", OPT_PARAM(scaler_params[0])},
{"scaler-param-b", OPT_PARAM(scaler_params[1])},
{"scaler-chroma", OPT_CHOICE_C(scaler_chroma, mp_zimg_scalers)},
{"scaler-chroma-param-a", OPT_PARAM(scaler_chroma_params[0])},
{"scaler-chroma-param-b", OPT_PARAM(scaler_chroma_params[1])},
{"dither", OPT_CHOICE(dither,
{"no", ZIMG_DITHER_NONE},
{"ordered", ZIMG_DITHER_ORDERED},
{"random", ZIMG_DITHER_RANDOM},
{"error-diffusion", ZIMG_DITHER_ERROR_DIFFUSION})},
{"fast", OPT_FLAG(fast)},
{0}
},
.size = sizeof(struct zimg_opts),