From 8924d2c27dc9901f54f590d7bd3161cc4a312533 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 22 Apr 2011 12:25:09 +0000 Subject: vo_fbdev: Add -geometry support reusing common code git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33298 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev2.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'libvo/vo_fbdev2.c') diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c index 612b145464..9da18551b2 100644 --- a/libvo/vo_fbdev2.c +++ b/libvo/vo_fbdev2.c @@ -36,6 +36,7 @@ #include "fastmemcpy.h" #include "sub/sub.h" #include "mp_msg.h" +#include "aspect.h" static const vo_info_t info = { "Framebuffer Device", @@ -108,8 +109,6 @@ static void (*draw_alpha_p)(int w, int h, unsigned char *src, static uint8_t *next_frame = NULL; // for double buffering static int in_width; static int in_height; -static int out_width; -static int out_height; static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) { @@ -233,19 +232,12 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, struct fb_cmap *cmap; int fs = flags & VOFLAG_FULLSCREEN; - out_width = width; - out_height = height; in_width = width; in_height = height; - if (fs) { - out_width = fb_vinfo.xres; - out_height = fb_vinfo.yres; - } - - if (out_width < in_width || out_height < in_height) { + if (fb_vinfo.xres < in_width || fb_vinfo.yres < in_height) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Screensize is smaller than video size (%dx%d < %dx%d)\n", - out_width, out_height, in_width, in_height); + fb_vinfo.xres, fb_vinfo.yres, in_width, in_height); return 1; } @@ -304,8 +296,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, } center = frame_buffer + - ( (out_width - in_width) / 2 ) * fb_pixel_size + - ( (out_height - in_height) / 2 ) * fb_line_len; + vo_dx * fb_pixel_size + + vo_dy * fb_line_len; #ifndef USE_CONVERT2FB if (!(next_frame = realloc(next_frame, in_width * in_height * fb_pixel_size))) { @@ -430,6 +422,11 @@ static int control(uint32_t request, void *data) switch (request) { case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); + case VOCTRL_UPDATE_SCREENINFO: + vo_screenwidth = fb_vinfo.xres; + vo_screenheight = fb_vinfo.yres; + aspect_save_screenres(vo_screenwidth, vo_screenheight); + return VO_TRUE; } return VO_NOTIMPL; } -- cgit v1.2.3 From 8c831a2e863f0c743be3377a6f5b2cfe7d35a614 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 22 Apr 2011 12:33:08 +0000 Subject: vo_fbdev: clip x/y offsets to avoid bad video placement git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33299 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 2 +- libvo/vo_fbdev2.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'libvo/vo_fbdev2.c') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 02f553db23..e2c4dd2bfd 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "config.h" #include "video_out.h" @@ -43,7 +44,6 @@ #include "geometry.h" #include "aspect.h" #include "mp_msg.h" -#include "libavutil/common.h" static const vo_info_t info = { "Framebuffer Device", diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c index 9da18551b2..74a03e9814 100644 --- a/libvo/vo_fbdev2.c +++ b/libvo/vo_fbdev2.c @@ -37,6 +37,7 @@ #include "sub/sub.h" #include "mp_msg.h" #include "aspect.h" +#include "libavutil/common.h" static const vo_info_t info = { "Framebuffer Device", @@ -231,6 +232,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, { struct fb_cmap *cmap; int fs = flags & VOFLAG_FULLSCREEN; + int x_offset = vo_dx + (d_width - width ) / 2; + int y_offset = vo_dy + (d_height - height) / 2; + x_offset = av_clip(x_offset, 0, fb_vinfo.xres - width); + y_offset = av_clip(y_offset, 0, fb_vinfo.yres - height); in_width = width; in_height = height; @@ -296,8 +301,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, } center = frame_buffer + - vo_dx * fb_pixel_size + - vo_dy * fb_line_len; + x_offset * fb_pixel_size + + y_offset * fb_line_len; #ifndef USE_CONVERT2FB if (!(next_frame = realloc(next_frame, in_width * in_height * fb_pixel_size))) { -- cgit v1.2.3 From 95d40b3f8dc4d4c7b67e3327e089a4e803f26afc Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 22 Apr 2011 16:43:14 +0000 Subject: cleanup: vo_fbdev: simplify some code Simplify by using FFMAX3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33300 b3059339-0415-0410-9bf9-f77b7e298cf2 Simplify colormap generation code, avoid some mallocs and add frees for one error case. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33302 b3059339-0415-0410-9bf9-f77b7e298cf2 Use memcpy_pic instead of reimplementing it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33303 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev2.c | 53 ++++++++++++++--------------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) (limited to 'libvo/vo_fbdev2.c') diff --git a/libvo/vo_fbdev2.c b/libvo/vo_fbdev2.c index 74a03e9814..bec9fea8ff 100644 --- a/libvo/vo_fbdev2.c +++ b/libvo/vo_fbdev2.c @@ -122,42 +122,25 @@ static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) bcols = 1 << var->blue.length; /* Make our palette the length of the deepest color */ - cols = (rcols > gcols ? rcols : gcols); - cols = (cols > bcols ? cols : bcols); + cols = FFMAX3(rcols, gcols, bcols); - red = malloc(cols * sizeof(red[0])); + red = malloc(3 * cols * sizeof(red[0])); if(!red) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate red palette with %d entries.\n", cols); return NULL; } - for(i=0; i< rcols; i++) - red[i] = (65535/(rcols-1)) * i; - - green = malloc(cols * sizeof(green[0])); - if(!green) { - mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate green palette with %d entries.\n", cols); - free(red); - return NULL; - } - for(i=0; i< gcols; i++) + green = red + cols; + blue = green + cols; + for (i = 0; i < cols; i++) { + red[i] = (65535/(rcols-1)) * i; green[i] = (65535/(gcols-1)) * i; - - blue = malloc(cols * sizeof(blue[0])); - if(!blue) { - mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate blue palette with %d entries.\n", cols); - free(red); - free(green); - return NULL; + blue[i] = (65535/(bcols-1)) * i; } - for(i=0; i< bcols; i++) - blue[i] = (65535/(bcols-1)) * i; cmap = malloc(sizeof(struct fb_cmap)); if(!cmap) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate color map\n"); free(red); - free(green); - free(blue); return NULL; } cmap->start = 0; @@ -279,12 +262,12 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, return 1; if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't put cmap: %s\n", strerror(errno)); + free(cmap->red); + free(cmap); return 1; } fb_cmap_changed = 1; free(cmap->red); - free(cmap->green); - free(cmap->blue); free(cmap); break; default: @@ -375,13 +358,8 @@ static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) uint8_t *dest = next_frame + (in_width * y + x) * fb_pixel_size; int next = in_width * fb_pixel_size; #endif - int i; - for (i = 0; i < h; i++) { - fast_memcpy(dest, in, w * fb_pixel_size); - dest += next; - in += stride[0]; - } + memcpy_pic(dest, in, w * fb_pixel_size, h, next, stride[0]); return 0; } @@ -392,14 +370,11 @@ static void check_events(void) static void flip_page(void) { #ifndef USE_CONVERT2FB - int i, out_offset = 0, in_offset = 0; + int out_offset = 0, in_offset = 0; - for (i = 0; i < in_height; i++) { - fast_memcpy(center + out_offset, next_frame + in_offset, - in_width * fb_pixel_size); - out_offset += fb_line_len; - in_offset += in_width * fb_pixel_size; - } + memcpy_pic(center + out_offset, next_frame + in_offset, + in_width * fb_pixel_size, in_height, + fb_line_len, in_width * fb_pixel_size); #endif } -- cgit v1.2.3