Browse Source

videotoolbox: add vt_utils helper

This helper will be used by the videotoobox codec, the cvpx chroma and by the
cvpx opengl converter.
pull/57/head
Thomas Guillem 9 years ago
parent
commit
1521d9bd8c
  1. 1
      modules/codec/Makefile.am
  2. 64
      modules/codec/vt_utils.c
  3. 40
      modules/codec/vt_utils.h
  4. 3
      modules/video_chroma/Makefile.am
  5. 3
      modules/video_output/Makefile.am

1
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 \

64
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;
}

40
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

3
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)

3
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

Loading…
Cancel
Save