[MPlayer-dev-eng] [PATCH] vo_directfb2 using suboption parse, make dfbopts a suboption.

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jun 17 10:29:48 CEST 2005


Hi,
title says it all. I will probably apply tomorrow if nobody has any
objections (or should I contact the direcfb2 maintainer directly first?).

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/vo_directfb2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_directfb2.c,v
retrieving revision 1.18
diff -u -r1.18 vo_directfb2.c
--- libvo/vo_directfb2.c	18 Apr 2005 15:52:38 -0000	1.18
+++ libvo/vo_directfb2.c	17 Jun 2005 08:27:35 -0000
@@ -44,6 +44,7 @@
 #include "sub.h"
 #include "mp_msg.h"
 #include "aspect.h"
+#include "subopt-helper.h"
 
 #ifndef min
 #define min(x,y) (((x)<(y))?(x):(y))
@@ -128,7 +129,6 @@
 ******************************/
 
 /* command line/config file options */
-char *dfb_params;
 static int layer_id = -1;
 static int buffer_mode = 1;
 static int use_input = 1;
@@ -143,103 +143,57 @@
 if (primary && primarylocked) primary->Unlock(primary);
 }
 
+static int get_parity(strarg_t *arg) {
+  if (strargcmp(arg, "top") == 0)
+    return 0;
+  if (strargcmp(arg, "bottom") == 0)
+    return 1;
+  return -1;
+}
+
+static int check_parity(void *arg) {
+  return get_parity(arg) != -1;
+}
+
+static int get_mode(strarg_t *arg) {
+  if (strargcmp(arg, "single") == 0)
+    return 1;
+  if (strargcmp(arg, "double") == 0)
+    return 2;
+  if (strargcmp(arg, "triple") == 0)
+    return 3;
+  return 0;
+}
+
+static int check_mode(void *arg) {
+  return get_mode(arg) != 0;
+}
 
 static uint32_t preinit(const char *arg)
 {
     DFBResult ret;
+    strarg_t mode_str = {0, NULL};
+    strarg_t par_str = {0, NULL};
+    strarg_t dfb_params = {0, NULL};
+    opt_t subopts[] = {
+      {"input",       OPT_ARG_BOOL, &use_input,  NULL},
+      {"buffermode",  OPT_ARG_STR,  &mode_str,   check_mode},
+      {"fieldparity", OPT_ARG_STR,  &par_str,    check_parity},
+      {"layer",       OPT_ARG_INT,  &layer_id,   NULL},
+      {"dfbopts",     OPT_ARG_STR,  &dfb_params, NULL},
+      {NULL}
+    };
 
     mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
 
     if (dfb) return 0; // we are already inited!
 
+    // set defaults
     buffer_mode = 1 + vo_doublebuffering; // honor -double switch
-
-// config stuff - borrowed from dfbmga (to be as compatible as it could be :-)
-    
-     if (vo_subdevice) {
-          int show_help = 0;
-          int opt_no = 0;
-          while (*vo_subdevice != '\0') {
-               if (!strncmp(vo_subdevice, "input", 5)) {
-                    use_input = !opt_no;
-                    vo_subdevice += 5;
-                    opt_no = 0;
-               } else if (!strncmp(vo_subdevice, "buffermode=", 11)) {
-                    if (opt_no) {
-                         show_help = 1;
-                         break;
-                    }
-                    vo_subdevice += 11;
-                    if (!strncmp(vo_subdevice, "single", 6)) {
-                         buffer_mode = 1;
-                         vo_subdevice += 6;
-                    } else if (!strncmp(vo_subdevice, "double", 6)) {
-                         buffer_mode = 2;
-                         vo_subdevice += 6;
-                    } else if (!strncmp(vo_subdevice, "triple", 6)) {
-                         buffer_mode = 3;
-                         vo_subdevice += 6;
-                    } else {
-                         show_help = 1;
-                         break;
-                    }
-                    opt_no = 0;
-               } else if (!strncmp(vo_subdevice, "fieldparity=", 12)) {
-                    if (opt_no) {
-                         show_help = 1;
-                         break;
-                    }
-                    vo_subdevice += 12;
-                    if (!strncmp(vo_subdevice, "top", 3)) {
-                         field_parity = 0;
-                         vo_subdevice += 3;
-                    } else if (!strncmp(vo_subdevice, "bottom", 6)) {
-                         field_parity = 1;
-                         vo_subdevice += 6;
-                    } else {
-                         show_help = 1;
-                         break;
-                    }
-                    opt_no = 0;
-               } else if (!strncmp(vo_subdevice, "layer=", 6)) {
-		    int tmp=-1;
-                    if (opt_no) {
-                         show_help = 1;
-                         break;
-                    }
-                    vo_subdevice += 6;
-		    if (sscanf(vo_subdevice,"%i",&tmp)) {
-			 layer_id=tmp;
-			 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Layer id is forced to %i\n",layer_id);
-		    } else {
-                         show_help = 1;
-                         break;
-                    }
-                    opt_no = 0;
-               } else if (!strncmp(vo_subdevice, "no", 2)) {
-                    if (opt_no) {
-                         show_help = 1;
-                         break;
-                    }
-                    vo_subdevice += 2;
-                    opt_no = 1;
-               } else if (*vo_subdevice == ':') {
-                    if (opt_no) {
-                         show_help = 1;
-                         break;
-                    }
-                    vo_subdevice++;
-                    opt_no = 0;
-               } else if (!strncmp(vo_subdevice, "help", 4)) {
-                    show_help = 1;
-                    vo_subdevice += 4;
-                    break;
-               } else  {
-                    vo_subdevice++;
-	       }
-          }
-	       
-          if (show_help) {
+    layer_id = -1;
+    use_input = 1;
+    field_parity = -1;
+     if (subopt_parse(arg, subopts) != 0) {
                mp_msg( MSGT_VO, MSGL_ERR,
                        "\n-vo directfb command line help:\n"
                        "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
@@ -255,23 +209,29 @@
                        "  fieldparity=(top|bottom)\n"
                        "    top      Top field first\n"
                        "    bottom   Bottom field first\n"
+		       "  dfbopts=<str>\n"
+		       "    Specify a parameter list for DirectFB\n"
                        "\n" );
                return -1;
-          }
      }
+    if (mode_str.len)
+      buffer_mode = get_mode(&mode_str);
+    if (par_str.len)
+      field_parity = get_parity(&par_str);
 
 
-	if (dfb_params)
+	if (dfb_params.len > 0)
 	{
 	    int argc = 2;
 	    char arg0[10] = "mplayer";
-	    char arg1[256] = "--dfb:";
+	    char *arg1 = (char *)malloc(dfb_params.len + 7);
 	    char* argv[3];
 	    char ** a;
 	    
 	    a = &argv[0];
 	    
-	    strncat(arg1,dfb_params,249);
+	    strcpy(arg1, "--dfb:");
+	    strncat(arg1, dfb_params.str, dfb_params.len);
 
 	    argv[0]=arg0;
 	    argv[1]=arg1;
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.248
diff -u -r1.248 cfg-mplayer.h
--- cfg-mplayer.h	6 Jun 2005 14:59:25 -0000	1.248
+++ cfg-mplayer.h	17 Jun 2005 08:27:35 -0000
@@ -205,7 +205,7 @@
 #endif
 #ifdef HAVE_DIRECTFB
 #if DIRECTFBVERSION > 912
-	{"dfbopts", &dfb_params, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"dfbopts", "-dfbopts is deprecated, use -vf directfb:dfbopts=... instead\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
 #endif
 #endif
 
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.1003
diff -u -r1.1003 mplayer.1
--- DOCS/man/en/mplayer.1	8 Jun 2005 20:37:35 -0000	1.1003
+++ DOCS/man/en/mplayer.1	17 Jun 2005 08:27:35 -0000
@@ -1973,10 +1973,6 @@
 Not supported by all video output drivers.
 .
 .TP
-.B \-dfbopts <value> (\-vo directfb only)
-Specify a parameter list for the directfb video output driver.
-.
-.TP
 .B \-display <name> (X11 only)
 Specify the hostname and display number of the X server you want to display
 on.
@@ -2732,6 +2728,8 @@
 motions watching interlaced film material.
 .IPs layer=N
 Will force layer with ID N for playback (default: -1 - auto).
+.IPs dfbopts=<str>
+Specify a parameter list for DirectFB.
 .RE
 .PD 1
 .


More information about the MPlayer-dev-eng mailing list