Mercurial > mplayer.hg
comparison libvo/geometry.c @ 7866:732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
author | mark |
---|---|
date | Wed, 23 Oct 2002 16:52:54 +0000 |
parents | |
children | 9fc45fe0d444 |
comparison
equal
deleted
inserted
replaced
7865:d151608b9f28 | 7866:732a8bfc7681 |
---|---|
1 /* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */ | |
2 | |
3 #include "geometry.h" | |
4 #include "../mp_msg.h" | |
5 #include <string.h> | |
6 | |
7 /* A string of the form xpos[%]:ypos[%] */ | |
8 char *vo_geometry = NULL; | |
9 | |
10 int geometry_error() | |
11 { | |
12 mp_msg(MSGT_VO, MSGL_ERR, "-geometry option format incorrect (%s)\n", vo_geometry); | |
13 exit_player(NULL); /* ????? what else could we do ? */ | |
14 return 0; | |
15 } | |
16 | |
17 int get_num(char *s, int *num, char *end) | |
18 { | |
19 char *e; | |
20 long int t; | |
21 | |
22 t = strtol(s, &e, 10); | |
23 | |
24 if(e != end) | |
25 return 0; | |
26 | |
27 *num = t; | |
28 return 1; | |
29 } | |
30 | |
31 int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs) | |
32 { | |
33 int xper = 0, yper = 0; | |
34 int glen; | |
35 char *colpos; | |
36 | |
37 *xpos = 0; *ypos = 0; | |
38 | |
39 if(vo_geometry == NULL) | |
40 return 1; | |
41 | |
42 glen = strlen(vo_geometry); | |
43 colpos = strchr(vo_geometry, ':'); | |
44 if(colpos == NULL) | |
45 colpos = (char *)(vo_geometry + glen); | |
46 | |
47 /* Parse the x bit */ | |
48 if(colpos[-1] == '%') { | |
49 if(!get_num(vo_geometry, &xper, colpos - 1)) | |
50 return geometry_error(); | |
51 } else { | |
52 if(!get_num(vo_geometry, xpos, colpos)) | |
53 return geometry_error(); | |
54 } | |
55 | |
56 if(*colpos != '\0') | |
57 if(vo_geometry[glen - 1] == '%') { | |
58 if(!get_num(colpos + 1, &yper, vo_geometry + glen - 1)) | |
59 return geometry_error(); | |
60 } else { | |
61 if(!get_num(colpos + 1, ypos, vo_geometry + glen)) | |
62 return geometry_error(); | |
63 } | |
64 | |
65 if(xper) | |
66 *xpos = (scrw - vidw) * ((float)xper / 100.0); | |
67 if(yper) | |
68 *ypos = (scrh - vidh) * ((float)yper / 100.0); | |
69 | |
70 if(*xpos + vidw > scrw) { | |
71 mp_msg(MSGT_VO, MSGL_ERR, "X position is too large\n"); | |
72 return geometry_error(); | |
73 } | |
74 if(*ypos + vidh > scrh) { | |
75 mp_msg(MSGT_VO, MSGL_ERR, "Y position is too large\n"); | |
76 return geometry_error(); | |
77 } | |
78 | |
79 return 1; | |
80 } |