From 4d2f354da651a3c1fd9776ed5829f57961a46c10 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Sep 2013 16:48:45 +0200 Subject: vaapi: potentially make reading surfaces back to system RAM faster Don't allocate a VAImage and a mp_image every time. VAImage are cached in the surfaces themselves, and for mp_image an explicit pool is created. The retry loop runs only once for each surface now. This also makes use of vaDeriveImage() if possible. --- video/decode/vaapi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'video/decode/vaapi.c') diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c index 82c46de81e..d7ee5b35dc 100644 --- a/video/decode/vaapi.c +++ b/video/decode/vaapi.c @@ -32,6 +32,7 @@ #include "mpvcore/av_common.h" #include "video/fmt-conversion.h" #include "video/vaapi.h" +#include "video/mp_image_pool.h" #include "video/decode/dec_video.h" #include "video/filter/vf.h" @@ -68,6 +69,7 @@ struct priv { struct va_surface_pool *pool; int rt_format; + struct mp_image_pool *sw_pool; bool printed_readback_warning; }; @@ -414,6 +416,7 @@ static int init_with_vactx(struct lavc_ctx *ctx, struct mp_vaapi_ctx *vactx) p->display = p->ctx->display; p->pool = va_surface_pool_alloc(p->display, p->rt_format); + p->sw_pool = talloc_steal(p, mp_image_pool_new(17)); p->va_context->display = p->display; p->va_context->config_id = VA_INVALID_ID; @@ -466,7 +469,7 @@ static struct mp_image *copy_image(struct lavc_ctx *ctx, struct mp_image *img) struct va_surface *surface = va_surface_in_mp_image(img); if (surface) { struct mp_image *simg = - va_surface_download(surface, p->ctx->image_formats); + va_surface_download(surface, p->ctx->image_formats, p->sw_pool); if (simg) { if (!p->printed_readback_warning) { mp_msg(MSGT_VO, MSGL_WARN, "[vaapi] Using GPU readback. This " -- cgit v1.2.3