summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/vf.c')
-rw-r--r--libmpcodecs/vf.c110
1 files changed, 65 insertions, 45 deletions
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index e6611efeb8..873b950910 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -135,17 +135,24 @@ static const vf_info_t* const filter_list[]={
&vf_info_vo,
&vf_info_format,
&vf_info_noformat,
+#ifdef CONFIG_LIBSWSCALE_INTERNALS
&vf_info_yuy2,
+#endif
&vf_info_flip,
+#ifdef CONFIG_LIBSWSCALE_INTERNALS
&vf_info_rgb2bgr,
+#endif
&vf_info_rotate,
&vf_info_mirror,
+#ifdef CONFIG_LIBSWSCALE_INTERNALS
&vf_info_palette,
+#endif
&vf_info_pp7,
#ifdef CONFIG_LIBAVCODEC
&vf_info_lavc,
&vf_info_lavcdeint,
&vf_info_screenshot,
+ &vf_info_uspp,
#endif
#ifdef CONFIG_ZR
&vf_info_zrmjpeg,
@@ -158,7 +165,9 @@ static const vf_info_t* const filter_list[]={
&vf_info_eq,
&vf_info_eq2,
&vf_info_gradfun,
+#ifdef CONFIG_LIBSWSCALE_INTERNALS
&vf_info_halfpack,
+#endif
&vf_info_dint,
&vf_info_1bpp,
&vf_info_2xsai,
@@ -190,9 +199,8 @@ static const vf_info_t* const filter_list[]={
&vf_info_delogo,
&vf_info_remove_logo,
&vf_info_hue,
-#ifdef CONFIG_LIBAVCODEC_A
+#ifdef CONFIG_LIBAVCODEC_INTERNALS
&vf_info_spp,
- &vf_info_uspp,
&vf_info_fspp,
&vf_info_qp,
&vf_info_mcdeint,
@@ -215,7 +223,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),
@@ -426,23 +433,27 @@ 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){
+struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts,
+ const vf_info_t * const *filter_list,
+ vf_instance_t *next, const char *name,
+ char **args, int *retcode)
+{
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;
@@ -464,13 +475,27 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t
args = (char**)args[1];
else
args = NULL;
- if(vf->info->open(vf,(char*)args)>0) return vf; // Success!
+ *retcode = vf->info->open(vf,(char*)args);
+ if (*retcode > 0)
+ return vf;
free(vf);
- mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name);
return NULL;
}
-vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){
+struct vf_instance *vf_open_plugin(struct MPOpts *opts,
+ const vf_info_t * const *filter_list,
+ vf_instance_t *next, const char *name,
+ char **args)
+{
+ struct vf_instance *vf = vf_open_plugin_noerr(opts, filter_list, next,
+ name, args, &(int){0});
+ if (!vf)
+ mp_tmsg(MSGT_VFILTER, MSGL_ERR, "Couldn't open video filter '%s'.\n",
+ name);
+ return vf;
+}
+
+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++)
@@ -482,17 +507,18 @@ 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_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n",
+ mp_gtext("Opening video filter: "), str);
}
} else if(strcmp(name,"vo")) {
if(args && strcmp(args[0],"_oldargs_") == 0)
- mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
- "[%s=%s]\n", name,args[1]);
+ mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s=%s]\n",
+ mp_gtext("Opening video filter: "), name, args[1]);
else
- mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
- "[%s]\n", name);
+ mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n",
+ mp_gtext("Opening video filter: "), name);
}
- return vf_open_plugin(filter_list,next,name,args);
+ return vf_open_plugin(opts, filter_list,next,name,args);
}
/**
@@ -503,11 +529,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
@@ -519,6 +546,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;
@@ -532,7 +560,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
@@ -583,12 +611,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;
}
@@ -607,7 +629,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)
{
@@ -616,7 +638,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;
@@ -630,9 +652,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){
@@ -640,12 +663,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
}
}
@@ -654,7 +677,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;
}
@@ -662,29 +685,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;
@@ -708,7 +723,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;
@@ -718,7 +736,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;
}
}
@@ -733,6 +751,8 @@ void vf_uninit_filter(vf_instance_t* vf){
free_mp_image(vf->imgctx.static_images[1]);
free_mp_image(vf->imgctx.temp_images[0]);
free_mp_image(vf->imgctx.export_images[0]);
+ for (int i = 0; i < NUM_NUMBERED_MPI; i++)
+ free_mp_image(vf->imgctx.numbered_images[i]);
free(vf);
}