[MPlayer-cvslog] CVS: main/libvo vo_zr2.c,1.5,1.6
Rik Snel CVS
syncmail at mplayerhq.hu
Sat Jan 8 15:25:24 CET 2005
CVS change done by Rik Snel CVS
Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv18112
Modified Files:
vo_zr2.c
Log Message:
vo_zr2 moves to subopt-helper (per Alex's request)
Index: vo_zr2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_zr2.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vo_zr2.c 28 Oct 2004 01:15:52 -0000 1.5
+++ vo_zr2.c 8 Jan 2005 14:25:22 -0000 1.6
@@ -1,7 +1,7 @@
/*
* vo_zr2.c - playback on zoran cards
* Based on vo_zr.c,v 1.27
- * Copyright (C) Rik Snel 2001-2003, License GNU GPL v2
+ * Copyright (C) Rik Snel 2001-2005, License GNU GPL v2
*/
/* $Id$ */
@@ -26,6 +26,7 @@
#include "video_out.h"
#include "video_out_internal.h"
#include "mp_msg.h"
+#include "subopt-helper.h"
#include "fastmemcpy.h"
static vo_info_t info = {
@@ -77,7 +78,7 @@
}
}
-static char *guess_device(char *suggestion) {
+static const char *guess_device(const char *suggestion, int inform) {
struct stat vstat;
int res;
char *devs[] = {
@@ -98,7 +99,7 @@
res = stat(suggestion, &vstat);
if (res == 0 && S_ISCHR(vstat.st_mode)) {
- VERBOSE("using device %s\n", suggestion);
+ if (inform) VERBOSE("using device %s\n", suggestion);
return suggestion;
} else {
if (res != 0) ERROR("%s does not exist\n", suggestion);
@@ -155,7 +156,7 @@
return VO_TRUE;
}
-static char *normstring(int norm) {
+static const char *normstring(int norm) {
switch (norm) {
case VIDEO_MODE_PAL:
return "PAL";
@@ -169,54 +170,66 @@
return "undefined";
}
+static int get_norm(strarg_t *n) {
+ if (!strncmp(n->str, "PAL", n->len)) return VIDEO_MODE_PAL;
+ if (!strncmp(n->str, "NTSC", n->len)) return VIDEO_MODE_NTSC;
+ if (!strncmp(n->str, "SECAM", n->len)) return VIDEO_MODE_SECAM;
+ if (!strncmp(n->str, "auto", n->len)) return VIDEO_MODE_AUTO;
+ return -1; /* invalid */
+}
+
+static int nc(strarg_t *norm) {
+ if (get_norm(norm) == -1) {
+ ERROR("norm \"%.*s\" is not supported, choose from PAL, NTSC, SECAM and auto\n", norm->len, norm->str);
+ return 0;
+ } else return 1;
+}
+
+static int pbc(int *prebuf) {
+ if (*prebuf) WARNING("prebuffering is not yet supported\n");
+ return 1;
+}
+
static uint32_t preinit(const char *arg) {
- char *dev = NULL, *ptr = NULL, *tmp;
+ strarg_t dev_arg = { 0, NULL }, norm_arg = { 0, NULL };
vo_zr2_priv_t *p = &priv;
- int last = 0, norm = VIDEO_MODE_AUTO;
+ const char *dev = NULL;
+ char dev_arg_str[256];
+ int norm = VIDEO_MODE_AUTO, prebuf = 0;
+ opt_t subopts[] = { /* don't want warnings with -Wall... */
+ { "dev", OPT_ARG_STR, &dev_arg, NULL, 0 },
+ { "prebuf", OPT_ARG_BOOL, &prebuf, (opt_test_f)pbc, 0 },
+ { "norm", OPT_ARG_STR, &norm_arg, (opt_test_f)nc, 0 },
+ { NULL, 0, NULL, NULL, 0 }
+ };
- VERBOSE("preinit() called\n");
+ VERBOSE("preinit() called with arg: %s\n", arg);
memset(p, 0, sizeof(*p)); /* set defaults */
p->vdes = -1;
- if (arg) {
- /* save subdevice string */
- p->subdevice = strdup(arg);
- if (!p->subdevice) {
- ERROR("out of memory, this is bad\n");
- uninit();
- return 1;
- }
-
- tmp = ptr = p->subdevice;
- do {
- while (*tmp != ':' && *tmp) tmp++;
- if (*tmp == ':') *tmp++ = '\0';
- else last = 1;
- DBG2("processing subdevice option \"%s\"\n", ptr);
- if (!strncmp("dev=", ptr, 4)) {
- dev = ptr + 4;
- VERBOSE("user specified device \"%s\"\n", dev);
- } else if (!strcasecmp("PAL", ptr)) {
- norm = VIDEO_MODE_PAL;
- VERBOSE("user specified video norm PAL\n");
- } else if (!strcasecmp("SECAM", ptr)) {
- norm = VIDEO_MODE_SECAM;
- VERBOSE("user specified video norm SECAM\n");
- } else if (!strcasecmp("NTSC", ptr)) {
- norm = VIDEO_MODE_NTSC;
- VERBOSE("user specified video norm NTSC\n");
- } else if (!strcmp("prebuf", ptr)) {
- WARNING("prebuffering is not yet supported\n");
- } else {
- WARNING("ignoring unknown subdevice option "
- "\"%s\", or missing argument\n",
- ptr);
- }
- ptr = tmp;
- } while (!last);
+ if (subopt_parse(arg, subopts)) {
+ mp_msg(MSGT_VO, MSGL_FATAL,
+ "Allowed suboptions for -vo zr2 are:\n"
+ "- dev=DEVICE (default: %s)\n"
+ "- norm=PAL|NTSC|SECAM|auto (default: auto)\n"
+ "- prebuf/noprebuf (default:"
+ " noprebuf)\n"
+ "\n"
+ "Example: mplayer -vo zr2:dev=/dev/video1:"
+ "norm=PAL movie.avi\n\n"
+ , guess_device(NULL, 0));
+ return -1;
+ }
+
+ /* interpret the strings we got from subopt_parse */
+ if (norm_arg.len) norm = get_norm(&norm_arg);
+ if (dev_arg.len) { /* produce a proper ASCIIZ from dev_arg */
+ memcpy(dev_arg_str, dev_arg.str, dev_arg.len);
+ dev_arg_str[dev_arg.len] = '\0';
+ dev = dev_arg_str;
}
- dev = guess_device(dev);
+ dev = guess_device(dev, 1);
if (!dev) {
uninit();
return 1;
More information about the MPlayer-cvslog
mailing list