plugins: re-indent all GstVaapiVideo* related source code.

This commit is contained in:
Gwenole Beauchesne 2014-08-21 10:45:31 +02:00
parent 97d7f21575
commit 038d56bdca
16 changed files with 1561 additions and 1572 deletions

View file

@ -38,174 +38,171 @@
#if GST_CHECK_VERSION(1,1,0)
static inline GstBuffer *
gst_surface_buffer_new(void)
gst_surface_buffer_new (void)
{
return gst_buffer_new();
return gst_buffer_new ();
}
#elif GST_CHECK_VERSION(1,0,0)
#include <gst/video/gstsurfacemeta.h>
#define GST_VAAPI_SURFACE_META_CAST(obj) \
((GstVaapiSurfaceMeta *)(obj))
((GstVaapiSurfaceMeta *) (obj))
typedef struct _GstVaapiSurfaceMeta GstVaapiSurfaceMeta;
struct _GstVaapiSurfaceMeta {
GstSurfaceMeta base;
GstBuffer *buffer;
struct _GstVaapiSurfaceMeta
{
GstSurfaceMeta base;
GstBuffer *buffer;
};
#define GST_VAAPI_SURFACE_META_INFO gst_vaapi_surface_meta_get_info()
static const GstMetaInfo *
gst_vaapi_surface_meta_get_info(void);
#define GST_VAAPI_SURFACE_META_INFO \
gst_vaapi_surface_meta_get_info ()
typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc)(
GstSurfaceMeta *meta, const gchar *type, GValue *dest);
static const GstMetaInfo *
gst_vaapi_surface_meta_get_info (void);
typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc) (GstSurfaceMeta *
meta, const gchar * type, GValue * dest);
#if USE_X11
static GstSurfaceConverter *
gst_vaapi_surface_create_converter_x11(GstSurfaceMeta *base_meta,
const gchar *type, GValue *dest)
gst_vaapi_surface_create_converter_x11 (GstSurfaceMeta * base_meta,
const gchar * type, GValue * dest)
{
GstVaapiSurfaceMeta * const meta = GST_VAAPI_SURFACE_META_CAST(base_meta);
GstVaapiSurfaceMeta *const meta = GST_VAAPI_SURFACE_META_CAST (base_meta);
return gst_vaapi_video_converter_x11_new(meta->buffer, type, dest);
return gst_vaapi_video_converter_x11_new (meta->buffer, type, dest);
}
#undef gst_vaapi_video_converter_x11_new
#define gst_vaapi_video_converter_x11_new \
gst_vaapi_surface_create_converter_x11
gst_vaapi_surface_create_converter_x11
#endif
#if USE_GLX
static GstSurfaceConverter *
gst_vaapi_surface_create_converter_glx(GstSurfaceMeta *base_meta,
const gchar *type, GValue *dest)
gst_vaapi_surface_create_converter_glx (GstSurfaceMeta * base_meta,
const gchar * type, GValue * dest)
{
GstVaapiSurfaceMeta * const meta = GST_VAAPI_SURFACE_META_CAST(base_meta);
GstVaapiSurfaceMeta *const meta = GST_VAAPI_SURFACE_META_CAST (base_meta);
return gst_vaapi_video_converter_glx_new(meta->buffer, type, dest);
return gst_vaapi_video_converter_glx_new (meta->buffer, type, dest);
}
#undef gst_vaapi_video_converter_glx_new
#define gst_vaapi_video_converter_glx_new \
gst_vaapi_surface_create_converter_glx
gst_vaapi_surface_create_converter_glx
#endif
static GstSurfaceConverter *
gst_vaapi_surface_create_converter(GstSurfaceMeta *base_meta,
const gchar *type, GValue *dest)
gst_vaapi_surface_create_converter (GstSurfaceMeta * base_meta,
const gchar * type, GValue * dest)
{
GstVaapiSurfaceMeta * const meta = GST_VAAPI_SURFACE_META_CAST(base_meta);
GstVaapiVideoMeta * const vmeta =
gst_buffer_get_vaapi_video_meta(meta->buffer);
GstSurfaceConverterCreateFunc func;
GstVaapiSurfaceMeta *const meta = GST_VAAPI_SURFACE_META_CAST (base_meta);
GstVaapiVideoMeta *const vmeta =
gst_buffer_get_vaapi_video_meta (meta->buffer);
GstSurfaceConverterCreateFunc func;
if (G_UNLIKELY(!vmeta))
return NULL;
if (G_UNLIKELY (!vmeta))
return NULL;
func = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter(vmeta);
func = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter (vmeta);
return func ? func(base_meta, type, dest) : NULL;
return func ? func (base_meta, type, dest) : NULL;
}
static gboolean
gst_vaapi_surface_meta_init(GstVaapiSurfaceMeta *meta, gpointer params,
GstBuffer *buffer)
gst_vaapi_surface_meta_init (GstVaapiSurfaceMeta * meta, gpointer params,
GstBuffer * buffer)
{
meta->base.create_converter = gst_vaapi_surface_create_converter;
meta->buffer = buffer;
return TRUE;
meta->base.create_converter = gst_vaapi_surface_create_converter;
meta->buffer = buffer;
return TRUE;
}
static void
gst_vaapi_surface_meta_free(GstVaapiSurfaceMeta *meta, GstBuffer *buffer)
gst_vaapi_surface_meta_free (GstVaapiSurfaceMeta * meta, GstBuffer * buffer)
{
}
static gboolean
gst_vaapi_surface_meta_transform(GstBuffer *dst_buffer, GstMeta *meta,
GstBuffer *src_buffer, GQuark type, gpointer data)
gst_vaapi_surface_meta_transform (GstBuffer * dst_buffer, GstMeta * meta,
GstBuffer * src_buffer, GQuark type, gpointer data)
{
GstVaapiVideoMeta * const src_vmeta =
gst_buffer_get_vaapi_video_meta(src_buffer);
GstVaapiVideoMeta *const src_vmeta =
gst_buffer_get_vaapi_video_meta (src_buffer);
if (GST_META_TRANSFORM_IS_COPY(type)) {
GstVaapiSurfaceMeta * const dst_smeta = GST_VAAPI_SURFACE_META_CAST(
gst_buffer_add_meta(dst_buffer, GST_VAAPI_SURFACE_META_INFO, NULL));
if (GST_META_TRANSFORM_IS_COPY (type)) {
GstVaapiSurfaceMeta *const dst_smeta =
GST_VAAPI_SURFACE_META_CAST (gst_buffer_add_meta (dst_buffer,
GST_VAAPI_SURFACE_META_INFO, NULL));
/* Note: avoid meta lookups in gst_vaapi_surface_create_converter()
by directly calling the GstVaapiVideoMeta::surface_converter hook */
dst_smeta->base.create_converter = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter(src_vmeta);
return TRUE;
}
return FALSE;
/* Note: avoid meta lookups in gst_vaapi_surface_create_converter()
by directly calling the GstVaapiVideoMeta::surface_converter hook */
dst_smeta->base.create_converter = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter (src_vmeta);
return TRUE;
}
return FALSE;
}
const GstMetaInfo *
gst_vaapi_surface_meta_get_info(void)
gst_vaapi_surface_meta_get_info (void)
{
static gsize g_meta_info;
static gsize g_meta_info;
if (g_once_init_enter(&g_meta_info)) {
gsize meta_info = GPOINTER_TO_SIZE(gst_meta_register(
GST_SURFACE_META_API_TYPE,
"GstVaapiSurfaceMeta", sizeof(GstVaapiSurfaceMeta),
(GstMetaInitFunction)gst_vaapi_surface_meta_init,
(GstMetaFreeFunction)gst_vaapi_surface_meta_free,
(GstMetaTransformFunction)gst_vaapi_surface_meta_transform));
g_once_init_leave(&g_meta_info, meta_info);
}
return GSIZE_TO_POINTER(g_meta_info);
if (g_once_init_enter (&g_meta_info)) {
gsize meta_info =
GPOINTER_TO_SIZE (gst_meta_register (GST_SURFACE_META_API_TYPE,
"GstVaapiSurfaceMeta", sizeof (GstVaapiSurfaceMeta),
(GstMetaInitFunction) gst_vaapi_surface_meta_init,
(GstMetaFreeFunction) gst_vaapi_surface_meta_free,
(GstMetaTransformFunction) gst_vaapi_surface_meta_transform));
g_once_init_leave (&g_meta_info, meta_info);
}
return GSIZE_TO_POINTER (g_meta_info);
}
static GstBuffer *
gst_surface_buffer_new(void)
gst_surface_buffer_new (void)
{
GstBuffer * const buffer = gst_buffer_new();
GstBuffer *const buffer = gst_buffer_new ();
if (buffer)
gst_buffer_add_meta(buffer, GST_VAAPI_SURFACE_META_INFO, NULL);
return buffer;
if (buffer)
gst_buffer_add_meta (buffer, GST_VAAPI_SURFACE_META_INFO, NULL);
return buffer;
}
#else
#include <gst/video/gstsurfacebuffer.h>
#define GST_VAAPI_TYPE_VIDEO_BUFFER \
(gst_vaapi_video_buffer_get_type())
#define GST_VAAPI_VIDEO_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBuffer))
#define GST_VAAPI_VIDEO_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBufferClass))
(gst_vaapi_video_buffer_get_type ())
#define GST_VAAPI_VIDEO_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBuffer))
#define GST_VAAPI_VIDEO_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBufferClass))
#define GST_VAAPI_IS_VIDEO_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_BUFFER))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER))
#define GST_VAAPI_IS_VIDEO_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_BUFFER))
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER))
#define GST_VAAPI_VIDEO_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBufferClass))
#define GST_VAAPI_VIDEO_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_VIDEO_BUFFER, \
GstVaapiVideoBufferClass))
typedef struct _GstVaapiVideoBufferClass GstVaapiVideoBufferClass;
typedef struct _GstVaapiVideoBufferClass GstVaapiVideoBufferClass;
/**
* GstVaapiVideoBuffer:
*
* A #GstBuffer holding video objects (#GstVaapiSurface and #GstVaapiImage).
*/
struct _GstVaapiVideoBuffer {
/*< private >*/
GstSurfaceBuffer parent_instance;
struct _GstVaapiVideoBuffer
{
/*< private >*/
GstSurfaceBuffer parent_instance;
};
/**
@ -213,134 +210,134 @@ struct _GstVaapiVideoBuffer {
*
* A #GstBuffer holding video objects
*/
struct _GstVaapiVideoBufferClass {
/*< private >*/
GstSurfaceBufferClass parent_class;
struct _GstVaapiVideoBufferClass
{
/*< private >*/
GstSurfaceBufferClass parent_class;
};
GType
gst_vaapi_video_buffer_get_type(void) G_GNUC_CONST;
gst_vaapi_video_buffer_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE(GstVaapiVideoBuffer,
gst_vaapi_video_buffer,
GST_TYPE_SURFACE_BUFFER)
G_DEFINE_TYPE (GstVaapiVideoBuffer,
gst_vaapi_video_buffer, GST_TYPE_SURFACE_BUFFER);
typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc)(
GstSurfaceBuffer *surface, const gchar *type, GValue *dest);
typedef GstSurfaceConverter *
(*GstSurfaceConverterCreateFunc) (GstSurfaceBuffer * surface,
const gchar * type, GValue * dest);
static GstSurfaceConverter *
gst_vaapi_video_buffer_create_converter(GstSurfaceBuffer *surface,
const gchar *type, GValue *dest)
gst_vaapi_video_buffer_create_converter (GstSurfaceBuffer * surface,
const gchar * type, GValue * dest)
{
GstVaapiVideoMeta * const meta =
gst_buffer_get_vaapi_video_meta(GST_BUFFER(surface));
GstSurfaceConverterCreateFunc func;
GstVaapiVideoMeta *const meta =
gst_buffer_get_vaapi_video_meta (GST_BUFFER (surface));
GstSurfaceConverterCreateFunc func;
g_return_val_if_fail(meta != NULL, NULL);
g_return_val_if_fail (meta != NULL, NULL);
func = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter(meta);
func = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter (meta);
return func ? func(surface, type, dest) : NULL;
return func ? func (surface, type, dest) : NULL;
}
static void
gst_vaapi_video_buffer_class_init(GstVaapiVideoBufferClass *klass)
gst_vaapi_video_buffer_class_init (GstVaapiVideoBufferClass * klass)
{
GstSurfaceBufferClass * const surface_class =
GST_SURFACE_BUFFER_CLASS(klass);
GstSurfaceBufferClass *const surface_class = GST_SURFACE_BUFFER_CLASS (klass);
surface_class->create_converter = gst_vaapi_video_buffer_create_converter;
surface_class->create_converter = gst_vaapi_video_buffer_create_converter;
}
static void
gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
gst_vaapi_video_buffer_init (GstVaapiVideoBuffer * buffer)
{
}
static inline GstBuffer *
gst_surface_buffer_new(void)
gst_surface_buffer_new (void)
{
return GST_BUFFER_CAST(gst_mini_object_new(GST_VAAPI_TYPE_VIDEO_BUFFER));
return GST_BUFFER_CAST (gst_mini_object_new (GST_VAAPI_TYPE_VIDEO_BUFFER));
}
#endif
static GFunc
get_surface_converter(GstVaapiDisplay *display)
get_surface_converter (GstVaapiDisplay * display)
{
GFunc func;
GFunc func;
switch (gst_vaapi_display_get_display_type(display)) {
switch (gst_vaapi_display_get_display_type (display)) {
#if USE_X11 && !GST_CHECK_VERSION(1,1,0)
case GST_VAAPI_DISPLAY_TYPE_X11:
func = (GFunc)gst_vaapi_video_converter_x11_new;
break;
func = (GFunc) gst_vaapi_video_converter_x11_new;
break;
#endif
#if USE_GLX && !GST_CHECK_VERSION(1,1,0)
case GST_VAAPI_DISPLAY_TYPE_GLX:
func = (GFunc)gst_vaapi_video_converter_glx_new;
break;
func = (GFunc) gst_vaapi_video_converter_glx_new;
break;
#endif
default:
func = NULL;
break;
}
return func;
func = NULL;
break;
}
return func;
}
static GstBuffer *
new_vbuffer(GstVaapiVideoMeta *meta)
new_vbuffer (GstVaapiVideoMeta * meta)
{
GstBuffer *buffer;
GstBuffer *buffer;
g_return_val_if_fail(meta != NULL, NULL);
g_return_val_if_fail (meta != NULL, NULL);
gst_vaapi_video_meta_set_surface_converter(meta,
get_surface_converter(gst_vaapi_video_meta_get_display(meta)));
gst_vaapi_video_meta_set_surface_converter (meta,
get_surface_converter (gst_vaapi_video_meta_get_display (meta)));
buffer = gst_surface_buffer_new();
if (buffer)
gst_buffer_set_vaapi_video_meta(buffer, meta);
gst_vaapi_video_meta_unref(meta);
return buffer;
buffer = gst_surface_buffer_new ();
if (buffer)
gst_buffer_set_vaapi_video_meta (buffer, meta);
gst_vaapi_video_meta_unref (meta);
return buffer;
}
GstBuffer *
gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta)
gst_vaapi_video_buffer_new (GstVaapiVideoMeta * meta)
{
g_return_val_if_fail(meta != NULL, NULL);
g_return_val_if_fail (meta != NULL, NULL);
return new_vbuffer(gst_vaapi_video_meta_ref(meta));
return new_vbuffer (gst_vaapi_video_meta_ref (meta));
}
GstBuffer *
gst_vaapi_video_buffer_new_empty(void)
gst_vaapi_video_buffer_new_empty (void)
{
return gst_surface_buffer_new();
return gst_surface_buffer_new ();
}
GstBuffer *
gst_vaapi_video_buffer_new_from_pool(GstVaapiVideoPool *pool)
gst_vaapi_video_buffer_new_from_pool (GstVaapiVideoPool * pool)
{
return new_vbuffer(gst_vaapi_video_meta_new_from_pool(pool));
return new_vbuffer (gst_vaapi_video_meta_new_from_pool (pool));
}
GstBuffer *
gst_vaapi_video_buffer_new_from_buffer(GstBuffer *buffer)
gst_vaapi_video_buffer_new_from_buffer (GstBuffer * buffer)
{
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
return meta ? new_vbuffer(gst_vaapi_video_meta_ref(meta)) : NULL;
return meta ? new_vbuffer (gst_vaapi_video_meta_ref (meta)) : NULL;
}
GstBuffer *
gst_vaapi_video_buffer_new_with_image(GstVaapiImage *image)
gst_vaapi_video_buffer_new_with_image (GstVaapiImage * image)
{
return new_vbuffer(gst_vaapi_video_meta_new_with_image(image));
return new_vbuffer (gst_vaapi_video_meta_new_with_image (image));
}
GstBuffer *
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
gst_vaapi_video_buffer_new_with_surface_proxy (GstVaapiSurfaceProxy * proxy)
{
return new_vbuffer(gst_vaapi_video_meta_new_with_surface_proxy(proxy));
return new_vbuffer (gst_vaapi_video_meta_new_with_surface_proxy (proxy));
}

