2010-03-12 23:48:50 +00:00
|
|
|
/*
|
|
|
|
* gstvaapivideobuffer.c - Gst VA video buffer
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2012-01-16 09:42:55 +00:00
|
|
|
* Copyright (C) 2011 Intel Corporation
|
2010-03-12 23:48:50 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +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.
|
2010-03-12 23:48:50 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-12 23:48:50 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-06-14 11:51:41 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-12 23:48:50 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* 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
|
2010-03-12 23:48:50 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-19 16:41:52 +00:00
|
|
|
/**
|
2010-03-24 08:16:32 +00:00
|
|
|
* SECTION:gstvaapivideobuffer
|
|
|
|
* @short_description: VA video buffer for GStreamer
|
2010-03-19 16:41:52 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2010-03-12 23:48:50 +00:00
|
|
|
#include "gstvaapivideobuffer.h"
|
|
|
|
|
|
|
|
#define DEBUG 1
|
2010-03-16 09:17:41 +00:00
|
|
|
#include "gstvaapidebug.h"
|
2010-03-12 23:48:50 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
G_DEFINE_TYPE(GstVaapiVideoBuffer,
|
|
|
|
gst_vaapi_video_buffer,
|
|
|
|
GST_TYPE_SURFACE_BUFFER)
|
2010-03-12 23:48:50 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc)(
|
|
|
|
GstSurfaceBuffer *surface, const gchar *type, GValue *dest);
|
2010-03-12 23:48:50 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
static GstSurfaceConverter *
|
|
|
|
gst_vaapi_video_buffer_create_converter(GstSurfaceBuffer *surface,
|
|
|
|
const gchar *type, GValue *dest)
|
2010-03-16 17:10:02 +00:00
|
|
|
{
|
2013-01-05 16:37:13 +00:00
|
|
|
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(surface);
|
|
|
|
GstSurfaceConverterCreateFunc func;
|
2010-03-12 23:48:50 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
func = (GstSurfaceConverterCreateFunc)
|
|
|
|
gst_vaapi_video_meta_get_surface_converter(vbuffer->meta);
|
2010-05-11 16:19:30 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
return func ? func(surface, type, dest) : NULL;
|
2010-03-12 23:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapi_video_buffer_class_init(GstVaapiVideoBufferClass *klass)
|
|
|
|
{
|
2013-01-05 16:37:13 +00:00
|
|
|
GstSurfaceBufferClass * const surface_class =
|
|
|
|
GST_SURFACE_BUFFER_CLASS(klass);
|
2010-03-12 23:48:50 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
surface_class->create_converter = gst_vaapi_video_buffer_create_converter;
|
2010-03-12 23:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
|
|
|
|
{
|
2012-07-24 11:52:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-29 21:56:10 +00:00
|
|
|
/**
|
2013-01-05 16:37:13 +00:00
|
|
|
* gst_vaapi_video_buffer_new:
|
|
|
|
* @meta: a #GstVaapiVideoMeta
|
2010-04-29 21:56:10 +00:00
|
|
|
*
|
2013-01-05 16:37:13 +00:00
|
|
|
* Creates a #GstBuffer that holds video @meta information.
|
2012-07-24 12:31:25 +00:00
|
|
|
*
|
2010-04-29 21:56:10 +00:00
|
|
|
* Return value: the newly allocated #GstBuffer, or %NULL or error
|
|
|
|
*/
|
|
|
|
GstBuffer *
|
2013-01-05 16:37:13 +00:00
|
|
|
gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta)
|
2010-04-29 21:56:10 +00:00
|
|
|
{
|
2010-05-11 16:19:30 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
g_return_val_if_fail(meta != NULL, NULL);
|
2010-05-11 16:19:30 +00:00
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
buffer = GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
|
2010-05-11 16:19:30 +00:00
|
|
|
if (!buffer)
|
|
|
|
return NULL;
|
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
gst_buffer_set_vaapi_video_meta(buffer, meta);
|
2010-05-11 16:19:30 +00:00
|
|
|
return buffer;
|
2010-03-12 23:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 16:41:52 +00:00
|
|
|
/**
|
2013-01-05 16:37:13 +00:00
|
|
|
* gst_vaapi_video_buffer_get_meta:
|
2010-03-19 16:41:52 +00:00
|
|
|
* @buffer: a #GstVaapiVideoBuffer
|
|
|
|
*
|
2013-01-05 16:37:13 +00:00
|
|
|
* Returns the #GstVaapiVideoMeta associated to this @buffer.
|
2010-03-19 16:41:52 +00:00
|
|
|
*
|
2013-01-05 16:37:13 +00:00
|
|
|
* Return value: the #GstVaapiVideoMeta bound to the @buffer, or %NULL
|
|
|
|
* if none was found
|
2010-03-19 16:41:52 +00:00
|
|
|
*/
|
2013-01-05 16:37:13 +00:00
|
|
|
GstVaapiVideoMeta *
|
|
|
|
gst_vaapi_video_buffer_get_meta(GstVaapiVideoBuffer *buffer)
|
2010-03-12 23:48:50 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
|
|
|
|
|
2013-01-05 16:37:13 +00:00
|
|
|
return buffer->meta;
|
2012-03-26 10:01:36 +00:00
|
|
|
}
|