Mercurial > mplayer.hg
annotate libvo/geometry.c @ 11086:7f659e7b7ce1
the yv12 image looked more like a yuy2 image ;)
author | faust3 |
---|---|
date | Sun, 12 Oct 2003 12:55:38 +0000 |
parents | b105d7aba10d |
children | d9478c8e5ffe |
rev | line source |
---|---|
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
1 /* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */ |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
2 |
9217
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
3 #include <stdio.h> |
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
4 #include <string.h> |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
5 #include "geometry.h" |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
6 #include "../mp_msg.h" |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
7 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
8 /* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */ |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
9 char *vo_geometry = NULL; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
10 |
9517 | 11 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; |
12 | |
13 // xpos,ypos: position of the left upper corner | |
14 // widw,widh: width and height of the window | |
15 // scrw,scrh: width and height of the current screen | |
16 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
17 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
18 int width, height, xoff, yoff, xper, yper; |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
19 |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
20 width = height = xoff = yoff = xper = yper = -1; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
21 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
22 if(vo_geometry != NULL) { |
9517 | 23 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
24 { | |
25 RESET_GEOMETRY | |
26 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) | |
27 { | |
28 RESET_GEOMETRY | |
29 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) | |
30 { | |
31 RESET_GEOMETRY | |
32 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) | |
33 { | |
34 RESET_GEOMETRY | |
35 if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2) | |
36 { | |
37 RESET_GEOMETRY | |
38 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2) | |
39 { | |
40 RESET_GEOMETRY | |
41 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) | |
42 { | |
43 RESET_GEOMETRY | |
44 if(sscanf(vo_geometry, "%i%%", &xper) != 1) | |
10734 | 45 { |
46 mp_msg(MSGT_VO, MSGL_ERR, | |
47 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | |
48 return 0; | |
49 } | |
9517 | 50 } |
51 } | |
52 } | |
53 } | |
54 } | |
55 } | |
56 } | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
57 |
9517 | 58 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
9947 | 59 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |
9517 | 60 width, height, xoff, yoff, xper, yper); |
61 | |
62 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | |
63 if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0); | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
64 |
9947 | 65 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
66 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | |
67 width, height, xoff, yoff, xper, yper); | |
68 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i," | |
69 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh); | |
70 | |
8768 | 71 /* FIXME: better checking of bounds... */ |
9947 | 72 if(width < 0 || width > scrw) width = (scrw < *widw) ? scrw : *widw; |
73 if(height < 0 || height > scrh) height = (scrh < *widh) ? scrh : *widh; | |
74 if(xoff < 0 || xoff + width > scrw) xoff = 0; | |
75 if(yoff < 0 || yoff + height > scrh) yoff = 0; | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
76 |
8768 | 77 if(xpos) *xpos = xoff; |
78 if(ypos) *ypos = yoff; | |
9517 | 79 if(widw) *widw = width; |
80 if(widh) *widh = height; | |
8767 | 81 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
82 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
83 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
84 |
9517 | 85 #undef RESET_GEOMETRY |