[MPlayer-dev-eng] Re: 'D' to deinterlace

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Nov 5 18:58:14 CET 2006


Reimar Döffinger <Reimar.Doeffinger <at> stud.uni-karlsruhe.de> writes:

> 
> Hello,
> On Mon, Oct 16, 2006 at 01:07:01AM +0000, Carl Eugen Hoyos wrote:
> > +#define MP_CMD_DEINTERLACE 91
> 
> > +static int mp_property_deinterlace(m_option_t* prop,int action,void* arg) {
> > +    if (!sh_video || !sh_video->vfilter) return M_PROPERTY_UNAVAILABLE;
> > +    ((vf_instance_t*)sh_video->vfilter)->control
> > +            (sh_video->vfilter, VFCTRL_DEINTERLACE, 0);
> > +}
> 
> Both property and command is not a good idea. Property would be nicer,
> but a bit more effort. This implementation would not work at all, you
> need a switch(action) like most other property handlers have,
> implementing M_PROPERTY_GET, M_PROPERTY_SET, M_PROPERTY_STEP_UP and
> M_PROPERTY_STEP_DOWN should be enough (the later two obviously having
> the same implementation).
> You would at least need separate VFCTRL_GET_DEINTERLACE and
> VFCTRL_SET_DEINTERLAY, with e.g. SET taking as arguments 0 for disable,
> 1 for enable and -1 for toggle, and the GET taking a int * where the
> current state is returned.
> 
> > +    { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
> > +      0, 0, 0, NULL },
> >      { "ontop", mp_property_ontop, CONF_TYPE_FLAG,
> >        M_OPT_RANGE, 0, 1, NULL },
> 
> Other flags seems to use M_OPT_RANGE, 0, 1, so I'd do the same.
> 
> > +        bob_deinterlace = 1 - bob_deinterlace;
> 
> bob_deinterlace = !bob_deinterlace;
> 
> Greetings,
> Reimar Döffinger
> 

Thanks for your input! I tried to follow your suggestions.

Greetings, Carl Eugen

Index: input/input.h
===================================================================
--- input/input.h       (Revision 20709)
+++ input/input.h       (Arbeitskopie)
@@ -90,6 +90,7 @@
 #define MP_CMD_RADIO_SET_CHANNEL 88
 #define MP_CMD_RADIO_SET_FREQ 89
 #define MP_CMD_SET_MOUSE_POS 90
+#define MP_CMD_DEINTERLACE 91

 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
Index: input/input.c
===================================================================
--- input/input.c       (Revision 20709)
+++ input/input.c       (Arbeitskopie)
@@ -158,6 +158,7 @@
   { MP_CMD_CEXIT, "exit", 0, { {-1,{0}} } },
   { MP_CMD_CHIDE, "hide", 0, { {MP_CMD_ARG_INT,{3000}}, {-1,{0}} } },
 #endif
+  { MP_CMD_DEINTERLACE, "deinterlace", 0, { {-1,{0}} } },

   { MP_CMD_GET_VO_FULLSCREEN, "get_vo_fullscreen", 0, { {-1,{0}} } },
   { MP_CMD_GET_SUB_VISIBILITY, "get_sub_visibility", 0, { {-1,{0}} } },
@@ -370,6 +371,7 @@
   { { '7', 0 }, "saturation -1" },
   { { '8', 0 }, "saturation 1" },
   { { 'd', 0 }, "frame_drop" },
+  { { 'D', 0 }, "deinterlace" },
   { { 'r', 0 }, "sub_pos -1" },
   { { 't', 0 }, "sub_pos +1" },
   { { 'a', 0 }, "sub_alignment" },
Index: mplayer.c
===================================================================
--- mplayer.c   (Revision 20709)
+++ mplayer.c   (Arbeitskopie)
@@ -1880,6 +1880,31 @@
     }
 }

