[vlc-commits] vlc_vaapi: allow setting the picture context from a bare vaapi_pic_context

Steve Lhomme git at videolan.org
Fri Oct 25 08:07:32 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Oct 23 08:51:35 2019 +0200| [12832d4a8cbd9b2cea640189e36e4087fa8871d2] | committer: Steve Lhomme

vlc_vaapi: allow setting the picture context from a bare vaapi_pic_context

i.e. not backed by an original picture.

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

 modules/codec/avcodec/vaapi.c |  4 +++-
 modules/hw/vaapi/vlc_vaapi.c  | 18 +++++++++++++-----
 modules/hw/vaapi/vlc_vaapi.h  |  4 ++++
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 1623088133..6119c3e48d 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -129,7 +129,9 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
     (void) va;
 
     vlc_vaapi_PicAttachContext(pic);
-    *data = (void *) (uintptr_t) vlc_vaapi_PicGetSurface(pic);
+    struct vaapi_pic_context *vaapi_ctx =
+        container_of(pic->context, struct vaapi_pic_context, s);
+    *data = (void *) (uintptr_t) vaapi_ctx->surface;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c
index 1333284fab..2a75ccaa53 100644
--- a/modules/hw/vaapi/vlc_vaapi.c
+++ b/modules/hw/vaapi/vlc_vaapi.c
@@ -570,16 +570,24 @@ vlc_vaapi_PicSysHoldInstance(void *_sys, VADisplay *dpy)
     assert(vlc_vaapi_IsChromaOpaque(pic->format.i_chroma)); \
 } while(0)
 
+void
+vlc_vaapi_PicSetContext(picture_t *pic, struct vaapi_pic_context *vaapi_ctx)
+{
+    ASSERT_VAAPI_CHROMA(pic);
+    assert(pic->context == NULL);
+
+    pic->context = &vaapi_ctx->s;
+}
+
 void
 vlc_vaapi_PicAttachContext(picture_t *pic)
 {
     ASSERT_VAAPI_CHROMA(pic);
     assert(pic->p_sys != NULL);
-    assert(pic->context == NULL);
 
     picture_sys_t *p_sys = pic->p_sys;
     p_sys->ctx.picref = pic;
-    pic->context = &p_sys->ctx.ctx.s;
+    vlc_vaapi_PicSetContext(pic, &p_sys->ctx.ctx);
 }
 
 VASurfaceID
@@ -588,7 +596,7 @@ vlc_vaapi_PicGetSurface(picture_t *pic)
     ASSERT_VAAPI_CHROMA(pic);
     assert(pic->context);
 
-    return ((struct vaapi_pic_ctx *)pic->context)->ctx.surface;
+    return ((struct vaapi_pic_context *)pic->context)->surface;
 }
 
 VADisplay
@@ -597,6 +605,6 @@ vlc_vaapi_PicGetDisplay(picture_t *pic)
     ASSERT_VAAPI_CHROMA(pic);
     assert(pic->context);
 
-    struct vaapi_pic_ctx *pic_ctx = (struct vaapi_pic_ctx *)pic->context;
-    return pic_ctx->ctx.va_dpy;
+    struct vaapi_pic_context *pic_ctx = (struct vaapi_pic_context *)pic->context;
+    return pic_ctx->va_dpy;
 }
diff --git a/modules/hw/vaapi/vlc_vaapi.h b/modules/hw/vaapi/vlc_vaapi.h
index 910c02b374..2a344b9630 100644
--- a/modules/hw/vaapi/vlc_vaapi.h
+++ b/modules/hw/vaapi/vlc_vaapi.h
@@ -182,6 +182,10 @@ vlc_vaapi_PicSysHoldInstance(void *sys, VADisplay *dpy);
 void
 vlc_vaapi_PicAttachContext(picture_t *pic);
 
+/* Attachs the VASurface to the picture context */
+void
+vlc_vaapi_PicSetContext(picture_t *pic, struct vaapi_pic_context *);
+
 /* Get the VASurfaceID attached to the pic */
 VASurfaceID
 vlc_vaapi_PicGetSurface(picture_t *pic);



More information about the vlc-commits mailing list