[MPlayer-dev-eng] -geometry option draft1

Mark Zealey mark at zealos.org
Tue Oct 22 14:11:26 CEST 2002


Here's a sample patch, theres a few bugs, not sure how to return an error, and
maybe the string should be parsed elsewhere in mplayer, but hey, it works for me
(Only made a patch for tdfxfb, but should be blatently simple for any other
driver.

-- 

Mark Zealey (aka JALH on irc.oftc.net: #zealos and many more)
mark at zealos.org; mark at itsolve.co.uk

UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a17! C++++>$ P++++>+++++$ L+++>+++++$
!E---? W+++>$ !w--- r++ !t---?@ !X---?  !R- !tv b+ G+++ e>+++++ !h++* r!-- y--
-------------- next part --------------
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.173
diff -u -u -r1.173 cfg-mplayer.h
--- cfg-mplayer.h	9 Oct 2002 01:13:40 -0000	1.173
+++ cfg-mplayer.h	22 Oct 2002 12:23:08 -0000
@@ -58,6 +58,7 @@
 extern int vo_gamma_saturation;
 extern int vo_gamma_contrast;
 extern int vo_gamma_hue;
+extern char *vo_geometry;
 
 extern int opt_screen_size_x;
 extern int opt_screen_size_y;
@@ -239,6 +240,8 @@
 	// set screen dimensions (when not detectable or virtual!=visible)
 	{"screenw", &vo_screenwidth, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
 	{"screenh", &vo_screenheight, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
+	// Geometry string
+	{"geometry", &vo_geometry, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	// set aspect ratio of monitor - usefull for 16:9 TVout
 	{"monitoraspect", &monitor_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, NULL},
 	// video mode switching: (x11,xv,dga)
Index: libvo/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/Makefile,v
retrieving revision 1.37
diff -u -u -r1.37 Makefile
--- libvo/Makefile	28 Aug 2002 20:52:02 -0000	1.37
+++ libvo/Makefile	22 Oct 2002 12:23:08 -0000
@@ -3,7 +3,7 @@
 
 LIBNAME = libvo.a
 
-SRCS=aspect.c aclib.c osd.c font_load.c gtf.c spuenc.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_mpegpes.c vo_yuv4mpeg.c $(OPTIONAL_SRCS) sub.c font_load_ft.c
+SRCS=geometry.c aspect.c aclib.c osd.c font_load.c gtf.c spuenc.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_mpegpes.c vo_yuv4mpeg.c $(OPTIONAL_SRCS) sub.c font_load_ft.c
 OBJS=$(SRCS:.c=.o)
 
 ifeq ($(VIDIX),yes)
Index: libvo/video_out.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.h,v
retrieving revision 1.44
diff -u -u -r1.44 video_out.h
--- libvo/video_out.h	29 Sep 2002 21:53:05 -0000	1.44
+++ libvo/video_out.h	22 Oct 2002 12:23:08 -0000
@@ -166,6 +166,8 @@
 extern int vo_screenwidth;
 extern int vo_screenheight;
 
+extern int vo_xper, vo_yper;
+
 // requested resolution/bpp:  (-x -y -bpp options)
 extern int vo_dx;
 extern int vo_dy;
Index: libvo/vo_tdfxfb.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_tdfxfb.c,v
retrieving revision 1.19
diff -u -u -r1.19 vo_tdfxfb.c
--- libvo/vo_tdfxfb.c	10 Oct 2002 14:17:59 -0000	1.19
+++ libvo/vo_tdfxfb.c	22 Oct 2002 12:23:09 -0000
@@ -15,6 +15,7 @@
  * 13/04/02: Fix rough OSD stuff by rendering it straight onto the output
  * buffer. Added double-buffering. Supports hardware zoom/reduce zoom modes.
  * 13/04/02: Misc cleanups of the code.
+ * 22/10/02: Added geometry support to it
  *
  * Hints and tricks:
  * - Use -dr to get direct rendering
@@ -22,7 +23,8 @@
  * - To get a black background and nice smooth OSD, use -double
  * - To get the console as a background, but with scaled OSD, use -nodouble
  * - The driver supports both scaling and shrinking the image using the -x and
- *   -y options on the mplayer commandline.
+ *   -y options on the mplayer commandline. Also repositioning via the -geometry
+ *   option.
  */
 
 #include <stdio.h>
@@ -200,15 +202,9 @@
 /* Setup output screen dimensions etc */
 static void setup_screen(uint32_t full)
 {
+	aspect(&vidwidth, &vidheight, full ? A_ZOOM : A_NOZOOM);
+	geometry(&vidx, &vidy, screenwidth, screenheight, vidwidth, vidheight, full);
 	vo_fs = full;
-
-	aspect(&vidwidth,&vidheight, vo_fs ? A_ZOOM : A_NOZOOM);
-	if(vo_fs) {
-	  vidx = (screenwidth - vidwidth) / 2;
-	  vidy = (screenheight - vidheight) / 2;
-	} else
-	  vidx = vidy = 0;
-
 	clear_screen();
 }
 
-------------- next part --------------
/* This file (C) Mark Zealey <mark at zealos.org> 2002, released under GPL */

#include "geometry.h"
#include "../mp_msg.h"
#include <string.h>

/* A string of the form xpos[%]:ypos[%] */
char *vo_geometry = NULL;

int geometry_error()
{
	mp_msg(MSGT_VO, MSGL_ERR, "-geometry option format incorrect (%s)\n", vo_geometry);
	exit_player(NULL);		/* ????? what else could we do ? */
	return 0;
}

int get_num(char *s, int *num, char *end)
{
	char *e;
	long int t;

	t = strtol(s, &e, 10);

	if(e != end)
		return 0;

	*num = t;
	return 1;
}

int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs)
{
	int xper = 0, yper = 0;
	int glen;
	char *colpos;

	*xpos = 0; *ypos = 0;

	if(vo_geometry == NULL)
		return 1;

	glen = strlen(vo_geometry);
	colpos = strchr(vo_geometry, ':');
	if(colpos == NULL)
		colpos = (char *)(vo_geometry + glen);

	/* Parse the x bit */
	if(colpos[-1] == '%') {
		if(!get_num(vo_geometry, &xper, colpos - 1))
			return geometry_error();
	} else {
		if(!get_num(vo_geometry, xpos, colpos))
			return geometry_error();
	}

	if(*colpos != '\0')
		if(vo_geometry[glen - 1] == '%') {
			if(!get_num(colpos + 1, &yper, vo_geometry + glen - 1))
				return geometry_error();
		} else {
			if(!get_num(colpos + 1, ypos, vo_geometry + glen))
				return geometry_error();
		}

	if(xper)
		*xpos = (scrw - vidw) * ((float)xper / 100.0);
	if(yper)
		*ypos = (scrh - vidh) * ((float)yper / 100.0);

	if(*xpos + vidw > scrw) {
		mp_msg(MSGT_VO, MSGL_ERR, "X position is too large\n");
		return geometry_error();
	}
	if(*ypos + vidh > scrh) {
		mp_msg(MSGT_VO, MSGL_ERR, "Y position is too large\n");
		return geometry_error();
	}

	return 1;
}
-------------- next part --------------
/* This file (C) Mark Zealey <mark at zealos.org 2002, released under GPL */
#ifndef __GEOMETRY_H
#define __GEOMETRY_H

#include "aspect.h"

extern char *vo_geometry;
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs);

#endif /* !__GEOMETRY_H */


More information about the MPlayer-dev-eng mailing list