View file

@ -29,31 +29,31 @@
G_BEGIN_DECLS
typedef struct _GstVaapiVideoBuffer GstVaapiVideoBuffer;
typedef struct _GstVaapiVideoBuffer GstVaapiVideoBuffer;
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta);
gst_vaapi_video_buffer_new (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new_empty(void);
gst_vaapi_video_buffer_new_empty (void);
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new_from_pool(GstVaapiVideoPool *pool);
gst_vaapi_video_buffer_new_from_pool (GstVaapiVideoPool * pool);
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new_from_buffer(GstBuffer *buffer);
gst_vaapi_video_buffer_new_from_buffer (GstBuffer * buffer);
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new_with_image(GstVaapiImage *image);
gst_vaapi_video_buffer_new_with_image (GstVaapiImage * image);
G_GNUC_INTERNAL
GstBuffer *
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy);
gst_vaapi_video_buffer_new_with_surface_proxy (GstVaapiSurfaceProxy * proxy);
G_END_DECLS

View file

@ -28,317 +28,319 @@
#include "gstvaapivideometa_texture.h"
#endif
GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapivideopool);
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideopool);
#define GST_CAT_DEFAULT gst_debug_vaapivideopool
G_DEFINE_TYPE(GstVaapiVideoBufferPool,
gst_vaapi_video_buffer_pool,
GST_TYPE_BUFFER_POOL)
G_DEFINE_TYPE (GstVaapiVideoBufferPool,
gst_vaapi_video_buffer_pool, GST_TYPE_BUFFER_POOL);
enum {
PROP_0,
enum
{
PROP_0,
PROP_DISPLAY,
PROP_DISPLAY,
};
struct _GstVaapiVideoBufferPoolPrivate {
GstVideoInfo video_info[2];
guint video_info_index;
GstAllocator *allocator;
GstVaapiDisplay *display;
guint has_video_meta : 1;
guint has_video_alignment : 1;
guint has_texture_upload_meta : 1;
struct _GstVaapiVideoBufferPoolPrivate
{
GstVideoInfo video_info[2];
guint video_info_index;
GstAllocator *allocator;
GstVaapiDisplay *display;
guint has_video_meta:1;
guint has_video_alignment:1;
guint has_texture_upload_meta:1;
};
#define GST_VAAPI_VIDEO_BUFFER_POOL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPoolPrivate))
#define GST_VAAPI_VIDEO_BUFFER_POOL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPoolPrivate))
static void
gst_vaapi_video_buffer_pool_finalize(GObject *object)
gst_vaapi_video_buffer_pool_finalize (GObject * object)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL(object)->priv;
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL (object)->priv;
G_OBJECT_CLASS(gst_vaapi_video_buffer_pool_parent_class)->finalize(object);
G_OBJECT_CLASS (gst_vaapi_video_buffer_pool_parent_class)->finalize (object);
gst_vaapi_display_replace(&priv->display, NULL);
g_clear_object(&priv->allocator);
gst_vaapi_display_replace (&priv->display, NULL);
g_clear_object (&priv->allocator);
}
static void
gst_vaapi_video_buffer_pool_set_property(GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
gst_vaapi_video_buffer_pool_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL(object)->priv;
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL (object)->priv;
switch (prop_id) {
switch (prop_id) {
case PROP_DISPLAY:
priv->display = gst_vaapi_display_ref(g_value_get_pointer(value));
break;
priv->display = gst_vaapi_display_ref (g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_vaapi_video_buffer_pool_get_property(GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
gst_vaapi_video_buffer_pool_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL(object)->priv;
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL (object)->priv;
switch (prop_id) {
switch (prop_id) {
case PROP_DISPLAY:
g_value_set_pointer(value, priv->display);
break;
g_value_set_pointer (value, priv->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
fill_video_alignment(GstVaapiVideoBufferPool *pool, GstVideoAlignment *align)
fill_video_alignment (GstVaapiVideoBufferPool * pool, GstVideoAlignment * align)
{
GstVideoInfo * const vip =
&GST_VAAPI_VIDEO_ALLOCATOR_CAST(pool->priv->allocator)->image_info;
guint i;
GstVideoInfo *const vip =
&GST_VAAPI_VIDEO_ALLOCATOR_CAST (pool->priv->allocator)->image_info;
guint i;
gst_video_alignment_reset(align);
for (i = 0; i < GST_VIDEO_INFO_N_PLANES(vip); i++)
align->stride_align[i] =
(1U << g_bit_nth_lsf(GST_VIDEO_INFO_PLANE_STRIDE(vip, i), 0)) - 1;
gst_video_alignment_reset (align);
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (vip); i++)
align->stride_align[i] =
(1U << g_bit_nth_lsf (GST_VIDEO_INFO_PLANE_STRIDE (vip, i), 0)) - 1;
}
static const gchar **
gst_vaapi_video_buffer_pool_get_options(GstBufferPool *pool)
gst_vaapi_video_buffer_pool_get_options (GstBufferPool * pool)
{
static const gchar *g_options[] = {
GST_BUFFER_POOL_OPTION_VIDEO_META,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
NULL,
};
return g_options;
static const gchar *g_options[] = {
GST_BUFFER_POOL_OPTION_VIDEO_META,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
NULL,
};
return g_options;
}
static gboolean
gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool,
GstStructure *config)
gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
GstStructure * config)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL(pool)->priv;
GstCaps *caps = NULL;
GstVideoInfo * const cur_vip = &priv->video_info[priv->video_info_index];
GstVideoInfo * const new_vip = &priv->video_info[!priv->video_info_index];
GstVideoAlignment align;
GstAllocator *allocator;
gboolean changed_caps;
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL (pool)->priv;
GstCaps *caps = NULL;
GstVideoInfo *const cur_vip = &priv->video_info[priv->video_info_index];
GstVideoInfo *const new_vip = &priv->video_info[!priv->video_info_index];
GstVideoAlignment align;
GstAllocator *allocator;
gboolean changed_caps;
if (!gst_buffer_pool_config_get_params(config, &caps, NULL, NULL, NULL))
goto error_invalid_config;
if (!caps || !gst_video_info_from_caps(new_vip, caps))
goto error_no_caps;
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, NULL, NULL))
goto error_invalid_config;
if (!caps || !gst_video_info_from_caps (new_vip, caps))
goto error_no_caps;
changed_caps = !priv->allocator ||
GST_VIDEO_INFO_FORMAT(cur_vip) != GST_VIDEO_INFO_FORMAT(new_vip) ||
GST_VIDEO_INFO_WIDTH(cur_vip) != GST_VIDEO_INFO_WIDTH(new_vip) ||
GST_VIDEO_INFO_HEIGHT(cur_vip) != GST_VIDEO_INFO_HEIGHT(new_vip);
changed_caps = !priv->allocator ||
GST_VIDEO_INFO_FORMAT (cur_vip) != GST_VIDEO_INFO_FORMAT (new_vip) ||
GST_VIDEO_INFO_WIDTH (cur_vip) != GST_VIDEO_INFO_WIDTH (new_vip) ||
GST_VIDEO_INFO_HEIGHT (cur_vip) != GST_VIDEO_INFO_HEIGHT (new_vip);
if (changed_caps) {
allocator = gst_vaapi_video_allocator_new(priv->display, new_vip);
if (!allocator)
goto error_create_allocator;
gst_object_replace((GstObject **)&priv->allocator,
GST_OBJECT_CAST(allocator));
gst_object_unref(allocator);
priv->video_info_index ^= 1;
}
if (changed_caps) {
allocator = gst_vaapi_video_allocator_new (priv->display, new_vip);
if (!allocator)
goto error_create_allocator;
gst_object_replace ((GstObject **) & priv->allocator,
GST_OBJECT_CAST (allocator));
gst_object_unref (allocator);
priv->video_info_index ^= 1;
}
if (!gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))
goto error_no_vaapi_video_meta_option;
if (!gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))
goto error_no_vaapi_video_meta_option;
priv->has_video_meta = gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
priv->has_video_meta = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
priv->has_video_alignment = gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
if (priv->has_video_alignment) {
fill_video_alignment(GST_VAAPI_VIDEO_BUFFER_POOL(pool), &align);
gst_buffer_pool_config_set_video_alignment(config, &align);
}
priv->has_video_alignment = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
if (priv->has_video_alignment) {
fill_video_alignment (GST_VAAPI_VIDEO_BUFFER_POOL (pool), &align);
gst_buffer_pool_config_set_video_alignment (config, &align);
}
priv->has_texture_upload_meta = gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
priv->has_texture_upload_meta = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
return GST_BUFFER_POOL_CLASS(gst_vaapi_video_buffer_pool_parent_class)->
set_config(pool, config);
return
GST_BUFFER_POOL_CLASS
(gst_vaapi_video_buffer_pool_parent_class)->set_config (pool, config);
/* ERRORS */
/* ERRORS */
error_invalid_config:
{
GST_ERROR("invalid config");
return FALSE;
}
{
GST_ERROR ("invalid config");
return FALSE;
}
error_no_caps:
{
GST_ERROR("no valid caps in config");
return FALSE;
}
{
GST_ERROR ("no valid caps in config");
return FALSE;
}
error_create_allocator:
{
GST_ERROR("failed to create GstVaapiVideoAllocator object");
return FALSE;
}
{
GST_ERROR ("failed to create GstVaapiVideoAllocator object");
return FALSE;
}
error_no_vaapi_video_meta_option:
{
GST_ERROR("no GstVaapiVideoMeta option");
return FALSE;
}
{
GST_ERROR ("no GstVaapiVideoMeta option");
return FALSE;
}
}
static GstFlowReturn
gst_vaapi_video_buffer_pool_alloc_buffer(GstBufferPool *pool,
GstBuffer **out_buffer_ptr, GstBufferPoolAcquireParams *params)
gst_vaapi_video_buffer_pool_alloc_buffer (GstBufferPool * pool,
GstBuffer ** out_buffer_ptr, GstBufferPoolAcquireParams * params)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL(pool)->priv;
GstVaapiVideoMeta *meta;
GstMemory *mem;
GstBuffer *buffer;
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL (pool)->priv;
GstVaapiVideoMeta *meta;
GstMemory *mem;
GstBuffer *buffer;
if (!priv->allocator)
goto error_no_allocator;
if (!priv->allocator)
goto error_no_allocator;
meta = gst_vaapi_video_meta_new(priv->display);
if (!meta)
goto error_create_meta;
meta = gst_vaapi_video_meta_new (priv->display);
if (!meta)
goto error_create_meta;
buffer = gst_vaapi_video_buffer_new(meta);
if (!buffer)
goto error_create_buffer;
buffer = gst_vaapi_video_buffer_new (meta);
if (!buffer)
goto error_create_buffer;
mem = gst_vaapi_video_memory_new(priv->allocator, meta);
if (!mem)
goto error_create_memory;
gst_vaapi_video_meta_unref(meta);
gst_buffer_append_memory(buffer, mem);
mem = gst_vaapi_video_memory_new (priv->allocator, meta);
if (!mem)
goto error_create_memory;
gst_vaapi_video_meta_unref (meta);
gst_buffer_append_memory (buffer, mem);
if (priv->has_video_meta) {
GstVideoInfo * const vip =
&GST_VAAPI_VIDEO_ALLOCATOR_CAST(priv->allocator)->image_info;
GstVideoMeta *vmeta;
vmeta = gst_buffer_add_video_meta_full(buffer, 0,
GST_VIDEO_INFO_FORMAT(vip), GST_VIDEO_INFO_WIDTH(vip),
GST_VIDEO_INFO_HEIGHT(vip), GST_VIDEO_INFO_N_PLANES(vip),
&GST_VIDEO_INFO_PLANE_OFFSET(vip, 0),
&GST_VIDEO_INFO_PLANE_STRIDE(vip, 0));
vmeta->map = gst_video_meta_map_vaapi_memory;
vmeta->unmap = gst_video_meta_unmap_vaapi_memory;
}
if (priv->has_video_meta) {
GstVideoInfo *const vip =
&GST_VAAPI_VIDEO_ALLOCATOR_CAST (priv->allocator)->image_info;
GstVideoMeta *vmeta;
vmeta = gst_buffer_add_video_meta_full (buffer, 0,
GST_VIDEO_INFO_FORMAT (vip), GST_VIDEO_INFO_WIDTH (vip),
GST_VIDEO_INFO_HEIGHT (vip), GST_VIDEO_INFO_N_PLANES (vip),
&GST_VIDEO_INFO_PLANE_OFFSET (vip, 0),
&GST_VIDEO_INFO_PLANE_STRIDE (vip, 0));
vmeta->map = gst_video_meta_map_vaapi_memory;
vmeta->unmap = gst_video_meta_unmap_vaapi_memory;
}
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
if (priv->has_texture_upload_meta)
gst_buffer_add_texture_upload_meta(buffer);
if (priv->has_texture_upload_meta)
gst_buffer_add_texture_upload_meta (buffer);
#endif
*out_buffer_ptr = buffer;
return GST_FLOW_OK;
*out_buffer_ptr = buffer;
return GST_FLOW_OK;
/* ERRORS */
/* ERRORS */
error_no_allocator:
{
GST_ERROR("no GstAllocator in buffer pool");
return GST_FLOW_ERROR;
}
{
GST_ERROR ("no GstAllocator in buffer pool");
return GST_FLOW_ERROR;
}
error_create_meta:
{
GST_ERROR("failed to allocate vaapi video meta");
return GST_FLOW_ERROR;
}
{
GST_ERROR ("failed to allocate vaapi video meta");
return GST_FLOW_ERROR;
}
error_create_buffer:
{
GST_ERROR("failed to create video buffer");
gst_vaapi_video_meta_unref(meta);
return GST_FLOW_ERROR;
}
{
GST_ERROR ("failed to create video buffer");
gst_vaapi_video_meta_unref (meta);
return GST_FLOW_ERROR;
}
error_create_memory:
{
GST_ERROR("failed to create video memory");
gst_buffer_unref(buffer);
gst_vaapi_video_meta_unref(meta);
return GST_FLOW_ERROR;
}
{
GST_ERROR ("failed to create video memory");
gst_buffer_unref (buffer);
gst_vaapi_video_meta_unref (meta);
return GST_FLOW_ERROR;
}
}
static void
gst_vaapi_video_buffer_pool_reset_buffer(GstBufferPool *pool, GstBuffer *buffer)
gst_vaapi_video_buffer_pool_reset_buffer (GstBufferPool * pool,
GstBuffer * buffer)
{
GstMemory * const mem = gst_buffer_peek_memory(buffer, 0);
GstMemory *const mem = gst_buffer_peek_memory (buffer, 0);
/* Release the underlying surface proxy */
gst_vaapi_video_memory_reset_surface(GST_VAAPI_VIDEO_MEMORY_CAST(mem));
/* Release the underlying surface proxy */
gst_vaapi_video_memory_reset_surface (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
GST_BUFFER_POOL_CLASS(gst_vaapi_video_buffer_pool_parent_class)->
reset_buffer(pool, buffer);
GST_BUFFER_POOL_CLASS (gst_vaapi_video_buffer_pool_parent_class)->reset_buffer
(pool, buffer);
}
static void
gst_vaapi_video_buffer_pool_class_init(GstVaapiVideoBufferPoolClass *klass)
gst_vaapi_video_buffer_pool_class_init (GstVaapiVideoBufferPoolClass * klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstBufferPoolClass * const pool_class = GST_BUFFER_POOL_CLASS(klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstBufferPoolClass *const pool_class = GST_BUFFER_POOL_CLASS (klass);
GST_DEBUG_CATEGORY_INIT(gst_debug_vaapivideopool,
"vaapivideopool", 0, "VA-API video pool");
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapivideopool,
"vaapivideopool", 0, "VA-API video pool");
g_type_class_add_private(klass, sizeof(GstVaapiVideoBufferPoolPrivate));
g_type_class_add_private (klass, sizeof (GstVaapiVideoBufferPoolPrivate));
object_class->finalize = gst_vaapi_video_buffer_pool_finalize;
object_class->set_property = gst_vaapi_video_buffer_pool_set_property;
object_class->get_property = gst_vaapi_video_buffer_pool_get_property;
pool_class->get_options = gst_vaapi_video_buffer_pool_get_options;
pool_class->set_config = gst_vaapi_video_buffer_pool_set_config;
pool_class->alloc_buffer = gst_vaapi_video_buffer_pool_alloc_buffer;
pool_class->reset_buffer = gst_vaapi_video_buffer_pool_reset_buffer;
object_class->finalize = gst_vaapi_video_buffer_pool_finalize;
object_class->set_property = gst_vaapi_video_buffer_pool_set_property;
object_class->get_property = gst_vaapi_video_buffer_pool_get_property;
pool_class->get_options = gst_vaapi_video_buffer_pool_get_options;
pool_class->set_config = gst_vaapi_video_buffer_pool_set_config;
pool_class->alloc_buffer = gst_vaapi_video_buffer_pool_alloc_buffer;
pool_class->reset_buffer = gst_vaapi_video_buffer_pool_reset_buffer;
/**
* GstVaapiVideoBufferPool:display:
*
* The #GstVaapiDisplay this object is bound to.
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_pointer("display",
"Display",
"The GstVaapiDisplay to use for this video pool",
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
/**
* GstVaapiVideoBufferPool:display:
*
* The #GstVaapiDisplay this object is bound to.
*/
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_pointer ("display",
"Display",
"The GstVaapiDisplay to use for this video pool",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
gst_vaapi_video_buffer_pool_init(GstVaapiVideoBufferPool *pool)
gst_vaapi_video_buffer_pool_init (GstVaapiVideoBufferPool * pool)
{
GstVaapiVideoBufferPoolPrivate * const priv =
GST_VAAPI_VIDEO_BUFFER_POOL_GET_PRIVATE(pool);
GstVaapiVideoBufferPoolPrivate *const priv =
GST_VAAPI_VIDEO_BUFFER_POOL_GET_PRIVATE (pool);
pool->priv = priv;
pool->priv = priv;
gst_video_info_init(&priv->video_info[0]);
gst_video_info_init(&priv->video_info[1]);
gst_video_info_init (&priv->video_info[0]);
gst_video_info_init (&priv->video_info[1]);
}
GstBufferPool *
gst_vaapi_video_buffer_pool_new(GstVaapiDisplay *display)
gst_vaapi_video_buffer_pool_new (GstVaapiDisplay * display)
{
return g_object_new(GST_VAAPI_TYPE_VIDEO_BUFFER_POOL,
"display", display, NULL);
return g_object_new (GST_VAAPI_TYPE_VIDEO_BUFFER_POOL,
"display", display, NULL);
}

View file

@ -29,27 +29,21 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_VIDEO_BUFFER_POOL \
(gst_vaapi_video_buffer_pool_get_type())
#define GST_VAAPI_VIDEO_BUFFER_POOL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPool))
#define GST_VAAPI_VIDEO_BUFFER_POOL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPoolClass))
(gst_vaapi_video_buffer_pool_get_type ())
#define GST_VAAPI_VIDEO_BUFFER_POOL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPool))
#define GST_VAAPI_VIDEO_BUFFER_POOL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL, \
GstVaapiVideoBufferPoolClass))
#define GST_VAAPI_IS_VIDEO_BUFFER_POOL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL))
#define GST_VAAPI_IS_VIDEO_BUFFER_POOL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL))
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER_POOL))
typedef struct _GstVaapiVideoBufferPool GstVaapiVideoBufferPool;
typedef struct _GstVaapiVideoBufferPoolClass GstVaapiVideoBufferPoolClass;
typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
typedef struct _GstVaapiVideoBufferPool GstVaapiVideoBufferPool;
typedef struct _GstVaapiVideoBufferPoolClass GstVaapiVideoBufferPoolClass;
typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
/**
* GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META:
@ -57,7 +51,8 @@ typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
* An option that can be activated on bufferpool to request vaapi
* video metadata on buffers from the pool.
*/
#define GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META "GstBufferPoolOptionVaapiVideoMeta"
#define GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META \
"GstBufferPoolOptionVaapiVideoMeta"
/**
*
@ -71,7 +66,7 @@ typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
*/
#ifndef GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META
#define GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META \
"GstBufferPoolOptionVideoGLTextureUploadMeta"
"GstBufferPoolOptionVideoGLTextureUploadMeta"
#endif
/**
@ -79,11 +74,12 @@ typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
*
* A VA video buffer pool object.
*/
struct _GstVaapiVideoBufferPool {
GstBufferPool parent_instance;
struct _GstVaapiVideoBufferPool
{
GstBufferPool parent_instance;
/*< private >*/
GstVaapiVideoBufferPoolPrivate *priv;
/*< private >*/
GstVaapiVideoBufferPoolPrivate *priv;
};
/**
@ -91,17 +87,18 @@ struct _GstVaapiVideoBufferPool {
*
* A VA video buffer pool class.
*/
struct _GstVaapiVideoBufferPoolClass {
GstBufferPoolClass parent_class;
struct _GstVaapiVideoBufferPoolClass
{
GstBufferPoolClass parent_class;
};
G_GNUC_INTERNAL
GType
gst_vaapi_video_buffer_pool_get_type(void) G_GNUC_CONST;
gst_vaapi_video_buffer_pool_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstBufferPool *
gst_vaapi_video_buffer_pool_new(GstVaapiDisplay *display) G_GNUC_CONST;
gst_vaapi_video_buffer_pool_new (GstVaapiDisplay * display) G_GNUC_CONST;
G_END_DECLS

View file

@ -31,18 +31,18 @@
GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
#define GST_VAAPI_TYPE_DISPLAY \
gst_vaapi_display_get_type()
gst_vaapi_display_get_type ()
GType
gst_vaapi_display_get_type (void)
G_GNUC_CONST;
gst_vaapi_display_get_type (void) G_GNUC_CONST;
G_DEFINE_BOXED_TYPE (GstVaapiDisplay, gst_vaapi_display,
(GBoxedCopyFunc) gst_vaapi_display_ref,
(GBoxedFreeFunc) gst_vaapi_display_unref)
(GBoxedFreeFunc) gst_vaapi_display_unref);
GstContext *gst_vaapi_video_context_new_with_display (GstVaapiDisplay *
display, gboolean persistent)
GstContext *
gst_vaapi_video_context_new_with_display (GstVaapiDisplay * display,
gboolean persistent)
{
GstContext *context;
GstStructure *structure;

View file

@ -34,8 +34,8 @@
#define GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME "gst.vaapi.Display"
/* Fake GstVideoContext symbols */
#define GST_VIDEO_CONTEXT(obj) (GST_ELEMENT(obj))
#define GST_IS_VIDEO_CONTEXT(obj) (GST_IS_ELEMENT(obj))
#define GST_VIDEO_CONTEXT(obj) (GST_ELEMENT (obj))
#define GST_IS_VIDEO_CONTEXT(obj) (GST_IS_ELEMENT (obj))
#define GstVideoContext GstElement
#define gst_video_context_prepare gst_vaapi_video_context_prepare

View file

@ -30,68 +30,68 @@
#include "gstvaapivideometa.h"
#if GST_CHECK_VERSION(1,0,0)
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
typedef gboolean (*GstSurfaceUploadFunction) (GstSurfaceConverter *,
GstBuffer *);
#else
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
typedef gboolean (*GstSurfaceUploadFunction) (GstSurfaceConverter *,
GstSurfaceBuffer *);
#endif
static void
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface);
gst_vaapi_video_converter_glx_iface_init (GstSurfaceConverterInterface * iface);
G_DEFINE_TYPE_WITH_CODE(
GstVaapiVideoConverterGLX,
G_DEFINE_TYPE_WITH_CODE (GstVaapiVideoConverterGLX,
gst_vaapi_video_converter_glx,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(GST_TYPE_SURFACE_CONVERTER,
gst_vaapi_video_converter_glx_iface_init))
G_IMPLEMENT_INTERFACE (GST_TYPE_SURFACE_CONVERTER,
gst_vaapi_video_converter_glx_iface_init));
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXPrivate))
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXPrivate))
struct _GstVaapiVideoConverterGLXPrivate {
GstVaapiTexture *texture;
struct _GstVaapiVideoConverterGLXPrivate
{
GstVaapiTexture *texture;
};
static gboolean
gst_vaapi_video_converter_glx_upload(GstSurfaceConverter *self,
GstBuffer *buffer);
gst_vaapi_video_converter_glx_upload (GstSurfaceConverter * self,
GstBuffer * buffer);
static void
gst_vaapi_video_converter_glx_dispose(GObject *object)
gst_vaapi_video_converter_glx_dispose (GObject * object)
{
GstVaapiVideoConverterGLXPrivate * const priv =
GST_VAAPI_VIDEO_CONVERTER_GLX(object)->priv;
GstVaapiVideoConverterGLXPrivate *const priv =
GST_VAAPI_VIDEO_CONVERTER_GLX (object)->priv;
gst_vaapi_texture_replace(&priv->texture, NULL);
gst_vaapi_texture_replace (&priv->texture, NULL);
G_OBJECT_CLASS(gst_vaapi_video_converter_glx_parent_class)->dispose(object);
G_OBJECT_CLASS (gst_vaapi_video_converter_glx_parent_class)->dispose (object);
}
static void
gst_vaapi_video_converter_glx_class_init(GstVaapiVideoConverterGLXClass *klass)
gst_vaapi_video_converter_glx_class_init (GstVaapiVideoConverterGLXClass *
klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private(klass, sizeof(GstVaapiVideoConverterGLXPrivate));
g_type_class_add_private (klass, sizeof (GstVaapiVideoConverterGLXPrivate));
object_class->dispose = gst_vaapi_video_converter_glx_dispose;
object_class->dispose = gst_vaapi_video_converter_glx_dispose;
}
static void
gst_vaapi_video_converter_glx_init(GstVaapiVideoConverterGLX *buffer)
gst_vaapi_video_converter_glx_init (GstVaapiVideoConverterGLX * buffer)
{
buffer->priv = GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE(buffer);
buffer->priv = GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE (buffer);
}
static void
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface)
gst_vaapi_video_converter_glx_iface_init (GstSurfaceConverterInterface * iface)
{
iface->upload = (GstSurfaceUploadFunction)
gst_vaapi_video_converter_glx_upload;
iface->upload = (GstSurfaceUploadFunction)
gst_vaapi_video_converter_glx_upload;
}
/**
@ -107,53 +107,53 @@ gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface)
* Return value: the newly allocated #GstBuffer, or %NULL on error
*/
GstSurfaceConverter *
gst_vaapi_video_converter_glx_new(GstBuffer *buffer, const gchar *type,
GValue *dest)
gst_vaapi_video_converter_glx_new (GstBuffer * buffer, const gchar * type,
GValue * dest)
{
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
GstVaapiTexture *texture;
GstVaapiVideoConverterGLX *converter;
GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
GstVaapiTexture *texture;
GstVaapiVideoConverterGLX *converter;
/* Check for "opengl" request, or chain up to X11 converter */
if (strcmp(type, "opengl") != 0 || !G_VALUE_HOLDS_UINT(dest))
return gst_vaapi_video_converter_x11_new(buffer, type, dest);
/* Check for "opengl" request, or chain up to X11 converter */
if (strcmp (type, "opengl") != 0 || !G_VALUE_HOLDS_UINT (dest))
return gst_vaapi_video_converter_x11_new (buffer, type, dest);
/* FIXME Should we assume target and format ? */
texture = gst_vaapi_texture_new_with_texture(
gst_vaapi_video_meta_get_display(meta),
g_value_get_uint(dest), GL_TEXTURE_2D, GL_BGRA);
if (!texture)
return NULL;
/* FIXME Should we assume target and format ? */
texture =
gst_vaapi_texture_new_with_texture (gst_vaapi_video_meta_get_display
(meta), g_value_get_uint (dest), GL_TEXTURE_2D, GL_BGRA);
if (!texture)
return NULL;
converter = g_object_new(GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, NULL);
converter->priv->texture = texture;
return GST_SURFACE_CONVERTER(converter);
converter = g_object_new (GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, NULL);
converter->priv->texture = texture;
return GST_SURFACE_CONVERTER (converter);
}
gboolean
gst_vaapi_video_converter_glx_upload(GstSurfaceConverter *self,
GstBuffer *buffer)
gst_vaapi_video_converter_glx_upload (GstSurfaceConverter * self,
GstBuffer * buffer)
{
GstVaapiVideoConverterGLXPrivate * const priv =
GST_VAAPI_VIDEO_CONVERTER_GLX(self)->priv;
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
GstVaapiSurface * const surface = gst_vaapi_video_meta_get_surface(meta);
GstVaapiDisplay *new_dpy, *old_dpy;
GstVaapiVideoConverterGLXPrivate *const priv =
GST_VAAPI_VIDEO_CONVERTER_GLX (self)->priv;
GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
GstVaapiSurface *const surface = gst_vaapi_video_meta_get_surface (meta);
GstVaapiDisplay *new_dpy, *old_dpy;
new_dpy = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface));
old_dpy = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(priv->texture));
new_dpy = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
old_dpy = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (priv->texture));
if (old_dpy != new_dpy) {
const guint texture = gst_vaapi_texture_get_id(priv->texture);
if (old_dpy != new_dpy) {
const guint texture = gst_vaapi_texture_get_id (priv->texture);
gst_vaapi_texture_replace(&priv->texture, NULL);
priv->texture = gst_vaapi_texture_new_with_texture(new_dpy,
texture, GL_TEXTURE_2D, GL_BGRA);
}
gst_vaapi_texture_replace (&priv->texture, NULL);
priv->texture = gst_vaapi_texture_new_with_texture (new_dpy,
texture, GL_TEXTURE_2D, GL_BGRA);
}
if (!gst_vaapi_apply_composition(surface, buffer))
GST_WARNING("could not update subtitles");
if (!gst_vaapi_apply_composition (surface, buffer))
GST_WARNING ("could not update subtitles");
return gst_vaapi_texture_put_surface(priv->texture, surface,
gst_vaapi_video_meta_get_render_flags(meta));
return gst_vaapi_texture_put_surface (priv->texture, surface,
gst_vaapi_video_meta_get_render_flags (meta));
}

