summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-14 21:28:01 +0100
committerwm4 <wm4@nowhere>2020-03-18 19:52:01 +0100
commit26f4f18c0629998a9b91e94722d166866d8b80a3 (patch)
tree16d4891d241d528f63ee99f0017530bba7b3dc8b
parentcdd6eb0994bc6aeb8aeb0326e5d8c61c06eb38eb (diff)
downloadmpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.bz2
mpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.xz
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.
-rw-r--r--DOCS/tech-overview.txt2
-rw-r--r--audio/decode/ad_lavc.c8
-rw-r--r--audio/filter/af_format.c12
-rw-r--r--audio/filter/af_lavcac3enc.c12
-rw-r--r--audio/filter/af_rubberband.c58
-rw-r--r--audio/filter/af_scaletempo.c18
-rw-r--r--audio/out/ao.c11
-rw-r--r--audio/out/ao_alsa.c16
-rw-r--r--audio/out/ao_audiotrack.c4
-rw-r--r--audio/out/ao_coreaudio.c2
-rw-r--r--audio/out/ao_coreaudio_exclusive.c2
-rw-r--r--audio/out/ao_jack.c12
-rw-r--r--audio/out/ao_null.c18
-rw-r--r--audio/out/ao_openal.c6
-rw-r--r--audio/out/ao_opensles.c6
-rw-r--r--audio/out/ao_oss.c4
-rw-r--r--audio/out/ao_pcm.c6
-rw-r--r--audio/out/ao_pulse.c9
-rw-r--r--audio/out/ao_sdl.c2
-rw-r--r--common/encode_lavc.c52
-rw-r--r--demux/cache.c7
-rw-r--r--demux/demux.c57
-rw-r--r--demux/demux_cue.c2
-rw-r--r--demux/demux_lavf.c47
-rw-r--r--demux/demux_libarchive.c2
-rw-r--r--demux/demux_mkv.c18
-rw-r--r--demux/demux_raw.c56
-rw-r--r--filters/f_decoder_wrapper.c41
-rw-r--r--filters/f_lavfi.c22
-rw-r--r--filters/f_swresample.c15
-rw-r--r--input/cmd.h3
-rw-r--r--input/input.c35
-rw-r--r--options/m_option.h232
-rw-r--r--options/options.c1091
-rw-r--r--osdep/macosx_application.m48
-rw-r--r--player/command.c355
-rw-r--r--stream/stream.c6
-rw-r--r--stream/stream_cdda.c22
-rw-r--r--stream/stream_dvb.c14
-rw-r--r--stream/stream_lavf.c24
-rw-r--r--sub/osd.c44
-rw-r--r--video/csputils.c19
-rw-r--r--video/decode/vd_lavc.c43
-rw-r--r--video/filter/vf_d3d11vpp.c18
-rw-r--r--video/filter/vf_fingerprint.c6
-rw-r--r--video/filter/vf_format.c36
-rw-r--r--video/filter/vf_gpu.c4
-rw-r--r--video/filter/vf_sub.c4
-rw-r--r--video/filter/vf_vapoursynth.c9
-rw-r--r--video/filter/vf_vavpp.c22
-rw-r--r--video/filter/vf_vdpaupp.c26
-rw-r--r--video/image_writer.c20
-rw-r--r--video/out/android_common.c3
-rw-r--r--video/out/d3d11/context.c60
-rw-r--r--video/out/d3d11/hwdec_d3d11va.c2
-rw-r--r--video/out/drm_common.c42
-rw-r--r--video/out/gpu/lcms.c20
-rw-r--r--video/out/gpu/spirv.c2
-rw-r--r--video/out/gpu/video.c212
-rw-r--r--video/out/gpu/video_shaders.c8
-rw-r--r--video/out/opengl/context.c29
-rw-r--r--video/out/opengl/context_angle.c40
-rw-r--r--video/out/opengl/context_cocoa.c2
-rw-r--r--video/out/vo_direct3d.c30
-rw-r--r--video/out/vo_gpu.c8
-rw-r--r--video/out/vo_image.c4
-rw-r--r--video/out/vo_null.c2
-rw-r--r--video/out/vo_rpi.c8
-rw-r--r--video/out/vo_sdl.c6
-rw-r--r--video/out/vo_tct.c12
-rw-r--r--video/out/vo_vaapi.c12
-rw-r--r--video/out/vo_vdpau.c38
-rw-r--r--video/out/vo_xv.c28
-rw-r--r--video/out/vulkan/context.c20
-rw-r--r--video/out/wayland_common.c8
-rw-r--r--video/sws_utils.c42
-rw-r--r--video/vaapi.c2
-rw-r--r--video/zimg.c27
78 files changed, 1641 insertions, 1634 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/