video/out: replace VOCTRL_QUERY_FORMAT with vo_driver.query_format

This commit is contained in:
wm4 2012-11-04 16:24:18 +01:00
parent 191bcbd1f2
commit 58d3469fd6
15 changed files with 33 additions and 41 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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:

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,