[vlc-commits] vt_utils: add helpers to create cvpx video contexts

Thomas Guillem git at videolan.org
Fri Jan 10 13:02:06 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan  9 17:20:33 2020 +0100| [9c8ddad9730ea7ee6c32d55c22c546f657f25ccf] | committer: Thomas Guillem

vt_utils: add helpers to create cvpx video contexts

Create subtype for cvpx video contexts since Videotoolbox and cifilters video
contexts won't share a common context.

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

 modules/codec/vt_utils.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 modules/codec/vt_utils.h | 24 +++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
index 9e7cf7f3ef..067c197e15 100644
--- a/modules/codec/vt_utils.c
+++ b/modules/codec/vt_utils.c
@@ -314,3 +314,54 @@ cvpxpool_new_cvpx(CVPixelBufferPoolRef pool)
 
     return cvpx;
 }
+
+struct cvpx_video_context
+{
+    const struct vlc_video_context_operations *ops;
+    enum cvpx_video_context_type type;
+    uint8_t private[];
+};
+
+static void
+cvpx_video_context_Destroy(void *priv)
+{
+    struct cvpx_video_context *cvpx_vctx = priv;
+    if (cvpx_vctx->ops->destroy)
+        cvpx_vctx->ops->destroy(&cvpx_vctx->private);
+}
+
+vlc_video_context *
+vlc_video_context_CreateCVPX(vlc_decoder_device *device,
+                              enum cvpx_video_context_type type, size_t type_size,
+                              const struct vlc_video_context_operations *ops)
+{
+    static const struct vlc_video_context_operations vctx_ops =
+    {
+        cvpx_video_context_Destroy,
+    };
+    vlc_video_context *vctx =
+        vlc_video_context_Create(device, VLC_VIDEO_CONTEXT_CVPX,
+                                 sizeof(struct cvpx_video_context) + type_size,
+                                 &vctx_ops);
+    if (!vctx)
+        return NULL;
+    struct cvpx_video_context *cvpx_vctx =
+        vlc_video_context_GetPrivate(vctx, VLC_VIDEO_CONTEXT_CVPX);
+    assert(cvpx_vctx != NULL);
+    cvpx_vctx->type = type;
+    cvpx_vctx->ops = ops;
+
+    return vctx;
+}
+
+void *
+vlc_video_context_GetCVPXPrivate(vlc_video_context *vctx,
+                                 enum cvpx_video_context_type type)
+{
+    struct cvpx_video_context *cvpx_vctx =
+        vlc_video_context_GetPrivate(vctx, VLC_VIDEO_CONTEXT_CVPX);
+
+    if (cvpx_vctx && cvpx_vctx->type == type)
+        return &cvpx_vctx->private;
+    return NULL;
+}
diff --git a/modules/codec/vt_utils.h b/modules/codec/vt_utils.h
index 6132eae614..cc216065c5 100644
--- a/modules/codec/vt_utils.h
+++ b/modules/codec/vt_utils.h
@@ -77,4 +77,28 @@ CVPixelBufferPoolRef cvpxpool_create(const video_format_t *fmt, unsigned count);
  */
 CVPixelBufferRef cvpxpool_new_cvpx(CVPixelBufferPoolRef pool);
 
+enum cvpx_video_context_type
+{
+    CVPX_VIDEO_CONTEXT_DEFAULT,
+    CVPX_VIDEO_CONTEXT_VIDEOTOOLBOX,
+    CVPX_VIDEO_CONTEXT_CIFILTERS,
+};
+
+/*
+ * Create a CVPX video context for a subtype
+ * The private data of a subtype (VIDEOTOOLBOX, CIFILTERS) if only compatible
+ * for this subtype
+ */
+vlc_video_context *
+vlc_video_context_CreateCVPX(vlc_decoder_device *device,
+                             enum cvpx_video_context_type type, size_t type_size,
+                             const struct vlc_video_context_operations *ops);
+
+/*
+ * Get the video context sub private data
+ */
+void *
+vlc_video_context_GetCVPXPrivate(vlc_video_context *vctx,
+                                 enum cvpx_video_context_type type);
+
 #endif



More information about the vlc-commits mailing list