From 74f416fd2dd79ce2c033d2b4bd88cdc69d9448d7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 22 Nov 2012 19:37:20 +0100 Subject: vo_xv: allocate Xv images with aligned stride This is required, as the Xv image is directly used for rendering OSD and taking screenshots. These involve libswscale, which wants aligned strides. There doesn't seem to be an easy way to request aligned strides from Xv. Simply request an image with an aligned width, which usually results in an aligned stride. The padding border remains invisible. One caveat is that if padding is added, there might be scaling artifacts on the right pixel border of the screen. This is at least the case with nvidia binary drivers. Since we consider vo_xv a sensible choice only on crappy/slow hardware, performance is more important than quality. --- video/out/vo_xv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 3e749a5f2b..c2b705a611 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -239,11 +239,12 @@ static void allocate_xvimage(struct vo *vo, int foo) ctx->Shmem_Flag = 0; mp_tmsg(MSGT_VO, MSGL_INFO, "[VO_XV] Shared memory not supported\nReverting to normal Xv.\n"); } + int aligned_w = FFALIGN(ctx->image_width, 16); if (ctx->Shmem_Flag) { ctx->xvimage[foo] = (XvImage *) XvShmCreateImage(x11->display, x11->xv_port, ctx->xv_format, NULL, - ctx->image_width, ctx->image_height, + aligned_w, ctx->image_height, &ctx->Shminfo[foo]); ctx->Shminfo[foo].shmid = shmget(IPC_PRIVATE, @@ -262,7 +263,7 @@ static void allocate_xvimage(struct vo *vo, int foo) { ctx->xvimage[foo] = (XvImage *) XvCreateImage(x11->display, x11->xv_port, - ctx->xv_format, NULL, ctx->image_width, + ctx->xv_format, NULL, aligned_w, ctx->image_height); ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size); XSync(x11->display, False); @@ -318,8 +319,8 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index) XvImage *xv_image = ctx->xvimage[buf_index]; struct mp_image img = {0}; - img.w = img.width = xv_image->width; - img.h = img.height = xv_image->height; + img.w = img.width = ctx->image_width; + img.h = img.height = ctx->image_height; mp_image_setfmt(&img, ctx->image_format); bool swapuv = ctx->image_format == IMGFMT_YV12; -- cgit v1.2.3