Mercurial > mplayer.hg
comparison libvo/geometry.c @ 9517:d65ddafbc404
clean up of -geometry code.
disabled -geometry for all but -vo xv (will be fixed later)
author | attila |
---|---|
date | Sun, 02 Mar 2003 21:09:15 +0000 |
parents | 420e2b2f8e5a |
children | b552e7939ca2 |
comparison
equal
deleted
inserted
replaced
9516:1a98dc5021ef | 9517:d65ddafbc404 |
---|---|
14 mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | 14 mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); |
15 exit_player(NULL); /* ????? what else could we do ? */ | 15 exit_player(NULL); /* ????? what else could we do ? */ |
16 return 0; | 16 return 0; |
17 } | 17 } |
18 | 18 |
19 // A little kludge as to not to have to update all drivers | 19 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; |
20 // Only the vo_xv driver supports now the full [WxH][+X+Y] option | 20 |
21 int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh) | 21 // xpos,ypos: position of the left upper corner |
22 // widw,widh: width and height of the window | |
23 // scrw,scrh: width and height of the current screen | |
24 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) | |
22 { | 25 { |
23 int width, height, xoff, yoff, xper, yper; | 26 int width, height, xoff, yoff, xper, yper; |
24 | 27 |
25 width = height = xoff = yoff = xper = yper = -1; | 28 width = height = xoff = yoff = xper = yper = -1; |
26 | 29 |
27 /* no need to save a few extra cpu cycles here ;) */ | |
28 /* PUKE i will rewrite this code sometime maybe - euck but it works */ | |
29 if(vo_geometry != NULL) { | 30 if(vo_geometry != NULL) { |
30 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 && | 31 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
31 sscanf(vo_geometry, "%ix%i", &width, &height) != 2 && | 32 { |
32 sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2 && | 33 RESET_GEOMETRY |
33 sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2 && | 34 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) |
34 sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2 && | 35 { |
35 sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2 && | 36 RESET_GEOMETRY |
36 sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2 && | 37 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) |
37 sscanf(vo_geometry, "%i%%", &xper) != 1) | 38 { |
39 RESET_GEOMETRY | |
40 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) | |
41 { | |
42 RESET_GEOMETRY | |
43 if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2) | |
44 { | |
45 RESET_GEOMETRY | |
46 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2) | |
47 { | |
48 RESET_GEOMETRY | |
49 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) | |
50 { | |
51 RESET_GEOMETRY | |
52 if(sscanf(vo_geometry, "%i%%", &xper) != 1) | |
38 return geometry_error(); | 53 return geometry_error(); |
54 } | |
55 } | |
56 } | |
57 } | |
58 } | |
59 } | |
60 } | |
39 | 61 |
40 if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0); | 62 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
41 if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0); | 63 "height: %i, xoff: %i, yoff: %i, xper: %1, yper: %i\n", |
64 width, height, xoff, yoff, xper, yper); | |
65 | |
66 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | |
67 if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0); | |
42 | 68 |
43 /* FIXME: better checking of bounds... */ | 69 /* FIXME: better checking of bounds... */ |
44 if(width < 0 || width > scrw) width = vidw; | 70 if(width < 0 || width > scrw) width = *widw; |
45 if(height < 0 || height > scrh) height = vidh; | 71 if(height < 0 || height > scrh) height = *widh; |
46 if(xoff < 0 || xoff + vidw > scrw) xoff = 0; | 72 if(xoff < 0 || xoff + *widw > scrw) xoff = 0; |
47 if(yoff < 0 || yoff + vidh > scrh) yoff = 0; | 73 if(yoff < 0 || yoff + *widh > scrh) yoff = 0; |
48 | 74 |
49 if(xpos) *xpos = xoff; | 75 if(xpos) *xpos = xoff; |
50 if(ypos) *ypos = yoff; | 76 if(ypos) *ypos = yoff; |
51 if(pwidth) *pwidth = width; | 77 if(widw) *widw = width; |
52 if(pheight) *pheight = height; | 78 if(widh) *widh = height; |
53 } | 79 } |
54 return 1; | 80 return 1; |
55 } | 81 } |
56 | 82 |
57 // compatibility function | 83 #undef RESET_GEOMETRY |
58 // only libvo working with full geometry options. | |
59 int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh) | |
60 { | |
61 return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh); | |
62 } |