Rename vaapiconvert element to vaapiupload.

This commit is contained in:
Gwenole Beauchesne 2012-01-03 14:34:09 +01:00
parent 9b33d00315
commit 42fa974391
10 changed files with 222 additions and 219 deletions

5
NEWS
View file

@ -1,7 +1,10 @@
gst-vaapi NEWS -- summary of changes. 2011-12-16 gst-vaapi NEWS -- summary of changes. 2012-01-DD
Copyright (C) 2010-2011 Splitted-Desktop Systems Copyright (C) 2010-2011 Splitted-Desktop Systems
Copyright (C) 2011 Intel Corporation Copyright (C) 2011 Intel Corporation
Version 0.3.2 - DD.Jan.2012
* Rename vaapiconvert element to vaapiupload
Version 0.3.1 - 16.Dec.2011 Version 0.3.1 - 16.Dec.2011
* Fix check for supported VA images * Fix check for supported VA images
* Add support for partial VA image updates * Add support for partial VA image updates

2
README
View file

@ -23,7 +23,7 @@ GStreamer and helper libraries.
videos to video/x-vaapi-surfaces surfaces, depending on the videos to video/x-vaapi-surfaces surfaces, depending on the
underlying HW capabilities. underlying HW capabilities.
* `vaapiconvert' is used to convert from video/x-raw-yuv pixels to * `vaapiupload' is used to convert from video/x-raw-yuv pixels to
video/x-vaapi-surface surfaces. video/x-vaapi-surface surfaces.
* `vaapisink' is used to display video/x-vaapi-surface surfaces to * `vaapisink' is used to display video/x-vaapi-surface surfaces to

View file

@ -18,7 +18,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}
Suggests: gstreamer@GST_MAJORMINOR@-vaapi-doc Suggests: gstreamer@GST_MAJORMINOR@-vaapi-doc
Description: VA-API plugins for GStreamer Description: VA-API plugins for GStreamer
This package contains GStreamer plugins for VA-API support: This package contains GStreamer plugins for VA-API support:
- `vaapiconvert': converts from YUV pixels to VA surfaces - `vaapiupload': converts from YUV pixels to VA surfaces
- `vaapisink': a VA-API based video sink - `vaapisink': a VA-API based video sink
Package: gstreamer@GST_MAJORMINOR@-vaapi-doc Package: gstreamer@GST_MAJORMINOR@-vaapi-doc

View file

@ -12,7 +12,7 @@
<chapter> <chapter>
<title>gst-plugins-vaapi Plugins</title> <title>gst-plugins-vaapi Plugins</title>
<xi:include href="xml/gstvaapidecode.xml"/> <xi:include href="xml/gstvaapidecode.xml"/>
<xi:include href="xml/gstvaapiconvert.xml"/> <xi:include href="xml/gstvaapiupload.xml"/>
<xi:include href="xml/gstvaapisink.xml"/> <xi:include href="xml/gstvaapisink.xml"/>
</chapter> </chapter>

View file

@ -27,15 +27,15 @@ GST_VAAPIDECODE_GET_CLASS
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gstvaapiconvert</FILE> <FILE>gstvaapiupload</FILE>
<TITLE>GstVaapiConvert</TITLE> <TITLE>GstVaapiUpload</TITLE>
GstVaapiConvert GstVaapiUpload
<SUBSECTION Standard> <SUBSECTION Standard>
GST_VAAPICONVERT GST_VAAPIUPLOAD
GST_IS_VAAPICONVERT GST_IS_VAAPIUPLOAD
GST_TYPE_VAAPICONVERT GST_TYPE_VAAPIUPLOAD
gst_vaapiconvert_get_type gst_vaapiupload_get_type
GST_VAAPICONVERT_CLASS GST_VAAPIUPLOAD_CLASS
GST_IS_VAAPICONVERT_CLASS GST_IS_VAAPIUPLOAD_CLASS
GST_VAAPICONVERT_GET_CLASS GST_VAAPIUPLOAD_GET_CLASS
</SECTION> </SECTION>

View file

@ -1,3 +1,3 @@
gst_vaapisink_get_type gst_vaapisink_get_type
gst_vaapidecode_get_type gst_vaapidecode_get_type
gst_vaapiconvert_get_type gst_vaapiupload_get_type

View file

@ -17,17 +17,17 @@ endif
libgstvaapi_la_SOURCES = \ libgstvaapi_la_SOURCES = \
gstvaapi.c \ gstvaapi.c \
gstvaapiconvert.c \
gstvaapidecode.c \ gstvaapidecode.c \
gstvaapipluginutil.c \ gstvaapipluginutil.c \
gstvaapisink.c \ gstvaapisink.c \
gstvaapiupload.c \
$(NULL) $(NULL)
noinst_HEADERS = \ noinst_HEADERS = \
gstvaapiconvert.h \
gstvaapidecode.h \ gstvaapidecode.h \
gstvaapipluginutil.h \ gstvaapipluginutil.h \
gstvaapisink.h \ gstvaapisink.h \
gstvaapiupload.h \
$(NULL) $(NULL)
libgstvaapi_la_CFLAGS = \ libgstvaapi_la_CFLAGS = \

View file

