2013-01-05 07:31:24 +00:00
|
|
|
/*
|
|
|
|
* gstvaapivideometa.c - Gst VA video meta
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-01-05 07:31:24 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2013-01-05 07:31:24 +00:00
|
|
|
*
|
|
|
|
* This library 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 library 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 library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstvaapivideometa
|
|
|
|
* @short_description: VA video meta for GStreamer
|
2016-10-27 09:06:06 +00:00
|
|
|
*
|
|
|
|
* Describes a #GstMeta for VA-base video buffers.
|
2013-01-05 07:31:24 +00:00
|
|
|
*/
|
|
|
|
|
2015-04-03 14:08:30 +00:00
|
|
|
#include "gstcompat.h"
|
2013-03-26 09:31:10 +00:00
|
|
|
#include <gst/vaapi/gstvaapiimagepool.h>
|
|
|
|
#include <gst/vaapi/gstvaapisurfacepool.h>
|
2013-01-05 07:31:24 +00:00
|
|
|
#include "gstvaapivideometa.h"
|
2015-04-03 13:55:27 +00:00
|
|
|
#include "gstvaapivideomemory.h"
|
2014-11-21 14:23:13 +00:00
|
|
|
|
2013-01-05 07:31:24 +00:00
|
|
|
#define GST_VAAPI_VIDEO_META(obj) \
|
2014-08-21 08:45:31 +00:00
|
|
|
((GstVaapiVideoMeta *) (obj))
|
2013-01-05 07:31:24 +00:00
|
|
|
#define GST_VAAPI_IS_VIDEO_META(obj) \
|
2014-08-21 08:45:31 +00:00
|
|
|
(GST_VAAPI_VIDEO_META (obj) != NULL)
|
|
|
|
|
|
|
|
struct _GstVaapiVideoMeta
|
|
|
|
{
|
2014-11-21 14:23:13 +00:00
|
|
|
GstBuffer *buffer;
|
2014-08-21 08:45:31 +00:00
|
|
|
gint ref_count;
|
|
|
|
GstVaapiDisplay *display;
|
|
|
|
GstVaapiVideoPool *image_pool;
|
|
|
|
GstVaapiImage *image;
|
|
|
|
GstVaapiSurfaceProxy *proxy;
|
|
|
|
GFunc converter;
|
|
|
|
guint render_flags;
|
|
|
|
GstVaapiRectangle render_rect;
|
|
|
|
guint has_render_rect:1;
|
2013-01-05 07:31:24 +00:00
|
|
|
};
|
|
|
|
|
2014-11-21 14:23:13 +00:00
|
|
|
static gboolean
|
|
|
|
ensure_surface_proxy (GstVaapiVideoMeta * meta)
|
|
|
|
{
|
|
|
|
if (!meta->proxy)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (meta->buffer) {
|
|
|
|
GstMemory *const mem = gst_buffer_peek_memory (meta->buffer, 0);
|
|
|
|
|
|
|
|
if (GST_VAAPI_IS_VIDEO_MEMORY (mem))
|
|
|
|
return gst_vaapi_video_memory_sync (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-06 12:43:38 +00:00
|
|
|
static inline void
|
2014-08-21 08:45:31 +00:00
|
|
|
set_display (GstVaapiVideoMeta * meta, GstVaapiDisplay * display)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_display_replace (&meta->display, display);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-08-21 08:45:31 +00:00
|
|
|
set_image (GstVaapiVideoMeta * meta, GstVaapiImage * image)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2019-12-18 11:57:01 +00:00
|
|
|
meta->image =
|
|
|
|
(GstVaapiImage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (image));
|
|
|
|
set_display (meta, gst_vaapi_image_get_display (image));
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-23 16:56:43 +00:00
|
|
|
static gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
set_image_from_pool (GstVaapiVideoMeta * meta, GstVaapiVideoPool * pool)
|
2013-05-23 16:56:43 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiImage *image;
|
2013-05-23 16:56:43 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
image = gst_vaapi_video_pool_get_object (pool);
|
|
|
|
if (!image)
|
|
|
|
return FALSE;
|
2013-11-28 16:28:11 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
set_image (meta, image);
|
|
|
|
meta->image_pool = gst_vaapi_video_pool_ref (pool);
|
|
|
|
return TRUE;
|
2013-05-23 16:56:43 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 15:37:31 +00:00
|
|
|
static gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
set_surface_proxy (GstVaapiVideoMeta * meta, GstVaapiSurfaceProxy * proxy)
|
2013-11-28 15:37:31 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiSurface *surface;
|
2013-11-28 15:37:31 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
surface = GST_VAAPI_SURFACE_PROXY_SURFACE (proxy);
|
|
|
|
if (!surface)
|
|
|
|
return FALSE;
|
2013-11-28 15:37:31 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->proxy = gst_vaapi_surface_proxy_ref (proxy);
|
2019-12-19 13:19:10 +00:00
|
|
|
set_display (meta, gst_vaapi_surface_get_display (surface));
|
2014-08-21 08:45:31 +00:00
|
|
|
return TRUE;
|
2013-11-28 15:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
set_surface_proxy_from_pool (GstVaapiVideoMeta * meta, GstVaapiVideoPool * pool)
|
2013-11-28 15:37:31 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiSurfaceProxy *proxy;
|
|
|
|
gboolean success;
|
2013-11-28 15:37:31 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
proxy = gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL (pool));
|
|
|
|
if (!proxy)
|
|
|
|
return FALSE;
|
2013-11-28 15:37:31 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
success = set_surface_proxy (meta, proxy);
|
|
|
|
gst_vaapi_surface_proxy_unref (proxy);
|
|
|
|
return success;
|
2013-11-28 15:37:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 07:31:24 +00:00
|
|
|
static void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_image (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
if (meta->image) {
|
|
|
|
if (meta->image_pool)
|
|
|
|
gst_vaapi_video_pool_put_object (meta->image_pool, meta->image);
|
2019-12-18 11:57:01 +00:00
|
|
|
gst_vaapi_image_unref (meta->image);
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->image = NULL;
|
|
|
|
}
|
|
|
|
gst_vaapi_video_pool_replace (&meta->image_pool, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 16:28:11 +00:00
|
|
|
static inline void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_proxy (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_surface_proxy_replace (&meta->proxy, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_finalize (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_image (meta);
|
|
|
|
gst_vaapi_video_meta_destroy_proxy (meta);
|
|
|
|
gst_vaapi_display_replace (&meta->display, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_init (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-11-21 14:23:13 +00:00
|
|
|
meta->buffer = NULL;
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->ref_count = 1;
|
|
|
|
meta->display = NULL;
|
|
|
|
meta->image_pool = NULL;
|
|
|
|
meta->image = NULL;
|
|
|
|
meta->proxy = NULL;
|
|
|
|
meta->converter = NULL;
|
|
|
|
meta->render_flags = 0;
|
|
|
|
meta->has_render_rect = FALSE;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 15:36:45 +00:00
|
|
|
static inline GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
_gst_vaapi_video_meta_create (void)
|
2013-04-04 15:36:45 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
return g_slice_new (GstVaapiVideoMeta);
|
2013-04-04 15:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-08-21 08:45:31 +00:00
|
|
|
_gst_vaapi_video_meta_destroy (GstVaapiVideoMeta * meta)
|
2013-04-04 15:36:45 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_slice_free1 (sizeof (*meta), meta);
|
2013-04-04 15:36:45 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 07:31:24 +00:00
|
|
|
static inline GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
_gst_vaapi_video_meta_new (void)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta = _gst_vaapi_video_meta_create ();
|
|
|
|
if (!meta)
|
|
|
|
return NULL;
|
|
|
|
gst_vaapi_video_meta_init (meta);
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-03-26 09:31:10 +00:00
|
|
|
static inline void
|
2014-08-21 08:45:31 +00:00
|
|
|
_gst_vaapi_video_meta_free (GstVaapiVideoMeta * meta)
|
2013-03-26 09:31:10 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_atomic_int_inc (&meta->ref_count);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_finalize (meta);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (G_LIKELY (g_atomic_int_dec_and_test (&meta->ref_count)))
|
|
|
|
_gst_vaapi_video_meta_destroy (meta);
|
2013-04-04 15:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_copy:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Creates a copy of #GstVaapiVideoMeta object @meta. The original
|
|
|
|
* @meta object shall not contain any VA objects created from a
|
|
|
|
* #GstVaapiVideoPool.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoMeta, or %NULL on error
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_copy (GstVaapiVideoMeta * meta)
|
2013-04-04 15:36:45 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *copy;
|
2013-04-04 15:36:45 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-04-04 15:36:45 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (meta->image_pool)
|
|
|
|
return NULL;
|
2013-04-04 15:36:45 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
copy = _gst_vaapi_video_meta_create ();
|
|
|
|
if (!copy)
|
|
|
|
return NULL;
|
2013-04-04 15:36:45 +00:00
|
|
|
|
2014-11-21 14:23:13 +00:00
|
|
|
copy->buffer = NULL;
|
2014-08-21 08:45:31 +00:00
|
|
|
copy->ref_count = 1;
|
2018-06-13 16:00:18 +00:00
|
|
|
copy->display = gst_object_ref (meta->display);
|
2014-08-21 08:45:31 +00:00
|
|
|
copy->image_pool = NULL;
|
2019-12-18 11:57:01 +00:00
|
|
|
copy->image = meta->image ? (GstVaapiImage *)
|
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT_CAST (meta->image)) : NULL;
|
2014-08-21 08:45:31 +00:00
|
|
|
copy->proxy = meta->proxy ? gst_vaapi_surface_proxy_copy (meta->proxy) : NULL;
|
|
|
|
copy->converter = meta->converter;
|
|
|
|
copy->render_flags = meta->render_flags;
|
2013-02-15 16:24:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
copy->has_render_rect = meta->has_render_rect;
|
|
|
|
if (copy->has_render_rect)
|
|
|
|
copy->render_rect = meta->render_rect;
|
|
|
|
return copy;
|
2013-03-26 09:31:10 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 07:31:24 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_new:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Creates an empty #GstVaapiVideoMeta. The caller is responsible for completing
|
|
|
|
* the initialization of the meta with the gst_vaapi_video_meta_set_*()
|
|
|
|
* functions.
|
|
|
|
*
|
|
|
|
* This function shall only be called from within gstreamer-vaapi
|
|
|
|
* plugin elements.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoMeta, or %NULL or error
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_new (GstVaapiDisplay * display)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta = _gst_vaapi_video_meta_new ();
|
|
|
|
if (G_UNLIKELY (!meta))
|
|
|
|
return NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
set_display (meta, display);
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_new_from_pool:
|
|
|
|
* @pool: a #GstVaapiVideoPool
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiVideoMeta with a video object allocated from a @pool.
|
|
|
|
* Only #GstVaapiSurfacePool and #GstVaapiImagePool pools are supported.
|
|
|
|
*
|
|
|
|
* The meta object is destroyed through the last call to
|
|
|
|
* gst_vaapi_video_meta_unref() and the video objects are pushed back
|
|
|
|
* to their respective pools.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoMeta, or %NULL on error
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_new_from_pool (GstVaapiVideoPool * pool)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
|
|
|
GstVaapiVideoPoolObjectType object_type;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (pool != NULL, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta = _gst_vaapi_video_meta_new ();
|
|
|
|
if (G_UNLIKELY (!meta))
|
|
|
|
return NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
object_type = gst_vaapi_video_pool_get_object_type (pool);
|
|
|
|
switch (object_type) {
|
2013-05-23 16:56:43 +00:00
|
|
|
case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE:
|
2014-08-21 08:45:31 +00:00
|
|
|
if (!set_image_from_pool (meta, pool))
|
|
|
|
goto error;
|
|
|
|
break;
|
2013-05-23 16:56:43 +00:00
|
|
|
case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE:
|
2014-08-21 08:45:31 +00:00
|
|
|
if (!set_surface_proxy_from_pool (meta, pool))
|
2013-12-03 15:11:46 +00:00
|
|
|
goto error;
|
2014-08-21 08:45:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_ERROR ("unsupported video buffer pool of type %d", object_type);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
set_display (meta, gst_vaapi_video_pool_get_display (pool));
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2016-10-20 16:12:04 +00:00
|
|
|
/* ERRORS */
|
2013-01-05 07:31:24 +00:00
|
|
|
error:
|
2016-10-20 16:12:04 +00:00
|
|
|
{
|
|
|
|
gst_vaapi_video_meta_unref (meta);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_new_with_image:
|
|
|
|
* @image: a #GstVaapiImage
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiVideoMeta with the specified @image. The resulting
|
|
|
|
* meta holds an additional reference to the @image.
|
|
|
|
*
|
|
|
|
* This function shall only be called from within gstreamer-vaapi
|
|
|
|
* plugin elements.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoMeta, or %NULL on error
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_new_with_image (GstVaapiImage * image)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (image != NULL, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta = _gst_vaapi_video_meta_new ();
|
|
|
|
if (G_UNLIKELY (!meta))
|
|
|
|
return NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_image (meta, image);
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_new_with_surface_proxy:
|
|
|
|
* @proxy: a #GstVaapiSurfaceProxy
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiVideoMeta with the specified surface @proxy. The
|
|
|
|
* resulting meta holds an additional reference to the @proxy.
|
|
|
|
*
|
|
|
|
* This function shall only be called from within gstreamer-vaapi
|
|
|
|
* plugin elements.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoMeta, or %NULL on error
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_new_with_surface_proxy (GstVaapiSurfaceProxy * proxy)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (proxy != NULL, NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta = _gst_vaapi_video_meta_new ();
|
|
|
|
if (G_UNLIKELY (!meta))
|
|
|
|
return NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_surface_proxy (meta, proxy);
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_ref:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Atomically increases the reference count of the given @meta by one.
|
|
|
|
*
|
|
|
|
* Returns: The same @meta argument
|
|
|
|
*/
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_ref (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (meta != NULL, NULL);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_atomic_int_inc (&meta->ref_count);
|
|
|
|
return meta;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_unref:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Atomically decreases the reference count of the @meta by one. If
|
|
|
|
* the reference count reaches zero, the object will be free'd.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_unref (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (meta != NULL);
|
|
|
|
g_return_if_fail (meta->ref_count > 0);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (g_atomic_int_dec_and_test (&meta->ref_count))
|
|
|
|
_gst_vaapi_video_meta_free (meta);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_replace:
|
|
|
|
* @old_meta_ptr: a pointer to a #GstVaapiVideoMeta
|
|
|
|
* @new_meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* @new_meta. This means that @old_meta_ptr shall reference a valid
|
|
|
|
* Atomically replaces the meta object held in @old_meta_ptr with
|
|
|
|
* object. However, @new_meta can be NULL.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_replace (GstVaapiVideoMeta ** old_meta_ptr,
|
|
|
|
GstVaapiVideoMeta * new_meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstVaapiVideoMeta *old_meta;
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (old_meta_ptr != NULL);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
old_meta = g_atomic_pointer_get ((gpointer *) old_meta_ptr);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (old_meta == new_meta)
|
|
|
|
return;
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (new_meta)
|
|
|
|
gst_vaapi_video_meta_ref (new_meta);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
while (!g_atomic_pointer_compare_and_exchange ((gpointer *) old_meta_ptr,
|
|
|
|
old_meta, new_meta))
|
|
|
|
old_meta = g_atomic_pointer_get ((gpointer *) old_meta_ptr);
|
2013-03-26 09:31:10 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (old_meta)
|
|
|
|
gst_vaapi_video_meta_unref (old_meta);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_display:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the #GstVaapiDisplay the @meta is bound to. The @meta
|
|
|
|
* owns the returned #GstVaapiDisplay object so the caller is
|
|
|
|
* responsible for calling g_object_ref() when needed.
|
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiDisplay the @meta is bound to
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_display (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
return meta->display;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_image:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the #GstVaapiImage bound to the @meta. The @meta owns
|
|
|
|
* the #GstVaapiImage so the caller is responsible for calling
|
2019-12-18 11:57:01 +00:00
|
|
|
* gst_mini_object_ref() when needed.
|
2013-01-05 07:31:24 +00:00
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiImage bound to the @meta, or %NULL if
|
|
|
|
* there is none
|
|
|
|
*/
|
|
|
|
GstVaapiImage *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_image (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
return meta->image;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_set_image:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
* @image: a #GstVaapiImage
|
|
|
|
*
|
|
|
|
* Binds @image to the @meta. If the @meta contains another image
|
|
|
|
* previously allocated from a pool, it's pushed back to its parent
|
|
|
|
* pool and the pool is also released.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_image (GstVaapiVideoMeta * meta, GstVaapiImage * image)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_image (meta);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (image)
|
|
|
|
set_image (meta, image);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_set_image_from_pool
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
* @pool: a #GstVaapiVideoPool
|
|
|
|
*
|
|
|
|
* Binds a newly allocated video object from the @pool. The @pool
|
|
|
|
* shall be of type #GstVaapiImagePool. Previously allocated objects
|
|
|
|
* are released and returned to their parent pools, if any.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE on success
|
|
|
|
*/
|
|
|
|
gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_image_from_pool (GstVaapiVideoMeta * meta,
|
|
|
|
GstVaapiVideoPool * pool)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), FALSE);
|
|
|
|
g_return_val_if_fail (pool != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (gst_vaapi_video_pool_get_object_type (pool) ==
|
|
|
|
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE, FALSE);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_image (meta);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
return set_image_from_pool (meta, pool);
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_surface:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the #GstVaapiSurface bound to the @meta. The @meta
|
|
|
|
* owns the #GstVaapiSurface so the caller is responsible for calling
|
2019-12-18 11:57:01 +00:00
|
|
|
* gst_mini_object_ref() when needed.
|
2013-01-05 07:31:24 +00:00
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiSurface bound to the @meta, or %NULL if
|
|
|
|
* there is none
|
|
|
|
*/
|
|
|
|
GstVaapiSurface *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_surface (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2015-06-30 06:44:18 +00:00
|
|
|
return ensure_surface_proxy (meta) ?
|
|
|
|
GST_VAAPI_SURFACE_PROXY_SURFACE (meta->proxy) : NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_surface_proxy:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the #GstVaapiSurfaceProxy bound to the @meta. The @meta
|
|
|
|
* owns the #GstVaapiSurfaceProxy so the caller is responsible for calling
|
2013-05-06 12:43:38 +00:00
|
|
|
* gst_surface_proxy_ref() when needed.
|
2013-01-05 07:31:24 +00:00
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiSurfaceProxy bound to the @meta, or
|
|
|
|
* %NULL if there is none
|
|
|
|
*/
|
|
|
|
GstVaapiSurfaceProxy *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_surface_proxy (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-11-21 14:23:13 +00:00
|
|
|
return ensure_surface_proxy (meta) ? meta->proxy : NULL;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_set_surface_proxy:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
* @proxy: a #GstVaapiSurfaceProxy
|
|
|
|
*
|
|
|
|
* Binds surface @proxy to the @meta. If the @meta contains another
|
|
|
|
* surface previously allocated from a pool, it's pushed back to its
|
|
|
|
* parent pool and the pool is also released.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_surface_proxy (GstVaapiVideoMeta * meta,
|
|
|
|
GstVaapiSurfaceProxy * proxy)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
const GstVaapiRectangle *crop_rect;
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_destroy_proxy (meta);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (proxy) {
|
|
|
|
if (!set_surface_proxy (meta, proxy))
|
|
|
|
return;
|
2013-07-08 12:50:42 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
crop_rect = gst_vaapi_surface_proxy_get_crop_rect (proxy);
|
|
|
|
if (crop_rect)
|
|
|
|
gst_vaapi_video_meta_set_render_rect (meta, crop_rect);
|
|
|
|
}
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_render_flags:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the surface render flags bound to the @meta.
|
|
|
|
*
|
|
|
|
* Return value: a combination for #GstVaapiSurfaceRenderFlags
|
|
|
|
*/
|
|
|
|
guint
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_render_flags (GstVaapiVideoMeta * meta)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), 0);
|
|
|
|
g_return_val_if_fail (meta->proxy != NULL, 0);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
return meta->render_flags;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_set_render_flags:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
* @flags: a set of surface render flags
|
|
|
|
*
|
|
|
|
* Sets #GstVaapiSurfaceRenderFlags to the @meta.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_render_flags (GstVaapiVideoMeta * meta, guint flags)
|
2013-01-05 07:31:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
|
|
|
|
g_return_if_fail (meta->proxy != NULL);
|
2013-01-05 07:31:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->render_flags = flags;
|
2013-01-05 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 16:24:24 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_get_render_rect:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
*
|
|
|
|
* Retrieves the render rectangle bound to the @meta
|
|
|
|
*
|
|
|
|
* Return value: render rectangle associated with the video meta.
|
|
|
|
*/
|
|
|
|
const GstVaapiRectangle *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_get_render_rect (GstVaapiVideoMeta * meta)
|
2013-02-15 16:24:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_META (meta), NULL);
|
2013-02-15 16:24:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (!meta->has_render_rect)
|
|
|
|
return NULL;
|
|
|
|
return &meta->render_rect;
|
2013-02-15 16:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_video_meta_set_render_rect:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
|
|
|
* @rect: a #GstVaapiRectangle
|
|
|
|
*
|
|
|
|
* Sets the render rectangle @rect to the @meta.
|
|
|
|
*/
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_set_render_rect (GstVaapiVideoMeta * meta,
|
|
|
|
const GstVaapiRectangle * rect)
|
2013-02-15 16:24:24 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
|
2013-02-15 16:24:24 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->has_render_rect = rect != NULL;
|
|
|
|
if (meta->has_render_rect)
|
|
|
|
meta->render_rect = *rect;
|
2013-02-15 16:24:24 +00:00
|
|
|
}
|
|
|
|
|
2012-09-03 11:00:25 +00:00
|
|
|
#define GST_VAAPI_VIDEO_META_HOLDER(meta) \
|
2014-08-21 08:45:31 +00:00
|
|
|
((GstVaapiVideoMetaHolder *) (meta))
|
2012-09-03 11:00:25 +00:00
|
|
|
|
|
|
|
typedef struct _GstVaapiVideoMetaHolder GstVaapiVideoMetaHolder;
|
2014-08-21 08:45:31 +00:00
|
|
|
struct _GstVaapiVideoMetaHolder
|
|
|
|
{
|
|
|
|
GstMeta base;
|
|
|
|
GstVaapiVideoMeta *meta;
|
2012-09-03 11:00:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_holder_init (GstVaapiVideoMetaHolder * meta,
|
|
|
|
gpointer params, GstBuffer * buffer)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
meta->meta = NULL;
|
|
|
|
return TRUE;
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_holder_free (GstVaapiVideoMetaHolder * meta,
|
|
|
|
GstBuffer * buffer)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
if (meta->meta)
|
|
|
|
gst_vaapi_video_meta_unref (meta->meta);
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_holder_transform (GstBuffer * dst_buffer, GstMeta * meta,
|
|
|
|
GstBuffer * src_buffer, GQuark type, gpointer data)
|
|
|
|
{
|
|
|
|
GstVaapiVideoMetaHolder *const src_meta = GST_VAAPI_VIDEO_META_HOLDER (meta);
|
|
|
|
|
|
|
|
if (GST_META_TRANSFORM_IS_COPY (type)) {
|
|
|
|
GstVaapiVideoMeta *const dst_meta =
|
|
|
|
gst_vaapi_video_meta_copy (src_meta->meta);
|
|
|
|
gst_buffer_set_vaapi_video_meta (dst_buffer, dst_meta);
|
|
|
|
gst_vaapi_video_meta_unref (dst_meta);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_api_get_type (void)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
static gsize g_type;
|
|
|
|
static const gchar *tags[] = { "memory", NULL };
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (g_once_init_enter (&g_type)) {
|
|
|
|
GType type = gst_meta_api_type_register ("GstVaapiVideoMetaAPI", tags);
|
|
|
|
g_once_init_leave (&g_type, type);
|
|
|
|
}
|
|
|
|
return g_type;
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
#define GST_VAAPI_VIDEO_META_INFO gst_vaapi_video_meta_info_get ()
|
2012-09-03 11:00:25 +00:00
|
|
|
static const GstMetaInfo *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_vaapi_video_meta_info_get (void)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
static gsize g_meta_info;
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
if (g_once_init_enter (&g_meta_info)) {
|
|
|
|
gsize meta_info =
|
|
|
|
GPOINTER_TO_SIZE (gst_meta_register (GST_VAAPI_VIDEO_META_API_TYPE,
|
|
|
|
"GstVaapiVideoMeta", sizeof (GstVaapiVideoMetaHolder),
|
|
|
|
(GstMetaInitFunction) gst_vaapi_video_meta_holder_init,
|
|
|
|
(GstMetaFreeFunction) gst_vaapi_video_meta_holder_free,
|
|
|
|
(GstMetaTransformFunction) gst_vaapi_video_meta_holder_transform));
|
|
|
|
g_once_init_leave (&g_meta_info, meta_info);
|
|
|
|
}
|
|
|
|
return GSIZE_TO_POINTER (g_meta_info);
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstVaapiVideoMeta *
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_buffer_get_vaapi_video_meta (GstBuffer * buffer)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-11-21 14:23:13 +00:00
|
|
|
GstVaapiVideoMeta *meta;
|
2014-08-21 08:45:31 +00:00
|
|
|
GstMeta *m;
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
m = gst_buffer_get_meta (buffer, GST_VAAPI_VIDEO_META_API_TYPE);
|
|
|
|
if (!m)
|
|
|
|
return NULL;
|
2014-11-21 14:23:13 +00:00
|
|
|
|
|
|
|
meta = GST_VAAPI_VIDEO_META_HOLDER (m)->meta;
|
|
|
|
if (meta)
|
|
|
|
meta->buffer = buffer;
|
|
|
|
return meta;
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-08-21 08:45:31 +00:00
|
|
|
gst_buffer_set_vaapi_video_meta (GstBuffer * buffer, GstVaapiVideoMeta * meta)
|
2012-09-03 11:00:25 +00:00
|
|
|
{
|
2014-08-21 08:45:31 +00:00
|
|
|
GstMeta *m;
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
g_return_if_fail (GST_IS_BUFFER (buffer));
|
|
|
|
g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
|
2012-09-03 11:00:25 +00:00
|
|
|
|
2014-08-21 08:45:31 +00:00
|
|
|
m = gst_buffer_add_meta (buffer, GST_VAAPI_VIDEO_META_INFO, NULL);
|
|
|
|
if (m)
|
|
|
|
GST_VAAPI_VIDEO_META_HOLDER (m)->meta = gst_vaapi_video_meta_ref (meta);
|
2012-09-03 11:00:25 +00:00
|
|
|
}
|