[vlc-commits] vaapi: create VAAPI pools with a video context

Steve Lhomme git at videolan.org
Mon Dec 2 13:42:52 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Nov  8 13:26:39 2019 +0100| [9ac6a329d1d28f9772c0be70a97a2cd855fce854] | committer: Steve Lhomme

vaapi: create VAAPI pools with a video context

Rather than a decoder device. In the end we need to store the video context,
not the decoder device in the pictures.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ac6a329d1d28f9772c0be70a97a2cd855fce854
---

 modules/hw/vaapi/chroma.c                     |  2 +-
 modules/hw/vaapi/filters.c                    |  2 +-
 modules/hw/vaapi/vlc_vaapi.c                  |  9 ++++-----
 modules/hw/vaapi/vlc_vaapi.h                  |  2 +-
 modules/video_output/opengl/converter_vaapi.c | 11 ++++-------
 5 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/modules/hw/vaapi/chroma.c b/modules/hw/vaapi/chroma.c
index ceaa635d37..1f34d82ab0 100644
--- a/modules/hw/vaapi/chroma.c
+++ b/modules/hw/vaapi/chroma.c
@@ -355,7 +355,7 @@ vlc_vaapi_OpenChroma(vlc_object_t *obj)
         }
 
         filter_sys->dest_pics =
-            vlc_vaapi_PoolNew(obj, filter_sys->dec_device, filter_sys->dpy,
+            vlc_vaapi_PoolNew(obj, filter->vctx_out, filter_sys->dpy,
                               DEST_PICS_POOL_SZ, &filter_sys->va_surface_ids,
                               &filter->fmt_out.video);
         if (!filter_sys->dest_pics)
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index 35fe72318c..48436fba42 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -381,7 +381,7 @@ Open(filter_t * filter,
         goto error;
 
     filter_sys->dest_pics =
-        vlc_vaapi_PoolNew(VLC_OBJECT(filter), filter_sys->va.dec_device,
+        vlc_vaapi_PoolNew(VLC_OBJECT(filter), filter->vctx_in,
                           filter_sys->va.dpy, DEST_PICS_POOL_SZ,
                           &filter_sys->va.surface_ids, &filter->fmt_out.video);
     if (!filter_sys->dest_pics)
diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c
index a871085967..6270271b57 100644
--- a/modules/hw/vaapi/vlc_vaapi.c
+++ b/modules/hw/vaapi/vlc_vaapi.c
@@ -411,7 +411,7 @@ struct pic_sys_vaapi_instance
 {
     atomic_int pic_refcount;
     VADisplay va_dpy;
-    vlc_decoder_device *dec_device;
+    vlc_video_context *vctx;
     unsigned num_render_targets;
     VASurfaceID render_targets[];
 };
@@ -432,7 +432,6 @@ pool_pic_destroy_cb(picture_t *pic)
     {
         vaDestroySurfaces(instance->va_dpy, instance->render_targets,
                           instance->num_render_targets);
-        vlc_decoder_device_Release(instance->dec_device);
         free(instance);
     }
     free(pic->p_sys);
@@ -467,7 +466,7 @@ pic_sys_ctx_destroy_cb(struct picture_context_t *opaque)
 }
 
 picture_pool_t *
-vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device,
+vlc_vaapi_PoolNew(vlc_object_t *o, vlc_video_context *vctx,
                   VADisplay dpy, unsigned count, VASurfaceID **render_targets,
                   const video_format_t *restrict fmt)
 {
@@ -533,7 +532,7 @@ vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device,
 
     atomic_store(&instance->pic_refcount, count);
     instance->va_dpy = dpy;
-    instance->dec_device = vlc_decoder_device_Hold(dec_device);
+    instance->vctx = vctx;
 
     *render_targets = instance->render_targets;
     return pool;
@@ -556,7 +555,7 @@ vlc_vaapi_PicSysHoldInstance(void *_sys, VADisplay *dpy)
     picture_sys_t *sys = (picture_sys_t *)_sys;
     assert(sys->instance != NULL);
     *dpy = sys->instance->va_dpy;
-    return vlc_decoder_device_Hold(sys->instance->dec_device);
+    return vlc_video_context_HoldDevice(sys->instance->vctx);
 }
 
 #define ASSERT_VAAPI_CHROMA(pic) do { \
diff --git a/modules/hw/vaapi/vlc_vaapi.h b/modules/hw/vaapi/vlc_vaapi.h
index a83e1df78e..d6aff44e95 100644
--- a/modules/hw/vaapi/vlc_vaapi.h
+++ b/modules/hw/vaapi/vlc_vaapi.h
@@ -169,7 +169,7 @@ vlc_vaapi_CreateConfigChecked(vlc_object_t *o, VADisplay dpy,
 /* Create a pool backed by VASurfaceID. render_targets will destroyed once
  * the pool and every pictures are released. */
 picture_pool_t *
-vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device,
+vlc_vaapi_PoolNew(vlc_object_t *o, vlc_video_context *vctx,
                   VADisplay dpy, unsigned count, VASurfaceID **render_targets,
                   const video_format_t *restrict fmt);
 
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index d53f01c138..6fb1085ec8 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -233,11 +233,9 @@ tc_vaegl_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count)
     vlc_object_t *o = VLC_OBJECT(tc->gl);
     struct priv *priv = tc->priv;
 
-    vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(tc->vctx);
     picture_pool_t *pool =
-        vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), dec_device, priv->vadpy,
+        vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), tc->vctx, priv->vadpy,
                           requested_count, &priv->va_surface_ids, &tc->fmt);
-    vlc_decoder_device_Release(dec_device);
     if (!pool)
         return NULL;
 
@@ -336,14 +334,13 @@ tc_va_check_interop_blacklist(opengl_tex_converter_t *tc, VADisplay *vadpy)
 }
 
 static int
-tc_va_check_derive_image(opengl_tex_converter_t *tc,
-                         vlc_decoder_device *dec_device)
+tc_va_check_derive_image(opengl_tex_converter_t *tc)
 {
     vlc_object_t *o = VLC_OBJECT(tc->gl);
     struct priv *priv = tc->priv;
     VASurfaceID *va_surface_ids;
 
-    picture_pool_t *pool = vlc_vaapi_PoolNew(o, dec_device, priv->vadpy, 1,
+    picture_pool_t *pool = vlc_vaapi_PoolNew(o, tc->vctx, priv->vadpy, 1,
                                              &va_surface_ids, &tc->fmt);
     if (!pool)
         return VLC_EGENERIC;
@@ -423,7 +420,7 @@ Open(vlc_object_t *obj)
     if (tc_va_check_interop_blacklist(tc, priv->vadpy))
         goto error;
 
-    if (tc_va_check_derive_image(tc, dec_device))
+    if (tc_va_check_derive_image(tc))
         goto error;
 
     tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, vlc_sw_chroma,



More information about the vlc-commits mailing list