vlc | branch: master | Thomas Guillem <[email protected]> | Tue Apr 4 18:00:16 2017 +0200| [1521d9bd8cc9f042cf88ee7498ccebe6a217e08b] | committer: Thomas Guillem
videotoolbox: add vt_utils helper This helper will be used by the videotoobox codec, the cvpx chroma and by the cvpx opengl converter. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1521d9bd8cc9f042cf88ee7498ccebe6a217e08b --- modules/codec/Makefile.am | 1 + modules/codec/vt_utils.c | 64 ++++++++++++++++++++++++++++++++++++++++ modules/codec/vt_utils.h | 40 +++++++++++++++++++++++++ modules/video_chroma/Makefile.am | 3 +- modules/video_output/Makefile.am | 3 +- 5 files changed, 109 insertions(+), 2 deletions(-) diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am index bc8ee821f2..14fc7f00b1 100644 --- a/modules/codec/Makefile.am +++ b/modules/codec/Makefile.am @@ -317,6 +317,7 @@ EXTRA_LTLIBRARIES += liboggspots_plugin.la codec_LTLIBRARIES += $(LTLIBoggspots) libvideotoolbox_plugin_la_SOURCES = video_chroma/copy.c video_chroma/copy.h \ + codec/vt_utils.c codec/vt_utils.h \ codec/videotoolbox.m codec/hxxx_helper.c codec/hxxx_helper.h \ packetizer/hxxx_nal.h packetizer/hxxx_nal.c \ packetizer/hxxx_sei.h packetizer/hxxx_sei.c \ diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c new file mode 100644 index 0000000000..fc15780471 --- /dev/null +++ b/modules/codec/vt_utils.c @@ -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; +} diff --git a/modules/codec/vt_utils.h b/modules/codec/vt_utils.h new file mode 100644 index 0000000000..a338ff0aac --- /dev/null +++ b/modules/codec/vt_utils.h @@ -0,0 +1,40 @@ +/***************************************************************************** + * vt_utils.h: 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. + *****************************************************************************/ + +#ifndef VLC_CODEC_VTUTILS_H_ +#define VLC_CODEC_VTUTILS_H_ + +#include <VideoToolbox/VideoToolbox.h> +#include <vlc_picture.h> + +/* + * Attach a cvpx buffer to a picture + * + * The cvpx ref will be released when the picture is released + * @return VLC_SUCCESS or VLC_ENOMEM + */ +int cvpxpic_attach(picture_t *p_pic, CVPixelBufferRef cvpx); + +/* + * Get the cvpx buffer attached to a picture + */ +CVPixelBufferRef cvpxpic_get_ref(picture_t *pic); + +#endif diff --git a/modules/video_chroma/Makefile.am b/modules/video_chroma/Makefile.am index 5857334c25..5d5003c2ff 100644 --- a/modules/video_chroma/Makefile.am +++ b/modules/video_chroma/Makefile.am @@ -132,7 +132,8 @@ chroma_LTLIBRARIES += \ libd3d11_surface_plugin.la endif -libcvpx_plugin_la_SOURCES = video_chroma/cvpx.c video_chroma/copy.c video_chroma/copy.h +libcvpx_plugin_la_SOURCES = video_chroma/cvpx.c video_chroma/copy.c video_chroma/copy.h \ + codec/vt_utils.c codec/vt_utils.h libcvpx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(chromadir)' -Wl,-framework,Foundation -Wl,-framework,VideoToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo EXTRA_LTLIBRARIES += libcvpx_plugin.la chroma_LTLIBRARIES += $(LTLIBcvpx) diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am index 783c047932..dae0183d96 100644 --- a/modules/video_output/Makefile.am +++ b/modules/video_output/Makefile.am @@ -13,7 +13,8 @@ if HAVE_ANDROID OPENGL_COMMONSOURCES += video_output/opengl/converter_android.c endif if HAVE_OSX -OPENGL_COMMONSOURCES += video_output/opengl/converter_cvpx.c +OPENGL_COMMONSOURCES += video_output/opengl/converter_cvpx.c \ + codec/vt_utils.c codec/vt_utils.h OPENGL_COMMONCFLAGS += -DVLCGL_CONV_CVPX OPENGL_COMMONLDFLAGS += -Wl,-framework,IOSurface -Wl,-framework,CoreVideo endif _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
