summaryrefslogtreecommitdiffstats
path: root/video/vaapi.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-22 17:47:14 +0100
committerwm4 <wm4@nowhere>2015-01-22 18:18:23 +0100
commit74581a61064f56b170e555fa72d9cdca161d2307 (patch)
tree532223eaa3644b01501d443ebca9011ee12af963 /video/vaapi.c
parente9ac3fc3a1505c4db1773a2a24d35ac41ab69887 (diff)
downloadmpv-74581a61064f56b170e555fa72d9cdca161d2307.tar.bz2
mpv-74581a61064f56b170e555fa72d9cdca161d2307.tar.xz
video: handle hwdec screenshots differently
Instead of converting the hw surface to an image in the VO, provide a generic way to convet hw surfaces, and use this in the screenshot code. It's all relatively straightforward, except vdpau is being terrible. It needs a huge chunk of new code, because copying back is not simple.
Diffstat (limited to 'video/vaapi.c')
-rw-r--r--video/vaapi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/video/vaapi.c b/video/vaapi.c
index 13e78f0f31..54d75e775a 100644
--- a/video/vaapi.c
+++ b/video/vaapi.c
@@ -84,6 +84,13 @@ uint32_t va_fourcc_from_imgfmt(int imgfmt)
return 0;
}
+static struct mp_image *ctx_download_image(struct mp_hwdec_ctx *ctx,
+ struct mp_image *mpi,
+ struct mp_image_pool *swpool)
+{
+ return va_surface_download(mpi, swpool);
+}
+
struct va_image_formats {
VAImageFormat *entries;
int num;
@@ -125,6 +132,7 @@ struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog)
.hwctx = {
.priv = res,
.vaapi_ctx = res,
+ .download_image = ctx_download_image,
},
};
mpthread_mutex_init_recursive(&res->lock);
@@ -405,12 +413,12 @@ static struct mp_image *try_download(struct mp_image *src,
struct mp_image *dst = NULL;
struct mp_image tmp;
if (va_image_map(p->ctx, image, &tmp)) {
- dst = pool ? mp_image_pool_get(pool, tmp.imgfmt, tmp.w, tmp.h)
- : mp_image_alloc(tmp.imgfmt, tmp.w, tmp.h);
+ dst = mp_image_pool_get(pool, tmp.imgfmt, tmp.w, tmp.h);
if (dst)
mp_image_copy(dst, &tmp);
va_image_unmap(p->ctx, image);
}
+ mp_image_copy_attributes(dst, src);
return dst;
}