[vlc-devel] [PATCH 17/36] vdpau: set the video context in the picture context

Steve Lhomme robux4 at ycbcr.xyz
Thu Nov 21 15:14:08 CET 2019


---
 modules/hw/vdpau/avcodec.c   |  2 +-
 modules/hw/vdpau/chroma.c    |  2 +-
 modules/hw/vdpau/picture.c   | 10 ++++++----
 modules/hw/vdpau/vlc_vdpau.h |  4 ++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 74aa135f70c..6ff3a519563 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -78,7 +78,7 @@ static vlc_vdp_video_field_t *CreateSurface(vlc_va_t *va)
         return NULL;
     }
 
-    vlc_vdp_video_field_t *field = vlc_vdp_video_create(vctx_priv->vdp, surface);
+    vlc_vdp_video_field_t *field = vlc_vdp_video_create(vctx_priv->vdp, surface, sys->vctx);
     if (unlikely(field == NULL))
         vdp_video_surface_destroy(vctx_priv->vdp, surface);
     return field;
diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index 51a958ccc2d..ff816870d3f 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -420,7 +420,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 7bb72d56ec1..d876c1de9fd 100644
--- a/modules/hw/vdpau/picture.c
+++ b/modules/hw/vdpau/picture.c
@@ -67,6 +67,7 @@ static picture_context_t *VideoSurfaceCopy(picture_context_t *ctx)
         return NULL;
 
     *fnew = *fold;
+    vlc_video_context_Hold(fnew->context.vctx);
 
     atomic_fetch_add(&fold->frame->refs, 1);
     return &fnew->context;
@@ -82,7 +83,8 @@ static const VdpProcamp procamp_default =
 };
 
 vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *vdp,
-                                            VdpVideoSurface surface)
+                                            VdpVideoSurface surface,
+                                            vlc_video_context *vctx)
 {
     vlc_vdp_video_field_t *field = malloc(sizeof (*field));
     vlc_vdp_video_frame_t *frame = malloc(sizeof (*frame));
@@ -96,7 +98,7 @@ vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *vdp,
 
     field->context = (picture_context_t) {
         VideoSurfaceDestroy, VideoSurfaceCopy,
-        NULL /*TODO*/
+        vlc_video_context_Hold(vctx)
     };
     field->frame = frame;
     field->structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
@@ -110,9 +112,9 @@ vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *vdp,
 }
 
 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);
+    vlc_vdp_video_field_t *field = vlc_vdp_video_create(vdp, surface, vctx);
     if (unlikely(field == NULL))
         return VDP_STATUS_RESOURCES;
 
diff --git a/modules/hw/vdpau/vlc_vdpau.h b/modules/hw/vdpau/vlc_vdpau.h
index ba5d1443bf0..338817611d4 100644
--- a/modules/hw/vdpau/vlc_vdpau.h
+++ b/modules/hw/vdpau/vlc_vdpau.h
@@ -285,12 +285,12 @@ static inline vdp_t *GetVDPAUOpaqueDevice(vlc_decoder_device *device)
 /**
  * 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.
  */
-vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *, VdpVideoSurface);
+vlc_vdp_video_field_t *vlc_vdp_video_create(vdp_t *, VdpVideoSurface, vlc_video_context *);
 
 static inline void vlc_vdp_video_destroy(vlc_vdp_video_field_t *f)
 {
-- 
2.17.1



More information about the vlc-devel mailing list