mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
remove gstvaapiuploader
Working on bug #744042 I realized that the gstvaapiuploader is practically not used. This patch removes the gstvaapiuploader and add the method gst_vaapi_plugin_base_get_allowed_raw_caps () that returns the raw caps that the system can handle, which is used by vaapisink and vaapipostproc. Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=752777
This commit is contained in:
parent
b601bf0df6
commit
001a5c637d
8 changed files with 97 additions and 742 deletions
|
@ -52,7 +52,6 @@ libgstvaapi_source_c = \
|
||||||
gstvaapipluginutil.c \
|
gstvaapipluginutil.c \
|
||||||
gstvaapipostproc.c \
|
gstvaapipostproc.c \
|
||||||
gstvaapisink.c \
|
gstvaapisink.c \
|
||||||
gstvaapiuploader.c \
|
|
||||||
gstvaapivideobuffer.c \
|
gstvaapivideobuffer.c \
|
||||||
gstvaapivideocontext.c \
|
gstvaapivideocontext.c \
|
||||||
gstvaapivideometa.c \
|
gstvaapivideometa.c \
|
||||||
|
@ -68,7 +67,6 @@ libgstvaapi_source_h = \
|
||||||
gstvaapipluginutil.h \
|
gstvaapipluginutil.h \
|
||||||
gstvaapipostproc.h \
|
gstvaapipostproc.h \
|
||||||
gstvaapisink.h \
|
gstvaapisink.h \
|
||||||
gstvaapiuploader.h \
|
|
||||||
gstvaapivideobuffer.h \
|
gstvaapivideobuffer.h \
|
||||||
gstvaapivideocontext.h \
|
gstvaapivideocontext.h \
|
||||||
gstvaapivideometa.h \
|
gstvaapivideometa.h \
|
||||||
|
|
|
@ -57,16 +57,6 @@ ensure_display (GstVaapiEncode * encode)
|
||||||
return gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (encode));
|
return gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (encode));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_uploader (GstVaapiEncode * encode)
|
|
||||||
{
|
|
||||||
if (!ensure_display (encode))
|
|
||||||
return FALSE;
|
|
||||||
if (!gst_vaapi_plugin_base_ensure_uploader (GST_VAAPI_PLUGIN_BASE (encode)))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapiencode_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
gst_vaapiencode_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
|
@ -385,9 +375,6 @@ ensure_encoder (GstVaapiEncode * encode)
|
||||||
|
|
||||||
g_return_val_if_fail (klass->alloc_encoder, FALSE);
|
g_return_val_if_fail (klass->alloc_encoder, FALSE);
|
||||||
|
|
||||||
if (!ensure_uploader (encode))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
encode->encoder = klass->alloc_encoder (encode,
|
encode->encoder = klass->alloc_encoder (encode,
|
||||||
GST_VAAPI_PLUGIN_BASE_DISPLAY (encode));
|
GST_VAAPI_PLUGIN_BASE_DISPLAY (encode));
|
||||||
if (!encode->encoder)
|
if (!encode->encoder)
|
||||||
|
|
|
@ -238,7 +238,6 @@ gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin)
|
||||||
void
|
void
|
||||||
gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin)
|
gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin)
|
||||||
{
|
{
|
||||||
g_clear_object (&plugin->uploader);
|
|
||||||
gst_vaapi_display_replace (&plugin->display, NULL);
|
gst_vaapi_display_replace (&plugin->display, NULL);
|
||||||
gst_object_replace (&plugin->gl_context, NULL);
|
gst_object_replace (&plugin->gl_context, NULL);
|
||||||
|
|
||||||
|
@ -254,6 +253,7 @@ gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin)
|
||||||
gst_caps_replace (&plugin->srcpad_caps, NULL);
|
gst_caps_replace (&plugin->srcpad_caps, NULL);
|
||||||
plugin->srcpad_caps_changed = FALSE;
|
plugin->srcpad_caps_changed = FALSE;
|
||||||
gst_video_info_init (&plugin->srcpad_info);
|
gst_video_info_init (&plugin->srcpad_info);
|
||||||
|
gst_caps_replace (&plugin->allowed_raw_caps, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,29 +342,6 @@ gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vaapi_plugin_base_ensure_uploader:
|
|
||||||
* @plugin: a #GstVaapiPluginBase
|
|
||||||
*
|
|
||||||
* Makes sure the built-in #GstVaapiUploader object is created, or
|
|
||||||
* that it was successfully notified of any VA display change.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if the uploader was successfully created, %FALSE otherwise.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin)
|
|
||||||
{
|
|
||||||
if (plugin->uploader) {
|
|
||||||
if (!gst_vaapi_uploader_ensure_display (plugin->uploader, plugin->display))
|
|
||||||
return FALSE;
|
|
||||||
} else {
|
|
||||||
plugin->uploader = gst_vaapi_uploader_new (plugin->display);
|
|
||||||
if (!plugin->uploader)
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Checks whether the supplied pad peer element supports DMABUF sharing */
|
/* Checks whether the supplied pad peer element supports DMABUF sharing */
|
||||||
/* XXX: this is a workaround to the absence of any proposer way to
|
/* XXX: this is a workaround to the absence of any proposer way to
|
||||||
specify DMABUF memory capsfeatures or bufferpool option to downstream */
|
specify DMABUF memory capsfeatures or bufferpool option to downstream */
|
||||||
|
@ -521,14 +498,6 @@ gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
|
||||||
plugin->srcpad_caps_changed = TRUE;
|
plugin->srcpad_caps_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin->uploader && plugin->sinkpad_caps_is_raw) {
|
|
||||||
if (!gst_vaapi_uploader_ensure_display (plugin->uploader, plugin->display))
|
|
||||||
return FALSE;
|
|
||||||
if (!gst_vaapi_uploader_ensure_caps (plugin->uploader,
|
|
||||||
plugin->sinkpad_caps, plugin->srcpad_caps))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ensure_sinkpad_buffer_pool (plugin, plugin->sinkpad_caps))
|
if (!ensure_sinkpad_buffer_pool (plugin, plugin->sinkpad_caps))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -777,49 +746,6 @@ config_failed:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vaapi_plugin_base_allocate_input_buffer:
|
|
||||||
* @plugin: a #GstVaapiPluginBase
|
|
||||||
* @caps: the buffer caps constraints to honour
|
|
||||||
* @outbuf_ptr: the pointer location to the newly allocated buffer
|
|
||||||
*
|
|
||||||
* Creates a buffer that holds a VA surface memory for the sink pad to
|
|
||||||
* use it as the result for buffer_alloc() impementations.
|
|
||||||
*
|
|
||||||
* Return: #GST_FLOW_OK if the buffer could be created.
|
|
||||||
*/
|
|
||||||
GstFlowReturn
|
|
||||||
gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
|
|
||||||
GstCaps * caps, GstBuffer ** outbuf_ptr)
|
|
||||||
{
|
|
||||||
GstBuffer *outbuf;
|
|
||||||
|
|
||||||
*outbuf_ptr = NULL;
|
|
||||||
|
|
||||||
if (!plugin->sinkpad_caps_changed) {
|
|
||||||
if (!gst_video_info_from_caps (&plugin->sinkpad_info, caps))
|
|
||||||
return GST_FLOW_NOT_SUPPORTED;
|
|
||||||
plugin->sinkpad_caps_changed = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin->sinkpad_caps_is_raw)
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
|
|
||||||
if (!gst_vaapi_uploader_ensure_display (plugin->uploader, plugin->display))
|
|
||||||
return GST_FLOW_NOT_SUPPORTED;
|
|
||||||
if (!gst_vaapi_uploader_ensure_caps (plugin->uploader, caps, NULL))
|
|
||||||
return GST_FLOW_NOT_SUPPORTED;
|
|
||||||
|
|
||||||
outbuf = gst_vaapi_uploader_get_buffer (plugin->uploader);
|
|
||||||
if (!outbuf) {
|
|
||||||
GST_WARNING ("failed to allocate resources for raw YUV buffer");
|
|
||||||
return GST_FLOW_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
*outbuf_ptr = outbuf;
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_plugin_base_get_input_buffer:
|
* gst_vaapi_plugin_base_get_input_buffer:
|
||||||
* @plugin: a #GstVaapiPluginBase
|
* @plugin: a #GstVaapiPluginBase
|
||||||
|
@ -983,3 +909,82 @@ gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
||||||
gst_vaapi_plugin_base_set_display_type (plugin, display_type);
|
gst_vaapi_plugin_base_set_display_type (plugin, display_type);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ensure_allowed_raw_caps (GstVaapiPluginBase * plugin)
|
||||||
|
{
|
||||||
|
GArray *formats, *out_formats;
|
||||||
|
GstVaapiSurface *surface;
|
||||||
|
guint i;
|
||||||
|
GstCaps *out_caps;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
if (plugin->allowed_raw_caps)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
out_formats = formats = NULL;
|
||||||
|
surface = NULL;
|
||||||
|
|
||||||
|
formats = gst_vaapi_display_get_image_formats (plugin->display);
|
||||||
|
if (!formats)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
out_formats =
|
||||||
|
g_array_sized_new (FALSE, FALSE, sizeof (GstVideoFormat), formats->len);
|
||||||
|
if (!out_formats)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
surface =
|
||||||
|
gst_vaapi_surface_new (plugin->display, GST_VAAPI_CHROMA_TYPE_YUV420, 64,
|
||||||
|
64);
|
||||||
|
if (!surface)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
for (i = 0; i < formats->len; i++) {
|
||||||
|
const GstVideoFormat format = g_array_index (formats, GstVideoFormat, i);
|
||||||
|
GstVaapiImage *image;
|
||||||
|
|
||||||
|
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
|
continue;
|
||||||
|
image = gst_vaapi_image_new (plugin->display, format, 64, 64);
|
||||||
|
if (!image)
|
||||||
|
continue;
|
||||||
|
if (gst_vaapi_surface_put_image (surface, image))
|
||||||
|
g_array_append_val (out_formats, format);
|
||||||
|
gst_vaapi_object_unref (image);
|
||||||
|
}
|
||||||
|
|
||||||
|
out_caps = gst_vaapi_video_format_new_template_caps_from_list (out_formats);
|
||||||
|
if (!out_caps)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
gst_caps_replace (&plugin->allowed_raw_caps, out_caps);
|
||||||
|
gst_caps_unref (out_caps);
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
bail:
|
||||||
|
if (formats)
|
||||||
|
g_array_unref (formats);
|
||||||
|
if (out_formats)
|
||||||
|
g_array_unref (out_formats);
|
||||||
|
if (surface)
|
||||||
|
gst_vaapi_object_unref (surface);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_plugin_base_get_allowed_raw_caps:
|
||||||
|
* @plugin: a #GstVaapiPluginBase
|
||||||
|
*
|
||||||
|
* Returns the raw #GstCaps allowed by the element.
|
||||||
|
*
|
||||||
|
* Returns: the allowed raw #GstCaps or %NULL
|
||||||
|
**/
|
||||||
|
GstCaps *
|
||||||
|
gst_vaapi_plugin_base_get_allowed_raw_caps (GstVaapiPluginBase * plugin)
|
||||||
|
{
|
||||||
|
if (!ensure_allowed_raw_caps (plugin))
|
||||||
|
return NULL;
|
||||||
|
return plugin->allowed_raw_caps;
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <gst/video/gstvideoencoder.h>
|
#include <gst/video/gstvideoencoder.h>
|
||||||
#include <gst/video/gstvideosink.h>
|
#include <gst/video/gstvideosink.h>
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
#include <gst/vaapi/gstvaapidisplay.h>
|
||||||
#include "gstvaapiuploader.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_GST_GL_GL_H
|
#ifdef HAVE_GST_GL_GL_H
|
||||||
# include <gst/gl/gstglcontext.h>
|
# include <gst/gl/gstglcontext.h>
|
||||||
|
@ -103,13 +102,6 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
|
||||||
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
|
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
|
||||||
(new_display)))
|
(new_display)))
|
||||||
|
|
||||||
#define GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin) \
|
|
||||||
(GST_VAAPI_PLUGIN_BASE(plugin)->uploader)
|
|
||||||
#define GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS(plugin) \
|
|
||||||
(gst_vaapi_uploader_get_caps(GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin)))
|
|
||||||
#define GST_VAAPI_PLUGIN_BASE_UPLOADER_USED(plugin) \
|
|
||||||
(GST_VAAPI_PLUGIN_BASE(plugin)->uploader_used)
|
|
||||||
|
|
||||||
struct _GstVaapiPluginBase
|
struct _GstVaapiPluginBase
|
||||||
{
|
{
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
@ -147,8 +139,7 @@ struct _GstVaapiPluginBase
|
||||||
|
|
||||||
GstObject *gl_context;
|
GstObject *gl_context;
|
||||||
|
|
||||||
GstVaapiUploader *uploader;
|
GstCaps *allowed_raw_caps;
|
||||||
gboolean uploader_used;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVaapiPluginBaseClass
|
struct _GstVaapiPluginBaseClass
|
||||||
|
@ -211,10 +202,6 @@ G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
|
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
|
gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
|
||||||
|
@ -230,11 +217,6 @@ gboolean
|
||||||
gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
||||||
GstQuery * query, guint feature);
|
GstQuery * query, guint feature);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GstFlowReturn
|
|
||||||
gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
|
|
||||||
GstCaps * caps, GstBuffer ** outbuf_ptr);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
|
gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
|
||||||
|
@ -245,6 +227,10 @@ void
|
||||||
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
||||||
GstObject * object);
|
GstObject * object);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GstCaps *
|
||||||
|
gst_vaapi_plugin_base_get_allowed_raw_caps (GstVaapiPluginBase * plugin);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|
||||||
|
|
|
@ -213,16 +213,6 @@ gst_vaapipostproc_ensure_display (GstVaapiPostproc * postproc)
|
||||||
gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (postproc));
|
gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (postproc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_vaapipostproc_ensure_uploader (GstVaapiPostproc * postproc)
|
|
||||||
{
|
|
||||||
if (!gst_vaapipostproc_ensure_display (postproc))
|
|
||||||
return FALSE;
|
|
||||||
if (!gst_vaapi_plugin_base_ensure_uploader (GST_VAAPI_PLUGIN_BASE (postproc)))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapipostproc_ensure_filter (GstVaapiPostproc * postproc)
|
gst_vaapipostproc_ensure_filter (GstVaapiPostproc * postproc)
|
||||||
{
|
{
|
||||||
|
@ -265,8 +255,6 @@ gst_vaapipostproc_create (GstVaapiPostproc * postproc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!gst_vaapipostproc_ensure_display (postproc))
|
if (!gst_vaapipostproc_ensure_display (postproc))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!gst_vaapipostproc_ensure_uploader (postproc))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
postproc->use_vpp = FALSE;
|
postproc->use_vpp = FALSE;
|
||||||
postproc->has_vpp = gst_vaapipostproc_ensure_filter (postproc);
|
postproc->has_vpp = gst_vaapipostproc_ensure_filter (postproc);
|
||||||
|
@ -935,18 +923,19 @@ ensure_allowed_sinkpad_caps (GstVaapiPostproc * postproc)
|
||||||
out_caps = gst_caps_from_string (GST_VAAPIPOSTPROC_SURFACE_CAPS ", "
|
out_caps = gst_caps_from_string (GST_VAAPIPOSTPROC_SURFACE_CAPS ", "
|
||||||
GST_CAPS_INTERLACED_MODES);
|
GST_CAPS_INTERLACED_MODES);
|
||||||
if (!out_caps) {
|
if (!out_caps) {
|
||||||
GST_ERROR ("failed to create VA sink caps");
|
GST_ERROR_OBJECT (postproc, "failed to create VA sink caps");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append raw video caps */
|
/* Append raw video caps */
|
||||||
if (gst_vaapipostproc_ensure_uploader (postproc)) {
|
if (gst_vaapipostproc_ensure_display (postproc)) {
|
||||||
raw_caps = GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS (postproc);
|
raw_caps = gst_vaapi_plugin_base_get_allowed_raw_caps (GST_VAAPI_PLUGIN_BASE (postproc));
|
||||||
if (raw_caps) {
|
if (raw_caps) {
|
||||||
out_caps = gst_caps_make_writable (out_caps);
|
out_caps = gst_caps_make_writable (out_caps);
|
||||||
gst_caps_append (out_caps, gst_caps_copy (raw_caps));
|
gst_caps_append (out_caps, gst_caps_copy (raw_caps));
|
||||||
} else
|
} else {
|
||||||
GST_WARNING ("failed to create YUV sink caps");
|
GST_WARNING_OBJECT (postproc, "failed to create YUV sink caps");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
postproc->allowed_sinkpad_caps = out_caps;
|
postproc->allowed_sinkpad_caps = out_caps;
|
||||||
|
|
||||||
|
|
|
@ -979,16 +979,6 @@ gst_vaapisink_ensure_backend (GstVaapiSink * sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_vaapisink_ensure_uploader (GstVaapiSink * sink)
|
|
||||||
{
|
|
||||||
if (!gst_vaapisink_ensure_display (sink))
|
|
||||||
return FALSE;
|
|
||||||
if (!gst_vaapi_plugin_base_ensure_uploader (GST_VAAPI_PLUGIN_BASE (sink)))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapisink_ensure_render_rect (GstVaapiSink * sink, guint width,
|
gst_vaapisink_ensure_render_rect (GstVaapiSink * sink, guint width,
|
||||||
guint height)
|
guint height)
|
||||||
|
@ -1193,9 +1183,7 @@ gst_vaapisink_start (GstBaseSink * base_sink)
|
||||||
{
|
{
|
||||||
GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
|
GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
|
||||||
|
|
||||||
if (!gst_vaapi_plugin_base_open (GST_VAAPI_PLUGIN_BASE (sink)))
|
return gst_vaapi_plugin_base_open (GST_VAAPI_PLUGIN_BASE (sink));
|
||||||
return FALSE;
|
|
||||||
return gst_vaapisink_ensure_uploader (sink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -1214,17 +1202,17 @@ static GstCaps *
|
||||||
gst_vaapisink_get_caps_impl (GstBaseSink * base_sink)
|
gst_vaapisink_get_caps_impl (GstBaseSink * base_sink)
|
||||||
{
|
{
|
||||||
GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
|
GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
|
||||||
GstCaps *out_caps, *yuv_caps;
|
GstCaps *out_caps, *raw_caps;
|
||||||
|
|
||||||
out_caps = gst_static_pad_template_get_caps (&gst_vaapisink_sink_factory);
|
out_caps = gst_static_pad_template_get_caps (&gst_vaapisink_sink_factory);
|
||||||
if (!out_caps)
|
if (!out_caps)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (gst_vaapisink_ensure_uploader (sink)) {
|
if (gst_vaapisink_ensure_display (sink)) {
|
||||||
yuv_caps = GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS (sink);
|
raw_caps = gst_vaapi_plugin_base_get_allowed_raw_caps (GST_VAAPI_PLUGIN_BASE (sink));
|
||||||
if (yuv_caps) {
|
if (raw_caps) {
|
||||||
out_caps = gst_caps_make_writable (out_caps);
|
out_caps = gst_caps_make_writable (out_caps);
|
||||||
gst_caps_append (out_caps, gst_caps_copy (yuv_caps));
|
gst_caps_append (out_caps, gst_caps_copy (raw_caps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out_caps;
|
return out_caps;
|
||||||
|
|
|
@ -1,495 +0,0 @@
|
||||||
/*
|
|
||||||
* gstvaapiuploader.c - VA-API video upload helper
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
|
||||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
|
||||||
* Copyright (C) 2011-2013 Intel Corporation
|
|
||||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gstcompat.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
|
||||||
#include <gst/vaapi/gstvaapiimagepool.h>
|
|
||||||
#include <gst/vaapi/gstvaapisurfacepool.h>
|
|
||||||
|
|
||||||
#include "gstvaapiuploader.h"
|
|
||||||
#include "gstvaapipluginutil.h"
|
|
||||||
#include "gstvaapivideobuffer.h"
|
|
||||||
|
|
||||||
#define GST_HELPER_NAME "vaapiupload"
|
|
||||||
#define GST_HELPER_DESC "VA-API video uploader"
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapi_uploader);
|
|
||||||
#define GST_CAT_DEFAULT gst_debug_vaapi_uploader
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstVaapiUploader, gst_vaapi_uploader, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
#define GST_VAAPI_UPLOADER_CAST(obj) \
|
|
||||||
((GstVaapiUploader *)(obj))
|
|
||||||
#define GST_VAAPI_UPLOADER_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_VAAPI_TYPE_UPLOADER, \
|
|
||||||
GstVaapiUploaderPrivate))
|
|
||||||
|
|
||||||
struct _GstVaapiUploaderPrivate
|
|
||||||
{
|
|
||||||
GstVaapiDisplay *display;
|
|
||||||
GstCaps *allowed_caps;
|
|
||||||
GstVaapiVideoPool *images;
|
|
||||||
GstVideoInfo image_info;
|
|
||||||
GstVaapiVideoPool *surfaces;
|
|
||||||
GstVideoInfo surface_info;
|
|
||||||
guint direct_rendering;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
|
|
||||||
PROP_DISPLAY,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_destroy (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *const priv = uploader->priv;
|
|
||||||
|
|
||||||
gst_caps_replace (&priv->allowed_caps, NULL);
|
|
||||||
gst_vaapi_video_pool_replace (&priv->images, NULL);
|
|
||||||
gst_vaapi_video_pool_replace (&priv->surfaces, NULL);
|
|
||||||
gst_vaapi_display_replace (&priv->display, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_display (GstVaapiUploader * uploader, GstVaapiDisplay * display)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *const priv = uploader->priv;
|
|
||||||
|
|
||||||
gst_vaapi_display_replace (&priv->display, display);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_image (GstVaapiImage * image)
|
|
||||||
{
|
|
||||||
guint i, num_planes, width, height;
|
|
||||||
|
|
||||||
/* Make the image fully dirty */
|
|
||||||
if (!gst_vaapi_image_map (image))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_vaapi_image_get_size (image, &width, &height);
|
|
||||||
|
|
||||||
num_planes = gst_vaapi_image_get_plane_count (image);
|
|
||||||
for (i = 0; i < num_planes; i++) {
|
|
||||||
guchar *const plane = gst_vaapi_image_get_plane (image, i);
|
|
||||||
if (plane)
|
|
||||||
memset (plane, 0, gst_vaapi_image_get_pitch (image, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gst_vaapi_image_unmap (image))
|
|
||||||
gst_vaapi_image_unmap (image);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_allowed_caps (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *const priv = uploader->priv;
|
|
||||||
GstVaapiSurface *surface = NULL;
|
|
||||||
GArray *formats = NULL, *out_formats = NULL;
|
|
||||||
GstCaps *out_caps;
|
|
||||||
guint i;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{ WIDTH = 64, HEIGHT = 64 };
|
|
||||||
|
|
||||||
if (priv->allowed_caps)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
formats = gst_vaapi_display_get_image_formats (priv->display);
|
|
||||||
if (!formats)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
out_formats = g_array_sized_new (FALSE, FALSE, sizeof (GstVideoFormat),
|
|
||||||
formats->len);
|
|
||||||
if (!out_formats)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
surface = gst_vaapi_surface_new (priv->display,
|
|
||||||
GST_VAAPI_CHROMA_TYPE_YUV420, WIDTH, HEIGHT);
|
|
||||||
if (!surface)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
for (i = 0; i < formats->len; i++) {
|
|
||||||
const GstVideoFormat format = g_array_index (formats, GstVideoFormat, i);
|
|
||||||
GstVaapiImage *image;
|
|
||||||
|
|
||||||
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
|
||||||
continue;
|
|
||||||
image = gst_vaapi_image_new (priv->display, format, WIDTH, HEIGHT);
|
|
||||||
if (!image)
|
|
||||||
continue;
|
|
||||||
if (ensure_image (image) && gst_vaapi_surface_put_image (surface, image))
|
|
||||||
g_array_append_val (out_formats, format);
|
|
||||||
gst_vaapi_object_unref (image);
|
|
||||||
}
|
|
||||||
|
|
||||||
out_caps = gst_vaapi_video_format_new_template_caps_from_list (out_formats);
|
|
||||||
if (!out_caps)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
gst_caps_replace (&priv->allowed_caps, out_caps);
|
|
||||||
gst_caps_unref (out_caps);
|
|
||||||
success = TRUE;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (out_formats)
|
|
||||||
g_array_unref (out_formats);
|
|
||||||
if (formats)
|
|
||||||
g_array_unref (formats);
|
|
||||||
if (surface)
|
|
||||||
gst_vaapi_object_unref (surface);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_image_pool (GstVaapiUploader * uploader, GstCaps * caps,
|
|
||||||
gboolean * caps_changed_ptr)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *const priv = uploader->priv;
|
|
||||||
GstVaapiVideoPool *pool;
|
|
||||||
GstVideoInfo vi;
|
|
||||||
GstVideoFormat format;
|
|
||||||
guint width, height;
|
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&vi, caps))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
format = GST_VIDEO_INFO_FORMAT (&vi);
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (&vi);
|
|
||||||
height = GST_VIDEO_INFO_HEIGHT (&vi);
|
|
||||||
|
|
||||||
*caps_changed_ptr =
|
|
||||||
format != GST_VIDEO_INFO_FORMAT (&priv->image_info) ||
|
|
||||||
width != GST_VIDEO_INFO_WIDTH (&priv->image_info) ||
|
|
||||||
height != GST_VIDEO_INFO_HEIGHT (&priv->image_info);
|
|
||||||
if (!*caps_changed_ptr)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
pool = gst_vaapi_image_pool_new (priv->display, &vi);
|
|
||||||
if (!pool)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_video_info_set_format (&priv->image_info, format, width, height);
|
|
||||||
gst_vaapi_video_pool_replace (&priv->images, pool);
|
|
||||||
gst_vaapi_video_pool_unref (pool);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ensure_surface_pool (GstVaapiUploader * uploader, GstCaps * caps,
|
|
||||||
gboolean * caps_changed_ptr)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *const priv = uploader->priv;
|
|
||||||
GstVaapiVideoPool *pool;
|
|
||||||
GstVideoInfo vi;
|
|
||||||
GstVideoFormat format;
|
|
||||||
guint width, height;
|
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&vi, caps))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
format = GST_VIDEO_INFO_FORMAT (&vi);
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (&vi);
|
|
||||||
height = GST_VIDEO_INFO_HEIGHT (&vi);
|
|
||||||
|
|
||||||
*caps_changed_ptr =
|
|
||||||
format != GST_VIDEO_INFO_FORMAT (&priv->surface_info) ||
|
|
||||||
width != GST_VIDEO_INFO_WIDTH (&priv->surface_info) ||
|
|
||||||
height != GST_VIDEO_INFO_HEIGHT (&priv->surface_info);
|
|
||||||
if (!*caps_changed_ptr)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* Always try to downsample source buffers to YUV 4:2:0 format as
|
|
||||||
this saves memory bandwidth for further rendering */
|
|
||||||
/* XXX: this also means that visual quality is not preserved */
|
|
||||||
if (format != GST_VIDEO_FORMAT_ENCODED) {
|
|
||||||
const GstVaapiChromaType chroma_type =
|
|
||||||
gst_vaapi_video_format_get_chroma_type (format);
|
|
||||||
if (chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420) {
|
|
||||||
const GstVideoFormat image_format =
|
|
||||||
GST_VIDEO_INFO_FORMAT (&priv->image_info);
|
|
||||||
GST_INFO ("use implicit conversion of %s buffers to NV12 surfaces",
|
|
||||||
gst_video_format_to_string (image_format));
|
|
||||||
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pool = gst_vaapi_surface_pool_new_full (priv->display, &vi, 0);
|
|
||||||
if (!pool)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_video_info_set_format (&priv->surface_info, format, width, height);
|
|
||||||
gst_vaapi_video_pool_replace (&priv->surfaces, pool);
|
|
||||||
gst_vaapi_video_pool_unref (pool);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
gst_vaapi_uploader_destroy (GST_VAAPI_UPLOADER_CAST (object));
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_vaapi_uploader_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstVaapiUploader *const uploader = GST_VAAPI_UPLOADER_CAST (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_DISPLAY:
|
|
||||||
ensure_display (uploader, g_value_get_pointer (value));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstVaapiUploader *const uploader = GST_VAAPI_UPLOADER_CAST (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_DISPLAY:
|
|
||||||
g_value_set_pointer (value, uploader->priv->display);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_class_init (GstVaapiUploaderClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi_uploader,
|
|
||||||
GST_HELPER_NAME, 0, GST_HELPER_DESC);
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstVaapiUploaderPrivate));
|
|
||||||
|
|
||||||
object_class->finalize = gst_vaapi_uploader_finalize;
|
|
||||||
object_class->set_property = gst_vaapi_uploader_set_property;
|
|
||||||
object_class->get_property = gst_vaapi_uploader_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
|
||||||
PROP_DISPLAY,
|
|
||||||
g_param_spec_pointer ("display",
|
|
||||||
"Display",
|
|
||||||
"The GstVaapiDisplay this object is bound to",
|
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_uploader_init (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *priv;
|
|
||||||
|
|
||||||
priv = GST_VAAPI_UPLOADER_GET_PRIVATE (uploader);
|
|
||||||
uploader->priv = priv;
|
|
||||||
|
|
||||||
gst_video_info_init (&priv->image_info);
|
|
||||||
gst_video_info_init (&priv->surface_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
GstVaapiUploader *
|
|
||||||
gst_vaapi_uploader_new (GstVaapiDisplay * display)
|
|
||||||
{
|
|
||||||
return g_object_new (GST_VAAPI_TYPE_UPLOADER, "display", display, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_ensure_display (GstVaapiUploader * uploader,
|
|
||||||
GstVaapiDisplay * display)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE);
|
|
||||||
g_return_val_if_fail (display != NULL, FALSE);
|
|
||||||
|
|
||||||
return ensure_display (uploader, display);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_ensure_caps (GstVaapiUploader * uploader,
|
|
||||||
GstCaps * src_caps, GstCaps * out_caps)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *priv;
|
|
||||||
GstVaapiImage *image;
|
|
||||||
gboolean image_caps_changed, surface_caps_changed;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE);
|
|
||||||
g_return_val_if_fail (src_caps != NULL, FALSE);
|
|
||||||
|
|
||||||
if (!out_caps)
|
|
||||||
out_caps = src_caps;
|
|
||||||
|
|
||||||
if (!ensure_image_pool (uploader, src_caps, &image_caps_changed))
|
|
||||||
return FALSE;
|
|
||||||
if (!ensure_surface_pool (uploader, out_caps, &surface_caps_changed))
|
|
||||||
return FALSE;
|
|
||||||
if (!image_caps_changed && !surface_caps_changed)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
priv = uploader->priv;
|
|
||||||
priv->direct_rendering = 0;
|
|
||||||
|
|
||||||
/* Check if we can alias source and output buffers (same data_size) */
|
|
||||||
image = gst_vaapi_video_pool_get_object (priv->images);
|
|
||||||
if (image) {
|
|
||||||
if ((gst_vaapi_image_get_format (image) ==
|
|
||||||
GST_VIDEO_INFO_FORMAT (&priv->image_info)) &&
|
|
||||||
gst_vaapi_image_is_linear (image) &&
|
|
||||||
(gst_vaapi_image_get_data_size (image) ==
|
|
||||||
GST_VIDEO_INFO_SIZE (&priv->image_info)))
|
|
||||||
priv->direct_rendering = 1;
|
|
||||||
gst_vaapi_video_pool_put_object (priv->images, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_INFO ("direct-rendering: level %u", priv->direct_rendering);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_process (GstVaapiUploader * uploader,
|
|
||||||
GstBuffer * src_buffer, GstBuffer * out_buffer)
|
|
||||||
{
|
|
||||||
GstVaapiVideoMeta *src_meta, *out_meta;
|
|
||||||
GstVaapiSurface *surface;
|
|
||||||
GstVaapiImage *image;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE);
|
|
||||||
|
|
||||||
out_meta = gst_buffer_get_vaapi_video_meta (out_buffer);
|
|
||||||
if (!out_meta) {
|
|
||||||
GST_WARNING ("expected an output video buffer");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface = gst_vaapi_video_meta_get_surface (out_meta);
|
|
||||||
g_return_val_if_fail (surface != NULL, FALSE);
|
|
||||||
|
|
||||||
src_meta = gst_buffer_get_vaapi_video_meta (src_buffer);
|
|
||||||
if (src_meta) {
|
|
||||||
/* GstVaapiVideoBuffer with mapped VA image */
|
|
||||||
image = gst_vaapi_video_meta_get_image (src_meta);
|
|
||||||
if (!image || !gst_vaapi_image_unmap (image))
|
|
||||||
return FALSE;
|
|
||||||
} else {
|
|
||||||
/* Regular GstBuffer that needs to be uploaded to a VA image */
|
|
||||||
image = gst_vaapi_video_meta_get_image (out_meta);
|
|
||||||
if (!image) {
|
|
||||||
image = gst_vaapi_video_pool_get_object (uploader->priv->images);
|
|
||||||
if (!image)
|
|
||||||
return FALSE;
|
|
||||||
gst_vaapi_video_meta_set_image (out_meta, image);
|
|
||||||
}
|
|
||||||
if (!gst_vaapi_image_update_from_buffer (image, src_buffer, NULL))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
g_return_val_if_fail (image != NULL, FALSE);
|
|
||||||
|
|
||||||
if (!gst_vaapi_surface_put_image (surface, image)) {
|
|
||||||
GST_WARNING ("failed to upload YUV buffer to VA surface");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map again for next uploads */
|
|
||||||
if (!gst_vaapi_image_map (image))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GstCaps *
|
|
||||||
gst_vaapi_uploader_get_caps (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), NULL);
|
|
||||||
|
|
||||||
if (!ensure_allowed_caps (uploader))
|
|
||||||
return NULL;
|
|
||||||
return uploader->priv->allowed_caps;
|
|
||||||
}
|
|
||||||
|
|
||||||
GstBuffer *
|
|
||||||
gst_vaapi_uploader_get_buffer (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
GstVaapiUploaderPrivate *priv;
|
|
||||||
GstVaapiImage *image;
|
|
||||||
GstVaapiVideoMeta *meta;
|
|
||||||
GstVaapiSurfaceProxy *proxy;
|
|
||||||
GstBuffer *buffer;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), NULL);
|
|
||||||
|
|
||||||
priv = uploader->priv;
|
|
||||||
|
|
||||||
buffer = gst_vaapi_video_buffer_new_from_pool (priv->images);
|
|
||||||
if (!buffer) {
|
|
||||||
GST_WARNING ("failed to allocate video buffer");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy =
|
|
||||||
gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL
|
|
||||||
(priv->surfaces));
|
|
||||||
if (!proxy) {
|
|
||||||
GST_WARNING ("failed to allocate VA surface");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
meta = gst_buffer_get_vaapi_video_meta (buffer);
|
|
||||||
gst_vaapi_video_meta_set_surface_proxy (meta, proxy);
|
|
||||||
gst_vaapi_surface_proxy_unref (proxy);
|
|
||||||
|
|
||||||
image = gst_vaapi_video_meta_get_image (meta);
|
|
||||||
if (!gst_vaapi_image_map (image)) {
|
|
||||||
GST_WARNING ("failed to map VA image");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
|
|
||||||
error:
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_has_direct_rendering (GstVaapiUploader * uploader)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_VAAPI_IS_UPLOADER (uploader), FALSE);
|
|
||||||
|
|
||||||
return uploader->priv->direct_rendering;
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
* gstvaapiuploader.h - VA-API video upload helper
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
|
||||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
|
||||||
* Copyright (C) 2011-2012 Intel Corporation
|
|
||||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2.1
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this program; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GST_VAAPIUPLOADER_H
|
|
||||||
#define GST_VAAPIUPLOADER_H
|
|
||||||
|
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_UPLOADER \
|
|
||||||
(gst_vaapi_uploader_get_type ())
|
|
||||||
#define GST_VAAPI_UPLOADER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_UPLOADER, \
|
|
||||||
GstVaapiUploader))
|
|
||||||
#define GST_VAAPI_UPLOADER_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_UPLOADER, \
|
|
||||||
GstVaapiUploaderClass))
|
|
||||||
#define GST_VAAPI_IS_UPLOADER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_UPLOADER))
|
|
||||||
#define GST_VAAPI_IS_UPLOADER_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_UPLOADER))
|
|
||||||
#define GST_VAAPI_UPLOADER_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_UPLOADER, \
|
|
||||||
GstVaapiUploaderClass))
|
|
||||||
|
|
||||||
typedef struct _GstVaapiUploader GstVaapiUploader;
|
|
||||||
typedef struct _GstVaapiUploaderPrivate GstVaapiUploaderPrivate;
|
|
||||||
typedef struct _GstVaapiUploaderClass GstVaapiUploaderClass;
|
|
||||||
|
|
||||||
struct _GstVaapiUploader
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GstVaapiUploaderPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstVaapiUploaderClass
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GType
|
|
||||||
gst_vaapi_uploader_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GstVaapiUploader *
|
|
||||||
gst_vaapi_uploader_new (GstVaapiDisplay * display);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_ensure_display (GstVaapiUploader * uploader,
|
|
||||||
GstVaapiDisplay * display);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_ensure_caps (GstVaapiUploader * uploader,
|
|
||||||
GstCaps * src_caps, GstCaps * out_caps);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_process (GstVaapiUploader * uploader,
|
|
||||||
GstBuffer * src_buffer, GstBuffer * out_buffer);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GstCaps *
|
|
||||||
gst_vaapi_uploader_get_caps (GstVaapiUploader * uploader);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
GstBuffer *
|
|
||||||
gst_vaapi_uploader_get_buffer (GstVaapiUploader * uploader);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_uploader_has_direct_rendering (GstVaapiUploader * uploader);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GST_VAAPI_UPLOADER_H */
|
|
Loading…
Reference in a new issue