summaryrefslogtreecommitdiffstats
path: root/libvo/geometry.c
diff options
context:
space:
mode:
authormark <mark@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-23 16:52:54 +0000
committermark <mark@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-23 16:52:54 +0000
commita2dfc7a766c2f00408671327838602eebcc4cddf (patch)
tree1b668f5ecfebc6ad7688d652594f4e91179183d2 /libvo/geometry.c
parentddaa6dd19d52961065344b66a474dc4629d04cbd (diff)
downloadmpv-a2dfc7a766c2f00408671327838602eebcc4cddf.tar.bz2
mpv-a2dfc7a766c2f00408671327838602eebcc4cddf.tar.xz
Added the -geometry option (supports fbdev and tdfxfb drivers)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7867 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/geometry.c')
-rw-r--r--libvo/geometry.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/libvo/geometry.c b/libvo/geometry.c
new file mode 100644
index 0000000000..26afd69547
--- /dev/null
+++ b/libvo/geometry.c
@@ -0,0 +1,80 @@
+/* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */
+
+#include "geometry.h"
+#include "../mp_msg.h"
+#include <string.h>
+
+/* A string of the form xpos[%]:ypos[%] */
+char *vo_geometry = NULL;
+
+int geometry_error()
+{
+ mp_msg(MSGT_VO, MSGL_ERR, "-geometry option format incorrect (%s)\n", vo_geometry);
+ exit_player(NULL); /* ????? what else could we do ? */
+ return 0;
+}
+
+int get_num(char *s, int *num, char *end)
+{
+ char *e;
+ long int t;
+
+ t = strtol(s, &e, 10);
+
+ if(e != end)
+ return 0;
+
+ *num = t;
+ return 1;
+}
+
+int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs)
+{
+ int xper = 0, yper = 0;
+ int glen;
+ char *colpos;
+
+ *xpos = 0; *ypos = 0;
+
+ if(vo_geometry == NULL)
+ return 1;
+
+ glen = strlen(vo_geometry);
+ colpos = strchr(vo_geometry, ':');
+ if(colpos == NULL)
+ colpos = (char *)(vo_geometry + glen);
+
+ /* Parse the x bit */
+ if(colpos[-1] == '%') {
+ if(!get_num(vo_geometry, &xper, colpos - 1))
+ return geometry_error();
+ } else {
+ if(!get_num(vo_geometry, xpos, colpos))
+ return geometry_error();
+ }
+
+ if(*colpos != '\0')
+ if(vo_geometry[glen - 1] == '%') {
+ if(!get_num(colpos + 1, &yper, vo_geometry + glen - 1))
+ return geometry_error();
+ } else {
+ if(!get_num(colpos + 1, ypos, vo_geometry + glen))
+ return geometry_error();
+ }
+
+ if(xper)
+ *xpos = (scrw - vidw) * ((float)xper / 100.0);
+ if(yper)
+ *ypos = (scrh - vidh) * ((float)yper / 100.0);
+
+ if(*xpos + vidw > scrw) {
+ mp_msg(MSGT_VO, MSGL_ERR, "X position is too large\n");
+ return geometry_error();
+ }
+ if(*ypos + vidh > scrh) {
+ mp_msg(MSGT_VO, MSGL_ERR, "Y position is too large\n");
+ return geometry_error();
+ }
+
+ return 1;
+}