View file

@ -31,43 +31,37 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX \
(gst_vaapi_video_converter_glx_get_type ())
#define GST_VAAPI_VIDEO_CONVERTER_GLX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLX))
#define GST_VAAPI_VIDEO_CONVERTER_GLX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXClass))
(gst_vaapi_video_converter_glx_get_type ())
#define GST_VAAPI_VIDEO_CONVERTER_GLX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLX))
#define GST_VAAPI_VIDEO_CONVERTER_GLX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXClass))
#define GST_VAAPI_IS_VIDEO_CONVERTER_GLX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
#define GST_VAAPI_IS_VIDEO_CONVERTER_GLX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXClass))
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
GstVaapiVideoConverterGLXClass))
typedef struct _GstVaapiVideoConverterGLX GstVaapiVideoConverterGLX;
typedef struct _GstVaapiVideoConverterGLXPrivate GstVaapiVideoConverterGLXPrivate;
typedef struct _GstVaapiVideoConverterGLXClass GstVaapiVideoConverterGLXClass;
typedef struct _GstVaapiVideoConverterGLX GstVaapiVideoConverterGLX;
typedef struct _GstVaapiVideoConverterGLXPrivate
GstVaapiVideoConverterGLXPrivate;
typedef struct _GstVaapiVideoConverterGLXClass GstVaapiVideoConverterGLXClass;
/**
* GstVaapiVideoConverterGLX:
*
* Converter to transform VA buffers into GL textures.
*/
struct _GstVaapiVideoConverterGLX {
/*< private >*/
GObject parent_instance;
struct _GstVaapiVideoConverterGLX
{
/*< private >*/
GObject parent_instance;
GstVaapiVideoConverterGLXPrivate *priv;
GstVaapiVideoConverterGLXPrivate *priv;
};
/**
@ -75,19 +69,20 @@ struct _GstVaapiVideoConverterGLX {
*
* Converter class to transform VA buffers into GL textures.
*/
struct _GstVaapiVideoConverterGLXClass {
/*< private >*/
GObjectClass parent_class;
struct _GstVaapiVideoConverterGLXClass
{
/*< private >*/
GObjectClass parent_class;
};
G_GNUC_INTERNAL
GType
gst_vaapi_video_converter_glx_get_type(void) G_GNUC_CONST;
gst_vaapi_video_converter_glx_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstSurfaceConverter *
gst_vaapi_video_converter_glx_new(GstBuffer *buffer, const gchar *type,
GValue *dest);
gst_vaapi_video_converter_glx_new (GstBuffer * buffer, const gchar * type,
GValue * dest);
G_END_DECLS

View file

@ -27,86 +27,86 @@
#include "gstvaapivideometa.h"
#if GST_CHECK_VERSION(1,0,0)
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
typedef gboolean (*GstSurfaceUploadFunction) (GstSurfaceConverter *,
GstBuffer *);
#else
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
typedef gboolean (*GstSurfaceUploadFunction) (GstSurfaceConverter *,
GstSurfaceBuffer *);
#endif
static void
gst_vaapi_video_converter_x11_iface_init(GstSurfaceConverterInterface *iface);
gst_vaapi_video_converter_x11_iface_init (GstSurfaceConverterInterface * iface);
G_DEFINE_TYPE_WITH_CODE(
GstVaapiVideoConverterX11,
G_DEFINE_TYPE_WITH_CODE (GstVaapiVideoConverterX11,
gst_vaapi_video_converter_x11,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(GST_TYPE_SURFACE_CONVERTER,
gst_vaapi_video_converter_x11_iface_init))
G_IMPLEMENT_INTERFACE (GST_TYPE_SURFACE_CONVERTER,
gst_vaapi_video_converter_x11_iface_init));
#define GST_VAAPI_VIDEO_CONVERTER_X11_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Private))
#define GST_VAAPI_VIDEO_CONVERTER_X11_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Private))
struct _GstVaapiVideoConverterX11Private {
GstVaapiPixmap *pixmap;
XID pixmap_id;
struct _GstVaapiVideoConverterX11Private
{
GstVaapiPixmap *pixmap;
XID pixmap_id;
};
static gboolean
gst_vaapi_video_converter_x11_upload(GstSurfaceConverter *self,
GstBuffer *buffer);
gst_vaapi_video_converter_x11_upload (GstSurfaceConverter * self,
GstBuffer * buffer);
static void
gst_vaapi_video_converter_x11_dispose(GObject *object)
gst_vaapi_video_converter_x11_dispose (GObject * object)
{
GstVaapiVideoConverterX11Private * const priv =
GST_VAAPI_VIDEO_CONVERTER_X11(object)->priv;
GstVaapiVideoConverterX11Private *const priv =
GST_VAAPI_VIDEO_CONVERTER_X11 (object)->priv;
gst_vaapi_pixmap_replace(&priv->pixmap, NULL);
gst_vaapi_pixmap_replace (&priv->pixmap, NULL);
G_OBJECT_CLASS(gst_vaapi_video_converter_x11_parent_class)->dispose(object);
G_OBJECT_CLASS (gst_vaapi_video_converter_x11_parent_class)->dispose (object);
}
static void
gst_vaapi_video_converter_x11_class_init(GstVaapiVideoConverterX11Class *klass)
gst_vaapi_video_converter_x11_class_init (GstVaapiVideoConverterX11Class *
klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private(klass, sizeof(GstVaapiVideoConverterX11Private));
g_type_class_add_private (klass, sizeof (GstVaapiVideoConverterX11Private));
object_class->dispose = gst_vaapi_video_converter_x11_dispose;
object_class->dispose = gst_vaapi_video_converter_x11_dispose;
}
static void
gst_vaapi_video_converter_x11_init(GstVaapiVideoConverterX11 *buffer)
gst_vaapi_video_converter_x11_init (GstVaapiVideoConverterX11 * buffer)
{
buffer->priv = GST_VAAPI_VIDEO_CONVERTER_X11_GET_PRIVATE(buffer);
buffer->priv = GST_VAAPI_VIDEO_CONVERTER_X11_GET_PRIVATE (buffer);
}
static void
gst_vaapi_video_converter_x11_iface_init(GstSurfaceConverterInterface *iface)
gst_vaapi_video_converter_x11_iface_init (GstSurfaceConverterInterface * iface)
{
iface->upload = (GstSurfaceUploadFunction)
gst_vaapi_video_converter_x11_upload;
iface->upload = (GstSurfaceUploadFunction)
gst_vaapi_video_converter_x11_upload;
}
static gboolean
set_pixmap(GstVaapiVideoConverterX11 *converter, GstVaapiDisplay *display,
set_pixmap (GstVaapiVideoConverterX11 * converter, GstVaapiDisplay * display,
XID pixmap_id)
{
GstVaapiVideoConverterX11Private * const priv = converter->priv;
GstVaapiPixmap *pixmap;
GstVaapiVideoConverterX11Private *const priv = converter->priv;
GstVaapiPixmap *pixmap;
pixmap = gst_vaapi_pixmap_x11_new_with_xid(display, pixmap_id);
if (!pixmap)
return FALSE;
pixmap = gst_vaapi_pixmap_x11_new_with_xid (display, pixmap_id);
if (!pixmap)
return FALSE;
gst_vaapi_pixmap_replace(&priv->pixmap, pixmap);
gst_vaapi_pixmap_unref(pixmap);
priv->pixmap_id = pixmap_id;
return TRUE;
gst_vaapi_pixmap_replace (&priv->pixmap, pixmap);
gst_vaapi_pixmap_unref (pixmap);
priv->pixmap_id = pixmap_id;
return TRUE;
}
/**
@ -122,73 +122,73 @@ set_pixmap(GstVaapiVideoConverterX11 *converter, GstVaapiDisplay *display,
* Return value: the newly allocated #GstBuffer, or %NULL on error
*/
GstSurfaceConverter *
gst_vaapi_video_converter_x11_new(GstBuffer *buffer, const gchar *type,
GValue *dest)
gst_vaapi_video_converter_x11_new (GstBuffer * buffer, const gchar * type,
GValue * dest)
{
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
GstVaapiVideoConverterX11 *converter;
GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
GstVaapiVideoConverterX11 *converter;
/* We only support X11 pixmap conversion */
if (strcmp(type, "x11-pixmap") != 0 || !G_VALUE_HOLDS_UINT(dest))
return NULL;
/* We only support X11 pixmap conversion */
if (strcmp (type, "x11-pixmap") != 0 || !G_VALUE_HOLDS_UINT (dest))
return NULL;
converter = g_object_new(GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, NULL);
if (!converter)
return NULL;
converter = g_object_new (GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, NULL);
if (!converter)
return NULL;
if (!set_pixmap(converter, gst_vaapi_video_meta_get_display(meta),
g_value_get_uint(dest)))
goto error;
return GST_SURFACE_CONVERTER(converter);
if (!set_pixmap (converter, gst_vaapi_video_meta_get_display (meta),
g_value_get_uint (dest)))
goto error;
return GST_SURFACE_CONVERTER (converter);
error:
g_object_unref(converter);
return NULL;
g_object_unref (converter);
return NULL;
}
gboolean
gst_vaapi_video_converter_x11_upload(GstSurfaceConverter *self,
GstBuffer *buffer)
gst_vaapi_video_converter_x11_upload (GstSurfaceConverter * self,
GstBuffer * buffer)
{
GstVaapiVideoConverterX11 * const converter =
GST_VAAPI_VIDEO_CONVERTER_X11(self);
GstVaapiVideoConverterX11Private * const priv = converter->priv;
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
const GstVaapiRectangle *crop_rect = NULL;
GstVaapiSurface *surface;
GstVaapiDisplay *old_display, *new_display;
GstVaapiVideoConverterX11 *const converter =
GST_VAAPI_VIDEO_CONVERTER_X11 (self);
GstVaapiVideoConverterX11Private *const priv = converter->priv;
GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
const GstVaapiRectangle *crop_rect = NULL;
GstVaapiSurface *surface;
GstVaapiDisplay *old_display, *new_display;
g_return_val_if_fail(meta != NULL, FALSE);
g_return_val_if_fail (meta != NULL, FALSE);
surface = gst_vaapi_video_meta_get_surface(meta);
if (!surface)
return FALSE;
surface = gst_vaapi_video_meta_get_surface (meta);
if (!surface)
return FALSE;
old_display = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(priv->pixmap));
new_display = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface));
old_display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (priv->pixmap));
new_display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
if (old_display != new_display) {
if (!set_pixmap(converter, new_display, priv->pixmap_id))
return FALSE;
}
if (old_display != new_display) {
if (!set_pixmap (converter, new_display, priv->pixmap_id))
return FALSE;
}
if (!gst_vaapi_apply_composition(surface, buffer))
GST_WARNING("could not update subtitles");
if (!gst_vaapi_apply_composition (surface, buffer))
GST_WARNING ("could not update subtitles");
#if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta * const crop_meta = gst_buffer_get_video_crop_meta(buffer);
if (crop_meta) {
GstVaapiRectangle crop_rect_tmp;
crop_rect = &crop_rect_tmp;
crop_rect_tmp.x = crop_meta->x;
crop_rect_tmp.y = crop_meta->y;
crop_rect_tmp.width = crop_meta->width;
crop_rect_tmp.height = crop_meta->height;
}
GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (buffer);
if (crop_meta) {
GstVaapiRectangle crop_rect_tmp;
crop_rect = &crop_rect_tmp;
crop_rect_tmp.x = crop_meta->x;
crop_rect_tmp.y = crop_meta->y;
crop_rect_tmp.width = crop_meta->width;
crop_rect_tmp.height = crop_meta->height;
}
#endif
if (!crop_rect)
crop_rect = gst_vaapi_video_meta_get_render_rect(meta);
if (!crop_rect)
crop_rect = gst_vaapi_video_meta_get_render_rect (meta);
return gst_vaapi_pixmap_put_surface(priv->pixmap, surface, crop_rect,
gst_vaapi_video_meta_get_render_flags(meta));
return gst_vaapi_pixmap_put_surface (priv->pixmap, surface, crop_rect,
gst_vaapi_video_meta_get_render_flags (meta));
}

