From 22c76e85db88a772e3360892cd3a673a89c6fc7a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 Jun 2016 12:44:42 +0200 Subject: vo_xv: fix behavior with odd sizes The size check introduced in commit d941a57b did not consider that Xv can round up the image size to the next chroma boundary. Doing that makes sense, so it can't certainly be considered server misbehavior. Do 2 things against this: allow if the server returns a larger image (we just crop it then), and also allocate a properly aligned image in the first place. --- video/out/vo_xv.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 1e7ae7c4c5..a5a4728085 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -533,6 +533,8 @@ static bool allocate_xvimage(struct vo *vo, int foo) struct vo_x11_state *x11 = vo->x11; // align it for faster OSD rendering (draw_bmp.c swscale usage) int aligned_w = FFALIGN(ctx->image_width, 32); + // round up the height to next chroma boundary too + int aligned_h = FFALIGN(ctx->image_height, 2); #if HAVE_SHM && HAVE_XEXT if (x11->display_is_local && XShmQueryExtension(x11->display)) { ctx->Shmem_Flag = 1; @@ -546,7 +548,7 @@ static bool allocate_xvimage(struct vo *vo, int foo) ctx->xvimage[foo] = (XvImage *) XvShmCreateImage(x11->display, ctx->xv_port, ctx->xv_format, NULL, - aligned_w, ctx->image_height, + aligned_w, aligned_h, &ctx->Shminfo[foo]); if (!ctx->xvimage[foo]) return false; @@ -569,7 +571,7 @@ static bool allocate_xvimage(struct vo *vo, int foo) ctx->xvimage[foo] = (XvImage *) XvCreateImage(x11->display, ctx->xv_port, ctx->xv_format, NULL, aligned_w, - ctx->image_height); + aligned_h); if (!ctx->xvimage[foo]) return false; ctx->xvimage[foo]->data = av_malloc(ctx->xvimage[foo]->data_size); @@ -578,16 +580,16 @@ static bool allocate_xvimage(struct vo *vo, int foo) XSync(x11->display, False); } - if ((ctx->xvimage[foo]->width != aligned_w) || - (ctx->xvimage[foo]->height != ctx->image_height)) { - MP_ERR(vo, "Got XvImage with incorrect size: %ux%u (expected %ux%u)\n", + if ((ctx->xvimage[foo]->width < aligned_w) || + (ctx->xvimage[foo]->height < aligned_h)) { + MP_ERR(vo, "Got XvImage with too small size: %ux%u (expected %ux%u)\n", ctx->xvimage[foo]->width, ctx->xvimage[foo]->height, aligned_w, ctx->image_height); return false; } struct mp_image img = get_xv_buffer(vo, foo); - img.w = aligned_w; + mp_image_set_size(&img, aligned_w, aligned_h); mp_image_clear(&img, 0, 0, img.w, img.h); return true; } -- cgit v1.2.3