Use subopt parser

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14285 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2004-12-31 14:54:58 +00:00
parent f3f2e49ee2
commit d0b713ad24
1 changed files with 28 additions and 36 deletions

View File

@ -29,6 +29,7 @@
#include <fcntl.h> #include <fcntl.h>
#include "config.h" #include "config.h"
#include "subopt-helper.h"
#include "video_out.h" #include "video_out.h"
#include "video_out_internal.h" #include "video_out_internal.h"
@ -492,45 +493,36 @@ static void check_events(void)
{ {
} }
static uint32_t preinit(const char *arg) static uint32_t preinit(const char *arg)
{ {
if(arg) int il, il_bf;
{ strarg_t file;
int parse_err = 0; opt_t subopts[] = {
unsigned int parse_pos = 0; {"interlaced", OPT_ARG_BOOL, &il, NULL},
{"interlaced_bf", OPT_ARG_BOOL, &il_bf, NULL},
{"file", OPT_ARG_STR, &file, NULL},
{NULL}
};
while (arg[parse_pos] && !parse_err) { il = 0;
if (strncmp (&arg[parse_pos], "interlaced", 10) == 0) { il_bf = 0;
parse_pos += 10; file.len = 0;
config_interlace = Y4M_ILACE_TOP_FIRST; if (subopt_parse(arg, subopts) != 0) {
} mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg);
else if (strncmp (&arg[parse_pos], "interlaced_bf", 13) == 0) { return -1;
parse_pos += 13; }
config_interlace = Y4M_ILACE_BOTTOM_FIRST;
} config_interlace = Y4M_ILACE_NONE;
else if (strncmp (&arg[parse_pos], "file=", 5) == 0) { if (il)
int file_len; config_interlace = Y4M_ILACE_TOP_FIRST;
parse_pos += 5; if (il_bf)
file_len = strcspn (&arg[parse_pos], ":"); config_interlace = Y4M_ILACE_BOTTOM_FIRST;
if (file_len < 0) { yuv_filename = NULL;
parse_err = 1; if (file.len > 0) {
break; yuv_filename = malloc(file.len + 1);
} memcpy(yuv_filename, file.str, file.len);
yuv_filename = malloc (file_len + 1); yuv_filename[file.len] = 0;
memcpy (yuv_filename, &arg[parse_pos], file_len); }
yuv_filename[file_len] = 0;
parse_pos += file_len;
}
if (arg[parse_pos] == ':') parse_pos++;
else if (arg[parse_pos]) parse_err = 1;
}
if (parse_err) {
mp_msg(MSGT_VO,MSGL_FATAL,
MSGTR_VO_YUV4MPEG_UnknownSubDev,arg);
return -1;
}
}
/* Inform user which output mode is used */ /* Inform user which output mode is used */
switch (config_interlace) switch (config_interlace)