From 58d3469fd6e983887a64afc51e0611504b749b3e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 4 Nov 2012 16:24:18 +0100 Subject: video/out: replace VOCTRL_QUERY_FORMAT with vo_driver.query_format --- video/filter/vf_vo.c | 2 +- video/out/vo.c | 2 +- video/out/vo.h | 12 +++++++++--- video/out/vo_caca.c | 10 +++------- video/out/vo_corevideo.m | 3 +-- video/out/vo_direct3d.c | 7 ++++--- video/out/vo_image.c | 3 +-- video/out/vo_lavc.c | 3 +-- video/out/vo_null.c | 5 +---- video/out/vo_opengl.c | 6 +++--- video/out/vo_opengl_old.c | 3 +-- video/out/vo_sdl.c | 4 +--- video/out/vo_vdpau.c | 5 ++--- video/out/vo_x11.c | 3 +-- video/out/vo_xv.c | 6 +++--- 15 files changed, 33 insertions(+), 41 deletions(-) (limited to 'video') diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c index 3e1560ebdc..f1931126f3 100644 --- a/video/filter/vf_vo.c +++ b/video/filter/vf_vo.c @@ -113,7 +113,7 @@ static int control(struct vf_instance *vf, int request, void *data) static int query_format(struct vf_instance *vf, unsigned int fmt) { - int flags = vo_control(video_out, VOCTRL_QUERY_FORMAT, &fmt); + int flags = video_out->driver->query_format(video_out, fmt); // draw_slice() accepts stride, draw_frame() doesn't: if (flags) if (fmt == IMGFMT_YV12 || fmt == IMGFMT_I420 || fmt == IMGFMT_IYUV) diff --git a/video/out/vo.c b/video/out/vo.c index a1f3d915b1..629bba09a6 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -390,7 +390,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, vo->dheight = d_height; } - vo->default_caps = vo_control(vo, VOCTRL_QUERY_FORMAT, &format); + vo->default_caps = vo->driver->query_format(vo, format); int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, format); diff --git a/video/out/vo.h b/video/out/vo.h index 7798d6393b..186ce4d4cf 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -36,10 +36,8 @@ #define VO_EVENT_MOVE 16 enum mp_voctrl { - /* does the device support the required format */ - VOCTRL_QUERY_FORMAT = 1, /* signal a device reset seek */ - VOCTRL_RESET, + VOCTRL_RESET = 1, /* used to switch to fullscreen */ VOCTRL_FULLSCREEN, /* signal a device pause */ @@ -154,6 +152,14 @@ struct vo_driver { * returns: zero on successful initialization, non-zero on error. */ int (*preinit)(struct vo *vo, const char *arg); + + /* + * Whether the given image format is supported and config() will succeed. + * format: fourcc of pixel format + * returns: 0 on not supported, otherwise a bitmask of VFCAP_* values + */ + int (*query_format)(struct vo *vo, uint32_t format); + /* * Initialize (means CONFIGURE) the display driver. * params: diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c index 3c7614c195..a8a312d01a 100644 --- a/video/out/vo_caca.c +++ b/video/out/vo_caca.c @@ -355,7 +355,7 @@ static int preinit(struct vo *vo, const char *arg) return 0; } -static int query_format(uint32_t format) +static int query_format(struct vo *vo, uint32_t format) { if (format == IMGFMT_BGR24) return VFCAP_OSD | VFCAP_CSP_SUPPORTED; @@ -365,12 +365,7 @@ static int query_format(uint32_t format) static int control(struct vo *vo, uint32_t request, void *data) { - switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(*((uint32_t *)data)); - default: - return VO_NOTIMPL; - } + return VO_NOTIMPL; } const struct vo_driver video_out_caca = { @@ -381,6 +376,7 @@ const struct vo_driver video_out_caca = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m index c5b5399adc..1ace48eb9b 100644 --- a/video/out/vo_corevideo.m +++ b/video/out/vo_corevideo.m @@ -385,8 +385,6 @@ static int control(struct vo *vo, uint32_t request, void *data) { struct priv *p = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *(uint32_t*)data); case VOCTRL_ONTOP: p->mpglctx->ontop(vo); return VO_TRUE; @@ -442,6 +440,7 @@ const struct vo_driver video_out_corevideo = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index 2b6f39f8d2..d71b902b54 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -1212,8 +1212,9 @@ static bool init_rendering_mode(d3d_priv *priv, uint32_t fmt, bool initialize) * @return 0 on failure, device capabilities (not probed * currently) on success. */ -static int query_format(d3d_priv *priv, uint32_t movie_fmt) +static int query_format(struct vo *vo, uint32_t movie_fmt) { + d3d_priv *priv = vo->priv; if (!init_rendering_mode(priv, movie_fmt, false)) return 0; @@ -1444,8 +1445,6 @@ static int control(struct vo *vo, uint32_t request, void *data) d3d_priv *priv = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(priv, *(uint32_t*) data); case VOCTRL_FULLSCREEN: vo_w32_fullscreen(vo); resize_d3d(priv); @@ -2066,6 +2065,7 @@ const struct vo_driver video_out_direct3d = { "" }, .preinit = preinit_standard, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, @@ -2084,6 +2084,7 @@ const struct vo_driver video_out_direct3d_shaders = { "" }, .preinit = preinit_shaders, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 570955ca98..7862ceb596 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -146,8 +146,6 @@ static int control(struct vo *vo, uint32_t request, void *data) struct priv *p = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *(uint32_t *)data); case VOCTRL_SET_YUV_COLORSPACE: p->colorspace = *(struct mp_csp_details *)data; return true; @@ -182,6 +180,7 @@ const struct vo_driver video_out_image = {0}, }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index d01781ee9e..8134021b3f 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -512,8 +512,6 @@ static int control(struct vo *vo, uint32_t request, void *data) { struct priv *vc = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *((uint32_t *)data)); case VOCTRL_SET_YUV_COLORSPACE: vc->colorspace = *(struct mp_csp_details *)data; if (vc->stream) { @@ -539,6 +537,7 @@ const struct vo_driver video_out_lavc = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .uninit = uninit, diff --git a/video/out/vo_null.c b/video/out/vo_null.c index d5a657e290..67779284e0 100644 --- a/video/out/vo_null.c +++ b/video/out/vo_null.c @@ -81,10 +81,6 @@ static int preinit(struct vo *vo, const char *arg) static int control(struct vo *vo, uint32_t request, void *data) { - switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *((uint32_t *)data)); - } return VO_NOTIMPL; } @@ -96,6 +92,7 @@ const struct vo_driver video_out_null = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index dfd368fb3e..9403d7472e 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -1660,7 +1660,7 @@ static bool init_format(int fmt, struct gl_priv *init) return true; } -static int query_format(uint32_t format) +static int query_format(struct vo *vo, uint32_t format) { int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP | VFCAP_ACCEPT_STRIDE | VFCAP_OSD; @@ -1735,8 +1735,6 @@ static int control(struct vo *vo, uint32_t request, void *data) struct gl_priv *p = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(*(uint32_t *)data); case VOCTRL_ONTOP: if (!p->glctx->ontop) break; @@ -2257,6 +2255,7 @@ const struct vo_driver video_out_opengl = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, @@ -2275,6 +2274,7 @@ const struct vo_driver video_out_opengl_hq = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index c7063605c0..0fbc038784 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1081,8 +1081,6 @@ static int control(struct vo *vo, uint32_t request, void *data) struct gl_priv *p = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *(uint32_t *)data); case VOCTRL_ONTOP: if (!p->glctx->ontop) break; @@ -1170,6 +1168,7 @@ const struct vo_driver video_out_opengl_old = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 5d27962250..f5a17b84d3 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -995,9 +995,6 @@ static int control(struct vo *vo, uint32_t request, void *data) { struct priv *vc = vo->priv; switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *((uint32_t *)data)); - return 0; case VOCTRL_FULLSCREEN: set_fullscreen(vo, !vo_fs); return 1; @@ -1055,6 +1052,7 @@ const struct vo_driver video_out_sdl = { {NULL} }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index d98fa17a72..d6849564d1 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -1427,7 +1427,7 @@ static uint32_t get_image(struct vo *vo, mp_image_t *mpi) return VO_TRUE; } -static int query_format(uint32_t format) +static int query_format(struct vo *vo, uint32_t format) { int default_flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_FLIP; @@ -1604,8 +1604,6 @@ static int control(struct vo *vo, uint32_t request, void *data) if (vc->dropped_frame) vo->want_redraw = true; return true; - case VOCTRL_QUERY_FORMAT: - return query_format(*(uint32_t *)data); case VOCTRL_GET_IMAGE: return get_image(vo, data); case VOCTRL_BORDER: @@ -1686,6 +1684,7 @@ const struct vo_driver video_out_vdpau = { "" }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image_pts = draw_image, diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index f787017e90..d65326616c 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -598,8 +598,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return p->int_pause = 1; case VOCTRL_RESUME: return p->int_pause = 0; - case VOCTRL_QUERY_FORMAT: - return query_format(vo, *((uint32_t *) data)); case VOCTRL_FULLSCREEN: vo_x11_fullscreen(vo); vo_x11_clearwindow(vo, vo->x11->window); @@ -649,6 +647,7 @@ const struct vo_driver video_out_x11 = { #endif }, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 7512cef03b..a17fb2df13 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -463,8 +463,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) mp_draw_sub_backup_reset(ctx->osd_backup); } -static int query_format(struct xvctx *ctx, uint32_t format) +static int query_format(struct vo *vo, uint32_t format) { + struct xvctx *ctx = vo->priv; uint32_t i; int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN @@ -640,8 +641,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return (ctx->is_paused = 1); case VOCTRL_RESUME: return (ctx->is_paused = 0); - case VOCTRL_QUERY_FORMAT: - return query_format(ctx, *((uint32_t *) data)); case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_FULLSCREEN: @@ -691,6 +690,7 @@ static int control(struct vo *vo, uint32_t request, void *data) const struct vo_driver video_out_xv = { .info = &info, .preinit = preinit, + .query_format = query_format, .config = config, .control = control, .draw_image = draw_image, -- cgit v1.2.3