[vlc-devel] [PATCH 34/34] vaapi: create VAAPI pools with a video context

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 8 15:40:38 CET 2019


Rather than a decoder device. In the end we need to store the video context,
not the decoder device in the pictures.
---
 modules/hw/vaapi/chroma.c                     |  2 +-
 modules/hw/vaapi/filters.c                    |  2 +-
 modules/hw/vaapi/vlc_vaapi.c                  | 11 +++++------
 modules/hw/vaapi/vlc_vaapi.h                  |  2 +-
 modules/video_output/opengl/converter_vaapi.c | 11 ++++-------
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/modules/hw/vaapi/chroma.c b/modules/hw/vaapi/chroma.c
index e8432b14351..70415dbdba6 100644
--- a/modules/hw/vaapi/chroma.c
+++ b/modules/hw/vaapi/chroma.c
@@ -357,7 +357,7 @@ vlc_vaapi_OpenChroma(vlc_object_t *obj)
         filter->vctx_out = vlc_video_context_Create( filter_sys->dec_device, VLC_VIDEO_CONTEXT_VAAPI, 0, NULL );
 
         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, true);
         if (!filter_sys->dest_pics)
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index 4e299d4fb85..9bab9e89f05 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -383,7 +383,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,
                           true);
diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c
index 756785d0699..49cbf0a0d8a 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);
@@ -469,7 +468,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, bool b_force_fourcc)
 {
@@ -525,7 +524,7 @@ vlc_vaapi_PoolNew(vlc_object_t *o, vlc_decoder_device *dec_device,
             .p_sys = p_sys,
             .pf_destroy = pool_pic_destroy_cb,
         };
-        pics[i] = picture_NewFromResource(fmt, NULL /*TODO*/, &rsc);
+        pics[i] = picture_NewFromResource(fmt, vctx, &rsc);
         if (pics[i] == NULL)
         {
             free(p_sys);
@@ -540,7 +539,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;
@@ -563,7 +562,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 2a344b96308..ee0d7feb9c2 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, bool b_force_fourcc);
 
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index b4d7fc8bef3..4d3d7f0a0ae 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -233,12 +233,10 @@ 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,
                           true);
-    vlc_decoder_device_Release(dec_device);
     if (!pool)
         return NULL;
 
@@ -337,14 +335,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, true);
     if (!pool)
         return VLC_EGENERIC;
@@ -424,7 +421,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,
-- 
2.17.1



More information about the vlc-devel mailing list