Store video decoder functions in struct sh_video field

Remove the global variable mpvdec and move the video decoder pointer
to struct sh_video field vd_driver. Audio already had a similar
ad_driver field from before.
This commit is contained in:
Uoti Urpala 2008-04-24 06:41:12 +03:00
parent 0e757bf9da
commit 342ae8d3b5
3 changed files with 31 additions and 28 deletions

View File

@ -43,8 +43,6 @@ int field_dominance = -1;
int divx_quality = 0; int divx_quality = 0;
vd_functions_t *mpvdec = NULL;
int get_video_quality_max(sh_video_t *sh_video) int get_video_quality_max(sh_video_t *sh_video)
{ {
vf_instance_t *vf = sh_video->vfilter; vf_instance_t *vf = sh_video->vfilter;
@ -55,8 +53,9 @@ int get_video_quality_max(sh_video_t *sh_video)
return ret; return ret;
} }
} }
if (mpvdec) { struct vd_functions *vd = sh_video->vd_driver;
int ret = mpvdec->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL); if (vd) {
int ret = vd->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL);
if (ret > 0) { if (ret > 0) {
mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingCodecPP, ret); mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingCodecPP, ret);
return ret; return ret;
@ -73,8 +72,9 @@ void set_video_quality(sh_video_t *sh_video, int quality)
if (ret == CONTROL_TRUE) if (ret == CONTROL_TRUE)
return; // success return; // success
} }
if (mpvdec) struct vd_functions *vd = sh_video->vd_driver;
mpvdec->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality)); if (vd)
vd->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality));
} }
int set_video_colors(sh_video_t *sh_video, const char *item, int value) int set_video_colors(sh_video_t *sh_video, const char *item, int value)
@ -92,8 +92,9 @@ int set_video_colors(sh_video_t *sh_video, const char *item, int value)
return (1); return (1);
} }
/* try software control */ /* try software control */
if (mpvdec && struct vd_functions *vd = sh_video->vd_driver;
mpvdec->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value) if (vd &&
vd->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value)
== CONTROL_OK) == CONTROL_OK)
return 1; return 1;
mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_VideoAttributeNotSupportedByVO_VD, mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_VideoAttributeNotSupportedByVO_VD,
@ -117,8 +118,9 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
} }
} }
/* try software control */ /* try software control */
if (mpvdec) struct vd_functions *vd = sh_video->vd_driver;
return mpvdec->control(sh_video, VDCTRL_GET_EQUALIZER, item, value); if (vd)
return vd->control(sh_video, VDCTRL_GET_EQUALIZER, item, value);
return 0; return 0;
} }
@ -138,17 +140,17 @@ int set_rectangle(sh_video_t *sh_video, int param, int value)
void resync_video_stream(sh_video_t *sh_video) void resync_video_stream(sh_video_t *sh_video)
{ {
if (mpvdec) struct vd_functions *vd = sh_video->vd_driver;
mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); if (vd)
vd->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
} }
int get_current_video_decoder_lag(sh_video_t *sh_video) int get_current_video_decoder_lag(sh_video_t *sh_video)
{ {
int ret; struct vd_functions *vd = sh_video->vd_driver;
if (!vd)
if (!mpvdec)
return -1; return -1;
ret = mpvdec->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL); int ret = vd->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL);
if (ret >= 10) if (ret >= 10)
return ret - 10; return ret - 10;
return -1; return -1;
@ -159,7 +161,7 @@ void uninit_video(sh_video_t *sh_video)
if (!sh_video->initialized) if (!sh_video->initialized)
return; return;
mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_UninitVideoStr, sh_video->codec->drv); mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_UninitVideoStr, sh_video->codec->drv);
mpvdec->uninit(sh_video); sh_video->vd_driver->uninit(sh_video);
#ifdef DYNAMIC_PLUGINS #ifdef DYNAMIC_PLUGINS
if (sh_video->dec_handle) if (sh_video->dec_handle)
dlclose(sh_video->dec_handle); dlclose(sh_video->dec_handle);
@ -222,9 +224,9 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
if (!strcmp(mpcodecs_vd_drivers[i]->info->short_name, if (!strcmp(mpcodecs_vd_drivers[i]->info->short_name,
sh_video->codec->drv)) sh_video->codec->drv))
break; break;
mpvdec = mpcodecs_vd_drivers[i]; sh_video->vd_driver = mpcodecs_vd_drivers[i];
#ifdef DYNAMIC_PLUGINS #ifdef DYNAMIC_PLUGINS
if (!mpvdec) { if (!sh_video->vd_driver) {
/* try to open shared decoder plugin */ /* try to open shared decoder plugin */
int buf_len; int buf_len;
char *buf; char *buf;
@ -253,13 +255,13 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
if (strcmp(info_sym->short_name, sh_video->codec->drv)) if (strcmp(info_sym->short_name, sh_video->codec->drv))
break; break;
free(buf); free(buf);
mpvdec = funcs_sym; sh_video->vd_driver = funcs_sym;
mp_msg(MSGT_DECVIDEO, MSGL_V, mp_msg(MSGT_DECVIDEO, MSGL_V,
"Using external decoder plugin (%s/mplayer/vd_%s.so)!\n", "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
MPLAYER_LIBDIR, sh_video->codec->drv); MPLAYER_LIBDIR, sh_video->codec->drv);
} }
#endif #endif
if (!mpvdec) { // driver not available (==compiled in) if (!sh_video->vd_driver) { // driver not available (==compiled in)
mp_msg(MSGT_DECVIDEO, MSGL_WARN, mp_msg(MSGT_DECVIDEO, MSGL_WARN,
MSGTR_VideoCodecFamilyNotAvailableStr, MSGTR_VideoCodecFamilyNotAvailableStr,
sh_video->codec->name, sh_video->codec->drv); sh_video->codec->name, sh_video->codec->drv);
@ -279,13 +281,15 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
sh_video->bih->biWidth = sh_video->disp_w; sh_video->bih->biWidth = sh_video->disp_w;
sh_video->bih->biHeight = sh_video->disp_h; sh_video->bih->biHeight = sh_video->disp_h;
} }
// init() // init()
struct vd_functions *vd = sh_video->vd_driver;
mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_OpeningVideoDecoder, mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_OpeningVideoDecoder,
mpvdec->info->short_name, mpvdec->info->name); vd->info->short_name, vd->info->name);
// clear vf init error, it is no longer relevant // clear vf init error, it is no longer relevant
if (sh_video->vf_initialized < 0) if (sh_video->vf_initialized < 0)
sh_video->vf_initialized = 0; sh_video->vf_initialized = 0;
if (!mpvdec->init(sh_video)) { if (!vd->init(sh_video)) {
mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_VDecoderInitFailed); mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_VDecoderInitFailed);
sh_video->disp_w = orig_w; sh_video->disp_w = orig_w;
sh_video->disp_h = orig_h; sh_video->disp_h = orig_h;
@ -402,7 +406,7 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
} }
} }
mpi = mpvdec->decode(sh_video, start, in_size, drop_frame); mpi = sh_video->vd_driver->decode(sh_video, start, in_size, drop_frame);
//------------------------ frame decoded. -------------------- //------------------------ frame decoded. --------------------

