[MPlayer-dev-eng] De- and reactivate yadif

cehoyos at rainbow.studorg.tuwien.ac.at cehoyos at rainbow.studorg.tuwien.ac.at
Sat Nov 18 14:53:42 CET 2006


Hi Michael!

On 2006-11-18 10:32, Michael Niedermayer wrote:

[...]

> >  static int continue_buffered_image(struct vf_instance_s *vf);
> >  extern int correct_pts;
> > +static int do_deinterlace=1;
> 
> this should be part of the context, there can be multiple instances

Fixed

[...]
> > +static int control(struct vf_instance_s* vf, int request, void* data){
> > +    switch (request){
> > +      case VFCTRL_GET_DEINTERLACE:
> > +        *(int*)data = do_deinterlace;
> > +        return CONTROL_OK;
> > +      case VFCTRL_SET_DEINTERLACE:
> > +        if (*(int*)data == -1)
> > +            do_deinterlace = !do_deinterlace;
> > +        else
> > +            do_deinterlace = *(int*)data;
> 
> set, get ok but do_deinterlace = !do_deinterlace; is redundant, considering
> that this would have to be added to every deinterlacing filter set(!get) at
> one central spot is better 

Fixed

> > +    return CONTROL_NA;
> 
> this is wrong and breaks the control message passing, see any other filter
> which implements control()

Of course, fixed

I tried to fix another problem: When reenabling yadif, the last frame from
before turning off was shown again with the original patch.
I found two possibilities to fix this:
1) Always store_ref even if yadif is turned off
2) Call store_ref three times when yadif is reenabled

Thanks, Carl Eugen

1) is a bit slower:
Index: libmpcodecs/vf_yadif.c
===================================================================
--- libmpcodecs/vf_yadif.c	(Revision 21020)
+++ libmpcodecs/vf_yadif.c	(Arbeitskopie)
@@ -54,6 +54,7 @@
     mp_image_t *buffered_mpi;
     int stride[3];
     uint8_t *ref[4][3];
+    int do_deinterlace;
 };
 
 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);
@@ -410,7 +411,9 @@
     vf->priv->buffered_i = 0;
     vf->priv->buffered_pts = pts;
 
-    return continue_buffered_image(vf);
+    return vf->priv->do_deinterlace?
+           continue_buffered_image(vf):
+           vf_next_put_image(vf, mpi, pts);
 }
 
 static int continue_buffered_image(struct vf_instance_s *vf)
@@ -469,6 +472,18 @@
     return 0;
 }
 
+static int control(struct vf_instance_s* vf, int request, void* data){
+    switch (request){
+      case VFCTRL_GET_DEINTERLACE:
+        *(int*)data = vf->priv->do_deinterlace;
+        return CONTROL_OK;
+      case VFCTRL_SET_DEINTERLACE:
+        vf->priv->do_deinterlace = *(int*)data;
+        return CONTROL_OK;
+    }
+    return vf_next_control (vf, request, data);
+}
+
 static int open(vf_instance_t *vf, char* args){
 
     vf->config=config;
@@ -476,10 +491,12 @@
     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);

2) is much uglier:

Index: libmpcodecs/vf_yadif.c
===================================================================
--- libmpcodecs/vf_yadif.c	(Revision 21020)
+++ libmpcodecs/vf_yadif.c	(Arbeitskopie)
@@ -54,6 +54,7 @@
     mp_image_t *buffered_mpi;
     int stride[3];
     uint8_t *ref[4][3];
+    int do_deinterlace;
 };
 
 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);
@@ -395,6 +396,8 @@
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
     int tff;
 
+    if(!vf->priv->do_deinterlace) return vf_next_put_image(vf, mpi, pts);
+
     if(vf->priv->parity < 0) {
         if (mpi->fields & MP_IMGFIELD_ORDERED)
             tff = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
@@ -469,6 +472,23 @@
     return 0;
 }
 
+static int control(struct vf_instance_s* vf, int request, void* data){
+    switch (request){
+      case VFCTRL_GET_DEINTERLACE:
+        *(int*)data = vf->priv->do_deinterlace;
+        return CONTROL_OK;
+      case VFCTRL_SET_DEINTERLACE:
+        if (*(int*)data>vf->priv->do_deinterlace && vf->priv->buffered_mpi) {
+            store_ref(vf->priv, vf->priv->buffered_mpi->planes, vf->priv->buffered_mpi->stride, vf->priv->buffered_mpi->w, vf->priv->buffered_mpi->h);
+            store_ref(vf->priv, vf->priv->buffered_mpi->planes, vf->priv->buffered_mpi->stride, vf->priv->buffered_mpi->w, vf->priv->buffered_mpi->h);
+            store_ref(vf->priv, vf->priv->buffered_mpi->planes, vf->priv->buffered_mpi->stride, vf->priv->buffered_mpi->w, vf->priv->buffered_mpi->h);
+        }
+        vf->priv->do_deinterlace = *(int*)data;
+        return CONTROL_OK;
+    }
+    return vf_next_control (vf, request, data);
+}
+
 static int open(vf_instance_t *vf, char* args){
 
     vf->config=config;
@@ -476,10 +496,12 @@
     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);
 



More information about the MPlayer-dev-eng mailing list