[vlc-commits] vdpau: set the video context in the picture context

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 28 14:23:21 2019 +0100| [8e0a198488ff9daabc99518c7a498c307b99e031] | committer: Steve Lhomme

vdpau: set the video context in the picture context

And rely on VideoSurfaceCopyWithContext which is VideoSurfaceCopy (may not be
called directly anymore) but for fields attached to a picture and thus have a
reference to the video context.

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

 modules/hw/vdpau/avcodec.c   |  3 +++
 modules/hw/vdpau/chroma.c    |  2 +-
 modules/hw/vdpau/picture.c   | 15 ++++++++++++++-
 modules/hw/vdpau/vlc_vdpau.h |  7 ++++++-
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 06293bac15..473caa090f 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -119,6 +119,9 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
     if (field == NULL)
         return VLC_ENOMEM;
 
+    field->context.copy = VideoSurfaceCloneWithContext;
+    field->context.vctx = vlc_video_context_Hold(sys->vctx);
+
     pic->context = &field->context;
     *data = (void *)(uintptr_t)field->frame->surface;
     return VLC_SUCCESS;
diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index 88a1c180ff..92073079d0 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -415,7 +415,7 @@ static picture_t *VideoImport(filter_t *filter, picture_t *src)
     picture_CopyProperties(dst, src);
     picture_Release(src);
 
-    err = vlc_vdp_video_attach(sys->vdp, surface, dst);
+    err = vlc_vdp_video_attach(sys->vdp, surface, filter->vctx_out, dst);
     if (unlikely(err != VDP_STATUS_OK))
     {
         picture_Release(dst);
diff --git a/modules/hw/vdpau/picture.c b/modules/hw/vdpau/picture.c
index e50a3f3e47..dda8e29023 100644
--- a/modules/hw/vdpau/picture.c
+++ b/modules/hw/vdpau/picture.c
@@ -109,13 +109,26 @@ vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *vdp,
     return field;
 }
 
+picture_context_t *VideoSurfaceCloneWithContext(picture_context_t *src_ctx)
+{
+    picture_context_t *dst_ctx = VideoSurfaceCopy(src_ctx);
+    if (unlikely(dst_ctx == NULL))
+        return NULL;
+    vlc_video_context_Hold(dst_ctx->vctx);
+    return dst_ctx;
+}
+
 VdpStatus vlc_vdp_video_attach(vdp_t *vdp, VdpVideoSurface surface,
-                               picture_t *pic)
+                               vlc_video_context *vctx, picture_t *pic)
 {
     vlc_vdp_video_field_t *field = vlc_vdp_video_create(vdp, surface);
     if (unlikely(field == NULL))
         return VDP_STATUS_RESOURCES;
 
+    field->context.destroy = VideoSurfaceDestroy;
+    field->context.copy = VideoSurfaceCloneWithContext;
+    field->context.vctx = vlc_video_context_Hold(vctx);
+
     assert(pic->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_420
         || pic->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_422
         || pic->format.i_chroma == VLC_CODEC_VDPAU_VIDEO_444);
diff --git a/modules/hw/vdpau/vlc_vdpau.h b/modules/hw/vdpau/vlc_vdpau.h
index c7f57b97fa..708ef811a9 100644
--- a/modules/hw/vdpau/vlc_vdpau.h
+++ b/modules/hw/vdpau/vlc_vdpau.h
@@ -308,7 +308,7 @@ static inline vdpau_decoder_device_t *GetVDPAUOpaqueContext(vlc_video_context *v
 /**
  * Attaches a VDPAU video surface as context of a VLC picture.
  */
-VdpStatus vlc_vdp_video_attach(vdp_t *, VdpVideoSurface, picture_t *);
+VdpStatus vlc_vdp_video_attach(vdp_t *, VdpVideoSurface, vlc_video_context *, picture_t *);
 
 /**
  * Wraps a VDPAU video surface into a VLC picture context.
@@ -330,6 +330,11 @@ static inline vlc_vdp_video_field_t *vlc_vdp_video_copy(
     return VDPAU_FIELD_FROM_PICCTX(fold->context.copy(&fold->context));
 }
 
+/**
+ * Clone a VPD field based picture context that contains a video context
+ */
+picture_context_t *VideoSurfaceCloneWithContext(picture_context_t *);
+
 typedef struct vlc_vdp_output_surface
 {
     VdpOutputSurface surface;



More information about the vlc-commits mailing list