[vlc-commits] d3d11: add a helper function to allocate D3D11 based picture_t

Steve Lhomme git at videolan.org
Mon Dec 23 13:43:31 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Dec 23 13:11:15 2019 +0100| [779b9dbe06ed3f05be0152151d414d3ee608e081] | committer: Steve Lhomme

d3d11: add a helper function to allocate D3D11 based picture_t

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

 modules/video_chroma/d3d11_fmt.c | 35 +++++++++++++++++++++++++++++++++++
 modules/video_chroma/d3d11_fmt.h |  3 +++
 2 files changed, 38 insertions(+)

diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index 5e2f3a6c91..dddbfbb86b 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -787,3 +787,38 @@ picture_context_t *d3d11_pic_context_copy(picture_context_t *ctx)
     AcquireD3D11PictureSys(&pic_ctx->picsys);
     return &pic_ctx->s;
 }
+
+picture_t *D3D11_AllocPicture(vlc_object_t *obj, d3d11_device_t *d3d_dev,
+                              const video_format_t *fmt, vlc_video_context *vctx_out, const d3d_format_t *cfg)
+{
+    if (unlikely(cfg == NULL))
+        return NULL;
+
+    struct d3d11_pic_context *pic_ctx = calloc(1, sizeof(*pic_ctx));
+    if (unlikely(pic_ctx == NULL))
+        return NULL;
+
+    picture_t *pic = picture_NewFromFormat( fmt );
+    if (unlikely(pic == NULL))
+    {
+        free(pic_ctx);
+        return NULL;
+    }
+
+    if (AllocateTextures(obj, d3d_dev, cfg,
+                         fmt, 1, pic_ctx->picsys.texture, NULL) != VLC_SUCCESS)
+    {
+        picture_Release(pic);
+        free(pic_ctx);
+        return NULL;
+    }
+
+    D3D11_AllocateResourceView(obj, d3d_dev->d3ddevice, cfg, pic_ctx->picsys.texture, 0, pic_ctx->picsys.renderSrc);
+
+    pic_ctx->s = (picture_context_t) {
+        d3d11_pic_context_destroy, d3d11_pic_context_copy,
+        vlc_video_context_Hold(vctx_out),
+    };
+    pic->context = &pic_ctx->s;
+    return pic;
+}
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index b32b7a7428..f1350f84e7 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -218,4 +218,7 @@ static inline void d3d11_device_unlock(d3d11_device_t *d3d_dev)
 void d3d11_pic_context_destroy(picture_context_t *);
 picture_context_t *d3d11_pic_context_copy(picture_context_t *);
 
+picture_t *D3D11_AllocPicture(vlc_object_t *, d3d11_device_t *,
+                              const video_format_t *, vlc_video_context *, const d3d_format_t *);
+
 #endif /* include-guard */



More information about the vlc-commits mailing list