From 2e1063d781732f0c98f31e73ebc4f364d599818e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 22 Feb 2013 23:56:42 +0100 Subject: vf_yadif: switch to option parser, allow disabling by default Use the option parser instead of sscanf. Remove the parameter changing the field dominance (it has been marked deprecated for ages). Add a new suboption "enabled", which can be used to disable the filter by default, until it's enabled at runtime: mpv -vf yadif=enabled=no --- video/filter/vf_yadif.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'video') diff --git a/video/filter/vf_yadif.c b/video/filter/vf_yadif.c index 93d30b6fbc..d0c3bbe08b 100644 --- a/video/filter/vf_yadif.c +++ b/video/filter/vf_yadif.c @@ -27,6 +27,7 @@ #include "config.h" #include "core/cpudetect.h" #include "core/options.h" +#include "core/m_struct.h" #include "core/mp_msg.h" #include "video/img_format.h" @@ -50,6 +51,10 @@ struct vf_priv_s { int do_deinterlace; }; +static const struct vf_priv_s vf_priv_default = { + .do_deinterlace = 1, +}; + static void (*filter_line)(struct vf_priv_s *p, uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int refs, int parity); static void store_ref(struct vf_priv_s *p, uint8_t *src[3], int src_stride[3], int width, int height){ @@ -470,8 +475,6 @@ static void uninit(struct vf_instance *vf){ if(*p) free(*p - 3*vf->priv->stride[i/3]); *p= NULL; } - free(vf->priv); - vf->priv=NULL; } //===========================================================================// @@ -501,13 +504,9 @@ static int vf_open(vf_instance_t *vf, char *args){ vf->filter_ext=filter_image; vf->query_format=query_format; vf->uninit=uninit; - vf->priv=malloc(sizeof(struct vf_priv_s)); vf->control=control; - memset(vf->priv, 0, sizeof(struct vf_priv_s)); - vf->priv->mode=0; vf->priv->parity= -1; - vf->priv->do_deinterlace=1; if (args) sscanf(args, "%d:%d", &vf->priv->mode, &vf->priv->parity); @@ -519,11 +518,26 @@ static int vf_open(vf_instance_t *vf, char *args){ return 1; } +#undef ST_OFF +#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) +static const m_option_t vf_opts_fields[] = { + {"mode", ST_OFF(mode), CONF_TYPE_INT, M_OPT_RANGE, 0, 3}, + {"enabled", ST_OFF(do_deinterlace), CONF_TYPE_FLAG, 0, 0, 1}, + {0} +}; + +static const m_struct_t vf_opts = { + "yadif", + sizeof(struct vf_priv_s), + &vf_priv_default, + vf_opts_fields +}; + const vf_info_t vf_info_yadif = { "Yet Another DeInterlacing Filter", "yadif", "Michael Niedermayer", "", vf_open, - NULL + &vf_opts }; -- cgit v1.2.3