summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-22 00:59:00 +0200
committerwm4 <wm4@nowhere>2013-07-22 01:50:16 +0200
commit549ef68c62f2585d7818003cc2e57d82c7e46714 (patch)
tree99af24395c0bf4f94b2d3f641498cb079261521b /video
parent3fd7794d42c5389f01ddbf46b246ea053c9646c6 (diff)
downloadmpv-549ef68c62f2585d7818003cc2e57d82c7e46714.tar.bz2
mpv-549ef68c62f2585d7818003cc2e57d82c7e46714.tar.xz
vo_xv: use new option API
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_xv.c109
1 files changed, 25 insertions, 84 deletions
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index b40add2273..d9ffa8104f 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -77,7 +77,8 @@ struct xvctx {
int source; // CK_SRC_* constants
} xv_ck_info;
unsigned long xv_colorkey;
- unsigned int xv_port;
+ int xv_port;
+ int cfg_xv_adaptor;
XvAdaptorInfo *ai;
XvImageFormatValues *fo;
unsigned int formats, adaptors, xv_format;
@@ -398,62 +399,6 @@ static void xv_draw_colorkey(struct vo *vo, const struct mp_rect *rc)
}
}
-// Tests if a valid argument for the ck suboption was given.
-static int xv_test_ck(void *arg)
-{
- strarg_t *strarg = (strarg_t *)arg;
-
- if (strargcmp(strarg, "use") == 0 ||
- strargcmp(strarg, "set") == 0 ||
- strargcmp(strarg, "cur") == 0)
- return 1;
-
- return 0;
-}
-
-// Tests if a valid arguments for the ck-method suboption was given.
-static int xv_test_ckm(void *arg)
-{
- strarg_t *strarg = (strarg_t *)arg;
-
- if (strargcmp(strarg, "bg") == 0 ||
- strargcmp(strarg, "man") == 0 ||
- strargcmp(strarg, "auto") == 0)
- return 1;
-
- return 0;
-}
-
-/* Modify the colorkey_handling var according to str
- *
- * Checks if a valid pointer ( not NULL ) to the string
- * was given. And in that case modifies the colorkey_handling
- * var to reflect the requested behaviour.
- * If nothing happens the content of colorkey_handling stays
- * the same.
- */
-static void xv_setup_colorkeyhandling(struct xvctx *ctx,
- const char *ck_method_str,
- const char *ck_str)
-{
- /* check if a valid pointer to the string was passed */
- if (ck_str) {
- if (strncmp(ck_str, "use", 3) == 0)
- ctx->xv_ck_info.source = CK_SRC_USE;
- else if (strncmp(ck_str, "set", 3) == 0)
- ctx->xv_ck_info.source = CK_SRC_SET;
- }
- /* check if a valid pointer to the string was passed */
- if (ck_method_str) {
- if (strncmp(ck_method_str, "bg", 2) == 0)
- ctx->xv_ck_info.method = CK_METHOD_BACKGROUND;
- else if (strncmp(ck_method_str, "man", 3) == 0)
- ctx->xv_ck_info.method = CK_METHOD_MANUALFILL;
- else if (strncmp(ck_method_str, "auto", 4) == 0)
- ctx->xv_ck_info.method = CK_METHOD_AUTOPAINT;
- }
-}
-
static void read_xv_csp(struct vo *vo)
{
struct xvctx *ctx = vo->priv;
@@ -781,38 +726,14 @@ static int preinit(struct vo *vo, const char *arg)
XvPortID xv_p;
int busy_ports = 0;
unsigned int i;
- strarg_t ck_src_arg = { 0, NULL };
- strarg_t ck_method_arg = { 0, NULL };
- struct xvctx *ctx = talloc_ptrtype(vo, ctx);
- *ctx = (struct xvctx) {
- .xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR },
- };
- vo->priv = ctx;
- int xv_adaptor = -1;
+ struct xvctx *ctx = vo->priv;
+ int xv_adaptor = ctx->cfg_xv_adaptor;
if (!vo_x11_init(vo))
return -1;
struct vo_x11_state *x11 = vo->x11;
- const opt_t subopts[] =
- {
- /* name arg type arg var test */
- { "port", OPT_ARG_INT, &ctx->xv_port, int_pos },
- { "adaptor", OPT_ARG_INT, &xv_adaptor, int_non_neg },
- { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck },
- { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm },
- { NULL }
- };
-
- /* parse suboptions */
- if (subopt_parse(arg, subopts) != 0) {
- return -1;
- }
-
- /* modify colorkey settings according to the given options */
- xv_setup_colorkeyhandling(ctx, ck_method_arg.str, ck_src_arg.str);
-
/* check for Xvideo extension */
unsigned int ver, rel, req, ev, err;
if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
@@ -962,6 +883,8 @@ static int control(struct vo *vo, uint32_t request, void *data)
return r;
}
+#define OPT_BASE_STRUCT struct xvctx
+
const struct vo_driver video_out_xv = {
.info = &info,
.preinit = preinit,
@@ -971,5 +894,23 @@ const struct vo_driver video_out_xv = {
.draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page,
- .uninit = uninit
+ .uninit = uninit,
+ .priv_size = sizeof(struct xvctx),
+ .priv_defaults = &(const struct xvctx) {
+ .cfg_xv_adaptor = -1,
+ .xv_ck_info = {CK_METHOD_MANUALFILL, CK_SRC_CUR},
+ },
+ .options = (const struct m_option[]) {
+ OPT_INT("port", xv_port, M_OPT_MIN, .min = 0),
+ OPT_INT("adaptor", cfg_xv_adaptor, M_OPT_MIN, .min = -1),
+ 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,
+ ({"bg", CK_METHOD_BACKGROUND},
+ {"man", CK_METHOD_MANUALFILL},
+ {"auto", CK_METHOD_AUTOPAINT})),
+ {0}
+ },
};