summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-07 04:33:46 +0200
committerwm4 <wm4@nowhere>2012-10-24 21:56:33 +0200
commita45ad346e4158708b1ede75fcd6e8ec3c05d1d9e (patch)
tree55971d9eba25d98b302854d7eb0d5d72054ca790
parentb03e357c69034807c455617cdd2a5700382f4670 (diff)
downloadmpv-a45ad346e4158708b1ede75fcd6e8ec3c05d1d9e.tar.bz2
mpv-a45ad346e4158708b1ede75fcd6e8ec3c05d1d9e.tar.xz
vo_xv: simplify screenshot code
We now have a simple function to get a XvImage buffer as mp_image. Return that as screenshot. We don't even need to copy the image (we allocate a mp_image struct only, no image data).
-rw-r--r--libvo/vo_xv.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 7c2d3816c4..e12f8cbaf8 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -422,42 +422,12 @@ static mp_image_t *get_screenshot(struct vo *vo)
struct xvctx *ctx = vo->priv;
// try to get an image without OSD
- if (ctx->have_image_copy)
- copy_backup_image(vo, ctx->visible_buf, ctx->num_buffers);
-
- XvImage *xv_image = ctx->xvimage[ctx->visible_buf];
-
- int w = xv_image->width;
- int h = xv_image->height;
-
- mp_image_t *image = alloc_mpi(w, h, ctx->image_format);
-
- int bytes = 1;
- if (!(image->flags & MP_IMGFLAG_PLANAR) && (image->flags & MP_IMGFLAG_YUV))
- // packed YUV
- bytes = image->bpp / 8;
-
- memcpy_pic(image->planes[0], xv_image->data + xv_image->offsets[0],
- bytes * w, h, image->stride[0], xv_image->pitches[0]);
-
- if (image->flags & MP_IMGFLAG_PLANAR) {
- int swap = ctx->image_format == IMGFMT_YV12;
- int p1 = swap ? 2 : 1;
- int p2 = swap ? 1 : 2;
-
- w /= 2;
- h /= 2;
-
- memcpy_pic(image->planes[p1], xv_image->data + xv_image->offsets[1],
- w, h, image->stride[p1], xv_image->pitches[1]);
- memcpy_pic(image->planes[p2], xv_image->data + xv_image->offsets[2],
- w, h, image->stride[p2], xv_image->pitches[2]);
- }
-
- image->w = ctx->image_d_width;
- image->h = ctx->image_d_height;
+ int id = ctx->have_image_copy ? ctx->num_buffers : ctx->visible_buf;
+ struct mp_image img = get_xv_buffer(vo, id);
+ img.w = ctx->image_d_width;
+ img.h = ctx->image_d_height;
- return image;
+ return talloc_memdup(NULL, &img, sizeof(img));
}
static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)