diff options
Diffstat (limited to 'libmpcodecs/vf.c')
-rw-r--r-- | libmpcodecs/vf.c | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index ad72f304d3..445e631c21 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -195,7 +195,6 @@ static const vf_info_t* const filter_list[]={ }; // For the vf option -m_obj_settings_t* vf_settings = NULL; const m_obj_list_t vf_obj_list = { (void**)filter_list, M_ST_OFF(vf_info_t,name), @@ -441,12 +440,12 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, //============================================================================ // By default vf doesn't accept MPEGPES -static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int vf_default_query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt == IMGFMT_MPEGPES) return 0; return vf_next_query_format(vf,fmt); } -vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){ +vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){ vf_instance_t* vf; int i; for(i=0;;i++){ @@ -456,8 +455,8 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t } if(!strcmp(filter_list[i]->name,name)) break; } - vf=malloc(sizeof(vf_instance_t)); - memset(vf,0,sizeof(vf_instance_t)); + vf = calloc(1, sizeof *vf); + vf->opts = opts; vf->info=filter_list[i]; vf->next=next; vf->config=vf_next_config; @@ -485,7 +484,7 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t return NULL; } -vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){ +vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args){ if(args && strcmp(args[0],"_oldargs_")) { int i,l = 0; for(i = 0 ; args && args[2*i] ; i++) @@ -507,7 +506,7 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n", name); } - return vf_open_plugin(filter_list,next,name,args); + return vf_open_plugin(opts, filter_list,next,name,args); } /** @@ -518,11 +517,12 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args * \return pointer to the filter instance that was created. */ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) { + struct MPOpts *opts = (*vf)->opts; vf_instance_t *vo, *prev = NULL, *new; // Find the last filter (should be vf_vo) for (vo = *vf; vo->next; vo = vo->next) prev = vo; - new = vf_open_filter(vo, name, args); + new = vf_open_filter(opts, vo, name, args); if (prev) prev->next = new; else @@ -534,6 +534,7 @@ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) { unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){ vf_instance_t* vf=*vfp; + struct MPOpts *opts = vf->opts; const unsigned int* p; unsigned int best=0; int ret; @@ -547,7 +548,7 @@ unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned if(best) return best; // bingo, they have common csp! // ok, then try with scale: if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion! - vf=vf_open_filter(vf,"scale",NULL); + vf=vf_open_filter(opts, vf,"scale",NULL); if(!vf) return 0; // failed to init "scale" // try the preferred csp first: if(preferred && vf->query_format(vf,preferred)) best=preferred; else @@ -598,12 +599,6 @@ int vf_output_queued_frame(vf_instance_t *vf) tmp = last->continue_buffered_image; last->continue_buffered_image = NULL; ret = tmp(last); - if (ret > 0) { - vf->control(vf, VFCTRL_DRAW_OSD, NULL); -#ifdef CONFIG_ASS - vf->control(vf, VFCTRL_DRAW_EOSD, NULL); -#endif - } if (ret) return ret; } @@ -622,7 +617,7 @@ int vf_output_queued_frame(vf_instance_t *vf) * are unchanged, and returns either success or error. * */ -int vf_config_wrapper(struct vf_instance_s* vf, +int vf_config_wrapper(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -645,9 +640,10 @@ int vf_config_wrapper(struct vf_instance_s* vf, return r; } -int vf_next_config(struct vf_instance_s* vf, +int vf_next_config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int voflags, unsigned int outfmt){ + struct MPOpts *opts = vf->opts; int miss; int flags=vf->next->query_format(vf->next,outfmt); if(!flags){ @@ -655,7 +651,7 @@ int vf_next_config(struct vf_instance_s* vf, // let's insert the 'scale' filter, it does the job for us: vf_instance_t* vf2; if(vf->next->info==&vf_info_scale) return 0; // scale->scale - vf2=vf_open_filter(vf->next,"scale",NULL); + vf2=vf_open_filter(opts, vf->next,"scale",NULL); if(!vf2) return 0; // shouldn't happen! vf->next=vf2; flags=vf->next->query_format(vf->next,outfmt); @@ -669,7 +665,7 @@ int vf_next_config(struct vf_instance_s* vf, if(miss&VFCAP_ACCEPT_STRIDE){ // vf requires stride support but vf->next doesn't support it! // let's insert the 'expand' filter, it does the job for us: - vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL); + vf_instance_t* vf2=vf_open_filter(opts, vf->next,"expand",NULL); if(!vf2) return 0; // shouldn't happen! vf->next=vf2; } @@ -677,29 +673,21 @@ int vf_next_config(struct vf_instance_s* vf, return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt); } -int vf_next_control(struct vf_instance_s* vf, int request, void* data){ +int vf_next_control(struct vf_instance* vf, int request, void* data){ return vf->next->control(vf->next,request,data); } -void vf_extra_flip(struct vf_instance_s* vf) { - vf_next_control(vf, VFCTRL_DRAW_OSD, NULL); -#ifdef CONFIG_ASS - vf_next_control(vf, VFCTRL_DRAW_EOSD, NULL); -#endif - vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); -} - -int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt){ +int vf_next_query_format(struct vf_instance* vf, unsigned int fmt){ int flags=vf->next->query_format(vf->next,fmt); if(flags) flags|=vf->default_caps; return flags; } -int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts){ +int vf_next_put_image(struct vf_instance* vf,mp_image_t *mpi, double pts){ return vf->next->put_image(vf->next,mpi, pts); } -void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stride,int w, int h, int x, int y){ +void vf_next_draw_slice(struct vf_instance* vf,unsigned char** src, int * stride,int w, int h, int x, int y){ if (vf->next->draw_slice) { vf->next->draw_slice(vf->next,src,stride,w,h,x,y); return; @@ -723,7 +711,10 @@ void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stri //============================================================================ -vf_instance_t* append_filters(vf_instance_t* last){ +vf_instance_t *append_filters(vf_instance_t* last, + struct m_obj_settings *vf_settings) +{ + struct MPOpts *opts = last->opts; vf_instance_t* vf; int i; @@ -733,7 +724,7 @@ vf_instance_t* append_filters(vf_instance_t* last){ /* NOP */; for(i-- ; i >= 0 ; i--) { //printf("Open filter %s\n",vf_settings[i].name); - vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs); + vf = vf_open_filter(opts, last,vf_settings[i].name,vf_settings[i].attribs); if(vf) last=vf; } } |