View file

@ -29,43 +29,37 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_VIDEO_CONVERTER_X11 \
(gst_vaapi_video_converter_x11_get_type ())
#define GST_VAAPI_VIDEO_CONVERTER_X11(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11))
#define GST_VAAPI_VIDEO_CONVERTER_X11_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Class))
(gst_vaapi_video_converter_x11_get_type ())
#define GST_VAAPI_VIDEO_CONVERTER_X11(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11))
#define GST_VAAPI_VIDEO_CONVERTER_X11_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Class))
#define GST_VAAPI_IS_VIDEO_CONVERTER_X11(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11))
#define GST_VAAPI_IS_VIDEO_CONVERTER_X11_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11))
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11))
#define GST_VAAPI_VIDEO_CONVERTER_X11_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Class))
#define GST_VAAPI_VIDEO_CONVERTER_X11_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_VIDEO_CONVERTER_X11, \
GstVaapiVideoConverterX11Class))
typedef struct _GstVaapiVideoConverterX11 GstVaapiVideoConverterX11;
typedef struct _GstVaapiVideoConverterX11Private GstVaapiVideoConverterX11Private;
typedef struct _GstVaapiVideoConverterX11Class GstVaapiVideoConverterX11Class;
typedef struct _GstVaapiVideoConverterX11 GstVaapiVideoConverterX11;
typedef struct _GstVaapiVideoConverterX11Private
GstVaapiVideoConverterX11Private;
typedef struct _GstVaapiVideoConverterX11Class GstVaapiVideoConverterX11Class;
/**
* GstVaapiVideoConverterX11:
*
* Converter to transform VA buffers into GL textures.
*/
struct _GstVaapiVideoConverterX11 {
/*< private >*/
GObject parent_instance;
struct _GstVaapiVideoConverterX11
{
/*< private >*/
GObject parent_instance;
GstVaapiVideoConverterX11Private *priv;
GstVaapiVideoConverterX11Private *priv;
};
/**
@ -73,19 +67,20 @@ struct _GstVaapiVideoConverterX11 {
*
* Converter class to transform VA buffers into GL textures.
*/
struct _GstVaapiVideoConverterX11Class {
/*< private >*/
GObjectClass parent_class;
struct _GstVaapiVideoConverterX11Class
{
/*< private >*/
GObjectClass parent_class;
};
G_GNUC_INTERNAL
GType
gst_vaapi_video_converter_x11_get_type(void) G_GNUC_CONST;
gst_vaapi_video_converter_x11_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstSurfaceConverter *
gst_vaapi_video_converter_x11_new(GstBuffer *buffer, const gchar *type,
GValue *dest);
gst_vaapi_video_converter_x11_new (GstBuffer * buffer, const gchar * type,
GValue * dest);
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -31,16 +31,16 @@
G_BEGIN_DECLS
typedef struct _GstVaapiVideoMemory GstVaapiVideoMemory;
typedef struct _GstVaapiVideoAllocator GstVaapiVideoAllocator;
typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
typedef struct _GstVaapiVideoMemory GstVaapiVideoMemory;
typedef struct _GstVaapiVideoAllocator GstVaapiVideoAllocator;
typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
/* ------------------------------------------------------------------------ */
/* --- GstVaapiVideoMemory --- */
/* ------------------------------------------------------------------------ */
#define GST_VAAPI_VIDEO_MEMORY_CAST(mem) \
((GstVaapiVideoMemory *)(mem))
((GstVaapiVideoMemory *) (mem))
#define GST_VAAPI_VIDEO_MEMORY_NAME "GstVaapiVideoMemory"
@ -59,10 +59,11 @@ typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
*
* The set of all #GstVaapiVideoMemory map types.
*/
typedef enum {
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE = 1,
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_PLANAR,
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR
typedef enum
{
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE = 1,
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_PLANAR,
GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR
} GstVaapiVideoMemoryMapType;
/**
@ -71,56 +72,54 @@ typedef enum {
* A VA video memory object holder, including VA surfaces, images and
* proxies.
*/
struct _GstVaapiVideoMemory {
GstMemory parent_instance;
struct _GstVaapiVideoMemory
{
GstMemory parent_instance;
/*< private >*/
GstVaapiSurfaceProxy *proxy;
const GstVideoInfo *surface_info;
GstVaapiSurface *surface;
const GstVideoInfo *image_info;
GstVaapiImage *image;
GstVaapiVideoMeta *meta;
guint map_type;
gint map_count;
gboolean use_direct_rendering;
/*< private >*/
GstVaapiSurfaceProxy *proxy;
const GstVideoInfo *surface_info;
GstVaapiSurface *surface;
const GstVideoInfo *image_info;
GstVaapiImage *image;
GstVaapiVideoMeta *meta;
guint map_type;
gint map_count;
gboolean use_direct_rendering;
};
G_GNUC_INTERNAL
GstMemory *
gst_vaapi_video_memory_new(GstAllocator *allocator, GstVaapiVideoMeta *meta);
gst_vaapi_video_memory_new (GstAllocator * allocator, GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
gboolean
gst_video_meta_map_vaapi_memory(GstVideoMeta *meta, guint plane,
GstMapInfo *info, gpointer *data, gint *stride, GstMapFlags flags);
gst_video_meta_map_vaapi_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags);
G_GNUC_INTERNAL
gboolean
gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane,
GstMapInfo *info);
gst_video_meta_unmap_vaapi_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info);
G_GNUC_INTERNAL
void
gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem);
gst_vaapi_video_memory_reset_surface (GstVaapiVideoMemory * mem);
/* ------------------------------------------------------------------------ */
/* --- GstVaapiVideoAllocator --- */
/* ------------------------------------------------------------------------ */
#define GST_VAAPI_VIDEO_ALLOCATOR_CAST(allocator) \
((GstVaapiVideoAllocator *)(allocator))
((GstVaapiVideoAllocator *) (allocator))
#define GST_VAAPI_TYPE_VIDEO_ALLOCATOR \
(gst_vaapi_video_allocator_get_type())
#define GST_VAAPI_VIDEO_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_VIDEO_ALLOCATOR, \
GstVaapiVideoAllocator))
(gst_vaapi_video_allocator_get_type ())
#define GST_VAAPI_VIDEO_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_ALLOCATOR, \
GstVaapiVideoAllocator))
#define GST_VAAPI_IS_VIDEO_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_ALLOCATOR))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_ALLOCATOR))
#define GST_VAAPI_VIDEO_ALLOCATOR_NAME "GstVaapiVideoAllocator"
@ -129,16 +128,17 @@ gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem);
*
* A VA video memory allocator object.
*/
struct _GstVaapiVideoAllocator {
GstAllocator parent_instance;
struct _GstVaapiVideoAllocator
{
GstAllocator parent_instance;
/*< private >*/
GstVideoInfo video_info;
GstVideoInfo surface_info;
GstVaapiVideoPool *surface_pool;
GstVideoInfo image_info;
GstVaapiVideoPool *image_pool;
gboolean has_direct_rendering;
/*< private >*/
GstVideoInfo video_info;
GstVideoInfo surface_info;
GstVaapiVideoPool *surface_pool;
GstVideoInfo image_info;
GstVaapiVideoPool *image_pool;
gboolean has_direct_rendering;
};
/**
@ -146,18 +146,19 @@ struct _GstVaapiVideoAllocator {
*
* A VA video memory allocator class.
*/
struct _GstVaapiVideoAllocatorClass {
GstAllocatorClass parent_class;
struct _GstVaapiVideoAllocatorClass
{
GstAllocatorClass parent_class;
};
G_GNUC_INTERNAL
GType
gst_vaapi_video_allocator_get_type(void) G_GNUC_CONST;
gst_vaapi_video_allocator_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstAllocator *
gst_vaapi_video_allocator_new(GstVaapiDisplay *display,
const GstVideoInfo *vip);
gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
const GstVideoInfo * vip);
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -33,112 +33,114 @@
G_BEGIN_DECLS
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta;
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta;
#if GST_CHECK_VERSION(1,0,0)
#define GST_VAAPI_VIDEO_META_API_TYPE \
gst_vaapi_video_meta_api_get_type()
gst_vaapi_video_meta_api_get_type ()
G_GNUC_INTERNAL
GType
gst_vaapi_video_meta_api_get_type(void) G_GNUC_CONST;
gst_vaapi_video_meta_api_get_type (void) G_GNUC_CONST;
#endif
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_copy(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_copy (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new(GstVaapiDisplay *display);
gst_vaapi_video_meta_new (GstVaapiDisplay * display);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_from_pool(GstVaapiVideoPool *pool);
gst_vaapi_video_meta_new_from_pool (GstVaapiVideoPool * pool);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_with_image(GstVaapiImage *image);
gst_vaapi_video_meta_new_with_image (GstVaapiImage * image);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy);
gst_vaapi_video_meta_new_with_surface_proxy (GstVaapiSurfaceProxy * proxy);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_ref(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_ref (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_unref(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_unref (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_replace(GstVaapiVideoMeta **old_meta_ptr,
GstVaapiVideoMeta *new_meta);
gst_vaapi_video_meta_replace (GstVaapiVideoMeta ** old_meta_ptr,
GstVaapiVideoMeta * new_meta);
G_GNUC_INTERNAL
GstVaapiDisplay *
gst_vaapi_video_meta_get_display(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_display (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
GstVaapiImage *
gst_vaapi_video_meta_get_image(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_image (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_image(GstVaapiVideoMeta *meta, GstVaapiImage *image);
gst_vaapi_video_meta_set_image (GstVaapiVideoMeta * meta,
GstVaapiImage * image);
G_GNUC_INTERNAL
gboolean
gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta,
GstVaapiVideoPool *pool);
gst_vaapi_video_meta_set_image_from_pool (GstVaapiVideoMeta * meta,
GstVaapiVideoPool * pool);
G_GNUC_INTERNAL
GstVaapiSurface *
gst_vaapi_video_meta_get_surface(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_surface (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
GstVaapiSurfaceProxy *
gst_vaapi_video_meta_get_surface_proxy(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_surface_proxy (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_surface_proxy(GstVaapiVideoMeta *meta,
GstVaapiSurfaceProxy *proxy);
gst_vaapi_video_meta_set_surface_proxy (GstVaapiVideoMeta * meta,
GstVaapiSurfaceProxy * proxy);
G_GNUC_INTERNAL
GFunc
gst_vaapi_video_meta_get_surface_converter(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_surface_converter (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_surface_converter(GstVaapiVideoMeta *meta, GFunc func);
gst_vaapi_video_meta_set_surface_converter (GstVaapiVideoMeta * meta,
GFunc func);
G_GNUC_INTERNAL
guint
gst_vaapi_video_meta_get_render_flags(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_render_flags (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags);
gst_vaapi_video_meta_set_render_flags (GstVaapiVideoMeta * meta, guint flags);
G_GNUC_INTERNAL
const GstVaapiRectangle *
gst_vaapi_video_meta_get_render_rect(GstVaapiVideoMeta *meta);
gst_vaapi_video_meta_get_render_rect (GstVaapiVideoMeta * meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_render_rect(GstVaapiVideoMeta *meta,
const GstVaapiRectangle *rect);
gst_vaapi_video_meta_set_render_rect (GstVaapiVideoMeta * meta,
const GstVaapiRectangle * rect);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_buffer_get_vaapi_video_meta(GstBuffer *buffer);
gst_buffer_get_vaapi_video_meta (GstBuffer * buffer);
G_GNUC_INTERNAL
void
gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta);
gst_buffer_set_vaapi_video_meta (GstBuffer * buffer, GstVaapiVideoMeta * meta);
G_END_DECLS

View file

@ -30,108 +30,110 @@
#include "gstvaapipluginutil.h"
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
struct _GstVaapiVideoMetaTexture {
GstVaapiTexture *texture;
struct _GstVaapiVideoMetaTexture
{
GstVaapiTexture *texture;
};
static void
meta_texture_free(GstVaapiVideoMetaTexture *meta)
meta_texture_free (GstVaapiVideoMetaTexture * meta)
{
if (G_UNLIKELY(!meta))
return;
if (G_UNLIKELY (!meta))
return;
gst_vaapi_texture_replace(&meta->texture, NULL);
g_slice_free(GstVaapiVideoMetaTexture, meta);
gst_vaapi_texture_replace (&meta->texture, NULL);
g_slice_free (GstVaapiVideoMetaTexture, meta);
}
static GstVaapiVideoMetaTexture *
meta_texture_new(void)
meta_texture_new (void)
{
GstVaapiVideoMetaTexture *meta;
GstVaapiVideoMetaTexture *meta;
meta = g_slice_new(GstVaapiVideoMetaTexture);
if (!meta)
return NULL;
meta = g_slice_new (GstVaapiVideoMetaTexture);
if (!meta)
return NULL;
meta->texture = NULL;
return meta;
meta->texture = NULL;
return meta;
}
static GstVaapiVideoMetaTexture *
meta_texture_copy(GstVaapiVideoMetaTexture *meta)
meta_texture_copy (GstVaapiVideoMetaTexture * meta)
{
GstVaapiVideoMetaTexture *copy;
GstVaapiVideoMetaTexture *copy;
copy = meta_texture_new();
if (!copy)
return NULL;
copy = meta_texture_new ();
if (!copy)
return NULL;
gst_vaapi_texture_replace(&copy->texture, meta->texture);
return copy;
gst_vaapi_texture_replace (&copy->texture, meta->texture);
return copy;
}
static gboolean
gst_vaapi_texture_upload(GstVideoGLTextureUploadMeta *meta, guint texture_id[4])
gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta,
guint texture_id[4])
{
GstVaapiVideoMeta * const vmeta =
gst_buffer_get_vaapi_video_meta(meta->buffer);
GstVaapiVideoMetaTexture * const meta_texture = meta->user_data;
GstVaapiSurface * const surface = gst_vaapi_video_meta_get_surface(vmeta);
GstVaapiDisplay * const dpy = GST_VAAPI_OBJECT_DISPLAY(surface);
GstVaapiVideoMeta *const vmeta =
gst_buffer_get_vaapi_video_meta (meta->buffer);
GstVaapiVideoMetaTexture *const meta_texture = meta->user_data;
GstVaapiSurface *const surface = gst_vaapi_video_meta_get_surface (vmeta);
GstVaapiDisplay *const dpy = GST_VAAPI_OBJECT_DISPLAY (surface);
if (gst_vaapi_display_get_display_type(dpy) != GST_VAAPI_DISPLAY_TYPE_GLX)
return FALSE;
if (gst_vaapi_display_get_display_type (dpy) != GST_VAAPI_DISPLAY_TYPE_GLX)
return FALSE;
if (!meta_texture->texture ||
/* Check whether VA display changed */
GST_VAAPI_OBJECT_DISPLAY(meta_texture->texture) != dpy ||
/* Check whether texture id changed */
gst_vaapi_texture_get_id(meta_texture->texture) != texture_id[0]) {
/* FIXME: should we assume target? */
GstVaapiTexture * const texture =
gst_vaapi_texture_new_with_texture(dpy, texture_id[0],
GL_TEXTURE_2D, GL_RGBA);
gst_vaapi_texture_replace(&meta_texture->texture, texture);
if (!texture)
return FALSE;
gst_vaapi_texture_unref(texture);
}
return gst_vaapi_texture_put_surface(meta_texture->texture, surface,
gst_vaapi_video_meta_get_render_flags(vmeta));
if (!meta_texture->texture ||
/* Check whether VA display changed */
GST_VAAPI_OBJECT_DISPLAY (meta_texture->texture) != dpy ||
/* Check whether texture id changed */
gst_vaapi_texture_get_id (meta_texture->texture) != texture_id[0]) {
/* FIXME: should we assume target? */
GstVaapiTexture *const texture =
gst_vaapi_texture_new_with_texture (dpy, texture_id[0],
GL_TEXTURE_2D, GL_RGBA);
gst_vaapi_texture_replace (&meta_texture->texture, texture);
if (!texture)
return FALSE;
gst_vaapi_texture_unref (texture);
}
return gst_vaapi_texture_put_surface (meta_texture->texture, surface,
gst_vaapi_video_meta_get_render_flags (vmeta));
}
gboolean
gst_buffer_add_texture_upload_meta(GstBuffer *buffer)
gst_buffer_add_texture_upload_meta (GstBuffer * buffer)
{
GstVideoGLTextureUploadMeta *meta = NULL;
GstVideoGLTextureType tex_type[] = { GST_VIDEO_GL_TEXTURE_TYPE_RGBA };
GstVaapiVideoMetaTexture *meta_texture;
GstVideoGLTextureUploadMeta *meta = NULL;
GstVideoGLTextureType tex_type[] = { GST_VIDEO_GL_TEXTURE_TYPE_RGBA };
GstVaapiVideoMetaTexture *meta_texture;
if (!buffer)
return FALSE;
if (!buffer)
return FALSE;
meta_texture = meta_texture_new();
if (!meta_texture)
return FALSE;
meta_texture = meta_texture_new ();
if (!meta_texture)
return FALSE;
meta = gst_buffer_add_video_gl_texture_upload_meta(buffer,
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
1, tex_type, gst_vaapi_texture_upload,
meta_texture, (GBoxedCopyFunc)meta_texture_copy,
(GBoxedFreeFunc)meta_texture_free);
if (!meta)
goto error;
return TRUE;
meta = gst_buffer_add_video_gl_texture_upload_meta (buffer,
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
1, tex_type, gst_vaapi_texture_upload,
meta_texture, (GBoxedCopyFunc) meta_texture_copy,
(GBoxedFreeFunc) meta_texture_free);
if (!meta)
goto error;
return TRUE;
error:
meta_texture_free(meta_texture);
return FALSE;
meta_texture_free (meta_texture);
return FALSE;
}
gboolean
gst_buffer_ensure_texture_upload_meta(GstBuffer *buffer)
gst_buffer_ensure_texture_upload_meta (GstBuffer * buffer)
{
return gst_buffer_get_video_gl_texture_upload_meta(buffer) ||
gst_buffer_add_texture_upload_meta(buffer);
return gst_buffer_get_video_gl_texture_upload_meta (buffer) ||
gst_buffer_add_texture_upload_meta (buffer);
}
#endif

View file

@ -31,15 +31,15 @@
G_BEGIN_DECLS
typedef struct _GstVaapiVideoMetaTexture GstVaapiVideoMetaTexture;
typedef struct _GstVaapiVideoMetaTexture GstVaapiVideoMetaTexture;
G_GNUC_INTERNAL
gboolean
gst_buffer_add_texture_upload_meta(GstBuffer *buffer);
gst_buffer_add_texture_upload_meta (GstBuffer * buffer);
G_GNUC_INTERNAL
gboolean
gst_buffer_ensure_texture_upload_meta(GstBuffer *buffer);
gst_buffer_ensure_texture_upload_meta (GstBuffer * buffer);
G_END_DECLS