diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index 667504c773..a52580393b 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -43,8 +43,6 @@ int field_dominance = -1; int divx_quality = 0; -vd_functions_t *mpvdec = NULL; - int get_video_quality_max(sh_video_t *sh_video) { vf_instance_t *vf = sh_video->vfilter; @@ -55,8 +53,9 @@ int get_video_quality_max(sh_video_t *sh_video) return ret; } } - if (mpvdec) { - int ret = mpvdec->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL); + struct vd_functions *vd = sh_video->vd_driver; + if (vd) { + int ret = vd->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL); if (ret > 0) { mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingCodecPP, ret); return ret; @@ -73,8 +72,9 @@ void set_video_quality(sh_video_t *sh_video, int quality) if (ret == CONTROL_TRUE) return; // success } - if (mpvdec) - mpvdec->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality)); + struct vd_functions *vd = sh_video->vd_driver; + 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) @@ -92,8 +92,9 @@ int set_video_colors(sh_video_t *sh_video, const char *item, int value) return (1); } /* try software control */ - if (mpvdec && - mpvdec->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value) + struct vd_functions *vd = sh_video->vd_driver; + if (vd && + vd->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value) == CONTROL_OK) return 1; 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 */ - if (mpvdec) - return mpvdec->control(sh_video, VDCTRL_GET_EQUALIZER, item, value); + struct vd_functions *vd = sh_video->vd_driver; + if (vd) + return vd->control(sh_video, VDCTRL_GET_EQUALIZER, item, value); 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) { - if (mpvdec) - mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); + struct vd_functions *vd = sh_video->vd_driver; + if (vd) + vd->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); } int get_current_video_decoder_lag(sh_video_t *sh_video) { - int ret; - - if (!mpvdec) + struct vd_functions *vd = sh_video->vd_driver; + if (!vd) 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) return ret - 10; return -1; @@ -159,7 +161,7 @@ void uninit_video(sh_video_t *sh_video) if (!sh_video->initialized) return; 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 if (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, sh_video->codec->drv)) break; - mpvdec = mpcodecs_vd_drivers[i]; + sh_video->vd_driver = mpcodecs_vd_drivers[i]; #ifdef DYNAMIC_PLUGINS - if (!mpvdec) { + if (!sh_video->vd_driver) { /* try to open shared decoder plugin */ int buf_len; 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)) break; free(buf); - mpvdec = funcs_sym; + sh_video->vd_driver = funcs_sym; mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n", MPLAYER_LIBDIR, sh_video->codec->drv); } #endif - if (!mpvdec) { // driver not available (==compiled in) + if (!sh_video->vd_driver) { // driver not available (==compiled in) mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_VideoCodecFamilyNotAvailableStr, 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->biHeight = sh_video->disp_h; } + // init() + struct vd_functions *vd = sh_video->vd_driver; 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 if (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); sh_video->disp_w = orig_w; 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. -------------------- diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index 7fb6af600f..a94ac9ff85 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -132,8 +132,6 @@ int vo_gamma_contrast = 1000; int vo_gamma_saturation = 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){ struct MPOpts *opts = sh->opts; int i,j; @@ -182,7 +180,7 @@ csp_again: if((flags&VFCAP_CSP_SUPPORTED_BY_HW) || (flags&VFCAP_CSP_SUPPORTED && j<0)){ // check (query) if codec really support this outfmt... 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)); continue; } @@ -190,7 +188,7 @@ csp_again: } else 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 - 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; } } diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h index 1a79ca03f1..e52cc5cb3f 100644 --- a/libmpdemux/stheader.h +++ b/libmpdemux/stheader.h @@ -84,6 +84,7 @@ typedef struct sh_video { // output driver/filters: (set by libmpcodecs core) unsigned int outfmtidx; struct vf_instance *vfilter; // the video filter chain, used for this video stream + struct vd_functions *vd_driver; int vf_initialized; #ifdef DYNAMIC_PLUGINS void *dec_handle;