summaryrefslogtreecommitdiffstats
path: root/video
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 /video
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.
Diffstat (limited to 'video')
-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
37 files changed, 440 insertions, 434 deletions
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),
-
- 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-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)},
+
+ {"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