View File

@ -132,8 +132,6 @@ int vo_gamma_contrast = 1000;
int vo_gamma_saturation = 1000; int vo_gamma_saturation = 1000;
int vo_gamma_hue = 1000; int vo_gamma_hue = 1000;
extern vd_functions_t* mpvdec; // FIXME!
int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
struct MPOpts *opts = sh->opts; struct MPOpts *opts = sh->opts;
int i,j; int i,j;
@ -182,7 +180,7 @@ csp_again:
if((flags&VFCAP_CSP_SUPPORTED_BY_HW) || (flags&VFCAP_CSP_SUPPORTED && j<0)){ if((flags&VFCAP_CSP_SUPPORTED_BY_HW) || (flags&VFCAP_CSP_SUPPORTED && j<0)){
// check (query) if codec really support this outfmt... // check (query) if codec really support this outfmt...
sh->outfmtidx=j; // pass index to the control() function this way sh->outfmtidx=j; // pass index to the control() function this way
if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE){ if(sh->vd_driver->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE){
mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: codec query_format(%s) returned FALSE\n",vo_format_name(out_fmt)); mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: codec query_format(%s) returned FALSE\n",vo_format_name(out_fmt));
continue; continue;
} }
@ -190,7 +188,7 @@ csp_again:
} else } else
if(!palette && !(flags&(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_CSP_SUPPORTED)) && (out_fmt==IMGFMT_RGB8||out_fmt==IMGFMT_BGR8)){ if(!palette && !(flags&(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_CSP_SUPPORTED)) && (out_fmt==IMGFMT_RGB8||out_fmt==IMGFMT_BGR8)){
sh->outfmtidx=j; // pass index to the control() function this way sh->outfmtidx=j; // pass index to the control() function this way
if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)!=CONTROL_FALSE) if(sh->vd_driver->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)!=CONTROL_FALSE)
palette=1; palette=1;
} }
} }

View File

@ -84,6 +84,7 @@ typedef struct sh_video {
// output driver/filters: (set by libmpcodecs core) // output driver/filters: (set by libmpcodecs core)
unsigned int outfmtidx; unsigned int outfmtidx;
struct vf_instance *vfilter; // the video filter chain, used for this video stream struct vf_instance *vfilter; // the video filter chain, used for this video stream
struct vd_functions *vd_driver;
int vf_initialized; int vf_initialized;
#ifdef DYNAMIC_PLUGINS #ifdef DYNAMIC_PLUGINS
void *dec_handle; void *dec_handle;