summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-03 06:25:41 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-23 13:41:04 +0300
commit2bcfe1e077fe043751d3f7c73c82be761629419f (patch)
treed66207e0fad0af6d50b1d8a047d34570730a3413
parent3bb140d847eb214cf71256794170d72616edbaf4 (diff)
downloadmpv-2bcfe1e077fe043751d3f7c73c82be761629419f.tar.bz2
mpv-2bcfe1e077fe043751d3f7c73c82be761629419f.tar.xz
Add new video driver API
Create new video driver API that has a per-instance context structure and does not rely on keeping status in global or static variables. Existing drivers are not yet converted to this API; instead there is a wrapper which translates calls to them. In the new API, an old API call vo_functions->xyz(args) is generally replaced by vo_xyz(vo_instance, args). The changes to keep the vesa, dxr2 and xover drivers compiling have not been tested.
-rw-r--r--command.c10
-rw-r--r--libmenu/vf_menu.c4
-rw-r--r--libmpcodecs/vf_vo.c44
-rw-r--r--libvo/Makefile1
-rw-r--r--libvo/old_vo_wrapper.c80
-rw-r--r--libvo/old_vo_wrapper.h20
-rw-r--r--libvo/vesa_lvo.c12
-rw-r--r--libvo/vesa_lvo.h4
-rw-r--r--libvo/video_out.c165
-rw-r--r--libvo/video_out.h70
-rw-r--r--libvo/video_out_internal.h19
-rw-r--r--libvo/vo_cvidix.c2
-rw-r--r--libvo/vo_dxr2.c12
-rw-r--r--libvo/vo_fbdev.c3
-rw-r--r--libvo/vo_svga.c2
-rw-r--r--libvo/vo_vesa.c3
-rw-r--r--libvo/vo_winvidix.c2
-rw-r--r--libvo/vo_xover.c41
-rw-r--r--libvo/vo_xvidix.c2
-rw-r--r--libvo/vosub_vidix.c15
-rw-r--r--libvo/vosub_vidix.h6
-rw-r--r--mencoder.c15
-rw-r--r--mp_core.h2
-rw-r--r--mplayer.c19
-rw-r--r--spudec.c10
-rw-r--r--spudec.h2
26 files changed, 387 insertions, 178 deletions
diff --git a/command.c b/command.c
index 7ccd0ec9de..446198440c 100644
--- a/command.c
+++ b/command.c
@@ -976,7 +976,7 @@ static int mp_property_fullscreen(m_option_t * prop, int action, void *arg,
else
#endif
if (vo_config_count)
- mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
+ vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0);
return M_PROPERTY_OK;
default:
return m_property_flag(prop, action, arg, &vo_fs);
@@ -1019,7 +1019,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
{
if (!mpctx->video_out
- || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
+ || vo_control(mpctx->video_out, VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
@@ -1028,7 +1028,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
return M_PROPERTY_ERROR;
M_PROPERTY_CLAMP(prop, *(float *) arg);
vo_panscan = *(float *) arg;
- mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
+ vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
@@ -1038,7 +1038,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg,
vo_panscan = 1;
else if (vo_panscan < 0)
vo_panscan = 0;
- mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
+ vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
return M_PROPERTY_OK;
default:
return m_property_float_range(prop, action, arg, &vo_panscan);
@@ -1065,7 +1065,7 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
if (vo_config_count)
- mpctx->video_out->control(vo_ctrl, 0);
+ vo_control(mpctx->video_out, vo_ctrl, 0);
return M_PROPERTY_OK;
default:
return m_property_flag(prop, action, arg, vo_var);
diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c
index b2ba92ee58..ea63527951 100644
--- a/libmenu/vf_menu.c
+++ b/libmenu/vf_menu.c
@@ -44,12 +44,12 @@ struct vf_priv_s {
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts);
void vf_menu_pause_update(struct vf_instance_s* vf) {
- const vo_functions_t *video_out = mpctx_get_video_out(vf->priv->current->ctx);
+ const struct vo *video_out = mpctx_get_video_out(vf->priv->current->ctx);
if(pause_mpi) {
put_image(vf,pause_mpi, MP_NOPTS_VALUE);
// Don't draw the osd atm
//vf->control(vf,VFCTRL_DRAW_OSD,NULL);
- video_out->flip_page();
+ vo_flip_page(video_out);
}
}
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index 877826e3bc..5074148a8c 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -23,7 +23,7 @@ extern float sub_delay;
struct vf_priv_s {
double pts;
- const vo_functions_t *vo;
+ struct vo *vo;
#ifdef USE_ASS
ass_renderer_t* ass_priv;
int prev_visibility;
@@ -43,8 +43,7 @@ static int config(struct vf_instance_s* vf,
return 0;
}
- if(video_out->info)
- { const vo_info_t *info = video_out->info;
+ const vo_info_t *info = video_out->driver->info;
mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name,
width, height,
d_width, d_height,
@@ -57,12 +56,11 @@ static int config(struct vf_instance_s* vf,
mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author);
if(info->comment && strlen(info->comment) > 0)
mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
- }
// save vo's stride capability for the wanted colorspace:
vf->default_caps=query_format(vf,outfmt);
- if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt))
+ if (vo_config(video_out, width, height, d_width, d_height, flags, "MPlayer", outfmt))
return 0;
#ifdef USE_ASS
@@ -80,23 +78,21 @@ static int control(struct vf_instance_s* vf, int request, void* data)
case VFCTRL_GET_DEINTERLACE:
{
if(!video_out) return CONTROL_FALSE; // vo not configured?
- return(video_out->control(VOCTRL_GET_DEINTERLACE, data)
- == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE;
}
case VFCTRL_SET_DEINTERLACE:
{
if(!video_out) return CONTROL_FALSE; // vo not configured?
- return(video_out->control(VOCTRL_SET_DEINTERLACE, data)
- == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE;
}
case VFCTRL_DRAW_OSD:
if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- video_out->draw_osd();
+ vo_draw_osd(video_out);
return CONTROL_TRUE;
case VFCTRL_FLIP_PAGE:
{
if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
- video_out->flip_page();
+ vo_flip_page(video_out);
return CONTROL_TRUE;
}
case VFCTRL_SET_EQUALIZER:
@@ -104,14 +100,14 @@ static int control(struct vf_instance_s* vf, int request, void* data)
vf_equalizer_t *eq=data;
if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
struct voctrl_set_equalizer_args param = {eq->item, eq->value};
- return video_out->control(VOCTRL_SET_EQUALIZER, &param) == VO_TRUE;
+ return vo_control(video_out, VOCTRL_SET_EQUALIZER, &param) == VO_TRUE;
}
case VFCTRL_GET_EQUALIZER:
{
vf_equalizer_t *eq=data;
if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
struct voctrl_get_equalizer_args param = {eq->item, &eq->value};
- return video_out->control(VOCTRL_GET_EQUALIZER, &param) == VO_TRUE;
+ return vo_control(video_out, VOCTRL_GET_EQUALIZER, &param) == VO_TRUE;
}
#ifdef USE_ASS
case VFCTRL_INIT_EOSD:
@@ -130,7 +126,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) {
mp_eosd_res_t res;
memset(&res, 0, sizeof(res));
- if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
+ if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
ass_set_frame_size(vf->priv->ass_priv, res.w, res.h);
ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr);
ass_set_aspect_ratio(vf->priv->ass_priv, (double)res.w / res.h);
@@ -143,7 +139,7 @@ static int control(struct vf_instance_s* vf, int request, void* data)
} else
vf->priv->prev_visibility = 0;
vf->priv->prev_visibility = sub_visibility;
- return (video_out->control(VOCTRL_DRAW_EOSD, &images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+ return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE;
}
#endif
case VFCTRL_GET_PTS:
@@ -152,12 +148,11 @@ static int control(struct vf_instance_s* vf, int request, void* data)
return CONTROL_TRUE;
}
}
- // return video_out->control(request,data);
return CONTROL_UNKNOWN;
}
static int query_format(struct vf_instance_s* vf, unsigned int fmt){
- int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt);
+ int flags = vo_control(video_out, VOCTRL_QUERY_FORMAT, &fmt);
// draw_slice() accepts stride, draw_frame() doesn't:
if(flags)
if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV)
@@ -168,7 +163,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
static void get_image(struct vf_instance_s* vf,
mp_image_t *mpi){
if(vo_directrendering && vo_config_count)
- video_out->control(VOCTRL_GET_IMAGE,mpi);
+ vo_control(video_out, VOCTRL_GET_IMAGE, mpi);
}
static int put_image(struct vf_instance_s* vf,
@@ -177,15 +172,15 @@ static int put_image(struct vf_instance_s* vf,
// record pts (potentially modified by filters) for main loop
vf->priv->pts = pts;
// first check, maybe the vo/vf plugin implements draw_image using mpi:
- if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
+ if (vo_control(video_out, VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
// nope, fallback to old draw_frame/draw_slice:
if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
// blit frame:
// if(mpi->flags&MP_IMGFLAG_PLANAR)
if(vf->default_caps&VFCAP_ACCEPT_STRIDE)
- video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
+ vo_draw_slice(video_out, mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
else
- video_out->draw_frame(mpi->planes);
+ vo_draw_frame(video_out, mpi->planes);
}
return 1;
}
@@ -193,13 +188,13 @@ static int put_image(struct vf_instance_s* vf,
static void start_slice(struct vf_instance_s* vf,
mp_image_t *mpi) {
if(!vo_config_count) return; // vo not configured?
- video_out->control(VOCTRL_START_SLICE,mpi);
+ vo_control(video_out, VOCTRL_START_SLICE,mpi);
}
static void draw_slice(struct vf_instance_s* vf,
unsigned char** src, int* stride, int w,int h, int x, int y){
if(!vo_config_count) return; // vo not configured?
- video_out->draw_slice(src,stride,w,h,x,y);
+ vo_draw_slice(video_out, src,stride,w,h,x,y);
}
static void uninit(struct vf_instance_s* vf)
@@ -224,9 +219,8 @@ static int open(vf_instance_t *vf, char* args){
vf->start_slice=start_slice;
vf->uninit=uninit;
vf->priv=calloc(1, sizeof(struct vf_priv_s));
- vf->priv->vo = (const vo_functions_t *)args;
+ vf->priv->vo = (struct vo *)args;
if(!video_out) return 0; // no vo ?
-// if(video_out->preinit(args)) return 0; // preinit failed
return 1;
}
diff --git a/libvo/Makefile b/libvo/Makefile
index f2840e9161..7dd486a0f3 100644
--- a/libvo/Makefile
+++ b/libvo/Makefile
@@ -5,6 +5,7 @@ LIBNAME_MPLAYER = libvo.a
SRCS_MPLAYER = aspect.c \
geometry.c \
+ old_vo_wrapper.c \
spuenc.c \
video_out.c \
vo_mpegpes.c \
diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c
new file mode 100644
index 0000000000..b52622321a
--- /dev/null
+++ b/libvo/old_vo_wrapper.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <stdint.h>
+#include "old_vo_wrapper.h"
+#include "video_out.h"
+
+int old_vo_preinit(struct vo *vo, const char *arg)
+{
+ return vo->driver->old_functions->preinit(arg);
+}
+
+
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format)
+{
+ return vo->driver->old_functions->config(width, height, d_width,
+ d_height, flags, title, format);
+}
+
+
+int old_vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->old_functions->control(request, data);
+}
+
+
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ return vo->driver->old_functions->draw_frame(src);
+}
+
+
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y)
+{
+ return vo->driver->old_functions->draw_slice(src, stride, w, h, x, y);
+}
+
+
+void old_vo_draw_osd(struct vo *vo)
+{
+ vo->driver->old_functions->draw_osd();
+}
+
+
+void old_vo_flip_page(struct vo *vo)
+{
+ vo->driver->old_functions->flip_page();
+}
+
+
+void old_vo_check_events(struct vo *vo)
+{
+ vo->driver->old_functions->check_events();
+}
+
+
+void old_vo_uninit(struct vo *vo)
+{
+ vo->driver->old_functions->uninit();
+}
+
diff --git a/libvo/old_vo_wrapper.h b/libvo/old_vo_wrapper.h
new file mode 100644
index 0000000000..e6d20ce5ca
--- /dev/null
+++ b/libvo/old_vo_wrapper.h
@@ -0,0 +1,20 @@
+#ifndef MPLAYER_OLD_VO_WRAPPER_H
+#define MPLAYER_OLD_VO_WRAPPER_H
+
+#include <stdint.h>
+#include "video_out.h"
+
+int old_vo_preinit(struct vo *vo, const char *);
+int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format);
+int old_vo_control(struct vo *vo, uint32_t request, void *data);
+int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+ int w, int h, int x, int y);
+void old_vo_draw_osd(struct vo *vo);
+void old_vo_flip_page(struct vo *vo);
+void old_vo_check_events(struct vo *vo);
+void old_vo_uninit(struct vo *vo);
+
+#endif
diff --git a/libvo/vesa_lvo.c b/libvo/vesa_lvo.c
index cbb4e800dd..fc1573325b 100644
--- a/libvo/vesa_lvo.c
+++ b/libvo/vesa_lvo.c
@@ -43,13 +43,13 @@ static uint8_t *lvo_mem = NULL;
static uint8_t next_frame;
static mga_vid_config_t mga_vid_config;
static unsigned image_bpp,image_height,image_width,src_format;
-uint32_t vlvo_control(uint32_t request, void *data);
+int vlvo_control(uint32_t request, void *data);
#define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8)
#define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
#define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size))
-extern vo_functions_t video_out_vesa;
+extern struct vo_old_functions video_out_vesa;
int vlvo_preinit(const char *drvname)
{
@@ -155,7 +155,7 @@ void vlvo_term( void )
if(lvo_handler != -1) close(lvo_handler);
}
-uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
uint8_t *src;
uint8_t *dest;
@@ -195,7 +195,7 @@ uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,i
return 0;
}
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_draw_slice() was called\n");}
@@ -213,7 +213,7 @@ uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y
return 0;
}
-uint32_t vlvo_draw_frame(uint8_t *image[])
+int vlvo_draw_frame(uint8_t *image[])
{
/* Note it's very strange but sometime for YUY2 draw_frame is called */
fast_memcpy(lvo_mem,image[0],mga_vid_config.frame_size);
@@ -303,7 +303,7 @@ uint32_t vlvo_query_info(uint32_t format)
return VFCAP_CSP_SUPPORTED;
}
-uint32_t vlvo_control(uint32_t request, void *data)
+int vlvo_control(uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
diff --git a/libvo/vesa_lvo.h b/libvo/vesa_lvo.h
index 67a9ee0dd1..2581ace34e 100644
--- a/libvo/vesa_lvo.h
+++ b/libvo/vesa_lvo.h
@@ -21,8 +21,8 @@ int vlvo_init(unsigned src_width,unsigned src_height,
void vlvo_term( void );
uint32_t vlvo_query_info(uint32_t format);
-uint32_t vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
-uint32_t vlvo_draw_frame(uint8_t *src[]);
+int vlvo_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
+int vlvo_draw_frame(uint8_t *src[]);
void vlvo_flip_page(void);
void vlvo_draw_osd(void);
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 305750293a..b694cf944f 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -66,54 +66,54 @@ int vo_colorkey = 0x0000ff00; // default colorkey is green
//
// Externally visible list of all vo drivers
//
-extern vo_functions_t video_out_mga;
-extern vo_functions_t video_out_xmga;
-extern vo_functions_t video_out_x11;
-extern vo_functions_t video_out_xover;
-extern vo_functions_t video_out_xvmc;
-extern vo_functions_t video_out_xv;
-extern vo_functions_t video_out_gl;
-extern vo_functions_t video_out_gl2;
-extern vo_functions_t video_out_dga;
-extern vo_functions_t video_out_sdl;
-extern vo_functions_t video_out_3dfx;
-extern vo_functions_t video_out_tdfxfb;
-extern vo_functions_t video_out_s3fb;
-extern vo_functions_t video_out_null;
-extern vo_functions_t video_out_zr;
-extern vo_functions_t video_out_zr2;
-extern vo_functions_t video_out_bl;
-extern vo_functions_t video_out_fbdev;
-extern vo_functions_t video_out_fbdev2;
-extern vo_functions_t video_out_svga;
-extern vo_functions_t video_out_png;
-extern vo_functions_t video_out_ggi;
-extern vo_functions_t video_out_aa;
-extern vo_functions_t video_out_caca;
-extern vo_functions_t video_out_mpegpes;
-extern vo_functions_t video_out_yuv4mpeg;
-extern vo_functions_t video_out_directx;
-extern vo_functions_t video_out_dxr2;
-extern vo_functions_t video_out_dxr3;
-extern vo_functions_t video_out_ivtv;
-extern vo_functions_t video_out_v4l2;
-extern vo_functions_t video_out_jpeg;
-extern vo_functions_t video_out_gif89a;
-extern vo_functions_t video_out_vesa;
-extern vo_functions_t video_out_directfb;
-extern vo_functions_t video_out_dfbmga;
-extern vo_functions_t video_out_xvidix;
-extern vo_functions_t video_out_winvidix;
-extern vo_functions_t video_out_cvidix;
-extern vo_functions_t video_out_tdfx_vid;
-extern vo_functions_t video_out_xvr100;
-extern vo_functions_t video_out_tga;
-extern vo_functions_t video_out_macosx;
-extern vo_functions_t video_out_quartz;
-extern vo_functions_t video_out_pnm;
-extern vo_functions_t video_out_md5sum;
-
-const vo_functions_t* const video_out_drivers[] =
+extern struct vo_driver video_out_mga;
+extern struct vo_driver video_out_xmga;
+extern struct vo_driver video_out_x11;
+extern struct vo_driver video_out_xover;
+extern struct vo_driver video_out_xvmc;
+extern struct vo_driver video_out_xv;
+extern struct vo_driver video_out_gl;
+extern struct vo_driver video_out_gl2;
+extern struct vo_driver video_out_dga;
+extern struct vo_driver video_out_sdl;
+extern struct vo_driver video_out_3dfx;
+extern struct vo_driver video_out_tdfxfb;
+extern struct vo_driver video_out_s3fb;
+extern struct vo_driver video_out_null;
+extern struct vo_driver video_out_zr;
+extern struct vo_driver video_out_zr2;
+extern struct vo_driver video_out_bl;
+extern struct vo_driver video_out_fbdev;
+extern struct vo_driver video_out_fbdev2;
+extern struct vo_driver video_out_svga;
+extern struct vo_driver video_out_png;
+extern struct vo_driver video_out_ggi;
+extern struct vo_driver video_out_aa;
+extern struct vo_driver video_out_caca;
+extern struct vo_driver video_out_mpegpes;
+extern struct vo_driver video_out_yuv4mpeg;
+extern struct vo_driver video_out_directx;
+extern struct vo_driver video_out_dxr2;
+extern struct vo_driver video_out_dxr3;
+extern struct vo_driver video_out_ivtv;
+extern struct vo_driver video_out_v4l2;
+extern struct vo_driver video_out_jpeg;
+extern struct vo_driver video_out_gif89a;
+extern struct vo_driver video_out_vesa;
+extern struct vo_driver video_out_directfb;
+extern struct vo_driver video_out_dfbmga;
+extern struct vo_driver video_out_xvidix;
+extern struct vo_driver video_out_winvidix;
+extern struct vo_driver video_out_cvidix;
+extern struct vo_driver video_out_tdfx_vid;
+extern struct vo_driver video_out_xvr100;
+extern struct vo_driver video_out_tga;
+extern struct vo_driver video_out_macosx;
+extern struct vo_driver video_out_quartz;
+extern struct vo_driver video_out_pnm;
+extern struct vo_driver video_out_md5sum;
+
+const struct vo_driver *video_out_drivers[] =
{
#ifdef HAVE_XVR100
&video_out_xvr100,
@@ -243,6 +243,48 @@ const vo_functions_t* const video_out_drivers[] =
NULL
};
+
+static int vo_preinit(struct vo *vo, const char *arg)
+{
+ return vo->driver->preinit(vo, arg);
+}
+
+int vo_control(struct vo *vo, uint32_t request, void *data)
+{
+ return vo->driver->control(vo, request, data);
+}
+
+int vo_draw_frame(struct vo *vo, uint8_t *src[])
+{
+ return vo->driver->draw_frame(vo, src);
+}
+
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
+{
+ return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
+}
+
+void vo_draw_osd(struct vo *vo)
+{
+ vo->driver->draw_osd(vo);
+}
+
+void vo_flip_page(struct vo *vo)
+{
+ vo->driver->flip_page(vo);
+}
+
+void vo_check_events(struct vo *vo)
+{
+ vo->driver->check_events(vo);
+}
+
+void vo_destroy(struct vo *vo)
+{
+ vo->driver->uninit(vo);
+ free(vo);
+}
+
void list_video_out(void)
{
int i = 0;
@@ -255,9 +297,10 @@ void list_video_out(void)
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
}
-const vo_functions_t *init_best_video_out(char **vo_list)
+struct vo *init_best_video_out(char **vo_list)
{
int i;
+ struct vo *vo = malloc(sizeof *vo);
// first try the preferred drivers, with their optional subdevice param:
if (vo_list && vo_list[0])
while (vo_list[0][0]) {
@@ -272,13 +315,15 @@ const vo_functions_t *init_best_video_out(char **vo_list)
++vo_subdevice;
}
for (i = 0; video_out_drivers[i]; i++) {
- const vo_functions_t *video_driver = video_out_drivers[i];
+ const struct vo_driver *video_driver = video_out_drivers[i];
const vo_info_t *info = video_driver->info;
if (!strcmp(info->short_name, name)) {
// name matches, try it
- if (!video_driver->preinit(vo_subdevice)) {
+ memset(vo, 0, sizeof *vo);
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice)) {
free(name);
- return video_driver; // success!
+ return vo; // success!
}
}
}
@@ -291,14 +336,17 @@ const vo_functions_t *init_best_video_out(char **vo_list)
// now try the rest...
vo_subdevice = NULL;
for (i = 0; video_out_drivers[i]; i++) {
- const vo_functions_t *video_driver = video_out_drivers[i];
- if (!video_driver->preinit(vo_subdevice))
- return video_driver; // success!
+ const struct vo_driver *video_driver = video_out_drivers[i];
+ memset(vo, 0, sizeof *vo);
+ vo->driver = video_driver;
+ if (!vo_preinit(vo, vo_subdevice))
+ return vo; // success!
}
+ free(vo);
return NULL;
}
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format)
{
@@ -306,7 +354,7 @@ int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
aspect_save_orig(width, height);
aspect_save_prescale(d_width, d_height);
- if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
+ if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
aspect(&d_width, &d_height, A_NOZOOM);
vo_dx = (int)(vo_screenwidth - d_width) / 2;
vo_dy = (int)(vo_screenheight - d_height) / 2;
@@ -318,7 +366,8 @@ int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
vo_dheight = d_height;
}
- return vo->config(width, height, d_width, d_height, flags, title, format);
+ return vo->driver->config(vo, width, height, d_width, d_height, flags,
+ title, format);
}
#if defined(HAVE_FBDEV)||defined(HAVE_VESA)
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 06f93814fc..c22c0a5102 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -116,15 +116,23 @@ typedef struct vo_info_s
const char *comment;
} vo_info_t;
-typedef struct vo_functions_s
-{
+struct vo;
+
+struct vo_driver {
+ // Driver uses new API
+ int is_new;
+
+ // This is set if the driver is not new and contains pointers to
+ // old-API functions to be used instead of the ones below.
+ struct vo_old_functions *old_functions;
+
const vo_info_t *info;
/*
* Preinitializes driver (real INITIALIZATION)
* arg - currently it's vo_subdevice
* returns: zero on successful initialization, non-zero on error.
*/
- int (*preinit)(const char *arg);
+ int (*preinit)(struct vo *vo, const char *arg);
/*
* Initialize (means CONFIGURE) the display driver.
* params:
@@ -135,21 +143,21 @@ typedef struct vo_functions_s
* format: fourcc of pixel format
* returns : zero on successful initialization, non-zero on error.
*/
- int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t fullscreen, char *title,
- uint32_t format);
+ int (*config)(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
+ char *title, uint32_t format);
/*
* Control interface
*/
- int (*control)(uint32_t request, void *data);
+ int (*control)(struct vo *vo, uint32_t request, void *data);
/*
* Display a new RGB/BGR frame of the video to the screen.
* params:
* src[0] - pointer to the image
*/
- int (*draw_frame)(uint8_t *src[]);
+ int (*draw_frame)(struct vo *vo, uint8_t *src[]);
/*
* Draw a planar YUV slice to the buffer:
@@ -159,39 +167,67 @@ typedef struct vo_functions_s
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
- int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
+ int h, int x, int y);
/*
* Draws OSD to the screen buffer
*/
- void (*draw_osd)(void);
+ void (*draw_osd)(struct vo *vo);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/
- void (*flip_page)(void);
+ void (*flip_page)(struct vo *vo);
/*
* This func is called after every frames to handle keyboard and
* other events. It's called in PAUSE mode too!
*/
- void (*check_events)(void);
+ void (*check_events)(struct vo *vo);
/*
* Closes driver. Should restore the original state of the system.
*/
- void (*uninit)(void);
+ void (*uninit)(struct vo *vo);
+};
-} vo_functions_t;
+struct vo_old_functions {
+ int (*preinit)(const char *arg);
+ int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
+ uint32_t d_height, uint32_t fullscreen, char *title,
+ uint32_t format);
+ int (*control)(uint32_t request, void *data);
+ int (*draw_frame)(uint8_t *src[]);
+ int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
+ void (*draw_osd)(void);
+ void (*flip_page)(void);
+ void (*check_events)(void);
+ void (*uninit)(void);
+};
+
+struct vo {
+ const struct vo_driver *driver;
+ void *priv;
+};
-const vo_functions_t* init_best_video_out(char** vo_list);
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
+struct vo *init_best_video_out(char **vo_list);
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format);
void list_video_out(void);
+int vo_control(struct vo *vo, uint32_t request, void *data);
+int vo_draw_frame(struct vo *vo, uint8_t *src[]);
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
+void vo_draw_osd(struct vo *vo);
+void vo_flip_page(struct vo *vo);
+void vo_check_events(struct vo *vo);
+void vo_destroy(struct vo *vo);
+
+
// NULL terminated array of all drivers
-extern const vo_functions_t* const video_out_drivers[];
+extern const stru