annotate libvo/geometry.c @ 9450:915590b8193b

mwallp compiles again (michael moved libpostproc.....)
author gabucino
date Mon, 17 Feb 2003 11:45:10 +0000
parents 420e2b2f8e5a
children d65ddafbc404
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
8254
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 8123
diff changeset
7 #include "../mplayer.h" /* exit_player() */
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
8
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
9 /* 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
10 char *vo_geometry = NULL;
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
11
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
12 int geometry_error()
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
13 {
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
14 mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
15 exit_player(NULL); /* ????? what else could we do ? */
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
16 return 0;
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
17 }
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
18
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
19 // A little kludge as to not to have to update all drivers
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
20 // Only the vo_xv driver supports now the full [WxH][+X+Y] option
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
21 int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
22 {
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
23 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
24
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
25 width = height = xoff = yoff = xper = yper = -1;
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
26
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
27 /* no need to save a few extra cpu cycles here ;) */
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
28 /* PUKE i will rewrite this code sometime maybe - euck but it works */
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
29 if(vo_geometry != NULL) {
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
30 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
31 sscanf(vo_geometry, "%ix%i", &width, &height) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
32 sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
33 sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
34 sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
35 sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
36 sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2 &&
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
37 sscanf(vo_geometry, "%i%%", &xper) != 1)
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
38 return geometry_error();
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
39
8768
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
40 if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0);
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
41 if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0);
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
42
8768
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
43 /* FIXME: better checking of bounds... */
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
44 if(width < 0 || width > scrw) width = vidw;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
45 if(height < 0 || height > scrh) height = vidh;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
46 if(xoff < 0 || xoff + vidw > scrw) xoff = 0;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
47 if(yoff < 0 || yoff + vidh > scrh) yoff = 0;
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
48
8768
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
49 if(xpos) *xpos = xoff;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
50 if(ypos) *ypos = yoff;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
51 if(pwidth) *pwidth = width;
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
52 if(pheight) *pheight = height;
8767
e497d7e42d8a fix xv window position problem
attila
parents: 8745
diff changeset
53 }
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
54 return 1;
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
55 }
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
56
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
57 // compatibility function
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
58 // only libvo working with full geometry options.
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
59 int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
60 {
8745
93f78fb709e6 Added support for X style -geometry options (adapted from Henk's patch)
mark
parents: 8254
diff changeset
61 return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh);
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
62 }