mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
d1d864546c
commit
22c76e85db
|
@ -533,6 +533,8 @@ static bool allocate_xvimage(struct vo *vo, int foo)
|
||||||
struct vo_x11_state *x11 = vo->x11;
|
struct vo_x11_state *x11 = vo->x11;
|
||||||
// align it for faster OSD rendering (draw_bmp.c swscale usage)
|
// align it for faster OSD rendering (draw_bmp.c swscale usage)
|
||||||
int aligned_w = FFALIGN(ctx->image_width, 32);
|
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 HAVE_SHM && HAVE_XEXT
|
||||||
if (x11->display_is_local && XShmQueryExtension(x11->display)) {
|
if (x11->display_is_local && XShmQueryExtension(x11->display)) {
|
||||||
ctx->Shmem_Flag = 1;
|
ctx->Shmem_Flag = 1;
|
||||||
|
@ -546,7 +548,7 @@ static bool allocate_xvimage(struct vo *vo, int foo)
|
||||||
ctx->xvimage[foo] =
|
ctx->xvimage[foo] =
|
||||||
(XvImage *) XvShmCreateImage(x11->display, ctx->xv_port,
|
(XvImage *) XvShmCreateImage(x11->display, ctx->xv_port,
|
||||||
ctx->xv_format, NULL,
|
ctx->xv_format, NULL,
|
||||||
aligned_w, ctx->image_height,
|
aligned_w, aligned_h,
|
||||||
&ctx->Shminfo[foo]);
|
&ctx->Shminfo[foo]);
|
||||||
if (!ctx->xvimage[foo])
|
if (!ctx->xvimage[foo])
|
||||||
return false;
|
return false;
|
||||||
|
@ -569,7 +571,7 @@ static bool allocate_xvimage(struct vo *vo, int foo)
|
||||||
ctx->xvimage[foo] =
|
ctx->xvimage[foo] =
|
||||||
(XvImage *) XvCreateImage(x11->display, ctx->xv_port,
|
(XvImage *) XvCreateImage(x11->display, ctx->xv_port,
|
||||||
ctx->xv_format, NULL, aligned_w,
|
ctx->xv_format, NULL, aligned_w,
|
||||||
ctx->image_height);
|
aligned_h);
|
||||||
if (!ctx->xvimage[foo])
|
if (!ctx->xvimage[foo])
|
||||||
return false;
|
return false;
|
||||||
ctx->xvimage[foo]->data = av_malloc(ctx->xvimage[foo]->data_size);
|
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);
|
XSync(x11->display, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ctx->xvimage[foo]->width != aligned_w) ||
|
if ((ctx->xvimage[foo]->width < aligned_w) ||
|
||||||
(ctx->xvimage[foo]->height != ctx->image_height)) {
|
(ctx->xvimage[foo]->height < aligned_h)) {
|
||||||
MP_ERR(vo, "Got XvImage with incorrect size: %ux%u (expected %ux%u)\n",
|
MP_ERR(vo, "Got XvImage with too small size: %ux%u (expected %ux%u)\n",
|
||||||
ctx->xvimage[foo]->width, ctx->xvimage[foo]->height,
|
ctx->xvimage[foo]->width, ctx->xvimage[foo]->height,
|
||||||
aligned_w, ctx->image_height);
|
aligned_w, ctx->image_height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mp_image img = get_xv_buffer(vo, foo);
|
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);
|
mp_image_clear(&img, 0, 0, img.w, img.h);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue