From 45200bc6dfe57f53dce39cc3883a14d6b7a538a3 Mon Sep 17 00:00:00 2001 From: uau Date: Tue, 14 Nov 2006 14:02:55 +0000 Subject: [PATCH] Use vf control for reading pts from vf_vo git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20922 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf.h | 1 + libmpcodecs/vf_vo.c | 19 ++++++++++--------- mplayer.c | 8 +++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h index f3f46d1496..6984ee94d5 100644 --- a/libmpcodecs/vf.h +++ b/libmpcodecs/vf.h @@ -79,6 +79,7 @@ typedef struct vf_seteq_s #define VFCTRL_SCREENSHOT 14 /* Make a screenshot */ #define VFCTRL_INIT_EOSD 15 /* Select EOSD renderer */ #define VFCTRL_DRAW_EOSD 16 /* Render EOSD */ +#define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/ #include "vfcap.h" diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index f44d21d8e3..a7b2c48918 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -21,18 +21,14 @@ extern ass_track_t* ass_track; extern int sub_visibility; extern float sub_delay; -typedef struct vf_vo_data_s { +struct vf_priv_s { double pts; vo_functions_t *vo; -} vf_vo_data_t; - -struct vf_priv_s { - vf_vo_data_t* vf_vo_data; #ifdef USE_ASS ass_renderer_t* ass_priv; #endif }; -#define video_out (vf->priv->vf_vo_data->vo) +#define video_out (vf->priv->vo) static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */ @@ -115,7 +111,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) case VFCTRL_DRAW_EOSD: { ass_image_t* images = 0; - double pts = vf->priv->vf_vo_data->pts; + double pts = vf->priv->pts; if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE; if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) { mp_eosd_res_t res; @@ -130,6 +126,11 @@ static int control(struct vf_instance_s* vf, int request, void* data) return (video_out->control(VOCTRL_DRAW_EOSD, images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; } #endif + case VFCTRL_GET_PTS: + { + *(double *)data = vf->priv->pts; + return CONTROL_TRUE; + } } // return video_out->control(request,data); return CONTROL_UNKNOWN; @@ -154,7 +155,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ if(!vo_config_count) return 0; // vo not configured? // record pts (potentially modified by filters) for main loop - vf->priv->vf_vo_data->pts = pts; + 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. // nope, fallback to old draw_frame/draw_slice: @@ -203,7 +204,7 @@ 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->vf_vo_data=(vf_vo_data_t*)args; + vf->priv->vo = (vo_functions_t *)args; if(!video_out) return 0; // no vo ? // if(video_out->preinit(args)) return 0; // preinit failed return 1; diff --git a/mplayer.c b/mplayer.c index b291fdb8cb..d02b90335c 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3084,8 +3084,6 @@ char *tmp; int gui_no_filename=0; -struct {double pts; vo_functions_t *vo;} vf_vo_data; - srand((int) time(NULL)); InitTimer(); @@ -4107,10 +4105,9 @@ sh_video->video_out=video_out; inited_flags|=INITED_VO; } -vf_vo_data.vo = video_out; current_module="init_video_filters"; { - char* vf_arg[] = { "_oldargs_", (char*)&vf_vo_data , NULL }; + char* vf_arg[] = { "_oldargs_", (char*)video_out , NULL }; sh_video->vfilter=(void*)vf_open_filter(NULL,"vo",vf_arg); } #ifdef HAVE_MENU @@ -4385,7 +4382,8 @@ if(!sh_video) { eof = 1; break; } - sh_video->pts = vf_vo_data.pts; + ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, + VFCTRL_GET_PTS, &sh_video->pts); if (sh_video->pts == MP_NOPTS_VALUE) { mp_msg(MSGT_CPLAYER, MSGL_ERR, "pts after filters MISSING\n"); sh_video->pts = last_pts;