[MPlayer-cvslog] CVS: main/libvo vo_gl.c,1.61,1.62

Reimar Döffinger CVS syncmail at mplayerhq.hu
Fri Dec 31 15:58:51 CET 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv27879/libvo

Modified Files:
	vo_gl.c 
Log Message:
Use subopt helper to parse arguments


Index: vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- vo_gl.c	29 Dec 2004 14:33:40 -0000	1.61
+++ vo_gl.c	31 Dec 2004 14:58:49 -0000	1.62
@@ -6,6 +6,7 @@
 
 #include "mp_msg.h"
 #include "config.h"
+#include "subopt-helper.h"
 #include "video_out.h"
 #include "video_out_internal.h"
 #include "font_load.h"
@@ -470,63 +471,31 @@
   vo_x11_uninit();
 }
 
+static int int_non_neg(int *sh)
+{
+  if ( *sh < 0 )
+    return 0;
+  return 1;
+}
+
+static opt_t subopts[] = {
+  {"manyfmts",     OPT_ARG_BOOL, &many_fmts,    NULL},
+  {"osd",          OPT_ARG_BOOL, &use_osd,      NULL},
+  {"scaled-osd",   OPT_ARG_BOOL, &scaled_osd,   NULL},
+  {"aspect",       OPT_ARG_BOOL, &use_aspect,   NULL},
+  {"slice-height", OPT_ARG_INT,  &slice_height, (opt_test_f)int_non_neg},
+  {NULL}
+};
+
 static uint32_t preinit(const char *arg)
 {
-    int parse_err = 0;
-    unsigned int parse_pos = 0;
+    // set defaults
     many_fmts = 0;
     use_osd = 1;
     scaled_osd = 0;
     use_aspect = 1;
     slice_height = 4;
-    if(arg) 
-    {
-        while (arg[parse_pos] && !parse_err) {
-            if (strncmp (&arg[parse_pos], "manyfmts", 8) == 0) {
-                parse_pos += 8;
-                many_fmts = 1;
-            } else if (strncmp (&arg[parse_pos], "nomanyfmts", 10) == 0) {
-                parse_pos += 10;
-                many_fmts = 0;
-            } else if (strncmp (&arg[parse_pos], "osd", 3) == 0) {
-                parse_pos += 3;
-                use_osd = 1;
-            } else if (strncmp (&arg[parse_pos], "noosd", 5) == 0) {
-                parse_pos += 5;
-                use_osd = 0;
-            } else if (strncmp (&arg[parse_pos], "scaled-osd", 10) == 0) {
-                parse_pos += 10;
-                scaled_osd = 1;
-            } else if (strncmp (&arg[parse_pos], "noscaled-osd", 12) == 0) {
-                parse_pos += 12;
-                scaled_osd = 0;
-            } else if (strncmp (&arg[parse_pos], "aspect", 6) == 0) {
-                parse_pos += 6;
-                use_aspect = 1;
-            } else if (strncmp (&arg[parse_pos], "noaspect", 8) == 0) {
-                parse_pos += 8;
-                use_aspect = 0;
-            } else if (strncmp (&arg[parse_pos], "slice-height=", 13) == 0) {
-                int val;
-                char *end;
-                parse_pos += 13;
-                val = strtol(&arg[parse_pos], &end, 0);
-                if (val < 0) parse_err = 1;
-                else {
-                  slice_height = val;
-                  parse_pos = end - arg;
-                }
-            }
-            if (arg[parse_pos] == ':') parse_pos++;
-            else if (arg[parse_pos]) parse_err = 1;
-        }
-    }
-    if (parse_err) {
-      unsigned int i;
-      mp_msg(MSGT_VO, MSGL_FATAL, "Could not parse arguments:\n%s\n", arg);
-      for (i = 0; i < parse_pos; i++)
-        mp_msg(MSGT_VO, MSGL_FATAL, " ");
-      mp_msg(MSGT_VO, MSGL_FATAL, "^\n");
+    if (subopt_parse(arg, subopts) != 0) {
       mp_msg(MSGT_VO, MSGL_FATAL,
               "\n-vo gl command line help:\n"
               "Example: mplayer -vo gl:slice-height=4\n"




More information about the MPlayer-cvslog mailing list