summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-22 19:37:20 +0100
committerwm4 <wm4@nowhere>2012-11-22 19:54:06 +0100
commit74f416fd2dd79ce2c033d2b4bd88cdc69d9448d7 (patch)
tree60764be33d847ccbf08cac472d802f918fc2cde1 /video
parent1d3179a5f1dc2fdfeaac3582a925c2849ac265a9 (diff)
downloadmpv-74f416fd2dd79ce2c033d2b4bd88cdc69d9448d7.tar.bz2
mpv-74f416fd2dd79ce2c033d2b4bd88cdc69d9448d7.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_xv.c9
1 files changed, 5 insertions, 4 deletions
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;