mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-27 01:28:34 +00:00
plugins: initial port to GStreamer 1.0.
Port vaapidecode and vaapisink plugins to GStreamer API >= 1.0. This is rather minimalistic so that to test the basic functionality. Disable vaapiupload, vaapidownload and vaapipostproc plugins. The latter needs polishing wrt. to GStreamer 1.x functionality and the former are totally phased out in favor of GstVaapiVideoMemory map/unmap facilities, which are yet to be implemented. Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
parent
13ca9f382c
commit
38d84d968e
13 changed files with 228 additions and 55 deletions
|
@ -32,11 +32,8 @@ endif
|
|||
libgstvaapi_source_c = \
|
||||
gstvaapi.c \
|
||||
gstvaapidecode.c \
|
||||
gstvaapidownload.c \
|
||||
gstvaapipluginutil.c \
|
||||
gstvaapipostproc.c \
|
||||
gstvaapisink.c \
|
||||
gstvaapiupload.c \
|
||||
gstvaapiuploader.c \
|
||||
gstvaapivideobuffer.c \
|
||||
gstvaapivideometa.c \
|
||||
|
@ -44,11 +41,8 @@ libgstvaapi_source_c = \
|
|||
|
||||
libgstvaapi_source_h = \
|
||||
gstvaapidecode.h \
|
||||
gstvaapidownload.h \
|
||||
gstvaapipluginutil.h \
|
||||
gstvaapipostproc.h \
|
||||
gstvaapisink.h \
|
||||
gstvaapiupload.h \
|
||||
gstvaapiuploader.h \
|
||||
gstvaapivideobuffer.h \
|
||||
gstvaapivideometa.h \
|
||||
|
|
|
@ -32,18 +32,22 @@
|
|||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
{
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
gst_element_register(plugin, "vaapidownload",
|
||||
GST_RANK_SECONDARY,
|
||||
GST_TYPE_VAAPIDOWNLOAD);
|
||||
gst_element_register(plugin, "vaapiupload",
|
||||
GST_RANK_PRIMARY,
|
||||
GST_TYPE_VAAPIUPLOAD);
|
||||
#endif
|
||||
gst_element_register(plugin, "vaapidecode",
|
||||
GST_RANK_PRIMARY,
|
||||
GST_TYPE_VAAPIDECODE);
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
gst_element_register(plugin, "vaapipostproc",
|
||||
GST_RANK_PRIMARY,
|
||||
GST_TYPE_VAAPIPOSTPROC);
|
||||
#endif
|
||||
gst_element_register(plugin, "vaapisink",
|
||||
GST_RANK_PRIMARY,
|
||||
GST_TYPE_VAAPISINK);
|
||||
|
@ -52,7 +56,7 @@ plugin_init (GstPlugin *plugin)
|
|||
|
||||
GST_PLUGIN_DEFINE(
|
||||
GST_VERSION_MAJOR, GST_VERSION_MINOR,
|
||||
"vaapi",
|
||||
vaapi,
|
||||
"VA-API based elements",
|
||||
plugin_init,
|
||||
PACKAGE_VERSION,
|
||||
|
|
|
@ -80,6 +80,7 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory =
|
|||
GST_STATIC_CAPS(gst_vaapidecode_src_caps_str));
|
||||
|
||||
/* GstImplementsInterface interface */
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
static gboolean
|
||||
gst_vaapidecode_implements_interface_supported(
|
||||
GstImplementsInterface *iface,
|
||||
|
@ -94,6 +95,7 @@ gst_vaapidecode_implements_iface_init(GstImplementsInterfaceClass *iface)
|
|||
{
|
||||
iface->supported = gst_vaapidecode_implements_interface_supported;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GstVideoContext interface */
|
||||
static void
|
||||
|
@ -115,8 +117,10 @@ G_DEFINE_TYPE_WITH_CODE(
|
|||
GstVaapiDecode,
|
||||
gst_vaapidecode,
|
||||
GST_TYPE_VIDEO_DECODER,
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
|
||||
gst_vaapidecode_implements_iface_init);
|
||||
#endif
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
|
||||
gst_video_context_interface_init))
|
||||
|
||||
|
@ -233,7 +237,7 @@ error_decode_timeout:
|
|||
{
|
||||
GST_WARNING("decode timeout. Decoder required a VA surface but none "
|
||||
"got available within one second");
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
error_decode:
|
||||
{
|
||||
|
@ -245,7 +249,7 @@ error_decode:
|
|||
ret = GST_FLOW_NOT_SUPPORTED;
|
||||
break;
|
||||
default:
|
||||
ret = GST_FLOW_UNEXPECTED;
|
||||
ret = GST_FLOW_EOS;
|
||||
break;
|
||||
}
|
||||
gst_video_decoder_drop_frame(vdec, frame);
|
||||
|
@ -301,13 +305,13 @@ error_create_buffer:
|
|||
GST_VAAPI_ID_ARGS(surface_id));
|
||||
gst_video_decoder_drop_frame(vdec, out_frame);
|
||||
gst_video_codec_frame_unref(out_frame);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
error_commit_buffer:
|
||||
{
|
||||
GST_DEBUG("video sink rejected the video buffer (error %d)", ret);
|
||||
gst_video_codec_frame_unref(out_frame);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +341,7 @@ gst_vaapidecode_finish(GstVideoDecoder *vdec)
|
|||
error_flush:
|
||||
{
|
||||
GST_ERROR("failed to flush decoder (status %d)", status);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,7 +539,7 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
|
|||
break;
|
||||
default:
|
||||
GST_ERROR("parse error %d", status);
|
||||
ret = GST_FLOW_UNEXPECTED;
|
||||
ret = GST_FLOW_EOS;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
@ -571,12 +575,10 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
|
|||
/* sink pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
/* src pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -615,7 +617,8 @@ gst_vaapidecode_ensure_allowed_caps(GstVaapiDecode *decode)
|
|||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
NULL
|
||||
);
|
||||
gst_caps_merge_structure(decode->allowed_caps, structure);
|
||||
decode->allowed_caps =
|
||||
gst_caps_merge_structure(decode->allowed_caps, structure);
|
||||
}
|
||||
|
||||
gst_caps_unref(decode_caps);
|
||||
|
@ -652,7 +655,7 @@ gst_vaapidecode_get_caps(GstPad *pad)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
|
||||
gst_vaapidecode_query (GstPad *pad, GstObject *parent, GstQuery *query) {
|
||||
GstVaapiDecode *decode = GST_VAAPIDECODE (gst_pad_get_parent_element (pad));
|
||||
gboolean res;
|
||||
|
||||
|
@ -661,9 +664,9 @@ gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
|
|||
if (gst_vaapi_reply_to_query (query, decode->display))
|
||||
res = TRUE;
|
||||
else if (GST_PAD_IS_SINK(pad))
|
||||
res = decode->sinkpad_query(decode->sinkpad, query);
|
||||
res = decode->sinkpad_query(decode->sinkpad, parent, query);
|
||||
else
|
||||
res = decode->srcpad_query(decode->srcpad, query);
|
||||
res = decode->srcpad_query(decode->srcpad, parent, query);
|
||||
|
||||
g_object_unref (decode);
|
||||
return res;
|
||||
|
@ -690,7 +693,9 @@ gst_vaapidecode_init(GstVaapiDecode *decode)
|
|||
decode->sinkpad = GST_VIDEO_DECODER_SINK_PAD(vdec);
|
||||
decode->sinkpad_query = GST_PAD_QUERYFUNC(decode->sinkpad);
|
||||
gst_pad_set_query_function(decode->sinkpad, gst_vaapidecode_query);
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
gst_pad_set_getcaps_function(decode->sinkpad, gst_vaapidecode_get_caps);
|
||||
#endif
|
||||
|
||||
/* Pad through which data goes out of the element */
|
||||
decode->srcpad = GST_VIDEO_DECODER_SRC_PAD(vdec);
|
||||
|
|
|
@ -237,12 +237,10 @@ gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
|
|||
/* sink pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
/* src pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -335,9 +335,18 @@ gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
|
|||
gboolean
|
||||
gst_vaapi_apply_composition(GstVaapiSurface *surface, GstBuffer *buffer)
|
||||
{
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
GstVideoOverlayCompositionMeta * const cmeta =
|
||||
gst_buffer_get_video_overlay_composition_meta(buffer);
|
||||
GstVideoOverlayComposition *composition;
|
||||
|
||||
if (!cmeta)
|
||||
return TRUE;
|
||||
composition = cmeta->overlay;
|
||||
#else
|
||||
GstVideoOverlayComposition * const composition =
|
||||
gst_video_buffer_get_overlay_composition(buffer);
|
||||
|
||||
#endif
|
||||
if (!composition)
|
||||
return TRUE;
|
||||
return gst_vaapi_surface_set_subpictures_from_composition(surface,
|
||||
|
|
|
@ -651,12 +651,10 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
|
|||
/* sink pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
/* src pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
/**
|
||||
* GstVaapiPostproc:deinterlace-mode:
|
||||
|
|
|
@ -51,7 +51,21 @@
|
|||
#endif
|
||||
|
||||
/* Supported interfaces */
|
||||
#include <gst/interfaces/xoverlay.h>
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
# include <gst/video/videooverlay.h>
|
||||
#else
|
||||
# include <gst/interfaces/xoverlay.h>
|
||||
|
||||
# define GST_TYPE_VIDEO_OVERLAY GST_TYPE_X_OVERLAY
|
||||
# define GST_VIDEO_OVERLAY GST_X_OVERLAY
|
||||
# define GstVideoOverlay GstXOverlay
|
||||
# define GstVideoOverlayInterface GstXOverlayClass
|
||||
|
||||
# define gst_video_overlay_prepare_window_handle(sink) \
|
||||
gst_x_overlay_prepare_xwindow_id(sink)
|
||||
# define gst_video_overlay_got_window_handle(sink, window_handle) \
|
||||
gst_x_overlay_got_window_handle(sink, window_handle)
|
||||
#endif
|
||||
|
||||
#include "gstvaapisink.h"
|
||||
#include "gstvaapipluginutil.h"
|
||||
|
@ -65,9 +79,11 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapisink);
|
|||
|
||||
/* Default template */
|
||||
static const char gst_vaapisink_sink_caps_str[] =
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
"video/x-raw-yuv, "
|
||||
"width = (int) [ 1, MAX ], "
|
||||
"height = (int) [ 1, MAX ]; "
|
||||
#endif
|
||||
GST_VAAPI_SURFACE_CAPS;
|
||||
|
||||
static GstStaticPadTemplate gst_vaapisink_sink_factory =
|
||||
|
@ -78,6 +94,7 @@ static GstStaticPadTemplate gst_vaapisink_sink_factory =
|
|||
GST_STATIC_CAPS(gst_vaapisink_sink_caps_str));
|
||||
|
||||
/* GstImplementsInterface interface */
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
static gboolean
|
||||
gst_vaapisink_implements_interface_supported(
|
||||
GstImplementsInterface *iface,
|
||||
|
@ -85,7 +102,7 @@ gst_vaapisink_implements_interface_supported(
|
|||
)
|
||||
{
|
||||
return (type == GST_TYPE_VIDEO_CONTEXT ||
|
||||
type == GST_TYPE_X_OVERLAY);
|
||||
type == GST_TYPE_VIDEO_OVERLAY);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -93,6 +110,7 @@ gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface)
|
|||
{
|
||||
iface->supported = gst_vaapisink_implements_interface_supported;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GstVideoContext interface */
|
||||
static void
|
||||
|
@ -110,18 +128,20 @@ gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface);
|
||||
gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE(
|
||||
GstVaapiSink,
|
||||
gst_vaapisink,
|
||||
GST_TYPE_VIDEO_SINK,
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
|
||||
gst_vaapisink_implements_iface_init);
|
||||
#endif
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
|
||||
gst_vaapisink_video_context_iface_init);
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY,
|
||||
gst_vaapisink_xoverlay_iface_init))
|
||||
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_OVERLAY,
|
||||
gst_vaapisink_video_overlay_iface_init))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
@ -136,7 +156,7 @@ enum {
|
|||
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
|
||||
#define DEFAULT_ROTATION GST_VAAPI_ROTATION_0
|
||||
|
||||
/* GstXOverlay interface */
|
||||
/* GstVideoOverlay interface */
|
||||
|
||||
#if USE_X11
|
||||
static gboolean
|
||||
|
@ -147,7 +167,7 @@ static GstFlowReturn
|
|||
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
|
||||
|
||||
static void
|
||||
gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window)
|
||||
gst_vaapisink_video_overlay_set_window_handle(GstVideoOverlay *overlay, guintptr window)
|
||||
{
|
||||
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
|
||||
|
||||
|
@ -170,8 +190,8 @@ gst_vaapisink_xoverlay_set_window_handle(GstXOverlay *overlay, guintptr window)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapisink_xoverlay_set_render_rectangle(
|
||||
GstXOverlay *overlay,
|
||||
gst_vaapisink_video_overlay_set_render_rectangle(
|
||||
GstVideoOverlay *overlay,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
|
@ -192,12 +212,19 @@ gst_vaapisink_xoverlay_set_render_rectangle(
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
|
||||
gst_vaapisink_video_overlay_expose(GstVideoOverlay *overlay)
|
||||
{
|
||||
GstBaseSink * const base_sink = GST_BASE_SINK(overlay);
|
||||
GstBuffer *buffer;
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
GstSample * const sample = gst_base_sink_get_last_sample(base_sink);
|
||||
if (!sample)
|
||||
return;
|
||||
buffer = gst_sample_get_buffer(sample);
|
||||
#else
|
||||
buffer = gst_base_sink_get_last_buffer(base_sink);
|
||||
#endif
|
||||
if (buffer) {
|
||||
gst_vaapisink_show_frame(base_sink, buffer);
|
||||
gst_buffer_unref(buffer);
|
||||
|
@ -205,11 +232,11 @@ gst_vaapisink_xoverlay_expose(GstXOverlay *overlay)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface)
|
||||
gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface)
|
||||
{
|
||||
iface->set_window_handle = gst_vaapisink_xoverlay_set_window_handle;
|
||||
iface->set_render_rectangle = gst_vaapisink_xoverlay_set_render_rectangle;
|
||||
iface->expose = gst_vaapisink_xoverlay_expose;
|
||||
iface->set_window_handle = gst_vaapisink_video_overlay_set_window_handle;
|
||||
iface->set_render_rectangle = gst_vaapisink_video_overlay_set_render_rectangle;
|
||||
iface->expose = gst_vaapisink_video_overlay_expose;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -443,16 +470,16 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
|
|||
#if USE_GLX
|
||||
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
||||
sink->window = gst_vaapi_window_glx_new(display, width, height);
|
||||
goto notify_xoverlay_interface;
|
||||
goto notify_video_overlay_interface;
|
||||
#endif
|
||||
#if USE_X11
|
||||
case GST_VAAPI_DISPLAY_TYPE_X11:
|
||||
sink->window = gst_vaapi_window_x11_new(display, width, height);
|
||||
notify_xoverlay_interface:
|
||||
notify_video_overlay_interface:
|
||||
if (!sink->window)
|
||||
break;
|
||||
gst_x_overlay_got_window_handle(
|
||||
GST_X_OVERLAY(sink),
|
||||
gst_video_overlay_got_window_handle(
|
||||
GST_VIDEO_OVERLAY(sink),
|
||||
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window))
|
||||
);
|
||||
break;
|
||||
|
@ -589,7 +616,7 @@ gst_vaapisink_stop(GstBaseSink *base_sink)
|
|||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_vaapisink_get_caps(GstBaseSink *base_sink)
|
||||
gst_vaapisink_get_caps(GstBaseSink *base_sink, GstCaps *filter)
|
||||
{
|
||||
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
||||
GstCaps *out_caps, *yuv_caps;
|
||||
|
@ -642,7 +669,7 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
|
|||
}
|
||||
else {
|
||||
gst_vaapi_display_lock(sink->display);
|
||||
gst_x_overlay_prepare_xwindow_id(GST_X_OVERLAY(sink));
|
||||
gst_video_overlay_prepare_window_handle(GST_VIDEO_OVERLAY(sink));
|
||||
gst_vaapi_display_unlock(sink->display);
|
||||
if (sink->window)
|
||||
return TRUE;
|
||||
|
@ -840,24 +867,30 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
|
|||
gboolean success;
|
||||
|
||||
meta = gst_buffer_get_vaapi_video_meta(src_buffer);
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
if (!meta)
|
||||
return GST_FLOW_EOS;
|
||||
buffer = gst_buffer_ref(src_buffer);
|
||||
#else
|
||||
if (meta)
|
||||
buffer = gst_buffer_ref(src_buffer);
|
||||
else if (sink->use_video_raw) {
|
||||
buffer = gst_vaapi_uploader_get_buffer(sink->uploader);
|
||||
if (!buffer)
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
meta = gst_buffer_get_vaapi_video_meta(buffer);
|
||||
if (!meta)
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
|
||||
if (sink->use_video_raw &&
|
||||
!gst_vaapi_uploader_process(sink->uploader, src_buffer, buffer)) {
|
||||
GST_WARNING("failed to process raw YUV buffer");
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sink->display != gst_vaapi_video_meta_get_display(meta)) {
|
||||
g_clear_object(&sink->display);
|
||||
|
@ -918,9 +951,10 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
|
|||
|
||||
error:
|
||||
gst_buffer_unref(buffer);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
static GstFlowReturn
|
||||
gst_vaapisink_buffer_alloc(
|
||||
GstBaseSink *base_sink,
|
||||
|
@ -961,6 +995,7 @@ gst_vaapisink_buffer_alloc(
|
|||
*pbuf = buf;
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_vaapisink_query(GstBaseSink *base_sink, GstQuery *query)
|
||||
|
@ -1069,7 +1104,9 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
|||
basesink_class->preroll = gst_vaapisink_show_frame;
|
||||
basesink_class->render = gst_vaapisink_show_frame;
|
||||
basesink_class->query = gst_vaapisink_query;
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc;
|
||||
#endif
|
||||
|
||||
gst_element_class_set_static_metadata(element_class,
|
||||
"VA-API sink",
|
||||
|
@ -1079,7 +1116,6 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
|||
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
|
|
|
@ -215,12 +215,10 @@ gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
|
|||
/* sink pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
|
||||
/* src pad */
|
||||
pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
|
||||
gst_element_class_add_pad_template(element_class, pad_template);
|
||||
gst_object_unref(pad_template);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -449,10 +449,12 @@ gst_vaapi_uploader_get_buffer(GstVaapiUploader *uploader)
|
|||
goto error;
|
||||
}
|
||||
|
||||
#if 0
|
||||
GST_BUFFER_DATA(buffer) = gst_vaapi_image_get_plane(image, 0);
|
||||
GST_BUFFER_SIZE(buffer) = gst_vaapi_image_get_data_size(image);
|
||||
|
||||
gst_buffer_set_caps(buffer, priv->image_caps);
|
||||
#endif
|
||||
return buffer;
|
||||
|
||||
error:
|
||||
|
|
|
@ -26,12 +26,20 @@
|
|||
*/
|
||||
|
||||
#include "gst/vaapi/sysdeps.h"
|
||||
#include <gst/video/gstsurfacebuffer.h>
|
||||
#include "gstvaapivideobuffer.h"
|
||||
#if USE_GLX
|
||||
# include "gstvaapivideoconverter_glx.h"
|
||||
#endif
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
static inline GstBuffer *
|
||||
gst_surface_buffer_new(void)
|
||||
{
|
||||
return gst_buffer_new();
|
||||
}
|
||||
#else
|
||||
#include <gst/video/gstsurfacebuffer.h>
|
||||
|
||||
#define GST_VAAPI_TYPE_VIDEO_BUFFER \
|
||||
(gst_vaapi_video_buffer_get_type())
|
||||
|
||||
|
@ -117,6 +125,13 @@ gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
|
|||
{
|
||||
}
|
||||
|
||||
static inline GstBuffer *
|
||||
gst_surface_buffer_new(void)
|
||||
{
|
||||
return GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
|
||||
}
|
||||
#endif
|
||||
|
||||
static GFunc
|
||||
get_surface_converter(GstVaapiDisplay *display)
|
||||
{
|
||||
|
@ -145,7 +160,7 @@ new_vbuffer(GstVaapiVideoMeta *meta)
|
|||
gst_vaapi_video_meta_set_surface_converter(meta,
|
||||
get_surface_converter(gst_vaapi_video_meta_get_display(meta)));
|
||||
|
||||
buffer = GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
|
||||
buffer = gst_surface_buffer_new();
|
||||
if (buffer)
|
||||
gst_buffer_set_vaapi_video_meta(buffer, meta);
|
||||
gst_vaapi_video_meta_unref(meta);
|
||||
|
|
|
@ -27,8 +27,13 @@
|
|||
#include "gstvaapipluginutil.h"
|
||||
#include "gstvaapivideometa.h"
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
|
||||
GstBuffer *);
|
||||
#else
|
||||
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
|
||||
GstSurfaceBuffer *);
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface);
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
#include <gst/vaapi/gstvaapisurfacepool.h>
|
||||
#include "gstvaapivideometa.h"
|
||||
|
||||
#define GST_VAAPI_TYPE_VIDEO_META \
|
||||
(gst_vaapi_video_meta_get_type())
|
||||
|
||||
#define GST_VAAPI_VIDEO_META(obj) \
|
||||
((GstVaapiVideoMeta *)(obj))
|
||||
|
||||
|
@ -100,6 +97,8 @@ gst_vaapi_video_meta_destroy_surface(GstVaapiVideoMeta *meta)
|
|||
g_clear_object(&meta->surface_pool);
|
||||
}
|
||||
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
#define GST_VAAPI_TYPE_VIDEO_META gst_vaapi_video_meta_get_type()
|
||||
static GType
|
||||
gst_vaapi_video_meta_get_type(void)
|
||||
{
|
||||
|
@ -114,6 +113,7 @@ gst_vaapi_video_meta_get_type(void)
|
|||
}
|
||||
return (GType)g_type;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_vaapi_video_meta_finalize(GstVaapiVideoMeta *meta)
|
||||
|
@ -649,6 +649,105 @@ gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags)
|
|||
meta->render_flags = flags;
|
||||
}
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
|
||||
#define GST_VAAPI_VIDEO_META_HOLDER(meta) \
|
||||
((GstVaapiVideoMetaHolder *)(meta))
|
||||
|
||||
typedef struct _GstVaapiVideoMetaHolder GstVaapiVideoMetaHolder;
|
||||
struct _GstVaapiVideoMetaHolder {
|
||||
GstMeta base;
|
||||
GstVaapiVideoMeta *meta;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_video_meta_holder_init(GstVaapiVideoMetaHolder *meta,
|
||||
gpointer params, GstBuffer *buffer)
|
||||
{
|
||||
meta->meta = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_meta_holder_free(GstVaapiVideoMetaHolder *meta,
|
||||
GstBuffer *buffer)
|
||||
{
|
||||
if (meta->meta)
|
||||
gst_vaapi_video_meta_unref(meta->meta);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
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)) {
|
||||
gst_buffer_set_vaapi_video_meta(dst_buffer, src_meta->meta);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_vaapi_video_meta_api_get_type(void)
|
||||
{
|
||||
static gsize g_type;
|
||||
static const gchar *tags[] = { "memory", NULL };
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#define GST_VAAPI_VIDEO_META_INFO gst_vaapi_video_meta_info_get()
|
||||
static const GstMetaInfo *
|
||||
gst_vaapi_video_meta_info_get(void)
|
||||
{
|
||||
static gsize g_meta_info;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
GstVaapiVideoMeta *
|
||||
gst_buffer_get_vaapi_video_meta(GstBuffer *buffer)
|
||||
{
|
||||
GstMeta *m;
|
||||
|
||||
g_return_val_if_fail(GST_IS_BUFFER(buffer), NULL);
|
||||
|
||||
m = gst_buffer_get_meta(buffer, GST_VAAPI_VIDEO_META_API_TYPE);
|
||||
if (!m)
|
||||
return NULL;
|
||||
return GST_VAAPI_VIDEO_META_HOLDER(m)->meta;
|
||||
}
|
||||
|
||||
void
|
||||
gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta)
|
||||
{
|
||||
GstMeta *m;
|
||||
|
||||
g_return_if_fail(GST_IS_BUFFER(buffer));
|
||||
g_return_if_fail(GST_VAAPI_IS_VIDEO_META(meta));
|
||||
|
||||
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);
|
||||
}
|
||||
#else
|
||||
|
||||
#define GST_VAAPI_VIDEO_META_QUARK gst_vaapi_video_meta_quark_get()
|
||||
static GQuark
|
||||
gst_vaapi_video_meta_quark_get(void)
|
||||
|
@ -704,3 +803,4 @@ gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta)
|
|||
gst_structure_id_new(GST_VAAPI_VIDEO_META_QUARK,
|
||||
META_QUARK, GST_VAAPI_TYPE_VIDEO_META, meta, NULL));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,15 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta;
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
#define GST_VAAPI_VIDEO_META_API_TYPE \
|
||||
gst_vaapi_video_meta_api_get_type()
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GType
|
||||
gst_vaapi_video_meta_api_get_type(void) G_GNUC_CONST;
|
||||
#endif
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GstVaapiVideoMeta *
|
||||
gst_vaapi_video_meta_new(GstVaapiDisplay *display);
|
||||
|
|
Loading…
Reference in a new issue