+static int mp_property_deinterlace(m_option_t* prop,int action,void* arg) {
+    int toggle = -1;
+
+    if (!sh_video || !sh_video->vfilter) return M_PROPERTY_UNAVAILABLE;
+    switch(action) {
+    case M_PROPERTY_GET:
+        if(!arg) return 0;
+        ((vf_instance_t*)sh_video->vfilter)->control
+                (sh_video->vfilter, VFCTRL_GET_DEINTERLACE,arg);
+        return 1;
+    case M_PROPERTY_SET:
+        if(!arg) return 0;
+        M_PROPERTY_CLAMP(prop,*(int*)arg);
+        ((vf_instance_t*)sh_video->vfilter)->control
+                (sh_video->vfilter, VFCTRL_SET_DEINTERLACE,arg);
+        return 1;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        ((vf_instance_t*)sh_video->vfilter)->control
+                (sh_video->vfilter, VFCTRL_SET_DEINTERLACE, &toggle);
+    default:
+        return 1;
+    }
+}
+
 /// Panscan (RW)
 static int mp_property_panscan(m_option_t* prop,int action,void* arg) {

@@ -2424,6 +2449,8 @@
     // Video
     { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG,
       M_OPT_RANGE, 0, 1, NULL },
+    { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
+      M_OPT_RANGE, -1, 1, NULL },
     { "ontop", mp_property_ontop, CONF_TYPE_FLAG,
       M_OPT_RANGE, 0, 1, NULL },
     { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG,
@@ -2542,6 +2569,7 @@
     { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },
     // video
     { "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL },
+    { "deinterlace", MP_CMD_DEINTERLACE, 1, 0, -1, NULL },
     { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan },
     { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, MSGTR_OnTopStatus },
     { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, MSGTR_RootwinStatus },
Index: libmpcodecs/vf.h
===================================================================
--- libmpcodecs/vf.h    (Revision 20709)
+++ libmpcodecs/vf.h    (Arbeitskopie)
@@ -79,6 +79,8 @@
 #define VFCTRL_SCREENSHOT      14 /* Make a screenshot */
 #define VFCTRL_INIT_EOSD       15 /* Select EOSD renderer */
 #define VFCTRL_DRAW_EOSD       16 /* Render EOSD */
+#define VFCTRL_SET_DEINTERLACE 17 /* Set deinterlacing status */
+#define VFCTRL_GET_DEINTERLACE 18 /* Get deinterlacing status */

 #include "vfcap.h"

Index: libmpcodecs/vf_vo.c
===================================================================
--- libmpcodecs/vf_vo.c (Revision 20709)
+++ libmpcodecs/vf_vo.c (Arbeitskopie)
@@ -80,6 +80,18 @@
 static int control(struct vf_instance_s* vf, int request, void* data)
 {
     switch(request){
+    case VFCTRL_GET_DEINTERLACE:
+    {
+        if(!video_out) return CONTROL_FALSE; // vo not configured?
+        return(video_out->control(VOCTRL_GET_DEINTERLACE, data)
+                == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+    }
+    case VFCTRL_SET_DEINTERLACE:
+    {
+        if(!video_out) return CONTROL_FALSE; // vo not configured?
+        return(video_out->control(VOCTRL_SET_DEINTERLACE, data)
+                == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
+    }
 #ifdef USE_OSD
     case VFCTRL_DRAW_OSD:
        if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
Index: libvo/video_out.h
===================================================================
--- libvo/video_out.h   (Revision 20709)
+++ libvo/video_out.h   (Arbeitskopie)
@@ -65,6 +65,9 @@
   int mt, mb, ml, mr; // borders (top, bottom, left, right)
 } mp_eosd_res_t;

+#define VOCTRL_SET_DEINTERLACE 30
+#define VOCTRL_GET_DEINTERLACE 31
+
 // Vo can be used by xover
 #define VOCTRL_XOVERLAY_SUPPORT 22

Index: libvo/vo_xvmc.c
===================================================================
--- libvo/vo_xvmc.c     (Revision 20709)
+++ libvo/vo_xvmc.c     (Arbeitskopie)
@@ -1379,6 +1379,15 @@
 static int control(uint32_t request, void *data, ... )
 {
    switch (request){
+      case VOCTRL_GET_DEINTERLACE:
+        *(int*)data = bob_deinterlace;
+        return VO_TRUE;
+      case VOCTRL_SET_DEINTERLACE:
+        if (*(int*)data == -1)
+            bob_deinterlace = !bob_deinterlace;
+        else
+            bob_deinterlace = *(int*)data;
+        return VO_TRUE;
       case VOCTRL_QUERY_FORMAT:
          return query_format(*((uint32_t*)data));
       case VOCTRL_DRAW_IMAGE:





More information about the MPlayer-dev-eng mailing list