summaryrefslogtreecommitdiffstats
path: root/video/decode
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/decode
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/decode')
-rw-r--r--video/decode/vd_lavc.c43
1 files changed, 20 insertions, 23 deletions
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),