@ -27,16 +27,16 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "gstvaapiconvert.h" #include "gstvaapiupload.h"
#include "gstvaapidecode.h" #include "gstvaapidecode.h"
#include "gstvaapisink.h" #include "gstvaapisink.h"
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin *plugin)
{ {
gst_element_register(plugin, "vaapiconvert", gst_element_register(plugin, "vaapiupload",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPICONVERT); GST_TYPE_VAAPIUPLOAD);
gst_element_register(plugin, "vaapidecode", gst_element_register(plugin, "vaapidecode",
GST_RANK_PRIMARY, GST_RANK_PRIMARY,
GST_TYPE_VAAPIDECODE); GST_TYPE_VAAPIDECODE);

View file

@ -1,5 +1,5 @@
/* /*
* gstvaapiconvert.c - VA-API video converter * gstvaapiupload.c - VA-API video uploader
* *
* gstreamer-vaapi (C) 2010-2011 Splitted-Desktop Systems * gstreamer-vaapi (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2011 Intel Corporation * Copyright (C) 2011 Intel Corporation
@ -21,11 +21,11 @@
*/ */
/** /**
* SECTION:gstvaapiconvert * SECTION:gstvaapiupload
* @short_description: A VA-API based video pixels format converter * @short_description: A video to VA flow filter
* *
* vaapiconvert converts from raw YUV pixels to surfaces suitable for * vaapiupload converts from raw YUV pixels to VA surfaces suitable
* the vaapisink element. * for the vaapisink element, for example.
*/ */
#include "config.h" #include "config.h"
@ -45,16 +45,16 @@
#endif #endif
#include "gstvaapipluginutil.h" #include "gstvaapipluginutil.h"
#include "gstvaapiconvert.h" #include "gstvaapiupload.h"
#define GST_PLUGIN_NAME "vaapiconvert" #define GST_PLUGIN_NAME "vaapiupload"
#define GST_PLUGIN_DESC "A VA-API based video pixels format converter" #define GST_PLUGIN_DESC "A video to VA flow filter"
GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapiconvert); GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapiupload);
#define GST_CAT_DEFAULT gst_debug_vaapiconvert #define GST_CAT_DEFAULT gst_debug_vaapiupload
/* ElementFactory information */ /* ElementFactory information */
static const GstElementDetails gst_vaapiconvert_details = static const GstElementDetails gst_vaapiupload_details =
GST_ELEMENT_DETAILS( GST_ELEMENT_DETAILS(
"VA-API colorspace converter", "VA-API colorspace converter",
"Filter/Converter/Video", "Filter/Converter/Video",
@ -62,32 +62,32 @@ static const GstElementDetails gst_vaapiconvert_details =
"Gwenole Beauchesne <gwenole.beauchesne@intel.com>"); "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
/* Default templates */ /* Default templates */
static const char gst_vaapiconvert_yuv_caps_str[] = static const char gst_vaapiupload_yuv_caps_str[] =
"video/x-raw-yuv, " "video/x-raw-yuv, "
"width = (int) [ 1, MAX ], " "width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]; "; "height = (int) [ 1, MAX ]; ";
static const char gst_vaapiconvert_vaapi_caps_str[] = static const char gst_vaapiupload_vaapi_caps_str[] =
GST_VAAPI_SURFACE_CAPS; GST_VAAPI_SURFACE_CAPS;
static GstStaticPadTemplate gst_vaapiconvert_sink_factory = static GstStaticPadTemplate gst_vaapiupload_sink_factory =
GST_STATIC_PAD_TEMPLATE( GST_STATIC_PAD_TEMPLATE(
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapiconvert_yuv_caps_str)); GST_STATIC_CAPS(gst_vaapiupload_yuv_caps_str));
static GstStaticPadTemplate gst_vaapiconvert_src_factory = static GstStaticPadTemplate gst_vaapiupload_src_factory =
GST_STATIC_PAD_TEMPLATE( GST_STATIC_PAD_TEMPLATE(
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapiconvert_vaapi_caps_str)); GST_STATIC_CAPS(gst_vaapiupload_vaapi_caps_str));
#define GstVideoContextClass GstVideoContextInterface #define GstVideoContextClass GstVideoContextInterface
GST_BOILERPLATE_WITH_INTERFACE( GST_BOILERPLATE_WITH_INTERFACE(
GstVaapiConvert, GstVaapiUpload,
gst_vaapiconvert, gst_vaapiupload,
GstBaseTransform, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM, GST_TYPE_BASE_TRANSFORM,
GstVideoContext, GstVideoContext,
@ -97,8 +97,8 @@ GST_BOILERPLATE_WITH_INTERFACE(
/* /*
* Direct rendering levels (direct-rendering) * Direct rendering levels (direct-rendering)
* 0: upstream allocated YUV pixels * 0: upstream allocated YUV pixels
* 1: vaapiconvert allocated YUV pixels (mapped from VA image) * 1: vaapiupload allocated YUV pixels (mapped from VA image)
* 2: vaapiconvert allocated YUV pixels (mapped from VA surface) * 2: vaapiupload allocated YUV pixels (mapped from VA surface)
*/ */
#define DIRECT_RENDERING_DEFAULT 2 #define DIRECT_RENDERING_DEFAULT 2
@ -109,41 +109,41 @@ enum {
}; };
static gboolean static gboolean
gst_vaapiconvert_start(GstBaseTransform *trans); gst_vaapiupload_start(GstBaseTransform *trans);
static gboolean static gboolean
gst_vaapiconvert_stop(GstBaseTransform *trans); gst_vaapiupload_stop(GstBaseTransform *trans);
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_transform( gst_vaapiupload_transform(
GstBaseTransform *trans, GstBaseTransform *trans,
GstBuffer *inbuf, GstBuffer *inbuf,
GstBuffer *outbuf GstBuffer *outbuf
); );
static GstCaps * static GstCaps *
gst_vaapiconvert_transform_caps( gst_vaapiupload_transform_caps(
GstBaseTransform *trans, GstBaseTransform *trans,
GstPadDirection direction, GstPadDirection direction,
GstCaps *caps GstCaps *caps
); );
static gboolean static gboolean
gst_vaapiconvert_set_caps( gst_vaapiupload_set_caps(
GstBaseTransform *trans, GstBaseTransform *trans,
GstCaps *incaps, GstCaps *incaps,
GstCaps *outcaps GstCaps *outcaps
); );
static gboolean static gboolean
gst_vaapiconvert_get_unit_size( gst_vaapiupload_get_unit_size(
GstBaseTransform *trans, GstBaseTransform *trans,
GstCaps *caps, GstCaps *caps,
guint *size guint *size
); );
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_sinkpad_buffer_alloc( gst_vaapiupload_sinkpad_buffer_alloc(
GstPad *pad, GstPad *pad,
guint64 offset, guint64 offset,
guint size, guint size,
@ -152,7 +152,7 @@ gst_vaapiconvert_sinkpad_buffer_alloc(
); );
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_prepare_output_buffer( gst_vaapiupload_prepare_output_buffer(
GstBaseTransform *trans, GstBaseTransform *trans,
GstBuffer *inbuf, GstBuffer *inbuf,
gint size, gint size,
@ -161,7 +161,7 @@ gst_vaapiconvert_prepare_output_buffer(
); );
static gboolean static gboolean
gst_vaapiconvert_query( gst_vaapiupload_query(
GstPad *pad, GstPad *pad,
GstQuery *query GstQuery *query
); );
@ -169,15 +169,15 @@ gst_vaapiconvert_query(
/* GstVideoContext interface */ /* GstVideoContext interface */
static void static void
gst_vaapiconvert_set_video_context(GstVideoContext *context, const gchar *type, gst_vaapiupload_set_video_context(GstVideoContext *context, const gchar *type,
const GValue *value) const GValue *value)
{ {
GstVaapiConvert *convert = GST_VAAPICONVERT (context); GstVaapiUpload *upload = GST_VAAPIUPLOAD (context);
gst_vaapi_set_display (type, value, &convert->display); gst_vaapi_set_display (type, value, &upload->display);
} }
static gboolean static gboolean
gst_video_context_supported (GstVaapiConvert *convert, GType iface_type) gst_video_context_supported (GstVaapiUpload *upload, GType iface_type)
{ {
return (iface_type == GST_TYPE_VIDEO_CONTEXT); return (iface_type == GST_TYPE_VIDEO_CONTEXT);
} }
@ -185,72 +185,72 @@ gst_video_context_supported (GstVaapiConvert *convert, GType iface_type)
static void static void
gst_video_context_interface_init(GstVideoContextInterface *iface) gst_video_context_interface_init(GstVideoContextInterface *iface)
{ {
iface->set_context = gst_vaapiconvert_set_video_context; iface->set_context = gst_vaapiupload_set_video_context;
} }
static void static void
gst_vaapiconvert_destroy(GstVaapiConvert *convert) gst_vaapiupload_destroy(GstVaapiUpload *upload)
{ {
if (convert->images) { if (upload->images) {
g_object_unref(convert->images); g_object_unref(upload->images);
convert->images = NULL; upload->images = NULL;
} }
if (convert->surfaces) { if (upload->surfaces) {
g_object_unref(convert->surfaces); g_object_unref(upload->surfaces);
convert->surfaces = NULL; upload->surfaces = NULL;
} }
if (convert->display) { if (upload->display) {
g_object_unref(convert->display); g_object_unref(upload->display);
convert->display = NULL; upload->display = NULL;
} }
} }
static void static void
gst_vaapiconvert_base_init(gpointer klass) gst_vaapiupload_base_init(gpointer klass)
{ {
GstElementClass * const element_class = GST_ELEMENT_CLASS(klass); GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
gst_element_class_set_details(element_class, &gst_vaapiconvert_details); gst_element_class_set_details(element_class, &gst_vaapiupload_details);
/* sink pad */ /* sink pad */
gst_element_class_add_pad_template( gst_element_class_add_pad_template(
element_class, element_class,
gst_static_pad_template_get(&gst_vaapiconvert_sink_factory) gst_static_pad_template_get(&gst_vaapiupload_sink_factory)
); );
/* src pad */ /* src pad */
gst_element_class_add_pad_template( gst_element_class_add_pad_template(
element_class, element_class,
gst_static_pad_template_get(&gst_vaapiconvert_src_factory) gst_static_pad_template_get(&gst_vaapiupload_src_factory)
); );
} }
static void static void
gst_vaapiconvert_finalize(GObject *object) gst_vaapiupload_finalize(GObject *object)
{ {
gst_vaapiconvert_destroy(GST_VAAPICONVERT(object)); gst_vaapiupload_destroy(GST_VAAPIUPLOAD(object));
G_OBJECT_CLASS(parent_class)->finalize(object); G_OBJECT_CLASS(parent_class)->finalize(object);
} }
static void static void
gst_vaapiconvert_set_property( gst_vaapiupload_set_property(
GObject *object, GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec GParamSpec *pspec
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(object); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(object);
switch (prop_id) { switch (prop_id) {
case PROP_DIRECT_RENDERING: case PROP_DIRECT_RENDERING:
GST_OBJECT_LOCK(convert); GST_OBJECT_LOCK(upload);
convert->direct_rendering = g_value_get_uint(value); upload->direct_rendering = g_value_get_uint(value);
GST_OBJECT_UNLOCK(convert); GST_OBJECT_UNLOCK(upload);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -259,18 +259,18 @@ gst_vaapiconvert_set_property(
} }
static void static void
gst_vaapiconvert_get_property( gst_vaapiupload_get_property(
GObject *object, GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec GParamSpec *pspec
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(object); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(object);
switch (prop_id) { switch (prop_id) {
case PROP_DIRECT_RENDERING: case PROP_DIRECT_RENDERING:
g_value_set_uint(value, convert->direct_rendering); g_value_set_uint(value, upload->direct_rendering);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -279,28 +279,28 @@ gst_vaapiconvert_get_property(
} }
static void static void
gst_vaapiconvert_class_init(GstVaapiConvertClass *klass) gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
{ {
GObjectClass * const object_class = G_OBJECT_CLASS(klass); GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass); GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
GST_DEBUG_CATEGORY_INIT(gst_debug_vaapiconvert, GST_DEBUG_CATEGORY_INIT(gst_debug_vaapiupload,
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC); GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
object_class->finalize = gst_vaapiconvert_finalize; object_class->finalize = gst_vaapiupload_finalize;
object_class->set_property = gst_vaapiconvert_set_property; object_class->set_property = gst_vaapiupload_set_property;
object_class->get_property = gst_vaapiconvert_get_property; object_class->get_property = gst_vaapiupload_get_property;
trans_class->start = gst_vaapiconvert_start; trans_class->start = gst_vaapiupload_start;
trans_class->stop = gst_vaapiconvert_stop; trans_class->stop = gst_vaapiupload_stop;
trans_class->transform = gst_vaapiconvert_transform; trans_class->transform = gst_vaapiupload_transform;
trans_class->transform_caps = gst_vaapiconvert_transform_caps; trans_class->transform_caps = gst_vaapiupload_transform_caps;
trans_class->set_caps = gst_vaapiconvert_set_caps; trans_class->set_caps = gst_vaapiupload_set_caps;
trans_class->get_unit_size = gst_vaapiconvert_get_unit_size; trans_class->get_unit_size = gst_vaapiupload_get_unit_size;
trans_class->prepare_output_buffer = gst_vaapiconvert_prepare_output_buffer; trans_class->prepare_output_buffer = gst_vaapiupload_prepare_output_buffer;
/** /**
* GstVaapiConvert:direct-rendering: * GstVaapiUpload:direct-rendering:
* *
* Selects the direct rendering level. * Selects the direct rendering level.
* <orderedlist> * <orderedlist>
@ -330,67 +330,67 @@ gst_vaapiconvert_class_init(GstVaapiConvertClass *klass)
} }
static void static void
gst_vaapiconvert_init(GstVaapiConvert *convert, GstVaapiConvertClass *klass) gst_vaapiupload_init(GstVaapiUpload *upload, GstVaapiUploadClass *klass)
{ {
GstPad *sinkpad, *srcpad; GstPad *sinkpad, *srcpad;
convert->display = NULL; upload->display = NULL;
convert->images = NULL; upload->images = NULL;
convert->images_reset = FALSE; upload->images_reset = FALSE;
convert->image_width = 0; upload->image_width = 0;
convert->image_height = 0; upload->image_height = 0;
convert->surfaces = NULL; upload->surfaces = NULL;
convert->surfaces_reset = FALSE; upload->surfaces_reset = FALSE;
convert->surface_width = 0; upload->surface_width = 0;
convert->surface_height = 0; upload->surface_height = 0;
convert->direct_rendering_caps = 0; upload->direct_rendering_caps = 0;
convert->direct_rendering = G_MAXUINT32; upload->direct_rendering = G_MAXUINT32;
/* Override buffer allocator on sink pad */ /* Override buffer allocator on sink pad */
sinkpad = gst_element_get_static_pad(GST_ELEMENT(convert), "sink"); sinkpad = gst_element_get_static_pad(GST_ELEMENT(upload), "sink");
gst_pad_set_bufferalloc_function( gst_pad_set_bufferalloc_function(
sinkpad, sinkpad,
gst_vaapiconvert_sinkpad_buffer_alloc gst_vaapiupload_sinkpad_buffer_alloc
); );
gst_pad_set_query_function(sinkpad, gst_vaapiconvert_query); gst_pad_set_query_function(sinkpad, gst_vaapiupload_query);
g_object_unref(sinkpad); g_object_unref(sinkpad);
/* Override query on src pad */ /* Override query on src pad */
srcpad = gst_element_get_static_pad(GST_ELEMENT(convert), "src"); srcpad = gst_element_get_static_pad(GST_ELEMENT(upload), "src");
gst_pad_set_query_function(srcpad, gst_vaapiconvert_query); gst_pad_set_query_function(srcpad, gst_vaapiupload_query);
} }
static gboolean static gboolean
gst_vaapiconvert_start(GstBaseTransform *trans) gst_vaapiupload_start(GstBaseTransform *trans)
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
if (!gst_vaapi_ensure_display(convert, &convert->display)) if (!gst_vaapi_ensure_display(upload, &upload->display))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static gboolean static gboolean
gst_vaapiconvert_stop(GstBaseTransform *trans) gst_vaapiupload_stop(GstBaseTransform *trans)
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
if (convert->display) { if (upload->display) {
g_object_unref(convert->display); g_object_unref(upload->display);
convert->display = NULL; upload->display = NULL;
} }
return TRUE; return TRUE;
} }
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_transform( gst_vaapiupload_transform(
GstBaseTransform *trans, GstBaseTransform *trans,
GstBuffer *inbuf, GstBuffer *inbuf,
GstBuffer *outbuf GstBuffer *outbuf
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
GstVaapiVideoBuffer *vbuffer; GstVaapiVideoBuffer *vbuffer;
GstVaapiSurface *surface; GstVaapiSurface *surface;
GstVaapiImage *image; GstVaapiImage *image;
@ -401,7 +401,7 @@ gst_vaapiconvert_transform(
if (!surface) if (!surface)
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
if (convert->direct_rendering) { if (upload->direct_rendering) {
if (!GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) { if (!GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) {
GST_DEBUG("GstVaapiVideoBuffer was expected"); GST_DEBUG("GstVaapiVideoBuffer was expected");
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
@ -414,20 +414,20 @@ gst_vaapiconvert_transform(
if (!gst_vaapi_image_unmap(image)) if (!gst_vaapi_image_unmap(image))
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
if (convert->direct_rendering < 2) { if (upload->direct_rendering < 2) {
if (!gst_vaapi_surface_put_image(surface, image)) if (!gst_vaapi_surface_put_image(surface, image))
goto error_put_image; goto error_put_image;
} }
return GST_FLOW_OK; return GST_FLOW_OK;
} }
image = gst_vaapi_video_pool_get_object(convert->images); image = gst_vaapi_video_pool_get_object(upload->images);
if (!image) if (!image)
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
gst_vaapi_image_update_from_buffer(image, inbuf, NULL); gst_vaapi_image_update_from_buffer(image, inbuf, NULL);
success = gst_vaapi_surface_put_image(surface, image); success = gst_vaapi_surface_put_image(surface, image);
gst_vaapi_video_pool_put_object(convert->images, image); gst_vaapi_video_pool_put_object(upload->images, image);
if (!success) if (!success)
goto error_put_image; goto error_put_image;
return GST_FLOW_OK; return GST_FLOW_OK;
@ -443,13 +443,13 @@ error_put_image:
} }
static GstCaps * static GstCaps *
gst_vaapiconvert_transform_caps( gst_vaapiupload_transform_caps(
GstBaseTransform *trans, GstBaseTransform *trans,
GstPadDirection direction, GstPadDirection direction,
GstCaps *caps GstCaps *caps
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
GstCaps *out_caps = NULL; GstCaps *out_caps = NULL;
GstStructure *structure; GstStructure *structure;
const GValue *v_width, *v_height, *v_framerate, *v_par; const GValue *v_width, *v_height, *v_framerate, *v_par;
@ -468,15 +468,15 @@ gst_vaapiconvert_transform_caps(
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
if (!gst_structure_has_name(structure, "video/x-raw-yuv")) if (!gst_structure_has_name(structure, "video/x-raw-yuv"))
return NULL; return NULL;
out_caps = gst_caps_from_string(gst_vaapiconvert_vaapi_caps_str); out_caps = gst_caps_from_string(gst_vaapiupload_vaapi_caps_str);
} }
else { else {
if (!gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME)) if (!gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
return NULL; return NULL;
out_caps = gst_caps_from_string(gst_vaapiconvert_yuv_caps_str); out_caps = gst_caps_from_string(gst_vaapiupload_yuv_caps_str);
if (convert->display) { if (upload->display) {
GstCaps *allowed_caps, *inter_caps; GstCaps *allowed_caps, *inter_caps;
allowed_caps = gst_vaapi_display_get_image_caps(convert->display); allowed_caps = gst_vaapi_display_get_image_caps(upload->display);
if (!allowed_caps) if (!allowed_caps)
return NULL; return NULL;
inter_caps = gst_caps_intersect(out_caps, allowed_caps); inter_caps = gst_caps_intersect(out_caps, allowed_caps);
@ -499,7 +499,7 @@ gst_vaapiconvert_transform_caps(
} }
static gboolean static gboolean
gst_vaapiconvert_ensure_image_pool(GstVaapiConvert *convert, GstCaps *caps) gst_vaapiupload_ensure_image_pool(GstVaapiUpload *upload, GstCaps *caps)
{ {
GstStructure * const structure = gst_caps_get_structure(caps, 0); GstStructure * const structure = gst_caps_get_structure(caps, 0);
gint width, height; gint width, height;
@ -507,21 +507,21 @@ gst_vaapiconvert_ensure_image_pool(GstVaapiConvert *convert, GstCaps *caps)
gst_structure_get_int(structure, "width", &width); gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height); gst_structure_get_int(structure, "height", &height);
if (width != convert->image_width || height != convert->image_height) { if (width != upload->image_width || height != upload->image_height) {
convert->image_width = width; upload->image_width = width;
convert->image_height = height; upload->image_height = height;
if (convert->images) if (upload->images)
g_object_unref(convert->images); g_object_unref(upload->images);
convert->images = gst_vaapi_image_pool_new(convert->display, caps); upload->images = gst_vaapi_image_pool_new(upload->display, caps);
if (!convert->images) if (!upload->images)
return FALSE; return FALSE;
convert->images_reset = TRUE; upload->images_reset = TRUE;
} }
return TRUE; return TRUE;
} }
static gboolean static gboolean
gst_vaapiconvert_ensure_surface_pool(GstVaapiConvert *convert, GstCaps *caps) gst_vaapiupload_ensure_surface_pool(GstVaapiUpload *upload, GstCaps *caps)
{ {
GstStructure * const structure = gst_caps_get_structure(caps, 0); GstStructure * const structure = gst_caps_get_structure(caps, 0);
gint width, height; gint width, height;
@ -529,22 +529,22 @@ gst_vaapiconvert_ensure_surface_pool(GstVaapiConvert *convert, GstCaps *caps)
gst_structure_get_int(structure, "width", &width); gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height); gst_structure_get_int(structure, "height", &height);
if (width != convert->surface_width || height != convert->surface_height) { if (width != upload->surface_width || height != upload->surface_height) {
convert->surface_width = width; upload->surface_width = width;
convert->surface_height = height; upload->surface_height = height;
if (convert->surfaces) if (upload->surfaces)
g_object_unref(convert->surfaces); g_object_unref(upload->surfaces);
convert->surfaces = gst_vaapi_surface_pool_new(convert->display, caps); upload->surfaces = gst_vaapi_surface_pool_new(upload->display, caps);
if (!convert->surfaces) if (!upload->surfaces)
return FALSE; return FALSE;
convert->surfaces_reset = TRUE; upload->surfaces_reset = TRUE;
} }
return TRUE; return TRUE;
} }
static void static void
gst_vaapiconvert_ensure_direct_rendering_caps( gst_vaapiupload_ensure_direct_rendering_caps(
GstVaapiConvert *convert, GstVaapiUpload *upload,
GstCaps *caps GstCaps *caps
) )
{ {
@ -555,12 +555,12 @@ gst_vaapiconvert_ensure_direct_rendering_caps(
GstStructure *structure; GstStructure *structure;
gint width, height; gint width, height;
if (!convert->images_reset && !convert->surfaces_reset) if (!upload->images_reset && !upload->surfaces_reset)
return; return;
convert->images_reset = FALSE; upload->images_reset = FALSE;
convert->surfaces_reset = FALSE; upload->surfaces_reset = FALSE;
convert->direct_rendering_caps = 0; upload->direct_rendering_caps = 0;
structure = gst_caps_get_structure(caps, 0); structure = gst_caps_get_structure(caps, 0);
if (!structure) if (!structure)
@ -578,78 +578,78 @@ gst_vaapiconvert_ensure_direct_rendering_caps(
return; return;
/* Check if we can alias sink & output buffers (same data_size) */ /* Check if we can alias sink & output buffers (same data_size) */
image = gst_vaapi_video_pool_get_object(convert->images); image = gst_vaapi_video_pool_get_object(upload->images);
if (image) { if (image) {
if (convert->direct_rendering_caps == 0 && if (upload->direct_rendering_caps == 0 &&
(gst_vaapi_image_get_format(image) == vaformat && (gst_vaapi_image_get_format(image) == vaformat &&
gst_vaapi_image_is_linear(image) && gst_vaapi_image_is_linear(image) &&
(gst_vaapi_image_get_data_size(image) == (gst_vaapi_image_get_data_size(image) ==
gst_video_format_get_size(vformat, width, height)))) gst_video_format_get_size(vformat, width, height))))
convert->direct_rendering_caps = 1; upload->direct_rendering_caps = 1;
gst_vaapi_video_pool_put_object(convert->images, image); gst_vaapi_video_pool_put_object(upload->images, image);
} }
/* Check if we can access to the surface pixels directly */ /* Check if we can access to the surface pixels directly */
surface = gst_vaapi_video_pool_get_object(convert->surfaces); surface = gst_vaapi_video_pool_get_object(upload->surfaces);
if (surface) { if (surface) {
image = gst_vaapi_surface_derive_image(surface); image = gst_vaapi_surface_derive_image(surface);
if (image) { if (image) {
if (gst_vaapi_image_map(image)) { if (gst_vaapi_image_map(image)) {
if (convert->direct_rendering_caps == 1 && if (upload->direct_rendering_caps == 1 &&
(gst_vaapi_image_get_format(image) == vaformat && (gst_vaapi_image_get_format(image) == vaformat &&
gst_vaapi_image_is_linear(image) && gst_vaapi_image_is_linear(image) &&
(gst_vaapi_image_get_data_size(image) == (gst_vaapi_image_get_data_size(image) ==
gst_video_format_get_size(vformat, width, height)))) gst_video_format_get_size(vformat, width, height))))
convert->direct_rendering_caps = 2; upload->direct_rendering_caps = 2;
gst_vaapi_image_unmap(image); gst_vaapi_image_unmap(image);
} }
g_object_unref(image); g_object_unref(image);
} }
gst_vaapi_video_pool_put_object(convert->surfaces, surface); gst_vaapi_video_pool_put_object(upload->surfaces, surface);
} }
} }
static gboolean static gboolean
gst_vaapiconvert_negotiate_buffers( gst_vaapiupload_negotiate_buffers(
GstVaapiConvert *convert, GstVaapiUpload *upload,
GstCaps *incaps, GstCaps *incaps,
GstCaps *outcaps GstCaps *outcaps
) )
{ {
guint dr; guint dr;
if (!gst_vaapiconvert_ensure_image_pool(convert, incaps)) if (!gst_vaapiupload_ensure_image_pool(upload, incaps))
return FALSE; return FALSE;
if (!gst_vaapiconvert_ensure_surface_pool(convert, outcaps)) if (!gst_vaapiupload_ensure_surface_pool(upload, outcaps))
return FALSE; return FALSE;
gst_vaapiconvert_ensure_direct_rendering_caps(convert, incaps); gst_vaapiupload_ensure_direct_rendering_caps(upload, incaps);
dr = MIN(convert->direct_rendering, convert->direct_rendering_caps); dr = MIN(upload->direct_rendering, upload->direct_rendering_caps);
if (convert->direct_rendering != dr) { if (upload->direct_rendering != dr) {
convert->direct_rendering = dr; upload->direct_rendering = dr;
GST_DEBUG("direct-rendering level: %d", dr); GST_DEBUG("direct-rendering level: %d", dr);
} }
return TRUE; return TRUE;
} }
static gboolean static gboolean
gst_vaapiconvert_set_caps( gst_vaapiupload_set_caps(
GstBaseTransform *trans, GstBaseTransform *trans,
GstCaps *incaps, GstCaps *incaps,
GstCaps *outcaps GstCaps *outcaps
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
if (!gst_vaapiconvert_negotiate_buffers(convert, incaps, outcaps)) if (!gst_vaapiupload_negotiate_buffers(upload, incaps, outcaps))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static gboolean static gboolean
gst_vaapiconvert_get_unit_size( gst_vaapiupload_get_unit_size(
GstBaseTransform *trans, GstBaseTransform *trans,
GstCaps *caps, GstCaps *caps,
guint *size guint *size
@ -670,28 +670,28 @@ gst_vaapiconvert_get_unit_size(
} }
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_buffer_alloc( gst_vaapiupload_buffer_alloc(
GstBaseTransform *trans, GstBaseTransform *trans,
guint size, guint size,
GstCaps *caps, GstCaps *caps,
GstBuffer **pbuf GstBuffer **pbuf
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
GstBuffer *buffer = NULL; GstBuffer *buffer = NULL;
GstVaapiImage *image = NULL; GstVaapiImage *image = NULL;
GstVaapiSurface *surface = NULL; GstVaapiSurface *surface = NULL;
GstVaapiVideoBuffer *vbuffer; GstVaapiVideoBuffer *vbuffer;
/* Check if we can use direct-rendering */ /* Check if we can use direct-rendering */
if (!gst_vaapiconvert_negotiate_buffers(convert, caps, caps)) if (!gst_vaapiupload_negotiate_buffers(upload, caps, caps))
goto error; goto error;
if (!convert->direct_rendering) if (!upload->direct_rendering)
return GST_FLOW_OK; return GST_FLOW_OK;
switch (convert->direct_rendering) { switch (upload->direct_rendering) {
case 2: case 2:
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces); buffer = gst_vaapi_video_buffer_new_from_pool(upload->surfaces);
if (!buffer) if (!buffer)
goto error; goto error;
vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer); vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
@ -705,12 +705,12 @@ gst_vaapiconvert_buffer_alloc(
} }
/* We can't use the derive-image optimization. Disable it. */ /* We can't use the derive-image optimization. Disable it. */
convert->direct_rendering = 1; upload->direct_rendering = 1;
gst_buffer_unref(buffer); gst_buffer_unref(buffer);
buffer = NULL; buffer = NULL;
case 1: case 1:
buffer = gst_vaapi_video_buffer_new_from_pool(convert->images); buffer = gst_vaapi_video_buffer_new_from_pool(upload->images);
if (!buffer) if (!buffer)
goto error; goto error;
vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer); vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
@ -735,12 +735,12 @@ error:
GST_DEBUG("disable in/out buffer optimization"); GST_DEBUG("disable in/out buffer optimization");
if (buffer) if (buffer)
gst_buffer_unref(buffer); gst_buffer_unref(buffer);
convert->direct_rendering = 0; upload->direct_rendering = 0;
return GST_FLOW_OK; return GST_FLOW_OK;
} }
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_sinkpad_buffer_alloc( gst_vaapiupload_sinkpad_buffer_alloc(
GstPad *pad, GstPad *pad,
guint64 offset, guint64 offset,
guint size, guint size,
@ -755,13 +755,13 @@ gst_vaapiconvert_sinkpad_buffer_alloc(
if (!trans) if (!trans)
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
ret = gst_vaapiconvert_buffer_alloc(trans, size, caps, pbuf); ret = gst_vaapiupload_buffer_alloc(trans, size, caps, pbuf);
g_object_unref(trans); g_object_unref(trans);
return ret; return ret;
} }
static GstFlowReturn static GstFlowReturn
gst_vaapiconvert_prepare_output_buffer( gst_vaapiupload_prepare_output_buffer(
GstBaseTransform *trans, GstBaseTransform *trans,
GstBuffer *inbuf, GstBuffer *inbuf,
gint size, gint size,
@ -769,22 +769,22 @@ gst_vaapiconvert_prepare_output_buffer(
GstBuffer **poutbuf GstBuffer **poutbuf
) )
{ {
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans); GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
GstBuffer *buffer = NULL; GstBuffer *buffer = NULL;
if (convert->direct_rendering == 2) { if (upload->direct_rendering == 2) {
if (GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) { if (GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) {
buffer = gst_vaapi_video_buffer_new_from_buffer(inbuf); buffer = gst_vaapi_video_buffer_new_from_buffer(inbuf);
GST_BUFFER_SIZE(buffer) = size; GST_BUFFER_SIZE(buffer) = size;
} }
else { else {
GST_DEBUG("upstream element destroyed our in/out buffer"); GST_DEBUG("upstream element destroyed our in/out buffer");
convert->direct_rendering = 1; upload->direct_rendering = 1;
} }
} }
if (!buffer) { if (!buffer) {
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces); buffer = gst_vaapi_video_buffer_new_from_pool(upload->surfaces);
if (!buffer) if (!buffer)
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
} }
@ -795,18 +795,18 @@ gst_vaapiconvert_prepare_output_buffer(
} }
static gboolean static gboolean
gst_vaapiconvert_query(GstPad *pad, GstQuery *query) gst_vaapiupload_query(GstPad *pad, GstQuery *query)
{ {
GstVaapiConvert *convert = GST_VAAPICONVERT (gst_pad_get_parent_element (pad)); GstVaapiUpload *upload = GST_VAAPIUPLOAD (gst_pad_get_parent_element (pad));
gboolean res; gboolean res;
GST_DEBUG ("sharing display %p", convert->display); GST_DEBUG ("sharing display %p", upload->display);
if (gst_vaapi_reply_to_query (query, convert->display)) if (gst_vaapi_reply_to_query (query, upload->display))
res = TRUE; res = TRUE;
else else
res = gst_pad_query_default (pad, query); res = gst_pad_query_default (pad, query);
g_object_unref (convert); g_object_unref (upload);
return res; return res;
} }

View file

@ -1,5 +1,5 @@
/* /*
* gstvaapiconvert.h - VA-API video converter * gstvaapiupload.h - VA-API video uploader
* *
* gstreamer-vaapi (C) 2010-2011 Splitted-Desktop Systems * gstreamer-vaapi (C) 2010-2011 Splitted-Desktop Systems
* *
@ -19,8 +19,8 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
#ifndef GST_VAAPICONVERT_H #ifndef GST_VAAPIUPLOAD_H
#define GST_VAAPICONVERT_H #define GST_VAAPIUPLOAD_H
#include <gst/base/gstbasetransform.h> #include <gst/base/gstbasetransform.h>
#include <gst/vaapi/gstvaapidisplay.h> #include <gst/vaapi/gstvaapidisplay.h>
@ -31,37 +31,37 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_VAAPICONVERT \ #define GST_TYPE_VAAPIUPLOAD \
(gst_vaapiconvert_get_type()) (gst_vaapiupload_get_type())
#define GST_VAAPICONVERT(obj) \ #define GST_VAAPIUPLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_TYPE_VAAPICONVERT, \ GST_TYPE_VAAPIUPLOAD, \
GstVaapiConvert)) GstVaapiUpload))
#define GST_VAAPICONVERT_CLASS(klass) \ #define GST_VAAPIUPLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \ (G_TYPE_CHECK_CLASS_CAST((klass), \
GST_TYPE_VAAPICONVERT, \ GST_TYPE_VAAPIUPLOAD, \
GstVaapiConvertClass)) GstVaapiUploadClass))
#define GST_IS_VAAPICONVERT(obj) \ #define GST_IS_VAAPIUPLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPICONVERT)) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIUPLOAD))
#define GST_IS_VAAPICONVERT_CLASS(klass) \ #define GST_IS_VAAPIUPLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPICONVERT)) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIUPLOAD))
#define GST_VAAPICONVERT_GET_CLASS(obj) \ #define GST_VAAPIUPLOAD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \ (G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_TYPE_VAAPICONVERT, \ GST_TYPE_VAAPIUPLOAD, \
GstVaapiConvertClass)) GstVaapiUploadClass))
typedef struct _GstVaapiConvert GstVaapiConvert; typedef struct _GstVaapiUpload GstVaapiUpload;
typedef struct _GstVaapiConvertClass GstVaapiConvertClass; typedef struct _GstVaapiUploadClass GstVaapiUploadClass;
/* Max output surfaces */ /* Max output surfaces */
#define GST_VAAPICONVERT_MAX_SURFACES 2 #define GST_VAAPIUPLOAD_MAX_SURFACES 2
struct _GstVaapiConvert { struct _GstVaapiUpload {
/*< private >*/ /*< private >*/
GstBaseTransform parent_instance; GstBaseTransform parent_instance;
@ -78,14 +78,14 @@ struct _GstVaapiConvert {
unsigned int surfaces_reset : 1; unsigned int surfaces_reset : 1;
}; };
struct _GstVaapiConvertClass { struct _GstVaapiUploadClass {
/*< private >*/ /*< private >*/
GstBaseTransformClass parent_class; GstBaseTransformClass parent_class;
}; };
GType GType
gst_vaapiconvert_get_type(void); gst_vaapiupload_get_type(void);
G_END_DECLS G_END_DECLS
#endif /* GST_VAAPICONVERT_H */ #endif /* GST_VAAPIUPLOAD_H */