mirror of
https://github.com/mpv-player/mpv
synced 2025-03-31 07:51:55 +00:00
Added the -geometry option (supports fbdev and tdfxfb drivers)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7867 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ddaa6dd19d
commit
a2dfc7a766
@ -1048,6 +1048,27 @@ See also \-zoom.
|
||||
.B \-fsmode-dontuse <0-31> (OBSOLETE) (use \-fs option)
|
||||
Try this option if you still experience fullscreen problems.
|
||||
.TP
|
||||
.B \-geometry x[%][:y[%]]
|
||||
Adjust where the output is on the screen initially. The x and y specifications
|
||||
are in pixels measured from the top-right of the screen to the top-right of the
|
||||
image being displayed, however if a percentage sign is given after the argument
|
||||
it turns the value into a percentage of the screen size in that direction. The
|
||||
values given must be integers. Examples:
|
||||
|
||||
.PD 0
|
||||
.RSs
|
||||
.IPs 50:40
|
||||
Places the window at x=50, y=40
|
||||
.IPs 50%:50%
|
||||
Places the window in the middle of the screen
|
||||
.IPs 100%
|
||||
Places the window at the top left corner of the screen
|
||||
.IPs 100%:100%
|
||||
Places the window at the bottom left corner of the screen
|
||||
.RE
|
||||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-hue <\-100\ \-\ 100>
|
||||
Adjust hue of video signal (default: 0).
|
||||
You can get colored negative of image with this option.
|
||||
|
@ -58,6 +58,7 @@ extern int vo_gamma_brightness;
|
||||
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 @@ static config_t mplayer_opts[]={
|
||||
// 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)
|
||||
|
@ -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)
|
||||
|
80
libvo/geometry.c
Normal file
80
libvo/geometry.c
Normal file
@ -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;
|
||||
}
|
10
libvo/geometry.h
Normal file
10
libvo/geometry.h
Normal file
@ -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 */
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user