summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authormark <mark@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-23 16:52:54 +0000
committermark <mark@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-23 16:52:54 +0000
commita2dfc7a766c2f00408671327838602eebcc4cddf (patch)
tree1b668f5ecfebc6ad7688d652594f4e91179183d2 /libvo
parentddaa6dd19d52961065344b66a474dc4629d04cbd (diff)
downloadmpv-a2dfc7a766c2f00408671327838602eebcc4cddf.tar.bz2
mpv-a2dfc7a766c2f00408671327838602eebcc4cddf.tar.xz
Added the -geometry option (supports fbdev and tdfxfb drivers)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7867 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/Makefile2
-rw-r--r--libvo/geometry.c80
-rw-r--r--libvo/geometry.h10
-rw-r--r--libvo/vo_fbdev.c15
-rw-r--r--libvo/vo_tdfxfb.c14
5 files changed, 104 insertions, 17 deletions
diff --git a/libvo/Makefile b/libvo/Makefile
index 212784943f..c332f5007a 100644
--- a/libvo/Makefile
+++ b/libvo/Makefile
@@ -3,7 +3,7 @@ include config.mak
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)
diff --git a/libvo/geometry.c b/libvo/geometry.c
new file mode 100644
index 0000000000..26afd69547
--- /dev/null
+++ b/libvo/geometry.c
@@ -0,0 +1,80 @@
+/* This file (C) Mark Zealey <mark@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;
+}
diff --git a/libvo/geometry.h b/libvo/geometry.h
new file mode 100644
index 0000000000..dbfea6cd3b
--- /dev/null
+++ b/libvo/geometry.h
@@ -0,0 +1,10 @@
+/* This file (C) Mark Zealey <mark@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 */
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c
index 9d03a4fbb8..a9f0608ad4 100644
--- a/libvo/vo_fbdev.c
+++ b/libvo/vo_fbdev.c
@@ -1037,12 +1037,8 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
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 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
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) {
diff --git a/libvo/vo_tdfxfb.c b/libvo/vo_tdfxfb.c
index efb0d072c3..f74a25fd30 100644
--- a/libvo/vo_tdfxfb.c
+++ b/libvo/vo_tdfxfb.c
@@ -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 @@ static void clear_screen()
/* 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();
}