2002-10-23 16:52:54 +00:00
|
|
|
/* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */
|
|
|
|
|
|
|
|
#include "geometry.h"
|
|
|
|
#include "../mp_msg.h"
|
2002-11-23 10:58:14 +00:00
|
|
|
#include "../mplayer.h" /* exit_player() */
|
2002-10-23 16:52:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
/* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
|
2002-10-23 16:52:54 +00:00
|
|
|
char *vo_geometry = NULL;
|
|
|
|
|
|
|
|
int geometry_error()
|
|
|
|
{
|
2003-01-03 20:46:44 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
|
2002-10-23 16:52:54 +00:00
|
|
|
exit_player(NULL); /* ????? what else could we do ? */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
// A little kludge as to not to have to update all drivers
|
|
|
|
// Only the vo_xv driver supports now the full [WxH][+X+Y] option
|
|
|
|
int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
|
2002-10-23 16:52:54 +00:00
|
|
|
{
|
2003-01-03 20:46:44 +00:00
|
|
|
int width, height, xoff, yoff, xper, yper;
|
|
|
|
|
|
|
|
width = height = xoff = yoff = xper = yper = -1;
|
|
|
|
|
|
|
|
/* no need to save a few extra cpu cycles here ;) */
|
|
|
|
/* PUKE i will rewrite this code sometime maybe - euck but it works */
|
|
|
|
if(vo_geometry != NULL) {
|
|
|
|
if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 &&
|
|
|
|
sscanf(vo_geometry, "%ix%i", &width, &height) != 2 &&
|
|
|
|
sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2 &&
|
|
|
|
sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2 &&
|
|
|
|
sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2 &&
|
|
|
|
sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2 &&
|
|
|
|
sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2 &&
|
|
|
|
sscanf(vo_geometry, "%i%%", &xper) != 1)
|
|
|
|
return geometry_error();
|
|
|
|
}
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0);
|
|
|
|
if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0);
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
/* FIXME: better checking of bounds... */
|
|
|
|
if(width < 0 || width > scrw) width = vidw;
|
|
|
|
if(height < 0 || height > scrh) height = vidh;
|
|
|
|
if(xoff < 0 || xoff + vidw > scrw) xoff = 0;
|
|
|
|
if(yoff < 0 || yoff + vidh > scrh) yoff = 0;
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
if(xpos) *xpos = xoff;
|
|
|
|
if(ypos) *ypos = yoff;
|
|
|
|
if(pwidth) *pwidth = width;
|
|
|
|
if(pheight) *pheight = height;
|
2002-10-23 16:52:54 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
// compatibility function
|
|
|
|
// only libvo working with full geometry options.
|
|
|
|
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
|
2002-10-23 16:52:54 +00:00
|
|
|
{
|
2003-01-03 20:46:44 +00:00
|
|
|
return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh);
|
2002-10-23 16:52:54 +00:00
|
|
|
}
|