1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-15 11:25:10 +00:00

improved suboption parsing, fixes also compiler warnings

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13238 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2004-09-03 12:12:17 +00:00
parent 13abc1ced2
commit 0a2999f9f4

View File

@ -54,7 +54,7 @@ static int int_pause;
static uint32_t texture_width; static uint32_t texture_width;
static uint32_t texture_height; static uint32_t texture_height;
static int slice_height=1; static unsigned int slice_height = 1;
static void resize(int x,int y){ static void resize(int x,int y){
mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
@ -314,7 +314,7 @@ static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y
static uint32_t static uint32_t
draw_frame(uint8_t *src[]) draw_frame(uint8_t *src[])
{ {
int i; unsigned int i;
uint8_t *ImageData=src[0]; uint8_t *ImageData=src[0];
if (slice_height == 0) if (slice_height == 0)
@ -358,26 +358,40 @@ uninit(void)
static uint32_t preinit(const char *arg) static uint32_t preinit(const char *arg)
{ {
int parse_err = 0; int parse_err = 0;
unsigned int parse_pos = 0;
many_fmts = 0; many_fmts = 0;
slice_height = 4; slice_height = 4;
if(arg) if(arg)
{ {
char *parse_pos = (char *)&arg[0]; while (arg[parse_pos] && !parse_err) {
while (parse_pos[0] && !parse_err) { if (strncmp (&arg[parse_pos], "manyfmts", 8) == 0) {
if (strncmp (parse_pos, "manyfmts", 8) == 0) { parse_pos += 8;
parse_pos = &parse_pos[8];
many_fmts = 1; many_fmts = 1;
} else if (strncmp (parse_pos, "slice-height=", 13) == 0) { } else if (strncmp (&arg[parse_pos], "nomanyfmts", 10) == 0) {
parse_pos = &parse_pos[13]; parse_pos += 10;
slice_height = strtol(parse_pos, &parse_pos, 0); many_fmts = 0;
if (slice_height < 0) parse_err = 1; } 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 (parse_pos[0] == ':') parse_pos = &parse_pos[1]; if (arg[parse_pos] == ':') parse_pos++;
else if (parse_pos[0]) parse_err = 1; else if (arg[parse_pos]) parse_err = 1;
} }
} }
if (parse_err) { if (parse_err) {
mp_msg(MSGT_VO, MSGL_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");
mp_msg(MSGT_VO, MSGL_FATAL,
"\n-vo gl command line help:\n" "\n-vo gl command line help:\n"
"Example: mplayer -vo gl:slice-height=4\n" "Example: mplayer -vo gl:slice-height=4\n"
"\nOptions:\n" "\nOptions:\n"