From 2bcfe1e077fe043751d3f7c73c82be761629419f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 3 Apr 2008 06:25:41 +0300 Subject: 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. --- libvo/Makefile | 1 + libvo/old_vo_wrapper.c | 80 ++++++++++++++++++++++ libvo/old_vo_wrapper.h | 20 ++++++ libvo/vesa_lvo.c | 12 ++-- libvo/vesa_lvo.h | 4 +- libvo/video_out.c | 165 +++++++++++++++++++++++++++++---------------- libvo/video_out.h | 70 ++++++++++++++----- libvo/video_out_internal.h | 19 +++++- libvo/vo_cvidix.c | 2 +- libvo/vo_dxr2.c | 12 ++-- libvo/vo_fbdev.c | 3 +- libvo/vo_svga.c | 2 +- libvo/vo_vesa.c | 3 +- libvo/vo_winvidix.c | 2 +- libvo/vo_xover.c | 41 +++++------ libvo/vo_xvidix.c | 2 +- libvo/vosub_vidix.c | 15 +++-- libvo/vosub_vidix.h | 6 +- 18 files changed, 333 insertions(+), 126 deletions(-) create mode 100644 libvo/old_vo_wrapper.c create mode 100644 libvo/old_vo_wrapper.h (limited to 'libvo') 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 +#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 +#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 struct vo_driver *video_out_drivers[]; extern int vo_flags; diff --git a/libvo/video_out_internal.h b/libvo/video_out_internal.h index 1bfb91d18c..ba37f9ea50 100644 --- a/libvo/video_out_internal.h +++ b/libvo/video_out_internal.h @@ -29,6 +29,7 @@ #include "libmpcodecs/vfcap.h" #include "libmpcodecs/mp_image.h" #include "geometry.h" +#include "old_vo_wrapper.h" static int control(uint32_t request, void *data); static int config(uint32_t width, uint32_t height, uint32_t d_width, @@ -43,9 +44,20 @@ static void uninit(void); static int query_format(uint32_t format); static int preinit(const char *); -#define LIBVO_EXTERN(x) vo_functions_t video_out_##x =\ +#define LIBVO_EXTERN(x) struct vo_driver video_out_##x =\ {\ - &info,\ + .is_new = 0,\ + .info = &info,\ + .preinit = old_vo_preinit,\ + .config = old_vo_config,\ + .control = old_vo_control,\ + .draw_frame = old_vo_draw_frame,\ + .draw_slice = old_vo_draw_slice,\ + .draw_osd = old_vo_draw_osd,\ + .flip_page = old_vo_flip_page,\ + .check_events = old_vo_check_events,\ + .uninit = old_vo_uninit,\ + .old_functions = &(struct vo_old_functions){\ preinit,\ config,\ control,\ @@ -54,7 +66,8 @@ static int preinit(const char *); draw_osd,\ flip_page,\ check_events,\ - uninit\ + uninit,\ + }\ }; #include "osd.h" diff --git a/libvo/vo_cvidix.c b/libvo/vo_cvidix.c index 3e54616b50..f68ae611bd 100644 --- a/libvo/vo_cvidix.c +++ b/libvo/vo_cvidix.c @@ -152,7 +152,7 @@ static int preinit(const char *arg){ mp_msg(MSGT_VO, MSGL_INFO, "vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!\n"); vidix_name = NULL; } - if(vidix_preinit(vidix_name, &video_out_cvidix))return 1; + if (vidix_preinit(vidix_name, video_out_cvidix.old_functions))return 1; return 0; } diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c index 4b0d47326c..75e0ca1a81 100644 --- a/libvo/vo_dxr2.c +++ b/libvo/vo_dxr2.c @@ -37,7 +37,8 @@ static int movie_w,movie_h; static int playing = 0; // vo device used to blank the screen for the overlay init -static const vo_functions_t* sub_vo = NULL; +static const struct vo_old_functions *sub_vo = NULL; +static const struct vo_info_s *sub_info; static uint8_t* sub_img = NULL; static int sub_x,sub_y,sub_w,sub_h; @@ -432,7 +433,7 @@ static int dxr2_load_vga_params(dxr2_vgaParams_t* vga,char* name) { } static int dxr2_setup_vga_params(void) { - const vo_info_t* vi = sub_vo->info; + const vo_info_t* vi = sub_info; dxr2_vgaParams_t vga; int loaded = dxr2_load_vga_params(&vga,(char*)vi->short_name); @@ -646,7 +647,7 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t } // Does the sub vo support the x11 stuff // Fix me : test the other x11 vo's and enable them - if(strcmp(sub_vo->info->short_name,"x11") == 0) + if(strcmp(sub_info->short_name,"x11") == 0) sub_vo_win = 1; else sub_vo_win = 0; @@ -820,10 +821,11 @@ static int preinit(const char *arg) { const vo_info_t* vi = video_out_drivers[n]->info; if(!vi) continue; - if(strcasecmp(arg,vi->short_name) == 0) + if(!video_out_drivers[n]->is_new && strcasecmp(arg,vi->short_name) == 0) break; } - sub_vo = video_out_drivers[n]; + sub_vo = video_out_drivers[n]->old_functions; + sub_info = video_out_drivers[n]->info; } else { mp_msg(MSGT_VO,MSGL_WARN,"VO: [dxr2] We need a sub driver to initialize the overlay\n"); use_ol = 0; diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 1f99ef08d7..178f17869a 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -1132,7 +1132,8 @@ static int preinit(const char *vo_subdevice) if (memcmp(vo_subdevice, "vidix", 5) == 0) vidix_name = &vo_subdevice[5]; if(vidix_name) - pre_init_err = vidix_preinit(vidix_name,&video_out_fbdev); + pre_init_err = vidix_preinit(vidix_name, + video_out_fbdev.old_functions); else #endif { diff --git a/libvo/vo_svga.c b/libvo/vo_svga.c index 31b103f9c2..36873185c0 100644 --- a/libvo/vo_svga.c +++ b/libvo/vo_svga.c @@ -135,7 +135,7 @@ char s[64]; vidix_name[i-5]=0; if(arg[i]==':')i++; arg+=i; - vidix_preinit(vidix_name, &video_out_svga); + vidix_preinit(vidix_name, video_out_svga.old_functions); } #endif if(!strncmp(arg,"sq",2)) { diff --git a/libvo/vo_vesa.c b/libvo/vo_vesa.c index f5a40d284a..b5fafb24a5 100644 --- a/libvo/vo_vesa.c +++ b/libvo/vo_vesa.c @@ -1076,7 +1076,8 @@ static int preinit(const char *arg) if(arg) subdev_flags = parseSubDevice(arg); if(lvo_name) pre_init_err = vlvo_preinit(lvo_name); #ifdef CONFIG_VIDIX - else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa); + else if(vidix_name) pre_init_err = vidix_preinit(vidix_name, + video_out_vesa.old_functions); #endif // check if we can open /dev/mem (it will be opened later in config(), but if we // detect now that we can't we can exit cleanly) diff --git a/libvo/vo_winvidix.c b/libvo/vo_winvidix.c index a66b062cdf..5ddc6f5617 100644 --- a/libvo/vo_winvidix.c +++ b/libvo/vo_winvidix.c @@ -323,7 +323,7 @@ static int preinit(const char *arg){ vidix_name = NULL; } - if (vidix_preinit(vidix_name, &video_out_winvidix) != 0) + if (vidix_preinit(vidix_name, video_out_winvidix.old_functions) != 0) return(1); return(0); diff --git a/libvo/vo_xover.c b/libvo/vo_xover.c index 77d8306151..a51e9aa48c 100644 --- a/libvo/vo_xover.c +++ b/libvo/vo_xover.c @@ -67,8 +67,8 @@ static uint32_t window_width, window_height; static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth, drwDepth, drwcX, drwcY, dwidth, dheight; -static const vo_functions_t* sub_vo = NULL; - +static const struct vo_old_functions *sub_vo = NULL; +static const struct vo_info_s *sub_info; static void set_window(int force_update) { @@ -211,7 +211,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, mp_colorkey_t colork; char _title[255]; - sprintf(_title,"MPlayer %s X11 Overlay",sub_vo->info->name); + sprintf(_title,"MPlayer %s X11 Overlay", sub_info->name); title = _title; panscan_init(); @@ -384,10 +384,10 @@ static void uninit(void) sub_vo = NULL; vo_x11_uninit(); // Restore our callbacks - video_out_xover.draw_frame = draw_frame; - video_out_xover.draw_slice = draw_slice; - video_out_xover.flip_page = flip_page; - video_out_xover.draw_osd = draw_osd; + video_out_xover.old_functions->draw_frame = draw_frame; + video_out_xover.old_functions->draw_slice = draw_slice; + video_out_xover.old_functions->flip_page = flip_page; + video_out_xover.old_functions->draw_osd = draw_osd; } static int preinit(const char *arg) @@ -399,31 +399,34 @@ static int preinit(const char *arg) return 1; } - for(i = 0 ; video_out_drivers[i] != NULL ; i++) { - if(!strcmp(video_out_drivers[i]->info->short_name,arg) && - strcmp(video_out_drivers[i]->info->short_name,"xover")) + const struct vo_driver *candidate; + for(i = 0; (candidate = video_out_drivers[i]) != NULL; i++) + if (!candidate->is_new && !strcmp(candidate->info->short_name,arg) && + strcmp(candidate->info->short_name,"xover")) break; - } - if(!video_out_drivers[i]) { + if (!candidate) { mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subdriver %s not found\n", arg); return 1; } - if(video_out_drivers[i]->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) { + + const struct vo_old_functions *functions = candidate->old_functions; + if (functions->control(VOCTRL_XOVERLAY_SUPPORT,NULL) != VO_TRUE) { mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: %s doesn't support XOverlay\n", arg); return 1; } // X11 init if (!vo_init()) return VO_FALSE; - if(video_out_drivers[i]->preinit(NULL)) { + if(functions->preinit(NULL)) { mp_msg(MSGT_VO, MSGL_ERR, "VO XOverlay: Subvo init failed\n"); return 1; } - sub_vo = video_out_drivers[i]; + sub_vo = functions; + sub_info = candidate->info; // Setup the sub vo callbacks - video_out_xover.draw_frame = sub_vo->draw_frame; - video_out_xover.draw_slice = sub_vo->draw_slice; - video_out_xover.flip_page = sub_vo->flip_page; - video_out_xover.draw_osd = sub_vo->draw_osd; + video_out_xover.old_functions->draw_frame = sub_vo->draw_frame; + video_out_xover.old_functions->draw_slice = sub_vo->draw_slice; + video_out_xover.old_functions->flip_page = sub_vo->flip_page; + video_out_xover.old_functions->draw_osd = sub_vo->draw_osd; return 0; } diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c index 260cdc9ba1..0dd6f6d43a 100644 --- a/libvo/vo_xvidix.c +++ b/libvo/vo_xvidix.c @@ -464,7 +464,7 @@ static int preinit(const char *arg) if (!vo_init()) return (-1); - if (vidix_preinit(vidix_name, &video_out_xvidix) != 0) + if (vidix_preinit(vidix_name, video_out_xvidix.old_functions) != 0) return (1); return (0); diff --git a/libvo/vosub_vidix.c b/libvo/vosub_vidix.c index 2291814810..b9ff829faa 100644 --- a/libvo/vosub_vidix.c +++ b/libvo/vosub_vidix.c @@ -33,6 +33,7 @@ #include "video_out.h" #include "sub.h" #include "vosub_vidix.h" +#include "old_vo_wrapper.h" #include "libmpcodecs/vfcap.h" #include "libmpcodecs/mp_image.h" @@ -48,7 +49,7 @@ static int video_on=0; static vidix_capability_t vidix_cap; static vidix_playback_t vidix_play; static vidix_fourcc_t vidix_fourcc; -static vo_functions_t * vo_server; +static struct vo_old_functions *vo_server; static vidix_yuv_t dstrides; /*static uint32_t (*server_control)(uint32_t request, void *data, ...);*/ @@ -85,7 +86,7 @@ void vidix_term( void ) // vo_server->control=server_control; } -static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) +static int vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) { uint8_t *src; uint8_t *dest; @@ -149,7 +150,7 @@ static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h return -1; } -static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y) +static int vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h,int x,int y) { uint8_t *src; uint8_t *dest; @@ -195,7 +196,7 @@ static uint32_t vidix_draw_slice_410(uint8_t *image[], int stride[], int w,int h return -1; } -static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y) +static int vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y) { uint8_t *src; uint8_t *dest; @@ -212,7 +213,7 @@ static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,in return 0; } -uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) +int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) { mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawsliceWasCalled); return -1; @@ -230,7 +231,7 @@ static uint32_t vidix_draw_image(mp_image_t *mpi){ return VO_TRUE; } -uint32_t vidix_draw_frame(uint8_t *image[]) +int vidix_draw_frame(uint8_t *image[]) { mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SUB_VIDIX_DummyVidixdrawframeWasCalled); return -1; @@ -625,7 +626,7 @@ uint32_t vidix_control(uint32_t request, void *data) // return server_control(request,data); //VO_NOTIMPL; } -int vidix_preinit(const char *drvname,vo_functions_t *server) +int vidix_preinit(const char *drvname, struct vo_old_functions *server) { int err; if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { diff --git a/libvo/vosub_vidix.h b/libvo/vosub_vidix.h index 0c2e30d793..d5a96fcfc8 100644 --- a/libvo/vosub_vidix.h +++ b/libvo/vosub_vidix.h @@ -16,7 +16,7 @@ #include "video_out.h" /* drvname can be NULL */ -int vidix_preinit(const char *drvname,vo_functions_t *server); +int vidix_preinit(const char *drvname, struct vo_old_functions *server); int vidix_init(unsigned src_width,unsigned src_height, unsigned dest_x,unsigned dest_y,unsigned dst_width, unsigned dst_height,unsigned format,unsigned dest_bpp, @@ -27,8 +27,8 @@ void vidix_term( void ); uint32_t vidix_control(uint32_t request, void *data); uint32_t vidix_query_fourcc(uint32_t fourcc); -uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y); -uint32_t vidix_draw_frame(uint8_t *src[]); +int vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y); +int vidix_draw_frame(uint8_t *src[]); void vidix_flip_page(void); void vidix_draw_osd(void); -- cgit v1.2.3