#include <gst/gst.h>
-/* ------------------------------------------------------------------------ */
-/* --- GStreamer >= 1.0 --- */
-/* ------------------------------------------------------------------------ */
-
-#if GST_CHECK_VERSION(1,0,0)
#include <gst/video/gstvideometa.h>
/* GstStructure */
#define GST_MAKE_FORMAT_STRING(FORMAT) \
"format=(string)" G_STRINGIFY(FORMAT)
-/* ------------------------------------------------------------------------ */
-/* --- GStreamer = 0.10 --- */
-/* ------------------------------------------------------------------------ */
-
-#else
-
-/* GstMemory */
-typedef enum {
- GST_MEMORY_FLAG_READONLY = GST_MINI_OBJECT_FLAG_READONLY
-} GstMemoryFlags;
-
-typedef enum {
- GST_BUFFER_COPY_META = GST_BUFFER_COPY_QDATA,
- GST_BUFFER_COPY_MEMORY = 0,
-} GstBufferCopyFlags1_0;
-
-typedef enum {
- GST_MAP_READ = 1 << 0,
- GST_MAP_WRITE = 1 << 1
-} GstMapFlags;
-
-typedef struct {
- GstMapFlags flags;
- guint8 *data;
- gsize size;
-} GstMapInfo;
-
-/* GstBuffer */
-#undef gst_buffer_new_wrapped
-#define gst_buffer_new_wrapped(data, size) \
- gst_compat_buffer_new_wrapped_full(0, data, size, 0, size, data, g_free)
-#undef gst_buffer_new_wrapped_full
-#define gst_buffer_new_wrapped_full(flags, data, maxsize, ofs, size, ud, udd) \
- gst_compat_buffer_new_wrapped_full(flags, data, maxsize, ofs, size, ud, udd)
-#undef gst_buffer_new_allocate
-#define gst_buffer_new_allocate(allocator, size, params) \
- gst_compat_buffer_new_allocate((allocator), (size), (params))
-#undef gst_buffer_get_size
-#define gst_buffer_get_size(buffer) gst_compat_buffer_get_size(buffer)
-#undef gst_buffer_map
-#define gst_buffer_map(buffer, mip, f) gst_compat_buffer_map(buffer, mip, f)
-#undef gst_buffer_unmap
-#define gst_buffer_unmap(buffer, mip) gst_compat_buffer_unmap(buffer, mip)
-#undef gst_buffer_extract
-#define gst_buffer_extract(buffer, offset, dest, size) \
- gst_compat_buffer_extract(buffer, offset, dest, size)
-#undef gst_buffer_fill
-#define gst_buffer_fill(buffer, offset, src, size) \
- gst_compat_buffer_fill((buffer), (offset), (src), (size))
-#undef gst_buffer_copy_into
-#define gst_buffer_copy_into(dest, src, flags, offset, size) \
- gst_compat_buffer_copy_into(dest, src, flags, offset, size)
-
-static inline GstBuffer *
-gst_compat_buffer_new_wrapped_full(GstMemoryFlags flags, gpointer data,
- gsize maxsize, gsize offset, gsize size, gpointer user_data,
- GDestroyNotify notify)
-{
- GstBuffer *buffer;
-
- /* XXX: unsupported */
- g_return_val_if_fail(maxsize >= size, NULL);
-
- buffer = gst_buffer_new();
- if (!buffer)
- return NULL;
-
- GST_BUFFER_DATA(buffer) = data + offset;
- GST_BUFFER_SIZE(buffer) = size;
-
- if (notify)
- gst_mini_object_weak_ref(GST_MINI_OBJECT_CAST(buffer),
- (GstMiniObjectWeakNotify)notify, user_data);
- return buffer;
-}
-
-static inline GstBuffer *
-gst_compat_buffer_new_allocate(gpointer allocator, gsize size, gpointer params)
-{
- /* XXX: unsupported */
- g_return_val_if_fail(allocator == NULL, NULL);
- g_return_val_if_fail(params == NULL, NULL);
-
- return gst_buffer_new_and_alloc(size);
-}
-
-static inline gsize
-gst_compat_buffer_get_size(GstBuffer *buffer)
-{
- return GST_BUFFER_SIZE(buffer);
-}
-
-static inline gboolean
-gst_compat_buffer_map(GstBuffer *buffer, GstMapInfo *mip, GstMapFlags flags)
-{
- mip->flags = flags;
- mip->data = GST_BUFFER_DATA(buffer);
- mip->size = GST_BUFFER_SIZE(buffer);
- return TRUE;
-}
-
-static inline void
-gst_compat_buffer_unmap(GstBuffer *buffer, GstMapInfo *mip)
-{
-}
-
-static inline gsize
-gst_compat_buffer_extract(GstBuffer *buffer, gsize offset, gpointer dest,
- gsize size)
-{
- gsize esize;
-
- if (!buffer || !dest || offset >= GST_BUFFER_SIZE(buffer))
- return 0;
-
- esize = MIN(size, GST_BUFFER_SIZE(buffer) - offset);
- memcpy(dest, GST_BUFFER_DATA(buffer) + offset, esize);
- return esize;
-}
-
-static inline gsize
-gst_compat_buffer_fill(GstBuffer *buffer, gsize offset, gconstpointer src,
- gsize size)
-{
- gsize fsize;
-
- if (!buffer || !src || offset >= GST_BUFFER_SIZE(buffer))
- return 0;
-
- fsize = MIN(size, GST_BUFFER_SIZE(buffer) - offset);
- memcpy(GST_BUFFER_DATA(buffer) + offset, src, fsize);
- return fsize;
-}
-
-static inline void
-gst_compat_buffer_copy_into(GstBuffer *dest, GstBuffer *src,
- GstBufferCopyFlags flags, gsize offset, gsize size)
-{
- g_return_if_fail(offset == 0);
- g_return_if_fail(size == (gsize)-1);
-
- gst_buffer_copy_metadata(dest, src, flags);
-}
-
-/* GstAdapter */
-#include <gst/base/gstadapter.h>
-
-#undef gst_adapter_map
-#define gst_adapter_map(adapter, size) gst_compat_adapter_map(adapter, size)
-#undef gst_adapter_unmap
-#define gst_adapter_unmap(adapter) gst_compat_adapter_unmap(adapter)
-
-static inline gconstpointer
-gst_compat_adapter_map(GstAdapter *adapter, gsize size)
-{
- return gst_adapter_peek(adapter, size);
-}
-
-static inline void
-gst_compat_adapter_unmap(GstAdapter *adapter)
-{
-}
-
-/* GstCaps */
-#undef gst_caps_merge
-#define gst_caps_merge(caps1, caps2) gst_compat_caps_merge(caps1, caps2)
-#undef gst_caps_merge_structure
-#define gst_caps_merge_structure(caps, structure) \
- gst_compat_caps_merge_structure(caps, structure)
-
-static inline GstCaps *
-gst_compat_caps_merge(GstCaps *caps1, GstCaps *caps2)
-{
- (gst_caps_merge)(caps1, caps2);
- return caps1;
-}
-
-static inline GstCaps *
-gst_compat_caps_merge_structure(GstCaps *caps, GstStructure *structure)
-{
- (gst_caps_merge_structure)(caps, structure);
- return caps;
-}
-
-/* GstVideoOverlayComposition */
-#include <gst/video/video-overlay-composition.h>
-
-#undef gst_video_overlay_rectangle_get_pixels_unscaled_raw
-#define gst_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags) \
- gst_compat_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags)
-
-#ifndef HAVE_GST_VIDEO_OVERLAY_HWCAPS
-#define gst_video_overlay_rectangle_get_flags(rect) (0)
-#define gst_video_overlay_rectangle_get_global_alpha(rect) (1.0f)
-#endif
-
-static inline GstBuffer *
-gst_compat_video_overlay_rectangle_get_pixels_unscaled_raw(
- GstVideoOverlayRectangle *rect, GstVideoOverlayFormatFlags flags)
-{
- guint width, height, stride;
-
- /* Try to retrieve the original buffer that was passed to
- gst_video_overlay_rectangle_new_argb(). This will only work if
- there was no previous user that required pixels with non native
- alpha type */
- return gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
- &width, &height, &stride, flags);
-}
-
-typedef enum {
- GST_VIDEO_BUFFER_FLAG_TFF = GST_VIDEO_BUFFER_TFF,
- GST_VIDEO_BUFFER_FLAG_RFF = GST_VIDEO_BUFFER_RFF,
- GST_VIDEO_BUFFER_FLAG_ONEFIELD = GST_VIDEO_BUFFER_ONEFIELD
-} GstVideoBufferFlags;
-
-/* GstPad */
-#undef GST_FLOW_EOS
-#define GST_FLOW_EOS GST_FLOW_UNEXPECTED
-#undef GST_FLOW_FLUSHING
-#define GST_FLOW_FLUSHING GST_FLOW_WRONG_STATE
-
-#define GST_PAD_CHAIN_FUNCTION_ARGS \
- GstPad *pad, GstBuffer *buffer
-#define GST_PAD_EVENT_FUNCTION_ARGS \
- GstPad *pad, GstEvent *event
-
-static inline gboolean
-gst_compat_pad_start_task(GstPad *pad, GstTaskFunction func, gpointer user_data,
- GDestroyNotify notify)
-{
- g_return_val_if_fail(notify == NULL, FALSE);
-
- return gst_pad_start_task(pad, func, user_data);
-}
-
-#undef gst_pad_start_task
-#define gst_pad_start_task(pad, func, user_data, notify) \
- gst_compat_pad_start_task(pad, func, user_data, notify)
-
-/* GstElement */
-#undef GST_ELEMENT_FLAG_SINK
-#define GST_ELEMENT_FLAG_SINK GST_ELEMENT_IS_SINK
-#undef gst_element_class_set_static_metadata
-#define gst_element_class_set_static_metadata(klass, name, path, desc, author) \
- gst_compat_element_class_set_static_metadata(klass, name, path, desc, author)
-
-static inline void
-gst_compat_element_class_set_static_metadata(GstElementClass *klass,
- const gchar *name, const char *path, const gchar *desc, const gchar *author)
-{
- gst_element_class_set_details_simple(klass, name, path, desc, author);
-}
-
-/* GstTypeFind */
-#undef GstTypeFindPeekFunction
-#define GstTypeFindPeekFunction GstCompatTypeFindPeekFunction
-#undef GstTypeFindSuggestFunction
-#define GstTypeFindSuggestFunction GstCompatTypeFindSuggestFunction
-
-typedef guint8 *(*GstCompatTypeFindPeekFunction)(gpointer, gint64, guint);
-typedef void (*GstCompatTypeFindSuggestFunction)(gpointer, guint, const GstCaps *);
-
-/* GstQuery */
-#define GST_PAD_QUERY_FUNCTION_ARGS \
- GstPad *pad, GstQuery *query
-#define GST_PAD_QUERY_FUNCTION_CALL(func, pad, parent, query) \
- (func)(pad, query)
-
-/* Misc helpers */
-#define GST_MAKE_FORMAT_STRING(FORMAT) \
- "format=(fourcc)" G_STRINGIFY(FORMAT)
-
-#endif
-
#endif /* GST_COMPAT_H */
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_raw (rect, flags);
if (!buffer)
return FALSE;
-#if GST_CHECK_VERSION(1,0,0)
{
const guint n_blocks = gst_buffer_n_memory (buffer);
gsize ofs;
return FALSE;
}
}
-#else
- if (GST_BUFFER_DATA (overlay->rect_buffer) != GST_BUFFER_DATA (buffer))
- return FALSE;
-#endif
return TRUE;
}
if (!out_frame)
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
-#if !GST_CHECK_VERSION(1,0,0)
- if (!GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY (out_frame)) {
- const guint flags = GST_VAAPI_SURFACE_PROXY_FLAGS (out_frame->user_data);
- guint out_flags = 0;
-
- if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_TFF)
- out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_TFF;
- if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_RFF)
- out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_RFF;
- if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_ONEFIELD)
- out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_ONEFIELD;
- GST_VIDEO_CODEC_FRAME_FLAG_SET (out_frame, out_flags);
- }
-#endif
-
*out_frame_ptr = out_frame;
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
return image->image.data_size;
}
-#if GST_CHECK_VERSION(1,0,0)
#include <gst/video/gstvideometa.h>
static gboolean
return vmeta ? init_image_from_video_meta(raw_image, vmeta) : FALSE;
}
-#else
-static gboolean
-init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
-{
- GstCaps *caps;
- guchar *data;
- guint32 data_size;
- GstVideoInfo vi;
- guint i, frame_size;
-
- data = GST_BUFFER_DATA(buffer);
- data_size = GST_BUFFER_SIZE(buffer);
- caps = GST_BUFFER_CAPS(buffer);
-
- if (!caps)
- return FALSE;
-
- if (!gst_video_info_from_caps(&vi, caps))
- goto error_unsupported_caps;
-
- /* Check for compatible data size */
- frame_size = GST_VIDEO_INFO_SIZE(&vi);
- if (frame_size != data_size)
- goto error_incompatible_size;
-
- raw_image->format = GST_VIDEO_INFO_FORMAT(&vi);
- raw_image->width = GST_VIDEO_INFO_WIDTH(&vi);
- raw_image->height = GST_VIDEO_INFO_HEIGHT(&vi);
-
- raw_image->num_planes = GST_VIDEO_INFO_N_PLANES(&vi);
- for (i = 0; i < raw_image->num_planes; i++) {
- raw_image->pixels[i] = data + GST_VIDEO_INFO_PLANE_OFFSET(&vi, i);
- raw_image->stride[i] = GST_VIDEO_INFO_PLANE_STRIDE(&vi, i);
- }
- return TRUE;
-
- /* ERRORS */
-error_unsupported_caps:
- GST_ERROR("unsupported caps %" GST_PTR_FORMAT, caps);
- return FALSE;
-error_incompatible_size:
- GST_ERROR("incompatible frame size (%u) with buffer size (%u)",
- frame_size, data_size);
- return FALSE;
-}
-#endif
/* Copy N lines of an image */
static inline void
gfloat global_alpha;
guint width, height, stride;
guint hw_flags, flags;
-#if GST_CHECK_VERSION(1,0,0)
GstVideoMeta *vmeta;
GstMapInfo map_info;
-#endif
g_return_val_if_fail(GST_IS_VIDEO_OVERLAY_RECTANGLE(rect), NULL);
#endif
if (!gst_vaapi_display_has_subpicture_format(display, format, &hw_flags))
return NULL;
-
+
flags = hw_flags & from_GstVideoOverlayFormatFlags(
gst_video_overlay_rectangle_get_flags(rect));
-#if GST_CHECK_VERSION(1,0,0)
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
to_GstVideoOverlayFormatFlags(flags));
if (!buffer)
if (!gst_video_meta_map(vmeta, 0, &map_info, (gpointer *)&data,
(gint *)&stride, GST_MAP_READ))
return NULL;
-#else
- buffer = (gst_video_overlay_rectangle_get_pixels_unscaled_argb)(rect,
- &width, &height, &stride, to_GstVideoOverlayFormatFlags(flags));
- if (!buffer)
- return NULL;
- data = GST_BUFFER_DATA(buffer);
-#endif
image = gst_vaapi_image_new(display, format, width, height);
if (!image)
subpicture = gst_vaapi_subpicture_new(image, flags);
gst_vaapi_object_unref(image);
-#if GST_CHECK_VERSION(1,0,0)
gst_video_meta_unmap(vmeta, 0, &map_info);
-#endif
if (!subpicture)
return NULL;
return NULL;
}
-/**
- * gst_vaapi_video_format_from_string:
- * @str: a string representation of #GstVideoFormat
- *
- * Returns the #GstVideoFormat represented as the string @str.
- *
- * Return value: #GstVideoFormat for the string representation of
- * video format in @str.
- */
-GstVideoFormat
-gst_vaapi_video_format_from_string (const gchar * str)
-{
-#if GST_CHECK_VERSION(1,0,0)
- return gst_video_format_from_string (str);
-#else
- GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
-
- do {
- /* Validate input string */
- if (!str)
- break;
-
- /* Fast path: assume this represents a common fourcc value */
- const guint32 fourcc = GST_MAKE_FOURCC (str[0], str[1], str[2], str[3]);
- format = gst_video_format_from_fourcc (fourcc);
- if (format != GST_VIDEO_FORMAT_UNKNOWN)
- break;
-
- /* Slow path: check through all registered enum values */
- GEnumClass *const enum_class = g_type_class_ref (GST_TYPE_VIDEO_FORMAT);
- if (!enum_class)
- break;
-
- gchar *const video_format_str =
- g_strdup_printf ("GST_VIDEO_FORMAT_%s", str);
- if (video_format_str) {
- const GEnumValue *const enum_value =
- g_enum_get_value_by_name (enum_class, video_format_str);
-
- if (enum_value)
- format = enum_value->value;
- g_free (video_format_str);
- }
- g_type_class_unref (enum_class);
- } while (0);
- return format;
-#endif
-}
-
/**
* gst_vaapi_video_format_to_string:
* @format: a #GstVideoFormat
G_BEGIN_DECLS
-GstVideoFormat
-gst_vaapi_video_format_from_string (const gchar * str);
-
const gchar *
gst_vaapi_video_format_to_string (GstVideoFormat format);
#include "gst/vaapi/sysdeps.h"
#include <gst/gst.h>
-#include "gstvaapidownload.h"
-#include "gstvaapiupload.h"
#include "gstvaapidecode.h"
#include "gstvaapipostproc.h"
#include "gstvaapisink.h"
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 + 1,
GST_TYPE_VAAPIDECODE);
return TRUE;
}
-#if GST_CHECK_VERSION(1,0,0)
-/* XXX: use PLUGIN_NAME when GST_PLUGIN_DEFINE is fixed to use
- G_STRINGIFY() for name argument, instead of plain #name */
GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR,
vaapi, PLUGIN_DESC, plugin_init,
PACKAGE_VERSION, PLUGIN_LICENSE, PACKAGE, PACKAGE_BUGREPORT)
-#else
-GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR,
- PLUGIN_NAME, PLUGIN_DESC, plugin_init,
- PACKAGE_VERSION, PLUGIN_LICENSE, PACKAGE, PACKAGE_BUGREPORT)
-#endif
#if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL)
#include "gstvaapivideometa_texture.h"
#endif
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideomemory.h"
-#endif
#include <gst/vaapi/gstvaapidecoder_h264.h>
#include <gst/vaapi/gstvaapidecoder_jpeg.h>
GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
GstVaapiSurfaceProxy *proxy;
GstFlowReturn ret;
-#if GST_CHECK_VERSION(1,0,0)
const GstVaapiRectangle *crop_rect;
GstVaapiVideoMeta *meta;
guint flags;
-#endif
if (!GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY (out_frame)) {
proxy = gst_video_codec_frame_get_user_data (out_frame);
gst_vaapi_surface_proxy_set_destroy_notify (proxy,
(GDestroyNotify) gst_vaapidecode_release, gst_object_ref (decode));
-#if GST_CHECK_VERSION(1,0,0)
ret = gst_video_decoder_allocate_output_frame (vdec, out_frame);
if (ret != GST_FLOW_OK)
goto error_create_buffer;
#if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL)
if (decode->has_texture_upload_meta)
gst_buffer_ensure_texture_upload_meta (out_frame->output_buffer);
-#endif
-#else
- out_frame->output_buffer =
- gst_vaapi_video_buffer_new_with_surface_proxy (proxy);
- if (!out_frame->output_buffer)
- goto error_create_buffer;
#endif
}
gst_video_codec_frame_unref (out_frame);
return GST_FLOW_ERROR;
}
-#if GST_CHECK_VERSION(1,0,0)
error_get_meta:
{
GST_ELEMENT_ERROR (vdec, STREAM, FAILED,
gst_video_codec_frame_unref (out_frame);
return GST_FLOW_ERROR;
}
-#endif
error_commit_buffer:
{
if (ret != GST_FLOW_FLUSHING)
return gst_vaapidecode_push_all_decoded_frames (decode);
}
-#if GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapidecode_decide_allocation (GstVideoDecoder * vdec, GstQuery * query)
{
return gst_vaapi_plugin_base_decide_allocation (GST_VAAPI_PLUGIN_BASE (vdec),
query, feature);
}
-#endif
static inline gboolean
gst_vaapidecode_ensure_display (GstVaapiDecode * decode)
#if GST_CHECK_VERSION(1,5,0)
vdec_class->drain = GST_DEBUG_FUNCPTR (gst_vaapidecode_drain);
#endif
-
-#if GST_CHECK_VERSION(1,0,0)
vdec_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_vaapidecode_decide_allocation);
-#endif
#if GST_CHECK_VERSION(1,4,0)
vdec_class->src_query = GST_DEBUG_FUNCPTR (gst_vaapidecode_src_query);
vdec_class->sink_query = GST_DEBUG_FUNCPTR (gst_vaapidecode_sink_query);
}
switch (GST_QUERY_TYPE (query)) {
-#if GST_CHECK_VERSION(1,0,0)
case GST_QUERY_CAPS:{
GstCaps *caps, *filter = NULL;
GstPad *pad = GST_VIDEO_DECODER_SINK_PAD (vdec);
gst_caps_unref (caps);
break;
}
-#endif
default:{
#if GST_CHECK_VERSION(1,4,0)
ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->sink_query
}
switch (GST_QUERY_TYPE (query)) {
-#if GST_CHECK_VERSION(1,0,0)
case GST_QUERY_CAPS:{
GstCaps *caps, *filter = NULL;
GstPad *pad = GST_VIDEO_DECODER_SRC_PAD (vdec);
gst_caps_unref (caps);
break;
}
-#endif
default:{
#if GST_CHECK_VERSION(1,4,0)
ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->src_query
/* Pad through which data comes in to the element */
GstPad *pad = GST_VAAPI_PLUGIN_BASE_SINK_PAD (decode);
gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR (gst_vaapidecode_query));
-#if !GST_CHECK_VERSION(1,0,0)
- gst_pad_set_getcaps_function (pad, gst_vaapidecode_get_caps);
-#endif
/* Pad through which data goes out of the element */
pad = GST_VAAPI_PLUGIN_BASE_SRC_PAD (decode);
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "{ RGBA, BGRA }") ", "
GST_CAPS_INTERLACED_FALSE "; "
#endif
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
+++ /dev/null
-/*
- * gstvaapidownload.c - VA-API video downloader
- *
- * 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
- */
-
-/**
- * SECTION:gstvaapidownload
- * @short_description: A VA to video flow filter
- *
- * vaapidownload converts from VA surfaces to raw YUV pixels.
- */
-
-#include "gst/vaapi/sysdeps.h"
-#include <gst/gst.h>
-#include <gst/video/video.h>
-
-#include "gstvaapidownload.h"
-#include "gstvaapipluginutil.h"
-#include "gstvaapivideobuffer.h"
-
-#define GST_PLUGIN_NAME "vaapidownload"
-#define GST_PLUGIN_DESC "A VA to video flow filter"
-
-GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapidownload);
-#define GST_CAT_DEFAULT gst_debug_vaapidownload
-
-/* Default templates */
-static const char gst_vaapidownload_yuv_caps_str[] =
- "video/x-raw-yuv, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]; ";
-
-static const char gst_vaapidownload_vaapi_caps_str[] =
- GST_VAAPI_SURFACE_CAPS;
-
-static GstStaticPadTemplate gst_vaapidownload_sink_factory =
- GST_STATIC_PAD_TEMPLATE(
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(gst_vaapidownload_vaapi_caps_str));
-
-static GstStaticPadTemplate gst_vaapidownload_src_factory =
- GST_STATIC_PAD_TEMPLATE(
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(gst_vaapidownload_yuv_caps_str));
-
-typedef struct _TransformSizeCache TransformSizeCache;
-struct _TransformSizeCache {
- GstCaps *caps;
- guint size;
-};
-
-struct _GstVaapiDownload {
- /*< private >*/
- GstVaapiPluginBase parent_instance;
-
- GstCaps *allowed_caps;
- TransformSizeCache transform_size_cache[2];
- GstVaapiVideoPool *images;
- GstVideoFormat image_format;
- guint image_width;
- guint image_height;
- unsigned int images_reset : 1;
-};
-
-struct _GstVaapiDownloadClass {
- /*< private >*/
- GstVaapiPluginBaseClass parent_class;
-};
-
-G_DEFINE_TYPE_WITH_CODE(
- GstVaapiDownload,
- gst_vaapidownload,
- GST_TYPE_BASE_TRANSFORM,
- GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES)
-
-static gboolean
-gst_vaapidownload_start(GstBaseTransform *trans);
-
-static gboolean
-gst_vaapidownload_stop(GstBaseTransform *trans);
-
-static void
-gst_vaapidownload_before_transform(GstBaseTransform *trans, GstBuffer *buffer);
-
-static GstFlowReturn
-gst_vaapidownload_transform(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- GstBuffer *outbuf
-);
-
-static GstCaps *
-gst_vaapidownload_transform_caps(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps
-);
-
-static gboolean
-gst_vaapidownload_transform_size(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps,
- guint size,
- GstCaps *othercaps,
- guint *othersize
-);
-
-static gboolean
-gst_vaapidownload_set_caps(
- GstBaseTransform *trans,
- GstCaps *incaps,
- GstCaps *outcaps
-);
-
-static gboolean
-gst_vaapidownload_query(
- GstPad *pad,
- GstQuery *query
-);
-
-static void
-gst_vaapidownload_destroy(GstVaapiDownload *download)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS(download->transform_size_cache); i++) {
- TransformSizeCache * const tsc = &download->transform_size_cache[i];
- if (tsc->caps) {
- gst_caps_unref(tsc->caps);
- tsc->caps = NULL;
- tsc->size = 0;
- }
- }
-
- if (download->allowed_caps) {
- gst_caps_unref(download->allowed_caps);
- download->allowed_caps = NULL;
- }
-
- gst_vaapi_video_pool_replace(&download->images, NULL);
- GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(download, NULL);
-}
-
-static void
-gst_vaapidownload_finalize(GObject *object)
-{
- gst_vaapidownload_destroy(GST_VAAPIDOWNLOAD(object));
-
- gst_vaapi_plugin_base_finalize(GST_VAAPI_PLUGIN_BASE(object));
- G_OBJECT_CLASS(gst_vaapidownload_parent_class)->finalize(object);
-}
-
-static void
-gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
-{
- GObjectClass * const object_class = G_OBJECT_CLASS(klass);
- GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
- GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
- GstPadTemplate *pad_template;
-
- GST_DEBUG_CATEGORY_INIT(gst_debug_vaapidownload,
- GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
-
- gst_vaapi_plugin_base_class_init(GST_VAAPI_PLUGIN_BASE_CLASS(klass));
-
- object_class->finalize = gst_vaapidownload_finalize;
- trans_class->start = gst_vaapidownload_start;
- trans_class->stop = gst_vaapidownload_stop;
- trans_class->before_transform = gst_vaapidownload_before_transform;
- trans_class->transform = gst_vaapidownload_transform;
- trans_class->transform_caps = gst_vaapidownload_transform_caps;
- trans_class->transform_size = gst_vaapidownload_transform_size;
- trans_class->set_caps = gst_vaapidownload_set_caps;
-
- gst_element_class_set_static_metadata(element_class,
- "VA-API colorspace converter",
- "Filter/Converter/Video",
- GST_PLUGIN_DESC,
- "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
-
- /* sink pad */
- pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
- gst_element_class_add_pad_template(element_class, 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);
-}
-
-static void
-gst_vaapidownload_init(GstVaapiDownload *download)
-{
- GstPad *sinkpad, *srcpad;
-
- gst_vaapi_plugin_base_init(GST_VAAPI_PLUGIN_BASE(download), GST_CAT_DEFAULT);
-
- download->allowed_caps = NULL;
- download->images = NULL;
- download->images_reset = FALSE;
- download->image_format = GST_VIDEO_FORMAT_UNKNOWN;
- download->image_width = 0;
- download->image_height = 0;
-
- /* Override buffer allocator on sink pad */
- sinkpad = gst_element_get_static_pad(GST_ELEMENT(download), "sink");
- gst_pad_set_query_function(sinkpad, gst_vaapidownload_query);
- gst_object_unref(sinkpad);
-
- /* Override query on src pad */
- srcpad = gst_element_get_static_pad(GST_ELEMENT(download), "src");
- gst_pad_set_query_function(srcpad, gst_vaapidownload_query);
- gst_object_unref(srcpad);
-}
-
-static inline gboolean
-gst_vaapidownload_ensure_display(GstVaapiDownload *download)
-{
- return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(download));
-}
-
-static gboolean
-gst_vaapidownload_start(GstBaseTransform *trans)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
-
- if (!gst_vaapi_plugin_base_open(GST_VAAPI_PLUGIN_BASE(trans)))
- return FALSE;
- if (!gst_vaapidownload_ensure_display(download))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapidownload_stop(GstBaseTransform *trans)
-{
- gst_vaapi_plugin_base_close(GST_VAAPI_PLUGIN_BASE(trans));
- return TRUE;
-}
-
-static GstVideoFormat
-get_surface_format(GstVaapiSurface *surface)
-{
- GstVaapiImage *image;
- GstVideoFormat format = GST_VIDEO_FORMAT_NV12;
-
- /* XXX: NV12 is assumed by default */
- image = gst_vaapi_surface_derive_image(surface);
- if (image) {
- format = gst_vaapi_image_get_format(image);
- gst_vaapi_object_unref(image);
- }
- return format;
-}
-
-static gboolean
-gst_vaapidownload_update_src_caps(GstVaapiDownload *download, GstBuffer *buffer)
-{
- GstVaapiVideoMeta *meta;
- GstVaapiSurface *surface;
- GstVideoFormat format;
- GstVideoInfo vi;
- GstPad *srcpad;
- GstCaps *in_caps, *out_caps;
-
- meta = gst_buffer_get_vaapi_video_meta(buffer);
- surface = gst_vaapi_video_meta_get_surface(meta);
- if (!surface) {
- GST_WARNING("failed to retrieve VA surface from buffer");
- return FALSE;
- }
-
- format = get_surface_format(surface);
- if (format == download->image_format)
- return TRUE;
-
- in_caps = GST_BUFFER_CAPS(buffer);
- if (!in_caps || !gst_caps_is_fixed(in_caps)) {
- GST_WARNING("failed to retrieve caps from buffer");
- return FALSE;
- }
-
- if (!gst_video_info_from_caps(&vi, in_caps)) {
- GST_WARNING("failed to parse caps %" GST_PTR_FORMAT, in_caps);
- return FALSE;
- }
-
- gst_video_info_set_format(&vi, download->image_format,
- GST_VIDEO_INFO_WIDTH(&vi), GST_VIDEO_INFO_HEIGHT(&vi));
- out_caps = gst_video_info_to_caps(&vi);
- if (!out_caps) {
- GST_WARNING("failed to create caps from format %s",
- gst_video_format_to_string(download->image_format));
- return FALSE;
- }
-
- /* Try to renegotiate downstream caps */
- srcpad = gst_element_get_static_pad(GST_ELEMENT(download), "src");
- gst_pad_set_caps(srcpad, out_caps);
- gst_object_unref(srcpad);
-
- gst_vaapidownload_set_caps(GST_BASE_TRANSFORM(download), in_caps, out_caps);
- gst_caps_replace(&download->allowed_caps, out_caps);
- gst_caps_unref(out_caps);
- return TRUE;
-}
-
-static void
-gst_vaapidownload_before_transform(GstBaseTransform *trans, GstBuffer *buffer)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
-
- gst_vaapidownload_update_src_caps(download, buffer);
-}
-
-static GstFlowReturn
-gst_vaapidownload_transform(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- GstBuffer *outbuf
-)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
- GstVaapiVideoMeta *meta;
- GstVaapiSurface *surface;
- GstVaapiImage *image = NULL;
- gboolean success;
-
- meta = gst_buffer_get_vaapi_video_meta(inbuf);
- surface = gst_vaapi_video_meta_get_surface(meta);
- if (!surface)
- return GST_FLOW_UNEXPECTED;
-
- image = gst_vaapi_video_pool_get_object(download->images);
- if (!image)
- return GST_FLOW_UNEXPECTED;
- if (!gst_vaapi_surface_get_image(surface, image))
- goto error_get_image;
-
- success = gst_vaapi_image_get_buffer(image, outbuf, NULL);
- gst_vaapi_video_pool_put_object(download->images, image);
- if (!success)
- goto error_get_buffer;
- return GST_FLOW_OK;
-
-error_get_image:
- {
- const GstVideoFormat format = gst_vaapi_image_get_format(image);
- GST_WARNING("failed to download %s image from surface 0x%08x",
- gst_video_format_to_string(format),
- gst_vaapi_surface_get_id(surface));
- gst_vaapi_video_pool_put_object(download->images, image);
- return GST_FLOW_UNEXPECTED;
- }
-
-error_get_buffer:
- {
- GST_WARNING("failed to transfer image to output video buffer");
- return GST_FLOW_UNEXPECTED;
- }
-}
-
-static GstCaps *
-gst_vaapidownload_transform_caps(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps
-)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
- GstPad *srcpad;
- GstCaps *allowed_caps, *tmp_caps, *out_caps = NULL;
- GstStructure *structure;
- GArray *formats;
-
- g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
-
- structure = gst_caps_get_structure(caps, 0);
-
- if (direction == GST_PAD_SINK) {
- if (!gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
- return NULL;
- if (!gst_vaapidownload_ensure_display(download))
- return NULL;
- out_caps = gst_caps_from_string(gst_vaapidownload_yuv_caps_str);
-
- /* Build up allowed caps */
- /* XXX: we don't know the decoded surface format yet so we
- expose whatever VA images we support */
- if (download->allowed_caps)
- allowed_caps = gst_caps_ref(download->allowed_caps);
- else {
- formats = gst_vaapi_display_get_image_formats(
- GST_VAAPI_PLUGIN_BASE_DISPLAY(download));
- if (G_UNLIKELY(!formats))
- allowed_caps = gst_caps_new_empty();
- else {
- allowed_caps =
- gst_vaapi_video_format_new_template_caps_from_list(formats);
- g_array_unref(formats);
- }
- if (!allowed_caps)
- return NULL;
- }
- tmp_caps = gst_caps_intersect(out_caps, allowed_caps);
- gst_caps_unref(allowed_caps);
- gst_caps_unref(out_caps);
- out_caps = tmp_caps;
-
- /* Intersect with allowed caps from the peer, if any */
- srcpad = gst_element_get_static_pad(GST_ELEMENT(download), "src");
- allowed_caps = gst_pad_peer_get_caps(srcpad);
- if (allowed_caps) {
- tmp_caps = gst_caps_intersect(out_caps, allowed_caps);
- gst_caps_unref(allowed_caps);
- gst_caps_unref(out_caps);
- out_caps = tmp_caps;
- }
- }
- else {
- if (!gst_structure_has_name(structure, "video/x-raw-yuv"))
- return NULL;
- out_caps = gst_caps_from_string(gst_vaapidownload_vaapi_caps_str);
-
- structure = gst_caps_get_structure(out_caps, 0);
- gst_structure_set(
- structure,
- "type", G_TYPE_STRING, "vaapi",
- "opengl", G_TYPE_BOOLEAN, USE_GLX,
- NULL
- );
- }
-
- if (!gst_vaapi_append_surface_caps(out_caps, caps)) {
- gst_caps_unref(out_caps);
- return NULL;
- }
- return out_caps;
-}
-
-static gboolean
-gst_vaapidownload_ensure_image_pool(GstVaapiDownload *download, GstCaps *caps)
-{
- 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);
-
- if (format != download->image_format ||
- width != download->image_width ||
- height != download->image_height) {
- download->image_format = format;
- download->image_width = width;
- download->image_height = height;
- gst_vaapi_video_pool_replace(&download->images, NULL);
- download->images = gst_vaapi_image_pool_new(
- GST_VAAPI_PLUGIN_BASE_DISPLAY(download), &vi);
- if (!download->images)
- return FALSE;
- download->images_reset = TRUE;
- }
- return TRUE;
-}
-
-static inline gboolean
-gst_vaapidownload_negotiate_buffers(
- GstVaapiDownload *download,
- GstCaps *incaps,
- GstCaps *outcaps
-)
-{
- if (!gst_vaapidownload_ensure_image_pool(download, outcaps))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapidownload_set_caps(
- GstBaseTransform *trans,
- GstCaps *incaps,
- GstCaps *outcaps
-)
-{
- GstVaapiPluginBase * const plugin = GST_VAAPI_PLUGIN_BASE(trans);
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
-
- if (!gst_vaapi_plugin_base_set_caps(plugin, incaps, outcaps))
- return FALSE;
- if (!gst_vaapidownload_negotiate_buffers(download, incaps, outcaps))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapidownload_transform_size(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps,
- guint size,
- GstCaps *othercaps,
- guint *othersize
-)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
- GstStructure * const structure = gst_caps_get_structure(othercaps, 0);
- GstVideoFormat format;
- gint width, height;
- guint i;
-
- /* Lookup in cache */
- for (i = 0; i < G_N_ELEMENTS(download->transform_size_cache); i++) {
- TransformSizeCache * const tsc = &download->transform_size_cache[i];
- if (tsc->caps && tsc->caps == othercaps) {
- *othersize = tsc->size;
- return TRUE;
- }
- }
-
- /* Compute requested buffer size */
- if (gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
- *othersize = 0;
- else {
- if (!gst_video_format_parse_caps(othercaps, &format, &width, &height))
- return FALSE;
- *othersize = gst_video_format_get_size(format, width, height);
- }
-
- /* Update cache */
- for (i = 0; i < G_N_ELEMENTS(download->transform_size_cache); i++) {
- TransformSizeCache * const tsc = &download->transform_size_cache[i];
- if (!tsc->caps) {
- gst_caps_replace(&tsc->caps, othercaps);
- tsc->size = *othersize;
- }
- }
- return TRUE;
-}
-
-static gboolean
-gst_vaapidownload_query(GstPad *pad, GstQuery *query)
-{
- GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(gst_pad_get_parent_element(pad));
- GstVaapiDisplay * const display = GST_VAAPI_PLUGIN_BASE_DISPLAY(download);
- gboolean res;
-
- GST_DEBUG("sharing display %p", display);
-
- if (gst_vaapi_reply_to_query(query, display))
- res = TRUE;
- else
- res = gst_pad_query_default(pad, query);
-
- gst_object_unref(download);
- return res;
-
-}
+++ /dev/null
-/*
- * gstvaapidownload.h - VA-API video downloader
- *
- * 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 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_VAAPIDOWNLOAD_H
-#define GST_VAAPIDOWNLOAD_H
-
-#include "gstvaapipluginbase.h"
-#include <gst/vaapi/gstvaapisurface.h>
-#include <gst/vaapi/gstvaapiimagepool.h>
-#include <gst/vaapi/gstvaapisurfacepool.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_VAAPIDOWNLOAD \
- (gst_vaapidownload_get_type())
-
-#define GST_VAAPIDOWNLOAD(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GST_TYPE_VAAPIDOWNLOAD, \
- GstVaapiDownload))
-
-#define GST_VAAPIDOWNLOAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GST_TYPE_VAAPIDOWNLOAD, \
- GstVaapiDownloadClass))
-
-#define GST_IS_VAAPIDOWNLOAD(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIDOWNLOAD))
-
-#define GST_IS_VAAPIDOWNLOAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIDOWNLOAD))
-
-#define GST_VAAPIDOWNLOAD_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GST_TYPE_VAAPIDOWNLOAD, \
- GstVaapiDownloadClass))
-
-typedef struct _GstVaapiDownload GstVaapiDownload;
-typedef struct _GstVaapiDownloadClass GstVaapiDownloadClass;
-
-GType
-gst_vaapidownload_get_type(void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* GST_VAAPIDOWNLOAD_H */
#include "gstvaapiencode.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
#include "gstvaapivideobufferpool.h"
-#endif
#define GST_PLUGIN_NAME "vaapiencode"
#define GST_PLUGIN_DESC "A VA-API based video encoder"
if (buf_size <= 0)
goto error_invalid_buffer;
-#if GST_CHECK_VERSION(1,0,0)
buf =
gst_video_encoder_allocate_output_buffer (GST_VIDEO_ENCODER_CAST (encode),
buf_size);
-#else
- buf = gst_buffer_new_and_alloc (buf_size);
-#endif
if (!buf)
goto error_create_buffer;
if (!gst_vaapi_coded_buffer_copy_into (buf, coded_buf))
return FALSE;
}
-#if GST_CHECK_VERSION(1,0,0)
if (!gst_video_encoder_negotiate (venc))
return FALSE;
-#endif
encode->input_state_changed = FALSE;
return TRUE;
if (plugin->sinkpad_caps)
caps = gst_caps_ref (plugin->sinkpad_caps);
else {
-#if GST_CHECK_VERSION(1,0,0)
caps = gst_pad_get_pad_template_caps (plugin->sinkpad);
-#else
- caps = gst_caps_from_string (GST_VAAPI_SURFACE_CAPS);
-
- if (caps && ensure_uploader (GST_VAAPIENCODE_CAST (plugin))) {
- GstCaps *const yuv_caps = GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS (plugin);
- if (yuv_caps) {
- caps = gst_caps_make_writable (caps);
- gst_caps_append (caps, gst_caps_copy (yuv_caps));
- }
- }
-#endif
}
return caps;
}
-#if GST_CHECK_VERSION(1,0,0)
static GstCaps *
gst_vaapiencode_get_caps (GstVideoEncoder * venc, GstCaps * filter)
{
}
return out_caps;
}
-#else
-#define gst_vaapiencode_get_caps gst_vaapiencode_get_caps_impl
-#endif
static gboolean
gst_vaapiencode_destroy (GstVaapiEncode * encode)
change_state (element, transition);
}
-#if GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapiencode_propose_allocation (GstVideoEncoder * venc, GstQuery * query)
{
return FALSE;
return TRUE;
}
-#endif
static void
gst_vaapiencode_finalize (GObject * object)
venc_class->handle_frame = GST_DEBUG_FUNCPTR (gst_vaapiencode_handle_frame);
venc_class->finish = GST_DEBUG_FUNCPTR (gst_vaapiencode_finish);
venc_class->getcaps = GST_DEBUG_FUNCPTR (gst_vaapiencode_get_caps);
-
-#if GST_CHECK_VERSION(1,0,0)
venc_class->propose_allocation =
GST_DEBUG_FUNCPTR (gst_vaapiencode_propose_allocation);
-#endif
klass->get_property = gst_vaapiencode_default_get_property;
klass->set_property = gst_vaapiencode_default_set_property;
#include <gst/vaapi/gstvaapiutils_h264.h>
#include "gstvaapiencode_h264.h"
#include "gstvaapipluginutil.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapiencode_h264"
#define GST_PLUGIN_DESC "A VA-API based H.264 video encoder"
GST_VAAPI_SURFACE_CAPS ", "
#endif
GST_CAPS_INTERLACED_FALSE "; "
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#else
- "video/x-raw-yuv, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ], "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
#include <gst/vaapi/gstvaapiencoder_jpeg.h>
#include "gstvaapiencode_jpeg.h"
#include "gstvaapipluginutil.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapiencode_jpeg"
#define GST_PLUGIN_DESC "A VA-API based JPEG video encoder"
GST_VAAPI_SURFACE_CAPS ", "
#endif
GST_CAPS_INTERLACED_FALSE "; "
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
#include <gst/vaapi/gstvaapiencoder_mpeg2.h>
#include "gstvaapiencode_mpeg2.h"
#include "gstvaapipluginutil.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapiencode_mpeg2"
#define GST_PLUGIN_DESC "A VA-API based MPEG-2 video encoder"
GST_VAAPI_SURFACE_CAPS ", "
#endif
GST_CAPS_INTERLACED_FALSE "; "
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#else
- "video/x-raw-yuv, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ], "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
#include <gst/vaapi/gstvaapiencoder_vp8.h>
#include "gstvaapiencode_vp8.h"
#include "gstvaapipluginutil.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapiencode_vp8"
#define GST_PLUGIN_DESC "A VA-API based VP8 video encoder"
GST_VAAPI_SURFACE_CAPS ", "
#endif
GST_CAPS_INTERLACED_FALSE "; "
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
return !failure;
}
-#if GST_CHECK_VERSION(1,0,0)
-/* XXX: use PLUGIN_NAME when GST_PLUGIN_DEFINE is fixed to use
- G_STRINGIFY() for name argument, instead of plain #name */
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
vaapiparse, PLUGIN_DESC, plugin_init,
PACKAGE_VERSION, PLUGIN_LICENSE, PACKAGE, PACKAGE_BUGREPORT)
-#else
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
- PLUGIN_NAME, PLUGIN_DESC, plugin_init,
- PACKAGE_VERSION, PLUGIN_LICENSE, PACKAGE, PACKAGE_BUGREPORT)
-#endif
#include "gstvaapipluginutil.h"
#include "gstvaapivideocontext.h"
#include "gstvaapivideometa.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideobufferpool.h"
-#endif
#if GST_CHECK_VERSION(1,1,0)
#include <gst/allocators/allocators.h>
#endif
/* Default debug category is from the subclass */
#define GST_CAT_DEFAULT (plugin->debug_category)
-/* GstImplementsInterface interface */
-#if !GST_CHECK_VERSION(1,0,0)
-static gboolean
-implements_interface_supported (GstImplementsInterface * iface, GType type)
-{
- GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (iface);
-
- if (type == GST_TYPE_VIDEO_CONTEXT)
- return TRUE;
- return GST_VAAPI_PLUGIN_BASE_GET_CLASS (plugin)->has_interface (plugin, type);
-}
-
-static void
-implements_interface_init (GstImplementsInterfaceClass * iface)
-{
- iface->supported = implements_interface_supported;
-}
-#endif
-
/* GstVideoContext interface */
static void
plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
void
gst_vaapi_plugin_base_init_interfaces (GType g_define_type_id)
{
-#if !GST_CHECK_VERSION(1,0,0)
- G_IMPLEMENT_INTERFACE (GST_TYPE_IMPLEMENTS_INTERFACE,
- implements_interface_init);
-#endif
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_CONTEXT, video_context_interface_init);
#endif
gst_caps_replace (&plugin->sinkpad_caps, NULL);
plugin->sinkpad_caps_changed = FALSE;
gst_video_info_init (&plugin->sinkpad_info);
-#if GST_CHECK_VERSION(1,0,0)
if (plugin->sinkpad_buffer_pool) {
gst_object_unref (plugin->sinkpad_buffer_pool);
plugin->sinkpad_buffer_pool = NULL;
}
g_clear_object (&plugin->srcpad_buffer_pool);
-#endif
gst_caps_replace (&plugin->srcpad_caps, NULL);
plugin->srcpad_caps_changed = FALSE;
static gboolean
ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
{
-#if GST_CHECK_VERSION(1,0,0)
GstBufferPool *pool;
GstCaps *pool_caps;
GstStructure *config;
gst_object_unref (pool);
return FALSE;
}
-#else
- return TRUE;
-#endif
}
/**
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
-#if GST_CHECK_VERSION(1,0,0)
gboolean
gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
GstQuery * query)
return FALSE;
}
}
-#endif
/**
* gst_vaapi_plugin_base_decide_allocation:
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
-#if GST_CHECK_VERSION(1,0,0)
gboolean
gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
GstQuery * query, guint feature)
return FALSE;
}
}
-#endif
/**
* gst_vaapi_plugin_base_allocate_input_buffer:
{
GstVaapiVideoMeta *meta;
GstBuffer *outbuf;
-#if GST_CHECK_VERSION(1,0,0)
GstVideoFrame src_frame, out_frame;
gboolean success;
-#endif
g_return_val_if_fail (inbuf != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (outbuf_ptr != NULL, GST_FLOW_ERROR);
meta = gst_buffer_get_vaapi_video_meta (inbuf);
-#if GST_CHECK_VERSION(1,0,0)
if (meta) {
*outbuf_ptr = gst_buffer_ref (inbuf);
return GST_FLOW_OK;
gst_buffer_unref (outbuf);
return GST_FLOW_NOT_SUPPORTED;
}
-#else
- if (meta)
- outbuf = gst_buffer_ref (inbuf);
- else if (plugin->sinkpad_caps_is_raw) {
- outbuf = gst_vaapi_uploader_get_buffer (plugin->uploader);
- if (!outbuf)
- goto error_create_buffer;
- gst_buffer_copy_metadata (outbuf, inbuf,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);
- } else
- goto error_invalid_buffer;
-
- if (plugin->sinkpad_caps_is_raw &&
- !gst_vaapi_uploader_process (plugin->uploader, inbuf, outbuf))
- goto error_copy_buffer;
-
- *outbuf_ptr = outbuf;
- return GST_FLOW_OK;
-#endif
/* ERRORS */
error_invalid_buffer:
gboolean sinkpad_caps_is_raw;
GstVideoInfo sinkpad_info;
GstPadQueryFunction sinkpad_query;
-#if GST_CHECK_VERSION(1,0,0)
GstBufferPool *sinkpad_buffer_pool;
guint sinkpad_buffer_size;
-#endif
GstPad *srcpad;
GstCaps *srcpad_caps;
gboolean srcpad_caps_changed;
GstVideoInfo srcpad_info;
GstPadQueryFunction srcpad_query;
-#if GST_CHECK_VERSION(1,0,0)
GstBufferPool *srcpad_buffer_pool;
-#endif
GstVaapiDisplay *display;
GstVaapiDisplayType display_type;
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 = NULL;
if (cmeta)
composition = cmeta->overlay;
-#else
- GstVideoOverlayComposition *const composition =
- gst_video_buffer_get_overlay_composition (buffer);
-#endif
return gst_vaapi_surface_set_subpictures_from_composition (surface,
composition, TRUE);
}
gboolean
gst_vaapi_value_set_format (GValue * value, GstVideoFormat format)
{
-#if GST_CHECK_VERSION(1,0,0)
const gchar *str;
str = gst_video_format_to_string (format);
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, str);
-#else
- guint32 fourcc;
-
- fourcc = gst_video_format_to_fourcc (format);
- if (!fourcc)
- return FALSE;
-
- g_value_init (value, GST_TYPE_FOURCC);
- gst_value_set_fourcc (value, fourcc);
-#endif
return TRUE;
}
GstCaps *
gst_vaapi_video_format_new_template_caps (GstVideoFormat format)
{
-#if GST_CHECK_VERSION(1,0,0)
GstCaps *caps;
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
"format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
set_video_template_caps (caps);
return caps;
-#else
- return gst_video_format_new_template_caps (format);
-#endif
}
GstCaps *
gst_vaapi_video_format_new_template_caps_from_list (GArray * formats)
{
-#if GST_CHECK_VERSION(1,0,0)
GValue v_formats = G_VALUE_INIT;
GstCaps *caps;
gst_caps_set_value (caps, "format", &v_formats);
set_video_template_caps (caps);
g_value_unset (&v_formats);
-#else
- GstCaps *caps, *tmp_caps;
- guint i;
-
- g_return_val_if_fail (formats != NULL, NULL);
-
- caps = gst_caps_new_empty ();
- if (!caps)
- return NULL;
-
- for (i = 0; i < formats->len; i++) {
- const GstVideoFormat format = g_array_index (formats, GstVideoFormat, i);
- tmp_caps = gst_vaapi_video_format_new_template_caps (format);
- if (tmp_caps)
- gst_caps_append (caps, tmp_caps);
- }
-#endif
return caps;
}
gboolean
gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip)
{
-#if GST_CHECK_VERSION(1,0,0)
GstVideoInterlaceMode mode;
const gchar *mode_str;
}
gst_caps_set_simple (caps, "interlace-mode", G_TYPE_STRING, mode_str, NULL);
-#else
- gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN,
- vip ? GST_VIDEO_INFO_IS_INTERLACED (vip) : FALSE, NULL);
-#endif
return TRUE;
}
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapisurface.h>
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideomemory.h"
-#endif
G_GNUC_INTERNAL
gboolean
gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
/* Helpers to handle interlaced contents */
-#if GST_CHECK_VERSION(1,0,0)
# define GST_CAPS_INTERLACED_MODES \
"interlace-mode = (string){ progressive, interleaved, mixed }"
# define GST_CAPS_INTERLACED_FALSE \
"interlace-mode = (string)progressive"
-#else
-# define GST_CAPS_INTERLACED_MODES \
- "interlaced = (boolean){ true, false }"
-# define GST_CAPS_INTERLACED_FALSE \
- "interlaced = (boolean)false"
-#endif
G_GNUC_INTERNAL
gboolean
#include "gstvaapipostproc.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideobuffer.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapipostproc"
#define GST_PLUGIN_DESC "A video postprocessing filter"
static const char gst_vaapipostproc_sink_caps_str[] =
GST_VAAPIPOSTPROC_SURFACE_CAPS ", "
GST_CAPS_INTERLACED_MODES "; "
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#else
- "video/x-raw-yuv, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ", "
-#endif
GST_CAPS_INTERLACED_MODES;
/* *INDENT-ON* */
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "{ RGBA, BGRA }") ", "
GST_CAPS_INTERLACED_FALSE "; "
#endif
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-#else
- "video/x-raw-yuv, "
- "width = " GST_VIDEO_SIZE_RANGE ", "
- "height = " GST_VIDEO_SIZE_RANGE ", "
- "framerate = " GST_VIDEO_FPS_RANGE ", "
-#endif
GST_CAPS_INTERLACED_FALSE;
/* *INDENT-ON* */
case GST_VIDEO_INTERLACE_MODE_PROGRESSIVE:
return FALSE;
case GST_VIDEO_INTERLACE_MODE_MIXED:
-#if GST_CHECK_VERSION(1,0,0)
if (GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_FLAG_INTERLACED))
return TRUE;
-#else
- if (!GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_PROGRESSIVE))
- return TRUE;
-#endif
break;
default:
GST_ERROR ("unhandled \"interlace-mode\", disabling deinterlacing");
{
GstBuffer *outbuf;
-#if GST_CHECK_VERSION(1,0,0)
GstBufferPool *const pool =
GST_VAAPI_PLUGIN_BASE (postproc)->srcpad_buffer_pool;
GstFlowReturn ret;
ret = gst_buffer_pool_acquire_buffer (pool, &outbuf, NULL);
if (ret != GST_FLOW_OK || !outbuf)
goto error_create_buffer;
-#else
- /* Create a raw VA video buffer without GstVaapiVideoMeta attached
- to it yet, as this will be done next in the transform() hook */
- outbuf = gst_vaapi_video_buffer_new_empty ();
- if (!outbuf)
- goto error_create_buffer;
-
- gst_buffer_set_caps (outbuf, GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS (postproc));
-#endif
return outbuf;
/* ERRORS */
-#if GST_CHECK_VERSION(1,0,0)
error_activate_pool:
{
GST_ERROR ("failed to activate output video buffer pool");
return NULL;
}
-#endif
error_create_buffer:
{
GST_ERROR ("failed to create output video buffer");
gst_buffer_copy_into (outbuf, inbuf, flags | GST_BUFFER_COPY_FLAGS, 0, -1);
/* GstVideoCropMeta */
-#if GST_CHECK_VERSION(1,0,0)
if (!postproc->use_vpp) {
GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (inbuf);
if (crop_meta) {
*out_crop_meta = *crop_meta;
}
}
-#endif
/* GstVaapiVideoMeta */
inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf);
guint flags, deint_flags;
gboolean tff, deint, deint_refs, deint_changed;
GstVaapiRectangle *crop_rect = NULL;
-#if GST_CHECK_VERSION(1,0,0)
GstVaapiRectangle tmp_rect;
-#endif
/* Validate filters */
if ((postproc->flags & GST_VAAPI_POSTPROC_FLAG_FORMAT) &&
goto error_invalid_buffer;
inbuf_surface = gst_vaapi_video_meta_get_surface (inbuf_meta);
-#if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (inbuf);
if (crop_meta) {
crop_rect = &tmp_rect;
crop_rect->width = crop_meta->width;
crop_rect->height = crop_meta->height;
}
-#endif
if (!crop_rect)
crop_rect = (GstVaapiRectangle *)
gst_vaapi_video_meta_get_render_rect (inbuf_meta);
return out_caps;
}
-#if GST_CHECK_VERSION(1,0,0)
static GstCaps *
gst_vaapipostproc_transform_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
}
return caps;
}
-#else
-#define gst_vaapipostproc_transform_caps \
- gst_vaapipostproc_transform_caps_impl
-#endif
-
-#if GST_CHECK_VERSION(1,0,0)
-typedef gsize GstBaseTransformSizeType;
-#else
-typedef guint GstBaseTransformSizeType;
-#endif
static gboolean
gst_vaapipostproc_transform_size (GstBaseTransform * trans,
- GstPadDirection direction, GstCaps * caps, GstBaseTransformSizeType size,
- GstCaps * othercaps, GstBaseTransformSizeType * othersize)
+ GstPadDirection direction, GstCaps * caps, gsize size,
+ GstCaps * othercaps, gsize * othersize)
{
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
static GstFlowReturn
gst_vaapipostproc_prepare_output_buffer (GstBaseTransform * trans,
GstBuffer * inbuf,
-#if !GST_CHECK_VERSION(1,0,0)
- gint size, GstCaps * caps,
-#endif
GstBuffer ** outbuf_ptr)
{
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
direction, query);
}
-#if GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapipostproc_propose_allocation (GstBaseTransform * trans,
GstQuery * decide_query, GstQuery * query)
return gst_vaapi_plugin_base_decide_allocation (GST_VAAPI_PLUGIN_BASE (trans),
query, 0);
}
-#endif
static void
gst_vaapipostproc_finalize (GObject * object)
trans_class->transform = gst_vaapipostproc_transform;
trans_class->set_caps = gst_vaapipostproc_set_caps;
trans_class->query = gst_vaapipostproc_query;
-
-#if GST_CHECK_VERSION(1,0,0)
trans_class->propose_allocation = gst_vaapipostproc_propose_allocation;
trans_class->decide_allocation = gst_vaapipostproc_decide_allocation;
-#endif
trans_class->prepare_output_buffer = gst_vaapipostproc_prepare_output_buffer;
#include <gst/vaapi/gstvaapivalue.h>
/* Supported interfaces */
-#if GST_CHECK_VERSION(1,0,0)
# include <gst/video/videooverlay.h>
# include <gst/video/colorbalance.h>
# include <gst/video/navigation.h>
-#else
-# include <gst/interfaces/xoverlay.h>
-# include <gst/interfaces/colorbalance.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)
-
-# define GstColorBalanceInterface GstColorBalanceClass
-#endif
#include "gstvaapisink.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
-#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideomemory.h"
-#endif
#define GST_PLUGIN_NAME "vaapisink"
#define GST_PLUGIN_DESC "A VA-API based videosink"
"{ ENCODED, NV12, I420, YV12 }") ";"
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL);
#else
-#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) "; "
-#else
- "video/x-raw-yuv, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]; "
-#endif
GST_VAAPI_SURFACE_CAPS;
#endif
/* *INDENT-ON* */
iface->list_channels = gst_vaapisink_color_balance_list_channels;
iface->set_value = gst_vaapisink_color_balance_set_value;
iface->get_value = gst_vaapisink_color_balance_get_value;
-#if GST_CHECK_VERSION(1,0,0)
iface->get_balance_type = gst_vaapisink_color_balance_get_type;
-#else
- iface->balance_type = gst_vaapisink_color_balance_get_type (NULL);
-#endif
}
/* ------------------------------------------------------------------------ */
return out_caps;
}
-#if GST_CHECK_VERSION(1,0,0)
static inline GstCaps *
gst_vaapisink_get_caps (GstBaseSink * base_sink, GstCaps * filter)
{
out_caps = caps;
return out_caps;
}
-#else
-#define gst_vaapisink_get_caps gst_vaapisink_get_caps_impl
-#endif
static void
update_colorimetry (GstVaapiSink * sink, GstVideoColorimetry * cinfo)
{
-#if GST_CHECK_VERSION(1,0,0)
if (gst_video_colorimetry_matches (cinfo, GST_VIDEO_COLORIMETRY_BT601))
sink->color_standard = GST_VAAPI_COLOR_STANDARD_ITUR_BT_601;
else if (gst_video_colorimetry_matches (cinfo, GST_VIDEO_COLORIMETRY_BT709))
g_free (colorimetry_string);
}
#endif
-#endif
}
static gboolean
GstBuffer *buffer;
guint flags;
GstVaapiRectangle *surface_rect = NULL;
-#if GST_CHECK_VERSION(1,0,0)
GstVaapiRectangle tmp_rect;
-#endif
GstFlowReturn ret;
gint32 view_id;
-#if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta *const crop_meta =
gst_buffer_get_video_crop_meta (src_buffer);
if (crop_meta) {
surface_rect->width = crop_meta->width;
surface_rect->height = crop_meta->height;
}
-#endif
ret = gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (sink),
src_buffer, &buffer);
return ret;
}
-#if GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapisink_propose_allocation (GstBaseSink * base_sink, GstQuery * query)
{
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
return TRUE;
}
-#else
-static GstFlowReturn
-gst_vaapisink_buffer_alloc (GstBaseSink * base_sink, guint64 offset, guint size,
- GstCaps * caps, GstBuffer ** outbuf_ptr)
-{
- return
- gst_vaapi_plugin_base_allocate_input_buffer (GST_VAAPI_PLUGIN_BASE
- (base_sink), caps, outbuf_ptr);
-}
-#endif
static gboolean
gst_vaapisink_query (GstBaseSink * base_sink, GstQuery * query)
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->propose_allocation = gst_vaapisink_propose_allocation;
-#else
- basesink_class->buffer_alloc = gst_vaapisink_buffer_alloc;
-#endif
element_class->set_bus = gst_vaapisink_set_bus;
gst_element_class_set_static_metadata (element_class,
+++ /dev/null
-/*
- * gstvaapiupload.c - VA-API video upload element
- *
- * 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
- */
-
-/**
- * SECTION:gstvaapiupload
- * @short_description: A video to VA flow filter
- *
- * vaapiupload converts from raw YUV pixels to VA surfaces suitable
- * for the vaapisink element, for example.
- */
-
-#include "gst/vaapi/sysdeps.h"
-#include <gst/gst.h>
-#include <gst/video/video.h>
-
-#include "gstvaapiupload.h"
-#include "gstvaapipluginutil.h"
-#include "gstvaapivideobuffer.h"
-
-#define GST_PLUGIN_NAME "vaapiupload"
-#define GST_PLUGIN_DESC "A video to VA flow filter"
-
-GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapiupload);
-#define GST_CAT_DEFAULT gst_debug_vaapiupload
-
-/* Default templates */
-static const char gst_vaapiupload_yuv_caps_str[] =
- "video/x-raw-yuv, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]; ";
-
-static const char gst_vaapiupload_vaapi_caps_str[] =
- GST_VAAPI_SURFACE_CAPS;
-
-static GstStaticPadTemplate gst_vaapiupload_sink_factory =
- GST_STATIC_PAD_TEMPLATE(
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(gst_vaapiupload_yuv_caps_str));
-
-static GstStaticPadTemplate gst_vaapiupload_src_factory =
- GST_STATIC_PAD_TEMPLATE(
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(gst_vaapiupload_vaapi_caps_str));
-
-G_DEFINE_TYPE_WITH_CODE(
- GstVaapiUpload,
- gst_vaapiupload,
- GST_TYPE_BASE_TRANSFORM,
- GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES)
-
-static gboolean
-gst_vaapiupload_start(GstBaseTransform *trans);
-
-static gboolean
-gst_vaapiupload_stop(GstBaseTransform *trans);
-
-static GstFlowReturn
-gst_vaapiupload_transform(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- GstBuffer *outbuf
-);
-
-static GstCaps *
-gst_vaapiupload_transform_caps(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps
-);
-
-static gboolean
-gst_vaapiupload_set_caps(
- GstBaseTransform *trans,
- GstCaps *incaps,
- GstCaps *outcaps
-);
-
-static gboolean
-gst_vaapiupload_get_unit_size(
- GstBaseTransform *trans,
- GstCaps *caps,
- guint *size
-);
-
-static GstFlowReturn
-gst_vaapiupload_sinkpad_buffer_alloc(
- GstPad *pad,
- guint64 offset,
- guint size,
- GstCaps *caps,
- GstBuffer **pbuf
-);
-
-static GstFlowReturn
-gst_vaapiupload_prepare_output_buffer(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- gint size,
- GstCaps *caps,
- GstBuffer **poutbuf
-);
-
-static gboolean
-gst_vaapiupload_query(
- GstPad *pad,
- GstQuery *query
-);
-
-static void
-gst_vaapiupload_destroy(GstVaapiUpload *upload)
-{
- g_clear_object(&upload->uploader);
-}
-
-static void
-gst_vaapiupload_finalize(GObject *object)
-{
- gst_vaapiupload_destroy(GST_VAAPIUPLOAD(object));
-
- gst_vaapi_plugin_base_finalize(GST_VAAPI_PLUGIN_BASE(object));
- G_OBJECT_CLASS(gst_vaapiupload_parent_class)->finalize(object);
-}
-
-static void
-gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
-{
- GObjectClass * const object_class = G_OBJECT_CLASS(klass);
- GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
- GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
- GstPadTemplate *pad_template;
-
- GST_DEBUG_CATEGORY_INIT(gst_debug_vaapiupload,
- GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
-
- gst_vaapi_plugin_base_class_init(GST_VAAPI_PLUGIN_BASE_CLASS(klass));
-
- object_class->finalize = gst_vaapiupload_finalize;
-
- trans_class->start = gst_vaapiupload_start;
- trans_class->stop = gst_vaapiupload_stop;
- trans_class->transform = gst_vaapiupload_transform;
- trans_class->transform_caps = gst_vaapiupload_transform_caps;
- trans_class->set_caps = gst_vaapiupload_set_caps;
- trans_class->get_unit_size = gst_vaapiupload_get_unit_size;
- trans_class->prepare_output_buffer = gst_vaapiupload_prepare_output_buffer;
-
- gst_element_class_set_static_metadata(element_class,
- "VA-API colorspace converter",
- "Filter/Converter/Video",
- GST_PLUGIN_DESC,
- "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
-
- /* sink pad */
- pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
- gst_element_class_add_pad_template(element_class, 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);
-}
-
-static void
-gst_vaapiupload_init(GstVaapiUpload *upload)
-{
- GstPad *sinkpad, *srcpad;
-
- gst_vaapi_plugin_base_init(GST_VAAPI_PLUGIN_BASE(upload), GST_CAT_DEFAULT);
-
- /* Override buffer allocator on sink pad */
- sinkpad = gst_element_get_static_pad(GST_ELEMENT(upload), "sink");
- gst_pad_set_bufferalloc_function(
- sinkpad,
- gst_vaapiupload_sinkpad_buffer_alloc
- );
- gst_pad_set_query_function(sinkpad, gst_vaapiupload_query);
- gst_object_unref(sinkpad);
-
- /* Override query on src pad */
- srcpad = gst_element_get_static_pad(GST_ELEMENT(upload), "src");
- gst_pad_set_query_function(srcpad, gst_vaapiupload_query);
- gst_object_unref(srcpad);
-}
-
-static inline gboolean
-gst_vaapiupload_ensure_display(GstVaapiUpload *upload)
-{
- return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(upload));
-}
-
-static gboolean
-gst_vaapiupload_ensure_uploader(GstVaapiUpload *upload)
-{
- if (!gst_vaapiupload_ensure_display(upload))
- return FALSE;
-
- if (!upload->uploader) {
- upload->uploader = gst_vaapi_uploader_new(
- GST_VAAPI_PLUGIN_BASE_DISPLAY(upload));
- if (!upload->uploader)
- return FALSE;
- }
- if (!gst_vaapi_uploader_ensure_display(upload->uploader,
- GST_VAAPI_PLUGIN_BASE_DISPLAY(upload)))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapiupload_start(GstBaseTransform *trans)
-{
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
-
- if (!gst_vaapi_plugin_base_open(GST_VAAPI_PLUGIN_BASE(trans)))
- return FALSE;
- if (!gst_vaapiupload_ensure_uploader(upload))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapiupload_stop(GstBaseTransform *trans)
-{
- gst_vaapi_plugin_base_close(GST_VAAPI_PLUGIN_BASE(trans));
- return TRUE;
-}
-
-static GstFlowReturn
-gst_vaapiupload_transform(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- GstBuffer *outbuf
-)
-{
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
-
- if (!gst_vaapi_uploader_process(upload->uploader, inbuf, outbuf))
- return GST_FLOW_UNEXPECTED;
- return GST_FLOW_OK;
-}
-
-static GstCaps *
-gst_vaapiupload_transform_caps(
- GstBaseTransform *trans,
- GstPadDirection direction,
- GstCaps *caps
-)
-{
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
- GstCaps *out_caps = NULL;
- GstStructure *structure;
-
- g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
-
- structure = gst_caps_get_structure(caps, 0);
-
- if (direction == GST_PAD_SINK) {
- if (!gst_structure_has_name(structure, "video/x-raw-yuv"))
- return NULL;
- out_caps = gst_caps_from_string(gst_vaapiupload_vaapi_caps_str);
-
- structure = gst_caps_get_structure(out_caps, 0);
- gst_structure_set(
- structure,
- "type", G_TYPE_STRING, "vaapi",
- "opengl", G_TYPE_BOOLEAN, USE_GLX,
- NULL
- );
- }
- else {
- if (!gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
- return NULL;
- out_caps = gst_caps_from_string(gst_vaapiupload_yuv_caps_str);
- if (gst_vaapiupload_ensure_uploader(upload)) {
- GstCaps *allowed_caps, *inter_caps;
- allowed_caps = gst_vaapi_uploader_get_caps(upload->uploader);
- if (!allowed_caps)
- return NULL;
- inter_caps = gst_caps_intersect(out_caps, allowed_caps);
- gst_caps_unref(out_caps);
- out_caps = inter_caps;
- }
- }
-
- if (!gst_vaapi_append_surface_caps(out_caps, caps)) {
- gst_caps_unref(out_caps);
- return NULL;
- }
- return out_caps;
-}
-
-static gboolean
-gst_vaapiupload_set_caps(
- GstBaseTransform *trans,
- GstCaps *incaps,
- GstCaps *outcaps
-)
-{
- GstVaapiPluginBase * const plugin = GST_VAAPI_PLUGIN_BASE(trans);
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
-
- if (!gst_vaapi_plugin_base_set_caps(plugin, incaps, outcaps))
- return FALSE;
- if (!gst_vaapi_uploader_ensure_caps(upload->uploader, incaps, outcaps))
- return FALSE;
- return TRUE;
-}
-
-static gboolean
-gst_vaapiupload_get_unit_size(
- GstBaseTransform *trans,
- GstCaps *caps,
- guint *size
-)
-{
- GstStructure * const structure = gst_caps_get_structure(caps, 0);
- GstVideoFormat format;
- gint width, height;
-
- if (gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
- *size = 0;
- else {
- if (!gst_video_format_parse_caps(caps, &format, &width, &height))
- return FALSE;
- *size = gst_video_format_get_size(format, width, height);
- }
- return TRUE;
-}
-
-static GstFlowReturn
-gst_vaapiupload_buffer_alloc(
- GstBaseTransform *trans,
- guint size,
- GstCaps *caps,
- GstBuffer **pbuf
-)
-{
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
-
- *pbuf = NULL;
-
- if (!gst_vaapi_uploader_ensure_display(upload->uploader,
- GST_VAAPI_PLUGIN_BASE_DISPLAY(upload)))
- return GST_FLOW_NOT_SUPPORTED;
- if (!gst_vaapi_uploader_ensure_caps(upload->uploader, caps, NULL))
- return GST_FLOW_NOT_SUPPORTED;
-
- /* Allocate a regular GstBuffer if direct rendering is not supported */
- if (!gst_vaapi_uploader_has_direct_rendering(upload->uploader))
- return GST_FLOW_OK;
-
- *pbuf = gst_vaapi_uploader_get_buffer(upload->uploader);
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_vaapiupload_sinkpad_buffer_alloc(
- GstPad *pad,
- guint64 offset,
- guint size,
- GstCaps *caps,
- GstBuffer **pbuf
-)
-{
- GstBaseTransform *trans;
- GstFlowReturn ret;
-
- trans = GST_BASE_TRANSFORM(gst_pad_get_parent_element(pad));
- if (!trans)
- return GST_FLOW_UNEXPECTED;
-
- ret = gst_vaapiupload_buffer_alloc(trans, size, caps, pbuf);
- gst_object_unref(trans);
- return ret;
-}
-
-static GstFlowReturn
-gst_vaapiupload_prepare_output_buffer(
- GstBaseTransform *trans,
- GstBuffer *inbuf,
- gint size,
- GstCaps *caps,
- GstBuffer **poutbuf
-)
-{
- GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
- GstBuffer *buffer;
-
- *poutbuf = NULL;
-
- if (!gst_vaapi_uploader_has_direct_rendering(upload->uploader))
- buffer = gst_vaapi_uploader_get_buffer(upload->uploader);
- else
- buffer = gst_vaapi_video_buffer_new_from_buffer(inbuf);
- if (!buffer)
- return GST_FLOW_UNEXPECTED;
-
- gst_buffer_set_caps(buffer, caps);
- GST_BUFFER_DATA(buffer) = NULL;
- GST_BUFFER_SIZE(buffer) = 0;
-
- *poutbuf = buffer;
- return GST_FLOW_OK;
-}
-
-static gboolean
-gst_vaapiupload_query(GstPad *pad, GstQuery *query)
-{
- GstVaapiUpload *upload = GST_VAAPIUPLOAD (gst_pad_get_parent_element (pad));
- gboolean res;
-
- GST_DEBUG ("sharing display %p", GST_VAAPI_PLUGIN_BASE_DISPLAY(upload));
-
- if (gst_vaapi_reply_to_query (query, GST_VAAPI_PLUGIN_BASE_DISPLAY(upload)))
- res = TRUE;
- else
- res = gst_pad_query_default (pad, query);
-
- gst_object_unref (upload);
- return res;
-}
+++ /dev/null
-/*
- * gstvaapiupload.h - VA-API video upload element
- *
- * 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_VAAPIUPLOAD_H
-#define GST_VAAPIUPLOAD_H
-
-#include "gstvaapipluginbase.h"
-#include "gstvaapiuploader.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_VAAPIUPLOAD \
- (gst_vaapiupload_get_type())
-
-#define GST_VAAPIUPLOAD(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GST_TYPE_VAAPIUPLOAD, \
- GstVaapiUpload))
-
-#define GST_VAAPIUPLOAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GST_TYPE_VAAPIUPLOAD, \
- GstVaapiUploadClass))
-
-#define GST_IS_VAAPIUPLOAD(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIUPLOAD))
-
-#define GST_IS_VAAPIUPLOAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIUPLOAD))
-
-#define GST_VAAPIUPLOAD_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GST_TYPE_VAAPIUPLOAD, \
- GstVaapiUploadClass))
-
-typedef struct _GstVaapiUpload GstVaapiUpload;
-typedef struct _GstVaapiUploadClass GstVaapiUploadClass;
-
-struct _GstVaapiUpload {
- /*< private >*/
- GstVaapiPluginBase parent_instance;
-
- GstVaapiUploader *uploader;
-};
-
-struct _GstVaapiUploadClass {
- /*< private >*/
- GstVaapiPluginBaseClass parent_class;
-};
-
-GType
-gst_vaapiupload_get_type(void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* GST_VAAPIUPLOAD_H */
GST_WARNING ("failed to map VA image");
goto error;
}
-#if !GST_CHECK_VERSION(1,0,0)
- GST_BUFFER_DATA (buffer) = gst_vaapi_image_get_plane (image, 0);
- GST_BUFFER_SIZE (buffer) = gst_vaapi_image_get_data_size (image);
-#endif
return buffer;
error:
{
return gst_buffer_new ();
}
-#elif GST_CHECK_VERSION(1,0,0)
+#else
#include <gst/video/gstsurfacemeta.h>
#define GST_VAAPI_SURFACE_META_CAST(obj) \
gst_buffer_add_meta (buffer, GST_VAAPI_SURFACE_META_INFO, NULL);
return buffer;
}
-#else
-#include <gst/video/gstsurfacebuffer.h>
-
-#define GST_VAAPI_TYPE_VIDEO_BUFFER \
- (gst_vaapi_video_buffer_get_type ())
-#define GST_VAAPI_VIDEO_BUFFER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER, \
- GstVaapiVideoBuffer))
-#define GST_VAAPI_VIDEO_BUFFER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER, \
- GstVaapiVideoBufferClass))
-#define GST_VAAPI_IS_VIDEO_BUFFER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER))
-#define GST_VAAPI_IS_VIDEO_BUFFER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_BUFFER))
-#define GST_VAAPI_VIDEO_BUFFER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_VIDEO_BUFFER, \
- GstVaapiVideoBufferClass))
-
-typedef struct _GstVaapiVideoBufferClass GstVaapiVideoBufferClass;
-/**
- * GstVaapiVideoBuffer:
- *
- * A #GstBuffer holding video objects (#GstVaapiSurface and #GstVaapiImage).
- */
-struct _GstVaapiVideoBuffer
-{
- /*< private >*/
- GstSurfaceBuffer parent_instance;
-};
-
-/**
- * GstVaapiVideoBufferClass:
- *
- * A #GstBuffer holding video objects
- */
-struct _GstVaapiVideoBufferClass
-{
- /*< private >*/
- GstSurfaceBufferClass parent_class;
-};
-
-GType
-gst_vaapi_video_buffer_get_type (void) G_GNUC_CONST;
-
-G_DEFINE_TYPE (GstVaapiVideoBuffer,
- gst_vaapi_video_buffer, GST_TYPE_SURFACE_BUFFER);
-
-typedef GstSurfaceConverter *
-(*GstSurfaceConverterCreateFunc) (GstSurfaceBuffer * surface,
- const gchar * type, GValue * dest);
-
-static GstSurfaceConverter *
-gst_vaapi_video_buffer_create_converter (GstSurfaceBuffer * surface,
- const gchar * type, GValue * dest)
-{
- GstVaapiVideoMeta *const meta =
- gst_buffer_get_vaapi_video_meta (GST_BUFFER (surface));
- GstSurfaceConverterCreateFunc func;
-
- g_return_val_if_fail (meta != NULL, NULL);
-
- func = (GstSurfaceConverterCreateFunc)
- gst_vaapi_video_meta_get_surface_converter (meta);
-
- return func ? func (surface, type, dest) : NULL;
-}
-
-static void
-gst_vaapi_video_buffer_class_init (GstVaapiVideoBufferClass * klass)
-{
- GstSurfaceBufferClass *const surface_class = GST_SURFACE_BUFFER_CLASS (klass);
-
- surface_class->create_converter = gst_vaapi_video_buffer_create_converter;
-}
-
-static void
-gst_vaapi_video_buffer_init (GstVaapiVideoBuffer * buffer)
-{
-}
-
-static inline GstBuffer *
-gst_surface_buffer_new (void)
-{
- return GST_BUFFER_CAST (gst_mini_object_new (GST_VAAPI_TYPE_VIDEO_BUFFER));
-}
#endif
static GFunc
#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);
#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_x11_iface_init (GstSurfaceConverterInterface * iface);
if (!gst_vaapi_apply_composition (surface, buffer))
GST_WARNING ("could not update subtitles");
-#if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta *const crop_meta = gst_buffer_get_video_crop_meta (buffer);
if (crop_meta) {
GstVaapiRectangle crop_rect_tmp;
crop_rect_tmp.width = crop_meta->width;
crop_rect_tmp.height = crop_meta->height;
}
-#endif
if (!crop_rect)
crop_rect = gst_vaapi_video_meta_get_render_rect (meta);
#include <gst/vaapi/gstvaapiimagepool.h>
#include <gst/vaapi/gstvaapisurfacepool.h>
#include "gstvaapivideometa.h"
-
-#if GST_CHECK_VERSION(1,0,0)
-# include "gstvaapivideomemory.h"
-#endif
+#include "gstvaapivideomemory.h"
#define GST_VAAPI_VIDEO_META(obj) \
((GstVaapiVideoMeta *) (obj))
if (!meta->proxy)
return FALSE;
-#if GST_CHECK_VERSION(1,0,0)
if (meta->buffer) {
GstMemory *const mem = gst_buffer_peek_memory (meta->buffer, 0);
if (GST_VAAPI_IS_VIDEO_MEMORY (mem))
return gst_vaapi_video_memory_sync (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
}
-#endif
return TRUE;
}
gst_vaapi_surface_proxy_replace (&meta->proxy, NULL);
}
-#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)
-{
- static gsize g_type;
-
- if (g_once_init_enter (&g_type)) {
- GType type;
- type = g_boxed_type_register_static ("GstVaapiVideoMeta",
- (GBoxedCopyFunc) gst_vaapi_video_meta_ref,
- (GBoxedFreeFunc) gst_vaapi_video_meta_unref);
- g_once_init_leave (&g_type, type);
- }
- return (GType) g_type;
-}
-#endif
-
static void
gst_vaapi_video_meta_finalize (GstVaapiVideoMeta * meta)
{
meta->render_rect = *rect;
}
-#if GST_CHECK_VERSION(1,0,0)
-
#define GST_VAAPI_VIDEO_META_HOLDER(meta) \
((GstVaapiVideoMetaHolder *) (meta))
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)
-{
- static gsize g_quark;
-
- if (g_once_init_enter (&g_quark)) {
- gsize quark = (gsize) g_quark_from_static_string ("GstVaapiVideoMeta");
- g_once_init_leave (&g_quark, quark);
- }
- return g_quark;
-}
-
-#define META_QUARK meta_quark_get ()
-static GQuark
-meta_quark_get (void)
-{
- static gsize g_quark;
-
- if (g_once_init_enter (&g_quark)) {
- gsize quark = (gsize) g_quark_from_static_string ("meta");
- g_once_init_leave (&g_quark, quark);
- }
- return g_quark;
-}
-
-GstVaapiVideoMeta *
-gst_buffer_get_vaapi_video_meta (GstBuffer * buffer)
-{
- GstVaapiVideoMeta *meta;
- const GstStructure *structure;
- const GValue *value;
-
- g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
-
- structure = gst_buffer_get_qdata (buffer, GST_VAAPI_VIDEO_META_QUARK);
- if (!structure)
- return NULL;
-
- value = gst_structure_id_get_value (structure, META_QUARK);
- if (!value)
- return NULL;
-
- meta = GST_VAAPI_VIDEO_META (g_value_get_boxed (value));
- meta->buffer = buffer;
- return meta;
-}
-
-void
-gst_buffer_set_vaapi_video_meta (GstBuffer * buffer, GstVaapiVideoMeta * meta)
-{
- g_return_if_fail (GST_IS_BUFFER (buffer));
- g_return_if_fail (GST_VAAPI_IS_VIDEO_META (meta));
-
- gst_buffer_set_qdata (buffer, GST_VAAPI_VIDEO_META_QUARK,
- gst_structure_id_new (GST_VAAPI_VIDEO_META_QUARK,
- META_QUARK, GST_VAAPI_TYPE_VIDEO_META, meta, NULL));
-}
-#endif
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 *
GError *error = NULL;
if (g_src_format_str) {
- format = gst_vaapi_video_format_from_string(g_src_format_str);
+ format = gst_video_format_from_string(g_src_format_str);
if (format == GST_VIDEO_FORMAT_UNKNOWN)
goto error_invalid_format;
}
subrect.height = subinfo.height;
subrect.width = subinfo.width;
-#if GST_CHECK_VERSION(1,0,0)
{
GstVideoMeta * const vmeta =
gst_buffer_add_video_meta(buffer, GST_VIDEO_FRAME_FLAG_NONE,
overlay = gst_video_overlay_rectangle_new_raw(buffer,
subrect.x, subrect.y, subrect.width, subrect.height, flags);
}
-#else
- overlay = gst_video_overlay_rectangle_new_argb(buffer,
- subinfo.width, subinfo.height, subinfo.width * 4,
- subrect.x, subrect.y, subrect.width, subrect.height, flags);
-#endif
if (!overlay)
g_error("could not create video overlay");
gst_buffer_unref(buffer);