mirror of https://github.com/mpv-player/mpv
vo_xv: try harder to get correctly aligned pointers/strides
To get guaranteed alignment for the chroma planes with typical YV12 playback, we have to double the alignment on the image width, as the chroma planes have half the image width. Clear the image with black instead of green to hide scaling artifacts on the right border of the screen. (It might be possible to create the image layout ourselves by not calling XvShmCreateImage(), and filling in our own image width and exact strides, but that's probably too risky: the Xv client library sends an X protocol request to query the real image dimension and strides. It is unknown to me whether X servers or drivers would generally accept an image with mismatching parameters, even if the image is conceptually valid.) Allocate the image with av_malloc() in the non-SHM case. I suspect the non-SHM case doesn't matter much, though.
This commit is contained in:
parent
9ace4f1f49
commit
3b4682183c
|
@ -91,6 +91,7 @@ struct xvctx {
|
|||
|
||||
static void allocate_xvimage(struct vo *, int);
|
||||
static void deallocate_xvimage(struct vo *vo, int foo);
|
||||
static struct mp_image get_xv_buffer(struct vo *vo, int buf_index);
|
||||
|
||||
static void read_xv_csp(struct vo *vo)
|
||||
{
|
||||
|
@ -239,7 +240,7 @@ 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);
|
||||
int aligned_w = FFALIGN(ctx->image_width, 32);
|
||||
if (ctx->Shmem_Flag) {
|
||||
ctx->xvimage[foo] =
|
||||
(XvImage *) XvShmCreateImage(x11->display, x11->xv_port,
|
||||
|
@ -265,10 +266,11 @@ static void allocate_xvimage(struct vo *vo, int foo)
|
|||
(XvImage *) XvCreateImage(x11->display, x11->xv_port,
|
||||
ctx->xv_format, NULL, aligned_w,
|
||||
ctx->image_height);
|
||||
ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size);
|
||||
ctx->xvimage[foo]->data = av_malloc(ctx->xvimage[foo]->data_size);
|
||||
XSync(x11->display, False);
|
||||
}
|
||||
memset(ctx->xvimage[foo]->data, 128, ctx->xvimage[foo]->data_size);
|
||||
struct mp_image img = get_xv_buffer(vo, foo);
|
||||
vf_mpi_clear(&img, 0, 0, img.w, img.h);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -282,7 +284,7 @@ static void deallocate_xvimage(struct vo *vo, int foo)
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
free(ctx->xvimage[foo]->data);
|
||||
av_free(ctx->xvimage[foo]->data);
|
||||
}
|
||||
XFree(ctx->xvimage[foo]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue