diff options
Diffstat (limited to 'libmpcodecs/vf.c')
-rw-r--r-- | libmpcodecs/vf.c | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 08d0b130c1..878bbb1edd 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -197,7 +197,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), @@ -443,23 +442,23 @@ 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++){ if(!filter_list[i]){ - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Couldn't find video filter '%s'.\n",name); return NULL; // no such filter! } 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; @@ -483,11 +482,11 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t args = NULL; if(vf->info->open(vf,(char*)args)>0) return vf; // Success! free(vf); - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Couldn't open video filter '%s'.\n",name); 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++) @@ -499,17 +498,17 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args p += sprintf(str,"%s",name); for(i = 0 ; args && args[2*i] ; i++) p += sprintf(p," %s=%s",args[2*i],args[2*i+1]); - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str); + mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: " "[%s]\n",str); } } else if(strcmp(name,"vo")) { if(args && strcmp(args[0],"_oldargs_") == 0) - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter + mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: " "[%s=%s]\n", name,args[1]); else - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter + mp_tmsg(MSGT_VFILTER,MSGL_INFO,"Opening video filter: " "[%s]\n", name); } - return vf_open_plugin(filter_list,next,name,args); + return vf_open_plugin(opts, filter_list,next,name,args); } /** @@ -520,11 +519,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 @@ -536,6 +536,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; @@ -549,7 +550,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 @@ -600,12 +601,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; } @@ -624,7 +619,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) { @@ -633,7 +628,7 @@ int vf_config_wrapper(struct vf_instance_s* vf, if ((vf->fmt.orig_width != width) || (vf->fmt.orig_height != height) || (vf->fmt.orig_fmt != outfmt)) { - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"\nNew video file has different resolution or colorspace than the previous one.\n"); return 0; } return 1; @@ -647,9 +642,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){ @@ -657,12 +653,12 @@ 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); if(!flags){ - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Cannot find matching colorspace, even by inserting 'scale' :(\n"); return 0; // FAIL } } @@ -671,7 +667,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; } @@ -679,29 +675,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; @@ -725,7 +713,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; @@ -735,7 +726,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; } } |