|
@@ -0,0 +1,64 @@
|
|
|
+/*****************************************************************************
|
|
|
+ * vt_utils.c: videotoolbox/cvpx utility functions
|
|
|
+ *****************************************************************************
|
|
|
+ * Copyright (C) 2017 VLC authors, VideoLAN and VideoLabs
|
|
|
+ *
|
|
|
+ * This program is free software; you can redistribute it and/or modify it
|
|
|
+ * under the terms of the GNU Lesser General Public License as published by
|
|
|
+ * the Free Software Foundation; either version 2.1 of the License, or
|
|
|
+ * (at your option) any later version.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU Lesser General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU Lesser General Public License
|
|
|
+ * along with this program; if not, write to the Free Software Foundation,
|
|
|
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
|
+ *****************************************************************************/
|
|
|
+
|
|
|
+#ifdef HAVE_CONFIG_H
|
|
|
+# include "config.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#include "vt_utils.h"
|
|
|
+
|
|
|
+struct cvpxpic_ctx
|
|
|
+{
|
|
|
+ void (*pf_destroy)(void *); /* must be first @ref picture_Release() */
|
|
|
+ CVPixelBufferRef cvpx;
|
|
|
+};
|
|
|
+
|
|
|
+static void
|
|
|
+cvpxpic_destroy_cb(void *opaque)
|
|
|
+{
|
|
|
+ struct cvpxpic_ctx *ctx = opaque;
|
|
|
+
|
|
|
+ CFRelease(ctx->cvpx);
|
|
|
+ free(opaque);
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
+cvpxpic_attach(picture_t *p_pic, CVPixelBufferRef cvpx)
|
|
|
+{
|
|
|
+ /* will be freed by the vout */
|
|
|
+ struct cvpxpic_ctx *ctx = malloc(sizeof(struct cvpxpic_ctx));
|
|
|
+ if (ctx == NULL)
|
|
|
+ {
|
|
|
+ picture_Release(p_pic);
|
|
|
+ return VLC_ENOMEM;
|
|
|
+ }
|
|
|
+ ctx->pf_destroy = cvpxpic_destroy_cb;
|
|
|
+ ctx->cvpx = CVPixelBufferRetain(cvpx);
|
|
|
+ p_pic->context = ctx;
|
|
|
+
|
|
|
+ return VLC_SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
+CVPixelBufferRef
|
|
|
+cvpxpic_get_ref(picture_t *pic)
|
|
|
+{
|
|
|
+ assert(pic->context != NULL);
|
|
|
+ return ((struct cvpxpic_ctx *)pic->context)->cvpx;
|
|
|
+}
|