changeset 33212:c52a2600de15

Clip x/y offsets to avoid bad video placement.
author reimar
date Fri, 22 Apr 2011 12:33:08 +0000
parents 77a9d13fa30e
children d7b577e7e644
files libvo/vo_fbdev2.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_fbdev2.c	Fri Apr 22 12:25:09 2011 +0000
+++ b/libvo/vo_fbdev2.c	Fri Apr 22 12:33:08 2011 +0000
@@ -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 @@
 {
 	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 @@
 	}
 
 	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))) {