summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-31 14:58:49 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-31 14:58:49 +0000
commitefa1ae22749bb07fef67c079fd9cd8c9a96873da (patch)
tree3a687ef81cea5d50251b5fd7d3a7b51a74bc5101 /libvo
parent1f74d67f879c2b12fe3102a7f530f981b800510b (diff)
downloadmpv-efa1ae22749bb07fef67c079fd9cd8c9a96873da.tar.bz2
mpv-efa1ae22749bb07fef67c079fd9cd8c9a96873da.tar.xz
Use subopt helper to parse arguments
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14287 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_gl.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index e788a2765b..b82e68b28c 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -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 @@ uninit(void)
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"