summaryrefslogtreecommitdiffstats
path: root/video/filter
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/filter
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/filter')
-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
8 files changed, 63 insertions, 62 deletions
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}
};