From 26f4f18c0629998a9b91e94722d166866d8b80a3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 14 Mar 2020 21:28:01 +0100 Subject: [PATCH] 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. --- DOCS/tech-overview.txt | 2 +- audio/decode/ad_lavc.c | 8 +- audio/filter/af_format.c | 12 +- audio/filter/af_lavcac3enc.c | 12 +- audio/filter/af_rubberband.c | 58 +- audio/filter/af_scaletempo.c | 18 +- audio/out/ao.c | 11 +- audio/out/ao_alsa.c | 16 +- audio/out/ao_audiotrack.c | 4 +- audio/out/ao_coreaudio.c | 2 +- audio/out/ao_coreaudio_exclusive.c | 2 +- audio/out/ao_jack.c | 12 +- audio/out/ao_null.c | 18 +- audio/out/ao_openal.c | 6 +- audio/out/ao_opensles.c | 6 +- audio/out/ao_oss.c | 4 +- audio/out/ao_pcm.c | 6 +- audio/out/ao_pulse.c | 9 +- audio/out/ao_sdl.c | 2 +- common/encode_lavc.c | 50 +- demux/cache.c | 7 +- demux/demux.c | 57 +- demux/demux_cue.c | 2 +- demux/demux_lavf.c | 47 +- demux/demux_libarchive.c | 2 +- demux/demux_mkv.c | 18 +- demux/demux_raw.c | 56 +- filters/f_decoder_wrapper.c | 41 +- filters/f_lavfi.c | 22 +- filters/f_swresample.c | 15 +- input/cmd.h | 3 - input/input.c | 35 +- options/m_option.h | 232 +++---- options/options.c | 1029 ++++++++++++++-------------- osdep/macosx_application.m | 48 +- player/command.c | 355 +++++----- stream/stream.c | 6 +- stream/stream_cdda.c | 22 +- stream/stream_dvb.c | 14 +- stream/stream_lavf.c | 24 +- sub/osd.c | 44 +- video/csputils.c | 19 +- video/decode/vd_lavc.c | 43 +- video/filter/vf_d3d11vpp.c | 18 +- video/filter/vf_fingerprint.c | 6 +- video/filter/vf_format.c | 36 +- video/filter/vf_gpu.c | 4 +- video/filter/vf_sub.c | 4 +- video/filter/vf_vapoursynth.c | 9 +- video/filter/vf_vavpp.c | 22 +- video/filter/vf_vdpaupp.c | 26 +- video/image_writer.c | 20 +- video/out/android_common.c | 3 +- video/out/d3d11/context.c | 60 +- video/out/d3d11/hwdec_d3d11va.c | 2 +- video/out/drm_common.c | 40 +- video/out/gpu/lcms.c | 20 +- video/out/gpu/spirv.c | 2 +- video/out/gpu/video.c | 212 +++--- video/out/gpu/video_shaders.c | 8 +- video/out/opengl/context.c | 29 +- video/out/opengl/context_angle.c | 40 +- video/out/opengl/context_cocoa.c | 2 +- video/out/vo_direct3d.c | 30 +- video/out/vo_gpu.c | 8 +- video/out/vo_image.c | 4 +- video/out/vo_null.c | 2 +- video/out/vo_rpi.c | 8 +- video/out/vo_sdl.c | 6 +- video/out/vo_tct.c | 12 +- video/out/vo_vaapi.c | 12 +- video/out/vo_vdpau.c | 38 +- video/out/vo_xv.c | 28 +- video/out/vulkan/context.c | 20 +- video/out/wayland_common.c | 8 +- video/sws_utils.c | 42 +- video/vaapi.c | 2 +- video/zimg.c | 27 +- 78 files changed, 1608 insertions(+), 1601 deletions(-) diff --git a/DOCS/tech-overview.txt b/DOCS/tech-overview.txt index fba894606a..4bb06ff764 100644 --- a/DOCS/tech-overview.txt +++ b/DOCS/tech-overview.txt @@ -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 diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index a4e06822b7..eaaf0729e9 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -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), diff --git a/audio/filter/af_format.c b/audio/filter/af_format.c index 3e1eef664c..79d78d1d96 100644 --- a/audio/filter/af_format.c +++ b/audio/filter/af_format.c @@ -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} }, }, diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index c7582cf52b..38f93a1c08 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -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} }, }, diff --git a/audio/filter/af_rubberband.c b/audio/filter/af_rubberband.c index 4c2b69049d..4df2001c49 100644 --- a/audio/filter/af_rubberband.c +++ b/audio/filter/af_rubberband.c @@ -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} }, }, diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index b76abc8e78..911fd8914e 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -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} }, }, diff --git a/audio/out/ao.c b/audio/out/ao.c index 0136afca15..42e2cf63d5 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -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), diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index bb67fd84a8..b4fa18891b 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -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) { diff --git a/audio/out/ao_audiotrack.c b/audio/out/ao_audiotrack.c index f54f2584c0..b3be357c1b 100644 --- a/audio/out/ao_audiotrack.c +++ b/audio/out/ao_audiotrack.c @@ -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", diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index 2e02c6842b..533d102d32 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -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", diff --git a/audio/out/ao_coreaudio_exclusive.c b/audio/out/ao_coreaudio_exclusive.c index a5d4601384..19721e0951 100644 --- a/audio/out/ao_coreaudio_exclusive.c +++ b/audio/out/ao_coreaudio_exclusive.c @@ -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", diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c index 0d5a2da207..249c314f9d 100644 --- a/audio/out/ao_jack.c +++ b/audio/out/ao_jack.c @@ -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) { diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c index 3880ee8aa4..7e15b58e00 100644 --- a/audio/out/ao_null.c +++ b/audio/out/ao_null.c @@ -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", diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c index 2af9fadb4f..53fcaca05e 100644 --- a/audio/out/ao_openal.c +++ b/audio/out/ao_openal.c @@ -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", diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c index 482a85afea..67ebd46aff 100644 --- a/audio/out/ao_opensles.c +++ b/audio/out/ao_opensles.c @@ -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", diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index fbc535e413..fe87a3db73 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -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", diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index 5de213f07d..7d2656be49 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -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", diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 5b4ced6f11..fc5fb0caeb 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -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", diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c index 6144918dfe..c1c09b8c92 100644 --- a/audio/out/ao_sdl.c +++ b/audio/out/ao_sdl.c @@ -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", diff --git a/common/encode_lavc.c b/common/encode_lavc.c index b64232fb87..d246fdd6b6 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -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), diff --git a/demux/cache.c b/demux/cache.c index 4404c870de..f48598807c 100644 --- a/demux/cache.c +++ b/demux/cache.c @@ -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), diff --git a/demux/demux.c b/demux/demux.c index 82641cb6af..f5ced47887 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -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), diff --git a/demux/demux_cue.c b/demux/demux_cue.c index edd1a97d1b..b7b425af03 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -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), diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 212f954090..50b9e044e4 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -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), diff --git a/demux/demux_libarchive.c b/demux/demux_libarchive.c index 4be5193b22..dc8d201b19 100644 --- a/demux/demux_libarchive.c +++ b/demux/demux_libarchive.c @@ -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), diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index f16f537bd3..64cab29c03 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -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), diff --git a/demux/demux_raw.c b/demux/demux_raw.c index de657feb8c..e606a24c9f 100644 --- a/demux/demux_raw.c +++ b/demux/demux_raw.c @@ -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), diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index 6b297b671f..b49ec921c1 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -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), diff --git a/filters/f_lavfi.c b/filters/f_lavfi.c index 2e612d14fc..9e64215f39 100644 --- a/filters/f_lavfi.c +++ b/filters/f_lavfi.c @@ -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){ diff --git a/filters/f_swresample.c b/filters/f_swresample.c index 0197ca9662..4f26d82a59 100644 --- a/filters/f_swresample.c +++ b/filters/f_swresample.c @@ -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), diff --git a/input/cmd.h b/input/cmd.h index c22672b9d3..3ed07e8028 100644 --- a/input/cmd.h +++ b/input/cmd.h @@ -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 diff --git a/input/input.c b/input/input.c index f9475648b0..5a606fd189 100644 --- a/input/input.c +++ b/input/input.c @@ -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} }, diff --git a/options/m_option.h b/options/m_option.h index 97383237a5..fc48b42bd2 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -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 */ diff --git a/options/options.c b/options/options.c index b237c0b268..f6e1569994 100644 --- a/options/options.c +++ b/options/options.c @@ -106,66 +106,65 @@ static const struct m_sub_options screenshot_conf = { #define OPT_BASE_STRUCT struct mp_vo_opts static const m_option_t mp_vo_opt_list[] = { - OPT_SETTINGSLIST("vo", video_driver_list, 0, &vo_obj_list, ), - OPT_FLAG("taskbar-progress", taskbar_progress, 0), - OPT_FLAG("snap-window", snap_window, 0), - OPT_FLAG("ontop", ontop, 0), - OPT_CHOICE_OR_INT("ontop-level", ontop_level, 0, 0, INT_MAX, - ({"window", -1}, {"system", -2})), - OPT_FLAG("border", border, 0), - OPT_FLAG("fit-border", fit_border, 0), - OPT_FLAG("on-all-workspaces", all_workspaces, 0), - OPT_GEOMETRY("geometry", geometry, 0), - OPT_SIZE_BOX("autofit", autofit, 0), - OPT_SIZE_BOX("autofit-larger", autofit_larger, 0), - OPT_SIZE_BOX("autofit-smaller", autofit_smaller, 0), - OPT_DOUBLE("window-scale", window_scale, 0, .min = 0.001, .max = 100), - OPT_FLAG("window-minimized", window_minimized, 0), - OPT_FLAG("window-maximized", window_maximized, 0), - OPT_FLAG("force-window-position", force_window_position, 0), - OPT_STRING("x11-name", winname, 0), - OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0), - OPT_FLOATRANGE("monitorpixelaspect", monitor_pixel_aspect, 0, 1.0/32.0, 32.0), - {"fullscreen", OPTF_BOOL(fullscreen)}, - OPT_ALIAS("fs", "fullscreen"), - OPT_FLAG("native-keyrepeat", native_keyrepeat, 0), - OPT_FLOATRANGE("panscan", panscan, 0, 0.0, 1.0), - OPT_FLOATRANGE("video-zoom", zoom, 0, -20.0, 20.0), - OPT_FLOATRANGE("video-pan-x", pan_x, 0, -3.0, 3.0), - OPT_FLOATRANGE("video-pan-y", pan_y, 0, -3.0, 3.0), - OPT_FLOATRANGE("video-align-x", align_x, 0, -1.0, 1.0), - OPT_FLOATRANGE("video-align-y", align_y, 0, -1.0, 1.0), - OPT_FLOATRANGE("video-margin-ratio-left", margin_x[0], 0, 0.0, 1.0), - OPT_FLOATRANGE("video-margin-ratio-right", margin_x[1], 0, 0.0, 1.0), - OPT_FLOATRANGE("video-margin-ratio-top", margin_y[0], 0, 0.0, 1.0), - OPT_FLOATRANGE("video-margin-ratio-bottom", margin_y[1], 0, 0.0, 1.0), - OPT_CHOICE("video-unscaled", unscaled, 0, - ({"no", 0}, {"yes", 1}, {"downscale-big", 2})), - OPT_INT64("wid", WinID, 0), - OPT_CHOICE_OR_INT("screen", screen_id, 0, 0, 32, - ({"default", -1})), - OPT_CHOICE_OR_INT("fs-screen", fsscreen_id, 0, 0, 32, - ({"all", -2}, {"current", -1})), - OPT_FLAG("keepaspect", keepaspect, 0), - OPT_FLAG("keepaspect-window", keepaspect_window, 0), - OPT_FLAG("hidpi-window-scale", hidpi_window_scale, 0), - OPT_FLAG("native-fs", native_fs, 0), - OPT_DOUBLE("override-display-fps", override_display_fps, 0, - .min = 0, .max = DBL_MAX), - OPT_DOUBLERANGE("video-timing-offset", timing_offset, 0, 0.0, 1.0), + {"vo", OPT_SETTINGSLIST(video_driver_list, &vo_obj_list)}, + {"taskbar-progress", OPT_FLAG(taskbar_progress)}, + {"snap-window", OPT_FLAG(snap_window)}, + {"ontop", OPT_FLAG(ontop)}, + {"ontop-level", OPT_CHOICE(ontop_level, {"window", -1}, {"system", -2}), + M_RANGE(0, INT_MAX)}, + {"border", OPT_FLAG(border)}, + {"fit-border", OPT_FLAG(fit_border)}, + {"on-all-workspaces", OPT_FLAG(all_workspaces)}, + {"geometry", OPT_GEOMETRY(geometry)}, + {"autofit", OPT_SIZE_BOX(autofit)}, + {"autofit-larger", OPT_SIZE_BOX(autofit_larger)}, + {"autofit-smaller", OPT_SIZE_BOX(autofit_smaller)}, + {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)}, + {"window-minimized", OPT_FLAG(window_minimized)}, + {"window-maximized", OPT_FLAG(window_maximized)}, + {"force-window-position", OPT_FLAG(force_window_position)}, + {"x11-name", OPT_STRING(winname)}, + {"monitoraspect", OPT_FLOAT(force_monitor_aspect), M_RANGE(0.0, 9.0)}, + {"monitorpixelaspect", OPT_FLOAT(monitor_pixel_aspect), + M_RANGE(1.0/32.0, 32.0)}, + {"fullscreen", OPT_BOOL(fullscreen)}, + {"fs", OPT_ALIAS("fullscreen")}, + {"native-keyrepeat", OPT_FLAG(native_keyrepeat)}, + {"panscan", OPT_FLOAT(panscan), M_RANGE(0.0, 1.0)}, + {"video-zoom", OPT_FLOAT(zoom), M_RANGE(-20.0, 20.0)}, + {"video-pan-x", OPT_FLOAT(pan_x), M_RANGE(-3.0, 3.0)}, + {"video-pan-y", OPT_FLOAT(pan_y), M_RANGE(-3.0, 3.0)}, + {"video-align-x", OPT_FLOAT(align_x), M_RANGE(-1.0, 1.0)}, + {"video-align-y", OPT_FLOAT(align_y), M_RANGE(-1.0, 1.0)}, + {"video-margin-ratio-left", OPT_FLOAT(margin_x[0]), M_RANGE(0.0, 1.0)}, + {"video-margin-ratio-right", OPT_FLOAT(margin_x[1]), M_RANGE(0.0, 1.0)}, + {"video-margin-ratio-top", OPT_FLOAT(margin_y[0]), M_RANGE(0.0, 1.0)}, + {"video-margin-ratio-bottom", OPT_FLOAT(margin_y[1]), M_RANGE(0.0, 1.0)}, + {"video-unscaled", OPT_CHOICE(unscaled, + {"no", 0}, {"yes", 1}, {"downscale-big", 2})}, + {"wid", OPT_INT64(WinID)}, + {"screen", OPT_CHOICE(screen_id, {"default", -1}), M_RANGE(0, 32)}, + {"fs-screen", OPT_CHOICE(fsscreen_id, {"all", -2}, {"current", -1}), + M_RANGE(0, 32)}, + {"keepaspect", OPT_FLAG(keepaspect)}, + {"keepaspect-window", OPT_FLAG(keepaspect_window)}, + {"hidpi-window-scale", OPT_FLAG(hidpi_window_scale)}, + {"native-fs", OPT_FLAG(native_fs)}, + {"override-display-fps", OPT_DOUBLE(override_display_fps), + M_RANGE(0, DBL_MAX)}, + {"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)}, #if HAVE_X11 - OPT_CHOICE("x11-netwm", x11_netwm, 0, - ({"auto", 0}, {"no", -1}, {"yes", 1})), - OPT_CHOICE("x11-bypass-compositor", x11_bypass_compositor, 0, - ({"no", 0}, {"yes", 1}, {"fs-only", 2}, {"never", 3})), + {"x11-netwm", OPT_CHOICE(x11_netwm, {"auto", 0}, {"no", -1}, {"yes", 1})}, + {"x11-bypass-compositor", OPT_CHOICE(x11_bypass_compositor, + {"no", 0}, {"yes", 1}, {"fs-only", 2}, {"never", 3})}, #endif #if HAVE_WIN32_DESKTOP - OPT_STRING("vo-mmcss-profile", mmcss_profile, 0), + {"vo-mmcss-profile", OPT_STRING(mmcss_profile)}, #endif #if HAVE_DRM - OPT_SUBSTRUCT("", drm_opts, drm_conf, 0), + {"", OPT_SUBSTRUCT(drm_opts, drm_conf)}, #endif - OPT_INTRANGE("swapchain-depth", swapchain_depth, 0, 1, 8), + {"swapchain-depth", OPT_INT(swapchain_depth), M_RANGE(1, 8)}, {0} }; @@ -201,11 +200,11 @@ const struct m_sub_options vo_sub_opts = { const struct m_sub_options mp_sub_filter_opts = { .opts = (const struct m_option[]){ - OPT_FLAG("sub-filter-sdh", sub_filter_SDH, 0), - OPT_FLAG("sub-filter-sdh-harder", sub_filter_SDH_harder, 0), - OPT_FLAG("sub-filter-regex-enable", rf_enable, 0), - OPT_STRINGLIST("sub-filter-regex", rf_items, 0), - OPT_FLAG("sub-filter-regex-warn", rf_warn, 0), + {"sub-filter-sdh", OPT_FLAG(sub_filter_SDH)}, + {"sub-filter-sdh-harder", OPT_FLAG(sub_filter_SDH_harder)}, + {"sub-filter-regex-enable", OPT_FLAG(rf_enable)}, + {"sub-filter-regex", OPT_STRINGLIST(rf_items)}, + {"sub-filter-regex-warn", OPT_FLAG(rf_warn)}, {0} }, .size = sizeof(OPT_BASE_STRUCT), @@ -220,43 +219,44 @@ const struct m_sub_options mp_sub_filter_opts = { const struct m_sub_options mp_subtitle_sub_opts = { .opts = (const struct m_option[]){ - OPT_FLOAT("sub-delay", sub_delay, 0), - OPT_FLOAT("sub-fps", sub_fps, 0), - OPT_FLOAT("sub-speed", sub_speed, 0), - OPT_FLAG("sub-visibility", sub_visibility, 0), - OPT_FLAG("sub-forced-only", forced_subs_only, 0), - OPT_FLAG("stretch-dvd-subs", stretch_dvd_subs, 0), - OPT_FLAG("stretch-image-subs-to-screen", stretch_image_subs, 0), - OPT_FLAG("image-subs-video-resolution", image_subs_video_res, 0), - OPT_FLAG("sub-fix-timing", sub_fix_timing, 0), - OPT_INTRANGE("sub-pos", sub_pos, 0, 0, 100), - OPT_FLOATRANGE("sub-gauss", sub_gauss, 0, 0.0, 3.0), - OPT_FLAG("sub-gray", sub_gray, 0), - OPT_FLAG("sub-ass", ass_enabled, 0), - OPT_FLOATRANGE("sub-scale", sub_scale, 0, 0, 100), - OPT_FLOATRANGE("sub-ass-line-spacing", ass_line_spacing, 0, -1000, 1000), - OPT_FLAG("sub-use-margins", sub_use_margins, 0), - OPT_FLAG("sub-ass-force-margins", ass_use_margins, 0), - OPT_FLAG("sub-ass-vsfilter-aspect-compat", ass_vsfilter_aspect_compat, 0), - OPT_CHOICE("sub-ass-vsfilter-color-compat", ass_vsfilter_color_compat, 0, - ({"no", 0}, {"basic", 1}, {"full", 2}, {"force-601", 3})), - OPT_FLAG("sub-ass-vsfilter-blur-compat", ass_vsfilter_blur_compat, 0), - OPT_FLAG("embeddedfonts", use_embedded_fonts, 0), - OPT_STRINGLIST("sub-ass-force-style", ass_force_style_list, 0), - OPT_STRING("sub-ass-styles", ass_styles_file, M_OPT_FILE), - OPT_CHOICE("sub-ass-hinting", ass_hinting, 0, - ({"none", 0}, {"light", 1}, {"normal", 2}, {"native", 3})), - OPT_CHOICE("sub-ass-shaper", ass_shaper, 0, - ({"simple", 0}, {"complex", 1})), - OPT_FLAG("sub-ass-justify", ass_justify, 0), - OPT_CHOICE("sub-ass-override", ass_style_override, 0, - ({"no", 0}, {"yes", 1}, {"force", 3}, {"scale", 4}, {"strip", 5})), - OPT_FLAG("sub-scale-by-window", sub_scale_by_window, 0), - OPT_FLAG("sub-scale-with-window", sub_scale_with_window, 0), - OPT_FLAG("sub-ass-scale-with-window", ass_scale_with_window, 0), - OPT_SUBSTRUCT("sub", sub_style, sub_style_conf, 0), - OPT_FLAG("sub-clear-on-seek", sub_clear_on_seek, 0), - OPT_INTRANGE("teletext-page", teletext_page, 0, 1, 999), + {"sub-delay", OPT_FLOAT(sub_delay)}, + {"sub-fps", OPT_FLOAT(sub_fps)}, + {"sub-speed", OPT_FLOAT(sub_speed)}, + {"sub-visibility", OPT_FLAG(sub_visibility)}, + {"sub-forced-only", OPT_FLAG(forced_subs_only)}, + {"stretch-dvd-subs", OPT_FLAG(stretch_dvd_subs)}, + {"stretch-image-subs-to-screen", OPT_FLAG(stretch_image_subs)}, + {"image-subs-video-resolution", OPT_FLAG(image_subs_video_res)}, + {"sub-fix-timing", OPT_FLAG(sub_fix_timing)}, + {"sub-pos", OPT_INT(sub_pos), M_RANGE(0, 100)}, + {"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)}, + {"sub-gray", OPT_FLAG(sub_gray)}, + {"sub-ass", OPT_FLAG(ass_enabled)}, + {"sub-scale", OPT_FLOAT(sub_scale), M_RANGE(0, 100)}, + {"sub-ass-line-spacing", OPT_FLOAT(ass_line_spacing), + M_RANGE(-1000, 1000)}, + {"sub-use-margins", OPT_FLAG(sub_use_margins)}, + {"sub-ass-force-margins", OPT_FLAG(ass_use_margins)}, + {"sub-ass-vsfilter-aspect-compat", OPT_FLAG(ass_vsfilter_aspect_compat)}, + {"sub-ass-vsfilter-color-compat", OPT_CHOICE(ass_vsfilter_color_compat, + {"no", 0}, {"basic", 1}, {"full", 2}, {"force-601", 3})}, + {"sub-ass-vsfilter-blur-compat", OPT_FLAG(ass_vsfilter_blur_compat)}, + {"embeddedfonts", OPT_FLAG(use_embedded_fonts)}, + {"sub-ass-force-style", OPT_STRINGLIST(ass_force_style_list)}, + {"sub-ass-styles", OPT_STRING(ass_styles_file), .flags = M_OPT_FILE}, + {"sub-ass-hinting", OPT_CHOICE(ass_hinting, + {"none", 0}, {"light", 1}, {"normal", 2}, {"native", 3})}, + {"sub-ass-shaper", OPT_CHOICE(ass_shaper, + {"simple", 0}, {"complex", 1})}, + {"sub-ass-justify", OPT_FLAG(ass_justify)}, + {"sub-ass-override", OPT_CHOICE(ass_style_override, + {"no", 0}, {"yes", 1}, {"force", 3}, {"scale", 4}, {"strip", 5})}, + {"sub-scale-by-window", OPT_FLAG(sub_scale_by_window)}, + {"sub-scale-with-window", OPT_FLAG(sub_scale_with_window)}, + {"sub-ass-scale-with-window", OPT_FLAG(ass_scale_with_window)}, + {"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)}, + {"sub-clear-on-seek", OPT_FLAG(sub_clear_on_seek)}, + {"teletext-page", OPT_INT(teletext_page), M_RANGE(1, 999)}, {0} }, .size = sizeof(OPT_BASE_STRUCT), @@ -287,14 +287,14 @@ const struct m_sub_options mp_subtitle_sub_opts = { const struct m_sub_options mp_osd_render_sub_opts = { .opts = (const struct m_option[]){ - OPT_FLOATRANGE("osd-bar-align-x", osd_bar_align_x, 0, -1.0, +1.0), - OPT_FLOATRANGE("osd-bar-align-y", osd_bar_align_y, 0, -1.0, +1.0), - OPT_FLOATRANGE("osd-bar-w", osd_bar_w, 0, 1, 100), - OPT_FLOATRANGE("osd-bar-h", osd_bar_h, 0, 0.1, 50), - OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0), - OPT_FLOATRANGE("osd-scale", osd_scale, 0, 0, 100), - OPT_FLAG("osd-scale-by-window", osd_scale_by_window, 0), - OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0), + {"osd-bar-align-x", OPT_FLOAT(osd_bar_align_x), M_RANGE(-1.0, +1.0)}, + {"osd-bar-align-y", OPT_FLOAT(osd_bar_align_y), M_RANGE(-1.0, +1.0)}, + {"osd-bar-w", OPT_FLOAT(osd_bar_w), M_RANGE(1, 100)}, + {"osd-bar-h", OPT_FLOAT(osd_bar_h), M_RANGE(0.1, 50)}, + {"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)}, + {"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)}, + {"osd-scale-by-window", OPT_FLAG(osd_scale_by_window)}, + {"force-rgba-osd-rendering", OPT_FLAG(force_rgba_osd)}, {0} }, .size = sizeof(OPT_BASE_STRUCT), @@ -313,9 +313,9 @@ const struct m_sub_options mp_osd_render_sub_opts = { const struct m_sub_options dvd_conf = { .opts = (const struct m_option[]){ - OPT_STRING("dvd-device", device, M_OPT_FILE), - OPT_INT("dvd-speed", speed, 0), - OPT_INTRANGE("dvd-angle", angle, 0, 1, 99), + {"dvd-device", OPT_STRING(device), .flags = M_OPT_FILE}, + {"dvd-speed", OPT_INT(speed)}, + {"dvd-angle", OPT_INT(angle), M_RANGE(1, 99)}, {0} }, .size = sizeof(struct dvd_opts), @@ -329,7 +329,7 @@ const struct m_sub_options dvd_conf = { const struct m_sub_options filter_conf = { .opts = (const struct m_option[]){ - OPT_FLAG("deinterlace", deinterlace, 0), + {"deinterlace", OPT_FLAG(deinterlace)}, {0} }, .size = sizeof(OPT_BASE_STRUCT), @@ -356,550 +356,563 @@ static const m_option_t mp_opts[] = { M_OPT_OPTIONAL_PARAM, .offset = -1}, { "list-options", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, - OPT_FLAG("list-properties", property_print_help, CONF_NOCFG | M_OPT_NOPROP), + {"list-properties", OPT_FLAG(property_print_help), + .flags = CONF_NOCFG | M_OPT_NOPROP}, { "help", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, .offset = -1}, { "h", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, .offset = -1}, - OPT_PRINT("list-protocols", stream_print_proto_list), - OPT_PRINT("version", print_version), - OPT_PRINT("V", print_version), + {"list-protocols", OPT_PRINT(stream_print_proto_list)}, + {"version", OPT_PRINT(print_version)}, + {"V", OPT_PRINT(print_version)}, #if HAVE_TESTS - OPT_STRING("unittest", test_mode, CONF_NOCFG | M_OPT_NOPROP), + {"unittest", OPT_STRING(test_mode), .flags = CONF_NOCFG | M_OPT_NOPROP}, #endif - OPT_CHOICE("player-operation-mode", operation_mode, - M_OPT_PRE_PARSE | M_OPT_NOPROP, - ({"cplayer", 0}, {"pseudo-gui", 1})), + {"player-operation-mode", OPT_CHOICE(operation_mode, + {"cplayer", 0}, {"pseudo-gui", 1}), + .flags = M_OPT_PRE_PARSE | M_OPT_NOPROP}, - OPT_FLAG("shuffle", shuffle, 0), + {"shuffle", OPT_FLAG(shuffle)}, // ------------------------- common options -------------------- - OPT_FLAG("quiet", quiet, 0), - OPT_FLAG("really-quiet", msg_really_quiet, CONF_PRE_PARSE | UPDATE_TERM), - OPT_FLAG("terminal", use_terminal, CONF_PRE_PARSE | UPDATE_TERM), - OPT_GENERAL(char**, "msg-level", msg_levels, CONF_PRE_PARSE | UPDATE_TERM, - .type = &m_option_type_msglevels), - OPT_STRING("dump-stats", dump_stats, UPDATE_TERM | CONF_PRE_PARSE | M_OPT_FILE), - OPT_FLAG("msg-color", msg_color, CONF_PRE_PARSE | UPDATE_TERM), - OPT_STRING("log-file", log_file, CONF_PRE_PARSE | M_OPT_FILE | UPDATE_TERM), - OPT_FLAG("msg-module", msg_module, UPDATE_TERM), - OPT_FLAG("msg-time", msg_time, UPDATE_TERM), + {"quiet", OPT_FLAG(quiet)}, + {"really-quiet", OPT_FLAG(msg_really_quiet), + .flags = CONF_PRE_PARSE | UPDATE_TERM}, + {"terminal", OPT_FLAG(use_terminal), .flags = CONF_PRE_PARSE | UPDATE_TERM}, + {"msg-level", OPT_MSGLEVELS(msg_levels), + .flags = CONF_PRE_PARSE | UPDATE_TERM}, + {"dump-stats", OPT_STRING(dump_stats), + .flags = UPDATE_TERM | CONF_PRE_PARSE | M_OPT_FILE}, + {"msg-color", OPT_FLAG(msg_color), .flags = CONF_PRE_PARSE | UPDATE_TERM}, + {"log-file", OPT_STRING(log_file), + .flags = CONF_PRE_PARSE | M_OPT_FILE | UPDATE_TERM}, + {"msg-module", OPT_FLAG(msg_module), .flags = UPDATE_TERM}, + {"msg-time", OPT_FLAG(msg_time), .flags = UPDATE_TERM}, #if HAVE_WIN32_DESKTOP - OPT_CHOICE("priority", w32_priority, UPDATE_PRIORITY, - ({"no", 0}, - {"realtime", REALTIME_PRIORITY_CLASS}, - {"high", HIGH_PRIORITY_CLASS}, - {"abovenormal", ABOVE_NORMAL_PRIORITY_CLASS}, - {"normal", NORMAL_PRIORITY_CLASS}, - {"belownormal", BELOW_NORMAL_PRIORITY_CLASS}, - {"idle", IDLE_PRIORITY_CLASS})), + {"priority", OPT_CHOICE(w32_priority, + {"no", 0}, + {"realtime", REALTIME_PRIORITY_CLASS}, + {"high", HIGH_PRIORITY_CLASS}, + {"abovenormal", ABOVE_NORMAL_PRIORITY_CLASS}, + {"normal", NORMAL_PRIORITY_CLASS}, + {"belownormal", BELOW_NORMAL_PRIORITY_CLASS}, + {"idle", IDLE_PRIORITY_CLASS}), + .flags = UPDATE_PRIORITY}, #endif - OPT_FLAG("config", load_config, CONF_PRE_PARSE), - OPT_STRING("config-dir", force_configdir, - CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE), - OPT_STRINGLIST("reset-on-next-file", reset_options, 0), + {"config", OPT_FLAG(load_config), .flags = CONF_PRE_PARSE}, + {"config-dir", OPT_STRING(force_configdir), + .flags = CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE}, + {"reset-on-next-file", OPT_STRINGLIST(reset_options)}, #if HAVE_LUA || HAVE_JAVASCRIPT - OPT_PATHLIST("scripts", script_files, M_OPT_FILE), - OPT_CLI_ALIAS("script", "scripts-append"), - OPT_KEYVALUELIST("script-opts", script_opts, 0), - OPT_FLAG("load-scripts", auto_load_scripts, 0), + {"scripts", OPT_PATHLIST(script_files), .flags = M_OPT_FILE}, + {"script", OPT_CLI_ALIAS("scripts-append")}, + {"script-opts", OPT_KEYVALUELIST(script_opts)}, + {"load-scripts", OPT_FLAG(auto_load_scripts)}, #endif #if HAVE_LUA - OPT_FLAG("osc", lua_load_osc, UPDATE_BUILTIN_SCRIPTS), - OPT_FLAG("ytdl", lua_load_ytdl, UPDATE_BUILTIN_SCRIPTS), - OPT_STRING("ytdl-format", lua_ytdl_format, 0), - OPT_KEYVALUELIST("ytdl-raw-options", lua_ytdl_raw_options, 0), - OPT_FLAG("load-stats-overlay", lua_load_stats, UPDATE_BUILTIN_SCRIPTS), - OPT_FLAG("load-osd-console", lua_load_console, UPDATE_BUILTIN_SCRIPTS), + {"osc", OPT_FLAG(lua_load_osc), .flags = UPDATE_BUILTIN_SCRIPTS}, + {"ytdl", OPT_FLAG(lua_load_ytdl), .flags = UPDATE_BUILTIN_SCRIPTS}, + {"ytdl-format", OPT_STRING(lua_ytdl_format)}, + {"ytdl-raw-options", OPT_KEYVALUELIST(lua_ytdl_raw_options)}, + {"load-stats-overlay", OPT_FLAG(lua_load_stats), + .flags = UPDATE_BUILTIN_SCRIPTS}, + {"load-osd-console", OPT_FLAG(lua_load_console), + .flags = UPDATE_BUILTIN_SCRIPTS}, #endif // ------------------------- stream options -------------------- #if HAVE_DVDNAV - OPT_SUBSTRUCT("", dvd_opts, dvd_conf, 0), + {"", OPT_SUBSTRUCT(dvd_opts, dvd_conf)}, #endif - OPT_CHOICE_OR_INT("edition", edition_id, 0, 0, 8190, - ({"auto", -1})), + {"edition", OPT_CHOICE(edition_id, {"auto", -1}), M_RANGE(0, 8190)}, #if HAVE_LIBBLURAY - OPT_STRING("bluray-device", bluray_device, M_OPT_FILE), + {"bluray-device", OPT_STRING(bluray_device), .flags = M_OPT_FILE}, #endif /* HAVE_LIBBLURAY */ // ------------------------- demuxer options -------------------- - OPT_CHOICE_OR_INT("frames", play_frames, 0, 0, INT_MAX, ({"all", -1})), + {"frames", OPT_CHOICE(play_frames, {"all", -1}), M_RANGE(0, INT_MAX)}, - OPT_REL_TIME("start", play_start, 0), - OPT_REL_TIME("end", play_end, 0), - OPT_REL_TIME("length", play_length, 0), + {"start", OPT_REL_TIME(play_start)}, + {"end", OPT_REL_TIME(play_end)}, + {"length", OPT_REL_TIME(play_length)}, - OPT_CHOICE("play-dir", play_dir, 0, - ({"forward", 1}, {"+", 1}, {"backward", -1}, {"-", -1})), + {"play-dir", OPT_CHOICE(play_dir, + {"forward", 1}, {"+", 1}, {"backward", -1}, {"-", -1})}, - OPT_FLAG("rebase-start-time", rebase_start_time, 0), + {"rebase-start-time", OPT_FLAG(rebase_start_time)}, - OPT_TIME("ab-loop-a", ab_loop[0], 0, .min = MP_NOPTS_VALUE), - OPT_TIME("ab-loop-b", ab_loop[1], 0, .min = MP_NOPTS_VALUE), - OPT_CHOICE_OR_INT("ab-loop-count", ab_loop_count, 0, 0, INT_MAX, - ({"inf", -1})), + {"ab-loop-a", OPT_TIME(ab_loop[0]), .min = MP_NOPTS_VALUE}, + {"ab-loop-b", OPT_TIME(ab_loop[1]), .min = MP_NOPTS_VALUE}, + {"ab-loop-count", OPT_CHOICE(ab_loop_count, {"inf", -1}), + M_RANGE(0, INT_MAX)}, - OPT_CHOICE_OR_INT("playlist-start", playlist_pos, 0, 0, INT_MAX, - ({"auto", -1}, {"no", -1})), + {"playlist-start", OPT_CHOICE(playlist_pos, {"auto", -1}, {"no", -1}), + M_RANGE(0, INT_MAX)}, - OPT_FLAG("pause", pause, 0), - OPT_CHOICE("keep-open", keep_open, 0, - ({"no", 0}, - {"yes", 1}, - {"always", 2})), - OPT_FLAG("keep-open-pause", keep_open_pause, 0), - OPT_DOUBLE("image-display-duration", image_display_duration, - 0, 0, INFINITY), + {"pause", OPT_FLAG(pause)}, + {"keep-open", OPT_CHOICE(keep_open, + {"no", 0}, + {"yes", 1}, + {"always", 2})}, + {"keep-open-pause", OPT_FLAG(keep_open_pause)}, + {"image-display-duration", OPT_DOUBLE(image_display_duration), + M_RANGE(0, INFINITY)}, - OPT_CHOICE("index", index_mode, 0, ({"default", 1}, {"recreate", 0})), + {"index", OPT_CHOICE(index_mode, {"default", 1}, {"recreate", 0})}, // select audio/video/subtitle stream - OPT_TRACKCHOICE("aid", stream_id[0][STREAM_AUDIO]), - OPT_TRACKCHOICE("vid", stream_id[0][STREAM_VIDEO]), - OPT_TRACKCHOICE("sid", stream_id[0][STREAM_SUB]), - OPT_TRACKCHOICE("secondary-sid", stream_id[1][STREAM_SUB]), - OPT_ALIAS("sub", "sid"), - OPT_ALIAS("video", "vid"), - OPT_ALIAS("audio", "aid"), - OPT_STRINGLIST("alang", stream_lang[STREAM_AUDIO], 0), - OPT_STRINGLIST("slang", stream_lang[STREAM_SUB], 0), - OPT_STRINGLIST("vlang", stream_lang[STREAM_VIDEO], 0), - OPT_FLAG("track-auto-selection", stream_auto_sel, 0), + {"aid", OPT_TRACKCHOICE(stream_id[0][STREAM_AUDIO])}, + {"vid", OPT_TRACKCHOICE(stream_id[0][STREAM_VIDEO])}, + {"sid", OPT_TRACKCHOICE(stream_id[0][STREAM_SUB])}, + {"secondary-sid", OPT_TRACKCHOICE(stream_id[1][STREAM_SUB])}, + {"sub", OPT_ALIAS("sid")}, + {"video", OPT_ALIAS("vid")}, + {"audio", OPT_ALIAS("aid")}, + {"alang", OPT_STRINGLIST(stream_lang[STREAM_AUDIO])}, + {"slang", OPT_STRINGLIST(stream_lang[STREAM_SUB])}, + {"vlang", OPT_STRINGLIST(stream_lang[STREAM_VIDEO])}, + {"track-auto-selection", OPT_FLAG(stream_auto_sel)}, - OPT_STRING("lavfi-complex", lavfi_complex, UPDATE_LAVFI_COMPLEX), + {"lavfi-complex", OPT_STRING(lavfi_complex), .flags = UPDATE_LAVFI_COMPLEX}, - OPT_CHOICE("audio-display", audio_display, 0, - ({"no", 0}, {"attachment", 1})), + {"audio-display", OPT_CHOICE(audio_display, {"no", 0}, {"attachment", 1})}, - OPT_CHOICE_OR_INT("hls-bitrate", hls_bitrate, 0, 0, INT_MAX, - ({"no", -1}, {"min", 0}, {"max", INT_MAX})), + {"hls-bitrate", OPT_CHOICE(hls_bitrate, + {"no", -1}, {"min", 0}, {"max", INT_MAX}), M_RANGE(0, INT_MAX)}, - OPT_STRINGLIST("display-tags", display_tags, 0), + {"display-tags", OPT_STRINGLIST(display_tags)}, #if HAVE_CDDA - OPT_SUBSTRUCT("cdda", stream_cdda_opts, stream_cdda_conf, 0), - OPT_STRING("cdrom-device", cdrom_device, M_OPT_FILE), + {"cdda", OPT_SUBSTRUCT(stream_cdda_opts, stream_cdda_conf)}, + {"cdrom-device", OPT_STRING(cdrom_device), .flags = M_OPT_FILE}, #endif // demuxer.c - select audio/sub file/demuxer - OPT_PATHLIST("audio-files", audio_files, M_OPT_FILE), - OPT_CLI_ALIAS("audio-file", "audio-files-append"), - OPT_STRING("demuxer", demuxer_name, 0), - OPT_STRING("audio-demuxer", audio_demuxer_name, 0), - OPT_STRING("sub-demuxer", sub_demuxer_name, 0), - OPT_FLAG("demuxer-thread", demuxer_thread, 0), - OPT_DOUBLE("demuxer-termination-timeout", demux_termination_timeout, 0), - OPT_FLAG("demuxer-cache-wait", demuxer_cache_wait, 0), - OPT_FLAG("prefetch-playlist", prefetch_open, 0), - OPT_FLAG("cache-pause", cache_pause, 0), - OPT_FLAG("cache-pause-initial", cache_pause_initial, 0), - OPT_FLOAT("cache-pause-wait", cache_pause_wait, 0, .min = 0, .max = DBL_MAX), + {"audio-files", OPT_PATHLIST(audio_files), .flags = M_OPT_FILE}, + {"audio-file", OPT_CLI_ALIAS("audio-files-append")}, + {"demuxer", OPT_STRING(demuxer_name)}, + {"audio-demuxer", OPT_STRING(audio_demuxer_name)}, + {"sub-demuxer", OPT_STRING(sub_demuxer_name)}, + {"demuxer-thread", OPT_FLAG(demuxer_thread)}, + {"demuxer-termination-timeout", OPT_DOUBLE(demux_termination_timeout)}, + {"demuxer-cache-wait", OPT_FLAG(demuxer_cache_wait)}, + {"prefetch-playlist", OPT_FLAG(prefetch_open)}, + {"cache-pause", OPT_FLAG(cache_pause)}, + {"cache-pause-initial", OPT_FLAG(cache_pause_initial)}, + {"cache-pause-wait", OPT_FLOAT(cache_pause_wait), M_RANGE(0, DBL_MAX)}, - OPT_DOUBLE("mf-fps", mf_fps, 0), - OPT_STRING("mf-type", mf_type, 0), + {"mf-fps", OPT_DOUBLE(mf_fps)}, + {"mf-type", OPT_STRING(mf_type)}, #if HAVE_DVBIN - OPT_SUBSTRUCT("dvbin", stream_dvb_opts, stream_dvb_conf, 0), + {"dvbin", OPT_SUBSTRUCT(stream_dvb_opts, stream_dvb_conf)}, #endif - OPT_SUBSTRUCT("", stream_lavf_opts, stream_lavf_conf, 0), + {"", OPT_SUBSTRUCT(stream_lavf_opts, stream_lavf_conf)}, // ------------------------- a-v sync options -------------------- // set A-V sync correction speed (0=disables it): - OPT_FLOATRANGE("mc", default_max_pts_correction, 0, 0, 100), + {"mc", OPT_FLOAT(default_max_pts_correction), M_RANGE(0, 100)}, - OPT_INTRANGE("audio-samplerate", force_srate, UPDATE_AUDIO, 0, 16*48000), - OPT_CHANNELS("audio-channels", audio_output_channels, UPDATE_AUDIO), - OPT_AUDIOFORMAT("audio-format", audio_output_format, UPDATE_AUDIO), - OPT_DOUBLE("speed", playback_speed, 0, .min = 0.01, .max = 100.0), + {"audio-samplerate", OPT_INT(force_srate), .flags = UPDATE_AUDIO, + M_RANGE(0, 16*48000)}, + {"audio-channels", OPT_CHANNELS(audio_output_channels), .flags = UPDATE_AUDIO}, + {"audio-format", OPT_AUDIOFORMAT(audio_output_format), .flags = UPDATE_AUDIO}, + {"speed", OPT_DOUBLE(playback_speed), M_RANGE(0.01, 100.0)}, - OPT_FLAG("audio-pitch-correction", pitch_correction, 0), + {"audio-pitch-correction", OPT_FLAG(pitch_correction)}, // set a-v distance - OPT_FLOAT("audio-delay", audio_delay, 0), + {"audio-delay", OPT_FLOAT(audio_delay)}, // ------------------------- codec/vfilter options -------------------- - OPT_SETTINGSLIST("af-defaults", af_defs, 0, &af_obj_list, - .deprecation_message = "use --af + enable/disable flags"), - OPT_SETTINGSLIST("af", af_settings, 0, &af_obj_list, ), - OPT_SETTINGSLIST("vf-defaults", vf_defs, 0, &vf_obj_list, - .deprecation_message = "use --vf + enable/disable flags"), - OPT_SETTINGSLIST("vf", vf_settings, 0, &vf_obj_list, ), + {"af-defaults", OPT_SETTINGSLIST(af_defs, &af_obj_list), + .deprecation_message = "use --af + enable/disable flags"}, + {"af", OPT_SETTINGSLIST(af_settings, &af_obj_list)}, + {"vf-defaults", OPT_SETTINGSLIST(vf_defs, &vf_obj_list), + .deprecation_message = "use --vf + enable/disable flags"}, + {"vf", OPT_SETTINGSLIST(vf_settings, &vf_obj_list)}, - OPT_SUBSTRUCT("", filter_opts, filter_conf, 0), + {"", OPT_SUBSTRUCT(filter_opts, filter_conf)}, - OPT_SUBSTRUCT("", dec_wrapper, dec_wrapper_conf, 0), - OPT_SUBSTRUCT("", vd_lavc_params, vd_lavc_conf, 0), - OPT_SUBSTRUCT("ad-lavc", ad_lavc_params, ad_lavc_conf, 0), + {"", OPT_SUBSTRUCT(dec_wrapper, dec_wrapper_conf)}, + {"", OPT_SUBSTRUCT(vd_lavc_params, vd_lavc_conf)}, + {"ad-lavc", OPT_SUBSTRUCT(ad_lavc_params, ad_lavc_conf)}, - OPT_SUBSTRUCT("", demux_lavf, demux_lavf_conf, 0), - OPT_SUBSTRUCT("demuxer-rawaudio", demux_rawaudio, demux_rawaudio_conf, 0), - OPT_SUBSTRUCT("demuxer-rawvideo", demux_rawvideo, demux_rawvideo_conf, 0), - OPT_SUBSTRUCT("demuxer-mkv", demux_mkv, demux_mkv_conf, 0), - OPT_SUBSTRUCT("demuxer-cue", demux_cue, demux_cue_conf, 0), + {"", OPT_SUBSTRUCT(demux_lavf, demux_lavf_conf)}, + {"demuxer-rawaudio", OPT_SUBSTRUCT(demux_rawaudio, demux_rawaudio_conf)}, + {"demuxer-rawvideo", OPT_SUBSTRUCT(demux_rawvideo, demux_rawvideo_conf)}, + {"demuxer-mkv", OPT_SUBSTRUCT(demux_mkv, demux_mkv_conf)}, + {"demuxer-cue", OPT_SUBSTRUCT(demux_cue, demux_cue_conf)}, // ------------------------- subtitles options -------------------- - OPT_PATHLIST("sub-files", sub_name, M_OPT_FILE), - OPT_CLI_ALIAS("sub-file", "sub-files-append"), - OPT_PATHLIST("sub-file-paths", sub_paths, M_OPT_FILE), - OPT_PATHLIST("audio-file-paths", audiofile_paths, M_OPT_FILE), - OPT_PATHLIST("external-files", external_files, M_OPT_FILE), - OPT_CLI_ALIAS("external-file", "external-files-append"), - OPT_FLAG("autoload-files", autoload_files, 0), - OPT_CHOICE("sub-auto", sub_auto, 0, - ({"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})), - OPT_CHOICE("audio-file-auto", audiofile_auto, 0, - ({"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})), + {"sub-files", OPT_PATHLIST(sub_name), .flags = M_OPT_FILE}, + {"sub-file", OPT_CLI_ALIAS("sub-files-append")}, + {"sub-file-paths", OPT_PATHLIST(sub_paths), .flags = M_OPT_FILE}, + {"audio-file-paths", OPT_PATHLIST(audiofile_paths), .flags = M_OPT_FILE}, + {"external-files", OPT_PATHLIST(external_files), .flags = M_OPT_FILE}, + {"external-file", OPT_CLI_ALIAS("external-files-append")}, + {"autoload-files", OPT_FLAG(autoload_files)}, + {"sub-auto", OPT_CHOICE(sub_auto, + {"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})}, + {"audio-file-auto", OPT_CHOICE(audiofile_auto, + {"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})}, - OPT_SUBSTRUCT("", subs_rend, mp_subtitle_sub_opts, 0), - OPT_SUBSTRUCT("", subs_filt, mp_sub_filter_opts, 0), - OPT_SUBSTRUCT("", osd_rend, mp_osd_render_sub_opts, 0), + {"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)}, + {"", OPT_SUBSTRUCT(subs_filt, mp_sub_filter_opts)}, + {"", OPT_SUBSTRUCT(osd_rend, mp_osd_render_sub_opts)}, - OPT_FLAG("osd-bar", osd_bar_visible, UPDATE_OSD), + {"osd-bar", OPT_FLAG(osd_bar_visible), .flags = UPDATE_OSD}, //---------------------- libao/libvo options ------------------------ - OPT_SUBSTRUCT("", ao_opts, ao_conf, 0), - OPT_FLAG("audio-exclusive", audio_exclusive, UPDATE_AUDIO), - OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0), - OPT_FLAG("audio-stream-silence", audio_stream_silence, 0), - OPT_FLOATRANGE("audio-wait-open", audio_wait_open, 0, 0, 60), - OPT_CHOICE("force-window", force_vo, 0, - ({"no", 0}, {"yes", 1}, {"immediate", 2})), + {"", OPT_SUBSTRUCT(ao_opts, ao_conf)}, + {"audio-exclusive", OPT_FLAG(audio_exclusive), .flags = UPDATE_AUDIO}, + {"audio-fallback-to-null", OPT_FLAG(ao_null_fallback)}, + {"audio-stream-silence", OPT_FLAG(audio_stream_silence)}, + {"audio-wait-open", OPT_FLOAT(audio_wait_open), M_RANGE(0, 60)}, + {"force-window", OPT_CHOICE(force_vo, + {"no", 0}, {"yes", 1}, {"immediate", 2})}, - OPT_FLOATRANGE("volume-max", softvol_max, 0, 100, 1000), + {"volume-max", OPT_FLOAT(softvol_max), M_RANGE(100, 1000)}, // values <0 for volume and mute are legacy and ignored - OPT_FLOATRANGE("volume", softvol_volume, UPDATE_VOL, -1, 1000), - OPT_CHOICE("mute", softvol_mute, UPDATE_VOL, - ({"no", 0}, - {"auto", 0}, - {"yes", 1})), - OPT_CHOICE("replaygain", rgain_mode, UPDATE_VOL, - ({"no", 0}, - {"track", 1}, - {"album", 2})), - OPT_FLOATRANGE("replaygain-preamp", rgain_preamp, UPDATE_VOL, -15, 15), - OPT_FLAG("replaygain-clip", rgain_clip, UPDATE_VOL), - OPT_FLOATRANGE("replaygain-fallback", rgain_fallback, UPDATE_VOL, -200, 60), - OPT_CHOICE("gapless-audio", gapless_audio, 0, - ({"no", 0}, - {"yes", 1}, - {"weak", -1})), + {"volume", OPT_FLOAT(softvol_volume), .flags = UPDATE_VOL, + M_RANGE(-1, 1000)}, + {"mute", OPT_CHOICE(softvol_mute, + {"no", 0}, + {"auto", 0}, + {"yes", 1}), + .flags = UPDATE_VOL}, + {"replaygain", OPT_CHOICE(rgain_mode, + {"no", 0}, + {"track", 1}, + {"album", 2}), + .flags = UPDATE_VOL}, + {"replaygain-preamp", OPT_FLOAT(rgain_preamp), .flags = UPDATE_VOL, + M_RANGE(-15, 15)}, + {"replaygain-clip", OPT_FLAG(rgain_clip), .flags = UPDATE_VOL}, + {"replaygain-fallback", OPT_FLOAT(rgain_fallback), .flags = UPDATE_VOL, + M_RANGE(-200, 60)}, + {"gapless-audio", OPT_CHOICE(gapless_audio, + {"no", 0}, + {"yes", 1}, + {"weak", -1})}, - OPT_STRING("title", wintitle, 0), - OPT_STRING("force-media-title", media_title, 0), + {"title", OPT_STRING(wintitle)}, + {"force-media-title", OPT_STRING(media_title)}, - OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0, - 0, 30000, ({"no", -1}, {"always", -2})), - OPT_FLAG("cursor-autohide-fs-only", cursor_autohide_fs, 0), - OPT_FLAG("stop-screensaver", stop_screensaver, UPDATE_SCREENSAVER), + {"cursor-autohide", OPT_CHOICE(cursor_autohide_delay, + {"no", -1}, {"always", -2}), M_RANGE(0, 30000)}, + {"cursor-autohide-fs-only", OPT_FLAG(cursor_autohide_fs)}, + {"stop-screensaver", OPT_FLAG(stop_screensaver), .flags = UPDATE_SCREENSAVER}, - OPT_SUBSTRUCT("", video_equalizer, mp_csp_equalizer_conf, 0), + {"", OPT_SUBSTRUCT(video_equalizer, mp_csp_equalizer_conf)}, - OPT_FLAG("use-filedir-conf", use_filedir_conf, 0), - OPT_CHOICE("osd-level", osd_level, 0, - ({"0", 0}, {"1", 1}, {"2", 2}, {"3", 3})), - OPT_CHOICE("osd-on-seek", osd_on_seek, 0, - ({"no", 0}, - {"bar", 1}, - {"msg", 2}, - {"msg-bar", 3})), - OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000), - OPT_FLAG("osd-fractions", osd_fractions, 0), + {"use-filedir-conf", OPT_FLAG(use_filedir_conf)}, + {"osd-level", OPT_CHOICE(osd_level, + {"0", 0}, {"1", 1}, {"2", 2}, {"3", 3})}, + {"osd-on-seek", OPT_CHOICE(osd_on_seek, + {"no", 0}, + {"bar", 1}, + {"msg", 2}, + {"msg-bar", 3})}, + {"osd-duration", OPT_INT(osd_duration), M_RANGE(0, 3600000)}, + {"osd-fractions", OPT_FLAG(osd_fractions)}, - OPT_DOUBLE("sstep", step_sec, 0, .min = 0, .max = DBL_MAX), + {"sstep", OPT_DOUBLE(step_sec), M_RANGE(0, DBL_MAX)}, - OPT_CHOICE("framedrop", frame_dropping, 0, - ({"no", 0}, - {"vo", 1}, - {"decoder", 2}, - {"decoder+vo", 3})), - OPT_FLAG("video-latency-hacks", video_latency_hacks, 0), + {"framedrop", OPT_CHOICE(frame_dropping, + {"no", 0}, + {"vo", 1}, + {"decoder", 2}, + {"decoder+vo", 3})}, + {"video-latency-hacks", OPT_FLAG(video_latency_hacks)}, - OPT_FLAG("untimed", untimed, 0), + {"untimed", OPT_FLAG(untimed)}, - OPT_STRING("stream-dump", stream_dump, M_OPT_FILE), + {"stream-dump", OPT_STRING(stream_dump), .flags = M_OPT_FILE}, - OPT_FLAG("stop-playback-on-init-failure", stop_playback_on_init_failure, 0), + {"stop-playback-on-init-failure", OPT_FLAG(stop_playback_on_init_failure)}, - OPT_CHOICE_OR_INT("loop-playlist", loop_times, 0, 1, 10000, - ({"no", 1}, - {"inf", -1}, {"yes", -1}, - {"force", -2})), - OPT_CHOICE_OR_INT("loop-file", loop_file, 0, 0, 10000, - ({"no", 0}, - {"yes", -1}, - {"inf", -1})), - OPT_ALIAS("loop", "loop-file"), + {"loop-playlist", OPT_CHOICE(loop_times, + {"no", 1}, + {"inf", -1}, {"yes", -1}, + {"force", -2}), + M_RANGE(1, 10000)}, + {"loop-file", OPT_CHOICE(loop_file, + {"no", 0}, + {"yes", -1}, + {"inf", -1}), + M_RANGE(0, 10000)}, + {"loop", OPT_ALIAS("loop-file")}, - OPT_FLAG("resume-playback", position_resume, 0), - OPT_FLAG("resume-playback-check-mtime", position_check_mtime, 0), - OPT_FLAG("save-position-on-quit", position_save_on_quit, 0), - OPT_FLAG("write-filename-in-watch-later-config", write_filename_in_watch_later_config, 0), - OPT_FLAG("ignore-path-in-watch-later-config", ignore_path_in_watch_later_config, 0), - OPT_STRING("watch-later-directory", watch_later_directory, M_OPT_FILE), + {"resume-playback", OPT_FLAG(position_resume)}, + {"resume-playback-check-mtime", OPT_FLAG(position_check_mtime)}, + {"save-position-on-quit", OPT_FLAG(position_save_on_quit)}, + {"write-filename-in-watch-later-config", + OPT_FLAG(write_filename_in_watch_later_config)}, + {"ignore-path-in-watch-later-config", + OPT_FLAG(ignore_path_in_watch_later_config)}, + {"watch-later-directory", OPT_STRING(watch_later_directory), + .flags = M_OPT_FILE}, - OPT_FLAG("ordered-chapters", ordered_chapters, 0), - OPT_STRING("ordered-chapters-files", ordered_chapters_files, M_OPT_FILE), - OPT_INTRANGE("chapter-merge-threshold", chapter_merge_threshold, 0, 0, 10000), + {"ordered-chapters", OPT_FLAG(ordered_chapters)}, + {"ordered-chapters-files", OPT_STRING(ordered_chapters_files), + .flags = M_OPT_FILE}, + {"chapter-merge-threshold", OPT_INT(chapter_merge_threshold), + M_RANGE(0, 10000)}, - OPT_DOUBLE("chapter-seek-threshold", chapter_seek_threshold, 0), + {"chapter-seek-threshold", OPT_DOUBLE(chapter_seek_threshold)}, - OPT_STRING("chapters-file", chapter_file, M_OPT_FILE), + {"chapters-file", OPT_STRING(chapter_file), .flags = M_OPT_FILE}, - OPT_FLAG("merge-files", merge_files, 0), + {"merge-files", OPT_FLAG(merge_files)}, // a-v sync stuff: - OPT_FLAG("initial-audio-sync", initial_audio_sync, 0), - OPT_CHOICE("video-sync", video_sync, 0, - ({"audio", VS_DEFAULT}, - {"display-resample", VS_DISP_RESAMPLE}, - {"display-resample-vdrop", VS_DISP_RESAMPLE_VDROP}, - {"display-resample-desync", VS_DISP_RESAMPLE_NONE}, - {"display-adrop", VS_DISP_ADROP}, - {"display-vdrop", VS_DISP_VDROP}, - {"display-desync", VS_DISP_NONE}, - {"desync", VS_NONE})), - OPT_DOUBLE("video-sync-max-video-change", sync_max_video_change, 0, - .min = 0, .max = DBL_MAX), - OPT_DOUBLE("video-sync-max-audio-change", sync_max_audio_change, 0, - .min = 0, .max = 1), - OPT_DOUBLE("video-sync-adrop-size", sync_audio_drop_size, 0, - .min = 0, .max = 1), - OPT_CHOICE("hr-seek", hr_seek, 0, - ({"no", -1}, {"absolute", 0}, {"yes", 1}, {"always", 1}, - {"default", 2})), - OPT_FLOAT("hr-seek-demuxer-offset", hr_seek_demuxer_offset, 0), - OPT_FLAG("hr-seek-framedrop", hr_seek_framedrop, 0), - OPT_CHOICE_OR_INT("autosync", autosync, 0, 0, 10000, - ({"no", -1})), + {"initial-audio-sync", OPT_FLAG(initial_audio_sync)}, + {"video-sync", OPT_CHOICE(video_sync, + {"audio", VS_DEFAULT}, + {"display-resample", VS_DISP_RESAMPLE}, + {"display-resample-vdrop", VS_DISP_RESAMPLE_VDROP}, + {"display-resample-desync", VS_DISP_RESAMPLE_NONE}, + {"display-adrop", VS_DISP_ADROP}, + {"display-vdrop", VS_DISP_VDROP}, + {"display-desync", VS_DISP_NONE}, + {"desync", VS_NONE})}, + {"video-sync-max-video-change", OPT_DOUBLE(sync_max_video_change), + M_RANGE(0, DBL_MAX)}, + {"video-sync-max-audio-change", OPT_DOUBLE(sync_max_audio_change), + M_RANGE(0, 1)}, + {"video-sync-adrop-size", OPT_DOUBLE(sync_audio_drop_size), + M_RANGE(0, 1)}, + {"hr-seek", OPT_CHOICE(hr_seek, + {"no", -1}, {"absolute", 0}, {"yes", 1}, {"always", 1}, {"default", 2})}, + {"hr-seek-demuxer-offset", OPT_FLOAT(hr_seek_demuxer_offset)}, + {"hr-seek-framedrop", OPT_FLAG(hr_seek_framedrop)}, + {"autosync", OPT_CHOICE(autosync, {"no", -1}), M_RANGE(0, 10000)}, - OPT_CHOICE("term-osd", term_osd, 0, - ({"force", 1}, - {"auto", 2}, - {"no", 0})), + {"term-osd", OPT_CHOICE(term_osd, + {"force", 1}, {"auto", 2}, {"no", 0})}, - OPT_FLAG("term-osd-bar", term_osd_bar, 0), - OPT_STRING("term-osd-bar-chars", term_osd_bar_chars, 0), + {"term-osd-bar", OPT_FLAG(term_osd_bar)}, + {"term-osd-bar-chars", OPT_STRING(term_osd_bar_chars)}, - OPT_STRING("term-playing-msg", playing_msg, 0), - OPT_STRING("osd-playing-msg", osd_playing_msg, 0), - OPT_STRING("term-status-msg", status_msg, 0), - OPT_STRING("osd-status-msg", osd_status_msg, 0), - OPT_STRING("osd-msg1", osd_msg[0], 0), - OPT_STRING("osd-msg2", osd_msg[1], 0), - OPT_STRING("osd-msg3", osd_msg[2], 0), + {"term-playing-msg", OPT_STRING(playing_msg)}, + {"osd-playing-msg", OPT_STRING(osd_playing_msg)}, + {"term-status-msg", OPT_STRING(status_msg)}, + {"osd-status-msg", OPT_STRING(osd_status_msg)}, + {"osd-msg1", OPT_STRING(osd_msg[0])}, + {"osd-msg2", OPT_STRING(osd_msg[1])}, + {"osd-msg3", OPT_STRING(osd_msg[2])}, - OPT_FLAG("video-osd", video_osd, 0), + {"video-osd", OPT_FLAG(video_osd)}, - OPT_CHOICE("idle", player_idle_mode, 0, - ({"no", 0}, - {"once", 1}, - {"yes", 2})), + {"idle", OPT_CHOICE(player_idle_mode, + {"no", 0}, {"once", 1}, {"yes", 2})}, - OPT_FLAG("input-terminal", consolecontrols, UPDATE_TERM), + {"input-terminal", OPT_FLAG(consolecontrols), .flags = UPDATE_TERM}, - OPT_STRING("input-file", input_file, M_OPT_FILE, - .deprecation_message = "use --input-ipc-server"), - OPT_STRING("input-ipc-server", ipc_path, M_OPT_FILE), + {"input-file", OPT_STRING(input_file), + .flags = M_OPT_FILE, .deprecation_message = "use --input-ipc-server"}, + {"input-ipc-server", OPT_STRING(ipc_path), .flags = M_OPT_FILE}, - OPT_SUBSTRUCT("screenshot", screenshot_image_opts, screenshot_conf, 0), - OPT_STRING("screenshot-template", screenshot_template, 0), - OPT_STRING("screenshot-directory", screenshot_directory, M_OPT_FILE), + {"screenshot", OPT_SUBSTRUCT(screenshot_image_opts, screenshot_conf)}, + {"screenshot-template", OPT_STRING(screenshot_template)}, + {"screenshot-directory", OPT_STRING(screenshot_directory), + .flags = M_OPT_FILE}, - OPT_STRING("record-file", record_file, M_OPT_FILE, .deprecation_message = - "use --stream-record or the dump-cache command"), + {"record-file", OPT_STRING(record_file), .flags = M_OPT_FILE, + .deprecation_message = "use --stream-record or the dump-cache command"}, - OPT_SUBSTRUCT("", resample_opts, resample_conf, 0), + {"", OPT_SUBSTRUCT(resample_opts, resample_conf)}, - OPT_SUBSTRUCT("", input_opts, input_config, 0), + {"", OPT_SUBSTRUCT(input_opts, input_config)}, - OPT_SUBSTRUCT("", vo, vo_sub_opts, 0), - OPT_SUBSTRUCT("", demux_opts, demux_conf, 0), - OPT_SUBSTRUCT("", demux_cache_opts, demux_cache_conf, 0), - OPT_SUBSTRUCT("", stream_opts, stream_conf, 0), + {"", OPT_SUBSTRUCT(vo, vo_sub_opts)}, + {"", OPT_SUBSTRUCT(demux_opts, demux_conf)}, + {"", OPT_SUBSTRUCT(demux_cache_opts, demux_cache_conf)}, + {"", OPT_SUBSTRUCT(stream_opts, stream_conf)}, - OPT_SUBSTRUCT("", gl_video_opts, gl_video_conf, 0), - OPT_SUBSTRUCT("", spirv_opts, spirv_conf, 0), + {"", OPT_SUBSTRUCT(gl_video_opts, gl_video_conf)}, + {"", OPT_SUBSTRUCT(spirv_opts, spirv_conf)}, #if HAVE_GL - OPT_SUBSTRUCT("", opengl_opts, opengl_conf, 0), + {"", OPT_SUBSTRUCT(opengl_opts, opengl_conf)}, #endif #if HAVE_VULKAN - OPT_SUBSTRUCT("", vulkan_opts, vulkan_conf, 0), + {"", OPT_SUBSTRUCT(vulkan_opts, vulkan_conf)}, #endif #if HAVE_D3D11 - OPT_SUBSTRUCT("", d3d11_opts, d3d11_conf, 0), + {"", OPT_SUBSTRUCT(d3d11_opts, d3d11_conf)}, #if HAVE_D3D_HWACCEL - OPT_SUBSTRUCT("", d3d11va_opts, d3d11va_conf, 0), + {"", OPT_SUBSTRUCT(d3d11va_opts, d3d11va_conf)}, #endif #endif #if HAVE_EGL_ANGLE_WIN32 - OPT_SUBSTRUCT("", angle_opts, angle_conf, 0), + {"", OPT_SUBSTRUCT(angle_opts, angle_conf)}, #endif #if HAVE_GL_COCOA - OPT_SUBSTRUCT("", cocoa_opts, cocoa_conf, 0), + {"", OPT_SUBSTRUCT(cocoa_opts, cocoa_conf)}, #endif #if HAVE_COCOA - OPT_SUBSTRUCT("", macos_opts, macos_conf, 0), + {"", OPT_SUBSTRUCT(macos_opts, macos_conf)}, #endif #if HAVE_EGL_ANDROID - OPT_SUBSTRUCT("", android_opts, android_conf, 0), + {"", OPT_SUBSTRUCT(android_opts, android_conf)}, #endif #if HAVE_WAYLAND - OPT_SUBSTRUCT("", wayland_opts, wayland_conf, 0), + {"", OPT_SUBSTRUCT(wayland_opts, wayland_conf)}, #endif #if HAVE_GL_WIN32 - OPT_CHOICE("opengl-dwmflush", wingl_dwm_flush, 0, - ({"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})), + {"opengl-dwmflush", OPT_CHOICE(wingl_dwm_flush, + {"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})}, #endif #if HAVE_CUDA_HWACCEL - OPT_CHOICE_OR_INT("cuda-decode-device", cuda_device, 0, - 0, INT_MAX, ({"auto", -1})), + {"cuda-decode-device", OPT_CHOICE(cuda_device, {"auto", -1}), + M_RANGE(0, INT_MAX)}, #endif #if HAVE_VAAPI - OPT_SUBSTRUCT("vaapi", vaapi_opts, vaapi_conf, 0), + {"vaapi", OPT_SUBSTRUCT(vaapi_opts, vaapi_conf)}, #endif - OPT_SUBSTRUCT("sws", sws_opts, sws_conf, 0), + {"sws", OPT_SUBSTRUCT(sws_opts, sws_conf)}, #if HAVE_ZIMG - OPT_SUBSTRUCT("zimg", zimg_opts, zimg_conf, 0), + {"zimg", OPT_SUBSTRUCT(zimg_opts, zimg_conf)}, #endif - OPT_SUBSTRUCT("", encode_opts, encode_config, 0), + {"", OPT_SUBSTRUCT(encode_opts, encode_config)}, - OPT_REMOVED("a52drc", "use --ad-lavc-ac3drc=level"), - OPT_REMOVED("afm", "use --ad=..."), - OPT_REPLACED("aspect", "video-aspect-override"), - OPT_REMOVED("ass-bottom-margin", "use --vf=sub=bottom:top"), - OPT_REPLACED("ass", "sub-ass"), - OPT_REPLACED("audiofile", "audio-file"), - OPT_REMOVED("benchmark", "use --untimed (no stats)"), - OPT_REMOVED("capture", NULL), - OPT_REMOVED("stream-capture", NULL), - OPT_REMOVED("channels", "use --audio-channels (changed semantics)"), - OPT_REPLACED("cursor-autohide-delay", "cursor-autohide"), - OPT_REPLACED("delay", "audio-delay"), - OPT_REMOVED("dumpstream", "use --stream-dump="), - OPT_REPLACED("dvdangle", "dvd-angle"), - OPT_REPLACED("endpos", "length"), - OPT_REPLACED("font", "osd-font"), - OPT_REPLACED("forcedsubsonly", "sub-forced-only"), - OPT_REPLACED("format", "audio-format"), - OPT_REMOVED("hardframedrop", NULL), - OPT_REMOVED("identify", "use TOOLS/mpv_identify.sh"), - OPT_REMOVED("lavdopts", "use --vd-lavc-..."), - OPT_REMOVED("lavfdopts", "use --demuxer-lavf-..."), - OPT_REPLACED("lua", "script"), - OPT_REPLACED("lua-opts", "script-opts"), - OPT_REMOVED("mixer-channel", "use AO suboptions (alsa, oss)"), - OPT_REMOVED("mixer", "use AO suboptions (alsa, oss)"), - OPT_REPLACED("mouse-movements", "input-cursor"), - OPT_REPLACED("msgcolor", "msg-color"), - OPT_REMOVED("msglevel", "use --msg-level (changed semantics)"), - OPT_REPLACED("msgmodule", "msg-module"), - OPT_REPLACED("name", "x11-name"), - OPT_REPLACED("noar", "no-input-appleremote"), - OPT_REPLACED("noautosub", "no-sub-auto"), - OPT_REPLACED("noconsolecontrols", "no-input-terminal"), - OPT_REPLACED("nosound", "no-audio"), - OPT_REPLACED("osdlevel", "osd-level"), - OPT_REMOVED("panscanrange", "use --video-zoom, --video-pan-x/y"), - OPT_REPLACED("playing-msg", "term-playing-msg"), - OPT_REMOVED("pp", NULL), - OPT_REMOVED("pphelp", NULL), - OPT_REMOVED("rawaudio", "use --demuxer-rawaudio-..."), - OPT_REMOVED("rawvideo", "use --demuxer-rawvideo-..."), - OPT_REPLACED("spugauss", "sub-gauss"), - OPT_REPLACED("srate", "audio-samplerate"), - OPT_REPLACED("ss", "start"), - OPT_REPLACED("stop-xscreensaver", "stop-screensaver"), - OPT_REPLACED("sub-fuzziness", "sub-auto"), - OPT_REPLACED("subcp", "sub-codepage"), - OPT_REPLACED("subdelay", "sub-delay"), - OPT_REPLACED("subfile", "sub-file"), - OPT_REPLACED("subfont-text-scale", "sub-scale"), - OPT_REPLACED("subfont", "sub-text-font"), - OPT_REPLACED("subfps", "sub-fps"), - OPT_REPLACED("subpos", "sub-pos"), - OPT_REPLACED("tvscan", "tv-scan"), - OPT_REMOVED("use-filename-title", "use --title='${filename}'"), - OPT_REMOVED("vc", "use --vd=..., --hwdec=..."), - OPT_REMOVED("vobsub", "use --sub-file (pass the .idx file)"), - OPT_REMOVED("xineramascreen", "use --screen (different values)"), - OPT_REMOVED("xy", "use --autofit"), - OPT_REMOVED("zoom", "Inverse available as ``--video-unscaled"), - OPT_REPLACED("media-keys", "input-media-keys"), - OPT_REPLACED("right-alt-gr", "input-right-alt-gr"), - OPT_REPLACED("autosub", "sub-auto"), - OPT_REPLACED("autosub-match", "sub-auto"), - OPT_REPLACED("status-msg", "term-status-msg"), - OPT_REPLACED("idx", "index"), - OPT_REPLACED("forceidx", "index"), - OPT_REMOVED("cache-pause-below", "for 'no', use --no-cache-pause"), - OPT_REMOVED("no-cache-pause-below", "use --no-cache-pause"), - OPT_REMOVED("volstep", "edit input.conf directly instead"), - OPT_REMOVED("fixed-vo", "--fixed-vo=yes is now the default"), - OPT_REPLACED("mkv-subtitle-preroll", "demuxer-mkv-subtitle-preroll"), - OPT_REPLACED("ass-use-margins", "sub-use-margins"), - OPT_REPLACED("media-title", "force-media-title"), - OPT_REPLACED("input-unix-socket", "input-ipc-server"), - OPT_REPLACED("softvol-max", "volume-max"), - OPT_REMOVED("bluray-angle", "this didn't do anything for a few releases"), - OPT_REPLACED("sub-text-font", "sub-font"), - OPT_REPLACED("sub-text-font-size", "sub-font-size"), - OPT_REPLACED("sub-text-color", "sub-color"), - OPT_REPLACED("sub-text-border-color", "sub-border-color"), - OPT_REPLACED("sub-text-shadow-color", "sub-shadow-color"), - OPT_REPLACED("sub-text-back-color", "sub-back-color"), - OPT_REPLACED("sub-text-border-size", "sub-border-size"), - OPT_REPLACED("sub-text-shadow-offset", "sub-shadow-offset"), - OPT_REPLACED("sub-text-spacing", "sub-spacing"), - OPT_REPLACED("sub-text-margin-x", "sub-margin-x"), - OPT_REPLACED("sub-text-margin-y", "sub-margin-y"), - OPT_REPLACED("sub-text-align-x", "sub-align-x"), - OPT_REPLACED("sub-text-align-y", "sub-align-y"), - OPT_REPLACED("sub-text-blur", "sub-blur"), - OPT_REPLACED("sub-text-bold", "sub-bold"), - OPT_REPLACED("sub-text-italic", "sub-italic"), - OPT_REPLACED("ass-line-spacing", "sub-ass-line-spacing"), - OPT_REPLACED("ass-force-margins", "sub-ass-force-margins"), - OPT_REPLACED("ass-vsfilter-aspect-compat", "sub-ass-vsfilter-aspect-compat"), - OPT_REPLACED("ass-vsfilter-color-compat", "sub-ass-vsfilter-color-compat"), - OPT_REPLACED("ass-vsfilter-blur-compat", "sub-ass-vsfilter-blur-compat"), - OPT_REPLACED("ass-force-style", "sub-ass-force-style"), - OPT_REPLACED("ass-styles", "sub-ass-styles"), - OPT_REPLACED("ass-hinting", "sub-ass-hinting"), - OPT_REPLACED("ass-shaper", "sub-ass-shaper"), - OPT_REPLACED("ass-style-override", "sub-ass-style-override"), - OPT_REPLACED("ass-scale-with-window", "sub-ass-scale-with-window"), - OPT_REPLACED("sub-ass-style-override", "sub-ass-override"), - OPT_REMOVED("fs-black-out-screens", NULL), - OPT_REPLACED("sub-paths", "sub-file-paths"), - OPT_REMOVED("heartbeat-cmd", "use Lua scripting instead"), - OPT_REMOVED("no-ometadata", "use --no-ocopy-metadata"), - OPT_REMOVED("video-stereo-mode", "removed, try --vf=stereo3d"), - OPT_REMOVED("chapter", "use '--start=#123' '--end=#124' (for chapter 123)"), - OPT_REPLACED("video-aspect", "video-aspect-override"), - OPT_REPLACED("display-fps", "override-display-fps"), + {"a52drc", OPT_REMOVED("use --ad-lavc-ac3drc=level")}, + {"afm", OPT_REMOVED("use --ad=...")}, + {"aspect", OPT_REPLACED("video-aspect-override")}, + {"ass-bottom-margin", OPT_REMOVED("use --vf=sub=bottom:top")}, + {"ass", OPT_REPLACED("sub-ass")}, + {"audiofile", OPT_REPLACED("audio-file")}, + {"benchmark", OPT_REMOVED("use --untimed (no stats)")}, + {"capture", OPT_REMOVED(NULL)}, + {"stream-capture", OPT_REMOVED(NULL)}, + {"channels", OPT_REMOVED("use --audio-channels (changed semantics)")}, + {"cursor-autohide-delay", OPT_REPLACED("cursor-autohide")}, + {"delay", OPT_REPLACED("audio-delay")}, + {"dumpstream", OPT_REMOVED("use --stream-dump=")}, + {"dvdangle", OPT_REPLACED("dvd-angle")}, + {"endpos", OPT_REPLACED("length")}, + {"font", OPT_REPLACED("osd-font")}, + {"forcedsubsonly", OPT_REPLACED("sub-forced-only")}, + {"format", OPT_REPLACED("audio-format")}, + {"hardframedrop", OPT_REMOVED(NULL)}, + {"identify", OPT_REMOVED("use TOOLS/mpv_identify.sh")}, + {"lavdopts", OPT_REMOVED("use --vd-lavc-...")}, + {"lavfdopts", OPT_REMOVED("use --demuxer-lavf-...")}, + {"lua", OPT_REPLACED("script")}, + {"lua-opts", OPT_REPLACED("script-opts")}, + {"mixer-channel", OPT_REMOVED("use AO suboptions (alsa, oss)")}, + {"mixer", OPT_REMOVED("use AO suboptions (alsa, oss)")}, + {"mouse-movements", OPT_REPLACED("input-cursor")}, + {"msgcolor", OPT_REPLACED("msg-color")}, + {"msglevel", OPT_REMOVED("use --msg-level (changed semantics)")}, + {"msgmodule", OPT_REPLACED("msg-module")}, + {"name", OPT_REPLACED("x11-name")}, + {"noar", OPT_REPLACED("no-input-appleremote")}, + {"noautosub", OPT_REPLACED("no-sub-auto")}, + {"noconsolecontrols", OPT_REPLACED("no-input-terminal")}, + {"nosound", OPT_REPLACED("no-audio")}, + {"osdlevel", OPT_REPLACED("osd-level")}, + {"panscanrange", OPT_REMOVED("use --video-zoom, --video-pan-x/y")}, + {"playing-msg", OPT_REPLACED("term-playing-msg")}, + {"pp", OPT_REMOVED(NULL)}, + {"pphelp", OPT_REMOVED(NULL)}, + {"rawaudio", OPT_REMOVED("use --demuxer-rawaudio-...")}, + {"rawvideo", OPT_REMOVED("use --demuxer-rawvideo-...")}, + {"spugauss", OPT_REPLACED("sub-gauss")}, + {"srate", OPT_REPLACED("audio-samplerate")}, + {"ss", OPT_REPLACED("start")}, + {"stop-xscreensaver", OPT_REPLACED("stop-screensaver")}, + {"sub-fuzziness", OPT_REPLACED("sub-auto")}, + {"subcp", OPT_REPLACED("sub-codepage")}, + {"subdelay", OPT_REPLACED("sub-delay")}, + {"subfile", OPT_REPLACED("sub-file")}, + {"subfont-text-scale", OPT_REPLACED("sub-scale")}, + {"subfont", OPT_REPLACED("sub-text-font")}, + {"subfps", OPT_REPLACED("sub-fps")}, + {"subpos", OPT_REPLACED("sub-pos")}, + {"tvscan", OPT_REPLACED("tv-scan")}, + {"use-filename-title", OPT_REMOVED("use --title='${filename}'")}, + {"vc", OPT_REMOVED("use --vd=..., --hwdec=...")}, + {"vobsub", OPT_REMOVED("use --sub-file (pass the .idx file)")}, + {"xineramascreen", OPT_REMOVED("use --screen (different values)")}, + {"xy", OPT_REMOVED("use --autofit")}, + {"zoom", OPT_REMOVED("Inverse available as ``--video-unscaled")}, + {"media-keys", OPT_REPLACED("input-media-keys")}, + {"right-alt-gr", OPT_REPLACED("input-right-alt-gr")}, + {"autosub", OPT_REPLACED("sub-auto")}, + {"autosub-match", OPT_REPLACED("sub-auto")}, + {"status-msg", OPT_REPLACED("term-status-msg")}, + {"idx", OPT_REPLACED("index")}, + {"forceidx", OPT_REPLACED("index")}, + {"cache-pause-below", OPT_REMOVED("for 'no', use --no-cache-pause")}, + {"no-cache-pause-below", OPT_REMOVED("use --no-cache-pause")}, + {"volstep", OPT_REMOVED("edit input.conf directly instead")}, + {"fixed-vo", OPT_REMOVED("--fixed-vo=yes is now the default")}, + {"mkv-subtitle-preroll", OPT_REPLACED("demuxer-mkv-subtitle-preroll")}, + {"ass-use-margins", OPT_REPLACED("sub-use-margins")}, + {"media-title", OPT_REPLACED("force-media-title")}, + {"input-unix-socket", OPT_REPLACED("input-ipc-server")}, + {"softvol-max", OPT_REPLACED("volume-max")}, + {"bluray-angle", OPT_REMOVED("this didn't do anything for a few releases")}, + {"sub-text-font", OPT_REPLACED("sub-font")}, + {"sub-text-font-size", OPT_REPLACED("sub-font-size")}, + {"sub-text-color", OPT_REPLACED("sub-color")}, + {"sub-text-border-color", OPT_REPLACED("sub-border-color")}, + {"sub-text-shadow-color", OPT_REPLACED("sub-shadow-color")}, + {"sub-text-back-color", OPT_REPLACED("sub-back-color")}, + {"sub-text-border-size", OPT_REPLACED("sub-border-size")}, + {"sub-text-shadow-offset", OPT_REPLACED("sub-shadow-offset")}, + {"sub-text-spacing", OPT_REPLACED("sub-spacing")}, + {"sub-text-margin-x", OPT_REPLACED("sub-margin-x")}, + {"sub-text-margin-y", OPT_REPLACED("sub-margin-y")}, + {"sub-text-align-x", OPT_REPLACED("sub-align-x")}, + {"sub-text-align-y", OPT_REPLACED("sub-align-y")}, + {"sub-text-blur", OPT_REPLACED("sub-blur")}, + {"sub-text-bold", OPT_REPLACED("sub-bold")}, + {"sub-text-italic", OPT_REPLACED("sub-italic")}, + {"ass-line-spacing", OPT_REPLACED("sub-ass-line-spacing")}, + {"ass-force-margins", OPT_REPLACED("sub-ass-force-margins")}, + {"ass-vsfilter-aspect-compat", OPT_REPLACED("sub-ass-vsfilter-aspect-compat")}, + {"ass-vsfilter-color-compat", OPT_REPLACED("sub-ass-vsfilter-color-compat")}, + {"ass-vsfilter-blur-compat", OPT_REPLACED("sub-ass-vsfilter-blur-compat")}, + {"ass-force-style", OPT_REPLACED("sub-ass-force-style")}, + {"ass-styles", OPT_REPLACED("sub-ass-styles")}, + {"ass-hinting", OPT_REPLACED("sub-ass-hinting")}, + {"ass-shaper", OPT_REPLACED("sub-ass-shaper")}, + {"ass-style-override", OPT_REPLACED("sub-ass-style-override")}, + {"ass-scale-with-window", OPT_REPLACED("sub-ass-scale-with-window")}, + {"sub-ass-style-override", OPT_REPLACED("sub-ass-override")}, + {"fs-black-out-screens", OPT_REMOVED(NULL)}, + {"sub-paths", OPT_REPLACED("sub-file-paths")}, + {"heartbeat-cmd", OPT_REMOVED("use Lua scripting instead")}, + {"no-ometadata", OPT_REMOVED("use --no-ocopy-metadata")}, + {"video-stereo-mode", OPT_REMOVED("removed, try --vf=stereo3d")}, + {"chapter", OPT_REMOVED("use '--start=#123' '--end=#124' (for chapter 123)")}, + {"video-aspect", OPT_REPLACED("video-aspect-override")}, + {"display-fps", OPT_REPLACED("override-display-fps")}, {0} }; diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 10a992da2c..0002552560 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -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), diff --git a/player/command.c b/player/command.c index 2c86a0ecb7..d894f28f89 100644 --- a/player/command.c +++ b/player/command.c @@ -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, }, diff --git a/stream/stream.c b/stream/stream.c index f5f61e93c9..c7339b4c66 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -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), diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 375f1ebba3..b00bb22539 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -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), diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index c6edaa03e9..1111d3d7a5 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -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), diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 65c6b82a64..8bbfab8af8 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -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), diff --git a/sub/osd.c b/sub/osd.c index f7935e3772..e5cc677819 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -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} }; diff --git a/video/csputils.c b/video/csputils.c index 98c5c96c39..cc9aa4d64a 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -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), diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 76f2b46e3e..14f1343d6f 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -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), diff --git a/video/filter/vf_d3d11vpp.c b/video/filter/vf_d3d11vpp.c index 504b881f3f..e3aa90c05e 100644 --- a/video/filter/vf_d3d11vpp.c +++ b/video/filter/vf_d3d11vpp.c @@ -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} }; diff --git a/video/filter/vf_fingerprint.c b/video/filter/vf_fingerprint.c index 471d995f4f..d06f80502d 100644 --- a/video/filter/vf_fingerprint.c +++ b/video/filter/vf_fingerprint.c @@ -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} }; diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c index 6681467fc3..a2adcca54a 100644 --- a/video/filter/vf_format.c +++ b/video/filter/vf_format.c @@ -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} }; diff --git a/video/filter/vf_gpu.c b/video/filter/vf_gpu.c index 5528abaa60..463d626e7d 100644 --- a/video/filter/vf_gpu.c +++ b/video/filter/vf_gpu.c @@ -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} }, }, diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index 8b2c1c83f0..ab2e308563 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -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} }; diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index d6cef08b3f..b7ed163c82 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -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} }; diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 8c41ba8734..ad2ecc04dc 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -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} }; diff --git a/video/filter/vf_vdpaupp.c b/video/filter/vf_vdpaupp.c index fe3a903558..2f485bdbad 100644 --- a/video/filter/vf_vdpaupp.c +++ b/video/filter/vf_vdpaupp.c @@ -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} }; diff --git a/video/image_writer.c b/video/image_writer.c index 5438249c42..8c3cf98d19 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -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}, }; diff --git a/video/out/android_common.c b/video/out/android_common.c index 24b87d6017..52132f2d66 100644 --- a/video/out/android_common.c +++ b/video/out/android_common.c @@ -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), diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index bdfbacfe54..600058c1d2 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -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) { diff --git a/video/out/d3d11/hwdec_d3d11va.c b/video/out/d3d11/hwdec_d3d11va.c index 8d22fe3de5..02f796e003 100644 --- a/video/out/d3d11/hwdec_d3d11va.c +++ b/video/out/d3d11/hwdec_d3d11va.c @@ -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) { diff --git a/video/out/drm_common.c b/video/out/drm_common.c index 084cf22768..4ecad6f0c4 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -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) { diff --git a/video/out/gpu/lcms.c b/video/out/gpu/lcms.c index 1d4e90d7af..0f3a0bf646 100644 --- a/video/out/gpu/lcms.c +++ b/video/out/gpu/lcms.c @@ -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), diff --git a/video/out/gpu/spirv.c b/video/out/gpu/spirv.c index ee11d601a3..67088bc7df 100644 --- a/video/out/gpu/spirv.c +++ b/video/out/gpu/spirv.c @@ -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), diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 539934fe67..9d5df7c739 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -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), diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index 51b62ad7db..ff1660c85a 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -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), diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c index 07fa183acc..781352da34 100644 --- a/video/out/opengl/context.c +++ b/video/out/opengl/context.c @@ -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) { diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c index 76d104e9b9..2784026d1d 100644 --- a/video/out/opengl/context_angle.c +++ b/video/out/opengl/context_angle.c @@ -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) { diff --git a/video/out/opengl/context_cocoa.c b/video/out/opengl/context_cocoa.c index d0fcd63d62..b7cab8e718 100644 --- a/video/out/opengl/context_cocoa.c +++ b/video/out/opengl/context_cocoa.c @@ -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), diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index a131d210cb..455c3faafd 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -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} }; diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c index 5b21646aa2..f765e79d34 100644 --- a/video/out/vo_gpu.c +++ b/video/out/vo_gpu.c @@ -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} }; diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 2a3b8fae87..15c1a34498 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -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), diff --git a/video/out/vo_null.c b/video/out/vo_null.c index 7a0662fcb9..430cd8d12b 100644 --- a/video/out/vo_null.c +++ b/video/out/vo_null.c @@ -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", diff --git a/video/out/vo_rpi.c b/video/out/vo_rpi.c index 94bb30efe6..da066ec1d2 100644 --- a/video/out/vo_rpi.c +++ b/video/out/vo_rpi.c @@ -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}, }; diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 039547f2d4..b50fc6d94c 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -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, diff --git a/video/out/vo_tct.c b/video/out/vo_tct.c index 8018a6ba72..ddd27d0380 100644 --- a/video/out/vo_tct.c +++ b/video/out/vo_tct.c @@ -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) { diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index c94fbf56f7..91ce7bc534 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -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", diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 177fd5e270..b5b936243f 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -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", diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 06812336d1..43fc046f9f 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -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", diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c index a51a9a87db..000afe211e 100644 --- a/video/out/vulkan/context.c +++ b/video/out/vulkan/context.c @@ -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), diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 20a25f8652..ebb22e23c0 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -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), diff --git a/video/sws_utils.c b/video/sws_utils.c index 55faadb1ee..ee37fc4f91 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -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), diff --git a/video/vaapi.c b/video/vaapi.c index d0a2852a47..bee24c1e72 100644 --- a/video/vaapi.c +++ b/video/vaapi.c @@ -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) { diff --git a/video/zimg.c b/video/zimg.c index 8127e87b9d..6622094022 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -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),