summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-30 17:45:40 +0100
committerwm4 <wm4@nowhere>2012-12-03 21:08:51 +0100
commit3b4682183ceecdf6c34237f66b3ddcbc4cf849e2 (patch)
tree98042e69930adc9806d57ac69ef0cf91eaae70ae /video
parent9ace4f1f4982891a25ff98126649bcf5b3816326 (diff)
downloadmpv-3b4682183ceecdf6c34237f66b3ddcbc4cf849e2.tar.bz2
mpv-3b4682183ceecdf6c34237f66b3ddcbc4cf849e2.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_xv.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index c2b705a611..96cb072d17 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -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]);