[Mplayer-cvslog] CVS: main/libvo geometry.c,NONE,1.1 geometry.h,NONE,1.1 Makefile,1.37,1.38 vo_fbdev.c,1.71,1.72 vo_tdfxfb.c,1.19,1.20

JALH CVS (Mark Zealey) mark at mplayerhq.hu
Wed Oct 23 18:52:56 CEST 2002


Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv18614/libvo

Modified Files:
	Makefile vo_fbdev.c vo_tdfxfb.c 
Added Files:
	geometry.c geometry.h 
Log Message:
Added the -geometry option (supports fbdev and tdfxfb drivers)


--- NEW FILE ---
/* 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;
}

--- NEW FILE ---
/* 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 */

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/Makefile,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- Makefile	28 Aug 2002 20:52:02 -0000	1.37
+++ Makefile	23 Oct 2002 16:52:54 -0000	1.38
@@ -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: vo_fbdev.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_fbdev.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- vo_fbdev.c	23 Oct 2002 15:32:40 -0000	1.71
+++ vo_fbdev.c	23 Oct 2002 16:52:54 -0000	1.72
@@ -1037,12 +1037,8 @@
 		image_width=width;
 		image_height=height;
 	    }
-		if(fb_xres > image_width)
-		    x_offset = (fb_xres - image_width) / 2;
-		else x_offset = 0;
-		if(fb_yres > image_height)
-		    y_offset = (fb_yres - image_height) / 2;
-		else y_offset = 0;
+		geometry(&x_offset,&y_offset,fb_xres,fb_yres,image_width,image_height);
+
 		if(vidix_init(width,height,x_offset,y_offset,image_width,
 			    image_height,format,fb_bpp,
 			    fb_xres,fb_yres) != 0)
@@ -1058,13 +1054,18 @@
 	else
 #endif
 	{
+	    int x_offset,y_offset;
 	    if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
 				    MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
 		printf(FBDEV "Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
 		return 1;
 	    }
+
+	    geometry(&x_offset,&y_offset,fb_xres,fb_yres,out_width,out_height);
+
 	    L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size /
-		    2 + ( (out_height - in_height) / 2 ) * fb_line_len;
+		    2 + ( (out_height - in_height) / 2 ) * fb_line_len +
+		    x_offset * fb_pixel_size + y_offset * fb_line_len;
 
 	    if (verbose > 0) {
 		if (verbose > 1) {

Index: vo_tdfxfb.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_tdfxfb.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- vo_tdfxfb.c	10 Oct 2002 14:17:59 -0000	1.19
+++ vo_tdfxfb.c	23 Oct 2002 16:52:54 -0000	1.20
@@ -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();
 }
 




More information about the MPlayer-cvslog mailing list