mirror of
https://github.com/mpv-player/mpv
synced 2024-12-20 05:42:19 +00:00
Use subopt parser
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14285 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
f3f2e49ee2
commit
d0b713ad24
@ -29,6 +29,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "subopt-helper.h"
|
||||
#include "video_out.h"
|
||||
#include "video_out_internal.h"
|
||||
|
||||
@ -492,44 +493,35 @@ static void check_events(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static uint32_t preinit(const char *arg)
|
||||
{
|
||||
if(arg)
|
||||
{
|
||||
int parse_err = 0;
|
||||
unsigned int parse_pos = 0;
|
||||
int il, il_bf;
|
||||
strarg_t file;
|
||||
opt_t subopts[] = {
|
||||
{"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) {
|
||||
if (strncmp (&arg[parse_pos], "interlaced", 10) == 0) {
|
||||
parse_pos += 10;
|
||||
config_interlace = Y4M_ILACE_TOP_FIRST;
|
||||
}
|
||||
else if (strncmp (&arg[parse_pos], "interlaced_bf", 13) == 0) {
|
||||
parse_pos += 13;
|
||||
config_interlace = Y4M_ILACE_BOTTOM_FIRST;
|
||||
}
|
||||
else if (strncmp (&arg[parse_pos], "file=", 5) == 0) {
|
||||
int file_len;
|
||||
parse_pos += 5;
|
||||
file_len = strcspn (&arg[parse_pos], ":");
|
||||
if (file_len < 0) {
|
||||
parse_err = 1;
|
||||
break;
|
||||
}
|
||||
yuv_filename = malloc (file_len + 1);
|
||||
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);
|
||||
il = 0;
|
||||
il_bf = 0;
|
||||
file.len = 0;
|
||||
if (subopt_parse(arg, subopts) != 0) {
|
||||
mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
config_interlace = Y4M_ILACE_NONE;
|
||||
if (il)
|
||||
config_interlace = Y4M_ILACE_TOP_FIRST;
|
||||
if (il_bf)
|
||||
config_interlace = Y4M_ILACE_BOTTOM_FIRST;
|
||||
yuv_filename = NULL;
|
||||
if (file.len > 0) {
|
||||
yuv_filename = malloc(file.len + 1);
|
||||
memcpy(yuv_filename, file.str, file.len);
|
||||
yuv_filename[file.len] = 0;
|
||||
}
|
||||
|
||||
/* Inform user which output mode is used */
|
||||
|
Loading…
Reference in New Issue
Block a user