#include "gstvaallocator.h"
-#include <gst/va/gstvavideoformat.h>
#include <sys/types.h>
#include <unistd.h>
-#include "gstvacaps.h"
#include "gstvasurfacecopy.h"
+#include "gstvavideoformat.h"
#include "vasurfaceimage.h"
#define GST_CAT_DEFAULT gst_va_memory_debug
GstVaMemoryPool pool;
};
+struct _GstVaDmabufAllocatorClass
+{
+ GstDmaBufAllocatorClass parent_class;
+};
+
#define gst_va_dmabuf_allocator_parent_class dmabuf_parent_class
G_DEFINE_TYPE_WITH_CODE (GstVaDmabufAllocator, gst_va_dmabuf_allocator,
GST_TYPE_DMABUF_ALLOCATOR, _init_debug_category ());
gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator,
GstBuffer * buffer)
{
- GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator);
+ GstVaDmabufAllocator *self;
VASurfaceID surface;
+ g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE);
+
+ self = GST_VA_DMABUF_ALLOCATOR (allocator);
+
GST_VA_MEMORY_POOL_LOCK (&self->pool);
surface = gst_va_dmabuf_allocator_prepare_buffer_unlocked (self, buffer);
GST_VA_MEMORY_POOL_UNLOCK (&self->pool);
void
gst_va_dmabuf_allocator_flush (GstAllocator * allocator)
{
- GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator);
+ GstVaDmabufAllocator *self;
+
+ g_return_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator));
+
+ self = GST_VA_DMABUF_ALLOCATOR (allocator);
gst_va_memory_pool_flush (&self->pool, self->display);
}
gst_va_dmabuf_allocator_try (GstAllocator * allocator)
{
GstBuffer *buffer;
- GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator);
- GstVideoInfo info = self->info;
+ GstVaDmabufAllocator *self;
+ GstVideoInfo info;
gboolean ret;
+ g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE);
+
+ self = GST_VA_DMABUF_ALLOCATOR (allocator);
+ info = self->info;
+
buffer = gst_buffer_new ();
ret = gst_va_dmabuf_allocator_setup_buffer_full (allocator, buffer, &info);
gst_buffer_unref (buffer);
GstVaMemoryPool pool;
};
+struct _GstVaAllocatorClass
+{
+ GstAllocatorClass parent_class;
+};
+
typedef struct _GstVaMemory GstVaMemory;
struct _GstVaMemory
{
gboolean
gst_va_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer)
{
- GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
+ GstVaAllocator *self;
VASurfaceID surface;
+ g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE);
+
+ self = GST_VA_ALLOCATOR (allocator);
+
GST_VA_MEMORY_POOL_LOCK (&self->pool);
surface = gst_va_allocator_prepare_buffer_unlocked (self, buffer);
GST_VA_MEMORY_POOL_UNLOCK (&self->pool);
void
gst_va_allocator_flush (GstAllocator * allocator)
{
- GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
+ GstVaAllocator *self;
+
+ g_return_if_fail (GST_IS_VA_ALLOCATOR (allocator));
+
+ self = GST_VA_ALLOCATOR (allocator);
gst_va_memory_pool_flush (&self->pool, self->display);
}
static gboolean
gst_va_allocator_try (GstAllocator * allocator)
{
- GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
+ GstVaAllocator *self;
+
+ g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE);
+
+ self = GST_VA_ALLOCATOR (allocator);
self->fourcc = 0;
self->rt_format = 0;
gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
guint * usage_hint)
{
- GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
+ GstVaAllocator *self;
+
+ g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE);
+ self = GST_VA_ALLOCATOR (allocator);
if (GST_VIDEO_INFO_FORMAT (&self->info) == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE;
G_BEGIN_DECLS
+typedef struct _GstVaAllocator GstVaAllocator;
+typedef struct _GstVaAllocatorClass GstVaAllocatorClass;
+typedef struct _GstVaDmabufAllocator GstVaDmabufAllocator;
+typedef struct _GstVaDmabufAllocatorClass GstVaDmabufAllocatorClass;
+
#define GST_TYPE_VA_DMABUF_ALLOCATOR (gst_va_dmabuf_allocator_get_type())
-G_DECLARE_FINAL_TYPE (GstVaDmabufAllocator, gst_va_dmabuf_allocator, GST,
- VA_DMABUF_ALLOCATOR, GstDmaBufAllocator);
+#define GST_VA_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocator))
+#define GST_VA_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocatorClass))
+#define GST_IS_VA_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_DMABUF_ALLOCATOR))
+#define GST_IS_VA_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_DMABUF_ALLOCATOR))
+#define GST_VA_DMABUF_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_DMABUF_ALLOCATOR, GstVaDmabufAllocatorClass))
+GST_VA_API
+GType gst_va_dmabuf_allocator_get_type (void);
+GST_VA_API
GstAllocator * gst_va_dmabuf_allocator_new (GstVaDisplay * display);
+GST_VA_API
gboolean gst_va_dmabuf_allocator_setup_buffer (GstAllocator * allocator,
GstBuffer * buffer);
+GST_VA_API
gboolean gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator,
GstBuffer * buffer);
+GST_VA_API
void gst_va_dmabuf_allocator_flush (GstAllocator * allocator);
+GST_VA_API
gboolean gst_va_dmabuf_allocator_set_format (GstAllocator * allocator,
GstVideoInfo * info,
guint usage_hint);
+GST_VA_API
gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * allocator,
GstVideoInfo * info,
guint * usage_hint);
+GST_VA_API
gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display,
GstVideoInfo * info,
guint n_planes,
guint usage_hint);
#define GST_TYPE_VA_ALLOCATOR (gst_va_allocator_get_type())
-G_DECLARE_FINAL_TYPE (GstVaAllocator, gst_va_allocator, GST, VA_ALLOCATOR, GstAllocator);
+#define GST_VA_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_ALLOCATOR, GstVaAllocator))
+#define GST_VA_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_ALLOCATOR, GstVaAllocatorClass))
+#define GST_IS_VA_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_ALLOCATOR))
+#define GST_IS_VA_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_ALLOCATOR))
+#define GST_VA_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_ALLOCATOR, GstVaAllocatorClass))
#define GST_ALLOCATOR_VASURFACE "VAMemory"
#define GST_MAP_VA (GST_MAP_FLAG_LAST << 1)
+GST_VA_API
+GType gst_va_allocator_get_type (void);
+GST_VA_API
GstAllocator * gst_va_allocator_new (GstVaDisplay * display,
GArray * surface_formats);
+GST_VA_API
GstMemory * gst_va_allocator_alloc (GstAllocator * allocator);
+GST_VA_API
gboolean gst_va_allocator_setup_buffer (GstAllocator * allocator,
GstBuffer * buffer);
+GST_VA_API
gboolean gst_va_allocator_prepare_buffer (GstAllocator * allocator,
GstBuffer * buffer);
+GST_VA_API
void gst_va_allocator_flush (GstAllocator * allocator);
+GST_VA_API
gboolean gst_va_allocator_set_format (GstAllocator * allocator,
GstVideoInfo * info,
guint usage_hint);
+GST_VA_API
gboolean gst_va_allocator_get_format (GstAllocator * allocator,
GstVideoInfo * info,
guint * usage_hint);
+GST_VA_API
VASurfaceID gst_va_memory_get_surface (GstMemory * mem);
+GST_VA_API
VASurfaceID gst_va_buffer_get_surface (GstBuffer * buffer);
+GST_VA_API
gboolean gst_va_buffer_create_aux_surface (GstBuffer * buffer);
+GST_VA_API
VASurfaceID gst_va_buffer_get_aux_surface (GstBuffer * buffer);
G_END_DECLS
#endif
#include "gstvapool.h"
-
#include "gstvaallocator.h"
-#include "gstvacaps.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_pool_debug);
#define GST_CAT_DEFAULT gst_va_pool_debug
gboolean starting;
};
+struct _GstVaPoolClass
+{
+ GstBufferPoolClass parent_class;
+};
+
#define gst_va_pool_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstVaPool, gst_va_pool, GST_TYPE_BUFFER_POOL,
GST_DEBUG_CATEGORY_INIT (gst_va_pool_debug, "vapool", 0, "VA Pool"));
gboolean
gst_va_pool_requires_video_meta (GstBufferPool * pool)
{
+
+ g_return_val_if_fail (GST_IS_VA_POOL (pool), FALSE);
+
return GST_VA_POOL (pool)->force_videometa;
}
#pragma once
+#include <gst/va/va_fwd.h>
+#include <gst/va/va-prelude.h>
#include <gst/gst.h>
G_BEGIN_DECLS
+typedef struct _GstVaPool GstVaPool;
+typedef struct _GstVaPoolClass GstVaPoolClass;
+
#define GST_TYPE_VA_POOL (gst_va_pool_get_type())
-G_DECLARE_FINAL_TYPE (GstVaPool, gst_va_pool, GST, VA_POOL, GstBufferPool)
+#define GST_VA_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_POOL, GstVaPool))
+#define GST_VA_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_POOL, GstVaPoolClass))
+#define GST_IS_VA_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_POOL))
+#define GST_IS_VA_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_POOL))
+#define GST_VA_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_POOL, GstVaPoolClass))
+GST_VA_API
+GType gst_va_pool_get_type (void);
+GST_VA_API
GstBufferPool * gst_va_pool_new (void);
+GST_VA_API
gboolean gst_va_pool_requires_video_meta (GstBufferPool * pool);
+GST_VA_API
void gst_buffer_pool_config_set_va_allocation_params (GstStructure * config,
- guint usage_hint);
-
+ guint usage_hint);
+GST_VA_API
GstBufferPool * gst_va_pool_new_with_config (GstCaps * caps,
- guint size,
- guint min_buffers,
- guint max_buffers,
- guint usage_hint,
- GstAllocator * allocator,
- GstAllocationParams * alloc_params);
+ guint size,
+ guint min_buffers,
+ guint max_buffers,
+ guint usage_hint,
+ GstAllocator * allocator,
+ GstAllocationParams * alloc_params);
G_END_DECLS
* Boston, MA 02110-1301, USA.
*/
-#include "gstvasurfacecopy.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "gstvaallocator.h"
-#include "gstvadisplay_priv.h"
-#include "gstvafilter.h"
+#include "gstvasurfacecopy.h"
#include "vasurfaceimage.h"
#define GST_CAT_DEFAULT gst_va_memory_debug
gboolean has_copy;
GRecMutex lock;
- GstVaFilter *filter;
};
static gboolean
self->display = gst_object_ref (display);
self->has_copy = _has_copy (display);
self->info = *vinfo;
- self->filter = NULL;
g_rec_mutex_init (&self->lock);
- if (gst_va_display_has_vpp (display)) {
- self->filter = gst_va_filter_new (display);
- if (!(gst_va_filter_open (self->filter)
- && gst_va_filter_set_video_info (self->filter, vinfo, vinfo)))
- gst_clear_object (&self->filter);
- }
-
return self;
}
g_return_if_fail (self && GST_IS_VA_DISPLAY (self->display));
gst_clear_object (&self->display);
- if (self->filter) {
- gst_va_filter_close (self->filter);
- gst_clear_object (&self->filter);
- }
g_rec_mutex_clear (&self->lock);
g_slice_free (GstVaSurfaceCopy, self);
}
-static gboolean
-_vpp_copy_surface (GstVaSurfaceCopy * self, VASurfaceID dst, VASurfaceID src)
-{
- gboolean ret;
-
- GstVaSample gst_src = {
- .surface = src,
- };
- GstVaSample gst_dst = {
- .surface = dst,
- };
-
- g_rec_mutex_lock (&self->lock);
- ret = gst_va_filter_process (self->filter, &gst_src, &gst_dst);
- g_rec_mutex_unlock (&self->lock);
-
- return ret;
-}
-
gboolean
gst_va_surface_copy (GstVaSurfaceCopy * self, VASurfaceID dst, VASurfaceID src)
{
return TRUE;
}
- if (self->filter && _vpp_copy_surface (self, dst, src)) {
- GST_LOG ("VPP copy of %#x to %#x", src, dst);
- return TRUE;
- }
+ /* TODO: Add the VPP copy. */
if (!va_ensure_image (self->display, src, &self->info, &image, FALSE))
return FALSE;
va_sources = [
+ 'gstvaallocator.c',
'gstvadisplay.c',
'gstvadisplay_drm.c',
'gstvadisplay_wrapped.c',
+ 'gstvapool.c',
+ 'gstvasurfacecopy.c',
'gstvautils.c',
'gstvavideoformat.c',
+ 'vasurfaceimage.c',
]
va_headers = [
'gstva.h',
+ 'gstvaallocator.h',
'gstvadisplay.h',
'gstvadisplay_drm.h',
'gstvadisplay_wrapped.h',
+ 'gstvapool.h',
'gstvautils.h',
'gstvavideoformat.h',
- 'va_fwd.h',
'va-prelude.h',
+ 'va_fwd.h',
]
gstva_dep = dependency('', required : false)
gstva_dep = declare_dependency(link_with : gstva,
include_directories : [libsinc],
- dependencies : [gst_dep, gstvideo_dep, libva_dep, libva_drm_dep, libdrm_dep])
+ dependencies : [gst_dep, gstvideo_dep, gstallocators_dep, libva_dep, libva_drm_dep, libdrm_dep])
meson.override_dependency(pkg_name, gstva_dep)
* Boston, MA 02110-1301, USA.
*/
-#include "vasurfaceimage.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include <gst/va/gstvavideoformat.h>
+#include "vasurfaceimage.h"
+#include "gstvavideoformat.h"
#include <va/va.h>
gboolean
#include "config.h"
#endif
-#include <gst/codecs/gstav1decoder.h>
+#include <gst/va/gstvaallocator.h>
+
#include "gstvaav1dec.h"
#include "gstvabasedec.h"
-#include "gstvaallocator.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_av1dec_debug);
#ifndef GST_DISABLE_GST_DEBUG
#include "gstvabasedec.h"
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvapool.h>
#include <gst/va/gstvavideoformat.h>
-#include "gstvaallocator.h"
#include "gstvacaps.h"
-#include "gstvapool.h"
#define GST_CAT_DEFAULT (base->debug_category)
#define GST_VA_BASE_DEC_GET_PARENT_CLASS(obj) (GST_VA_BASE_DEC_GET_CLASS(obj)->parent_decoder_class)
#include "gstvabasetransform.h"
-#include "gstvaallocator.h"
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvapool.h>
+
#include "gstvacaps.h"
-#include "gstvapool.h"
#define GST_CAT_DEFAULT gst_va_base_transform_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#include "gstvadecoder.h"
+#include <gst/va/gstvaallocator.h>
#include <gst/va/gstvavideoformat.h>
-#include "gstvaallocator.h"
#include "gstvacaps.h"
#include "gstvadisplay_priv.h"
#include "gstvaprofile.h"
#include "gstvadeinterlace.h"
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvapool.h>
#include <gst/video/video.h>
-
#include <va/va_drmcommon.h>
-#include "gstvaallocator.h"
#include "gstvabasetransform.h"
#include "gstvacaps.h"
#include "gstvadisplay_priv.h"
#include "gstvafilter.h"
-#include "gstvapool.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_deinterlace_debug);
#define GST_CAT_DEFAULT gst_va_deinterlace_debug
#include "gstvaencoder.h"
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvadisplay_wrapped.h>
+#include <gst/va/gstvapool.h>
+#include <gst/va/gstvavideoformat.h>
+
#include "vacompat.h"
-#include "gstvaallocator.h"
-#include "gstvapool.h"
#include "gstvacaps.h"
#include "gstvadisplay_priv.h"
-#include "gstvavideoformat.h"
-#include <gst/va/gstvadisplay_wrapped.h>
#define VA_ENTRYPOINT_FLAG(entry) (1U << G_PASTE(VAEntrypoint, entry))
#include "gstvafilter.h"
-#include <gst/video/video.h>
+#include <gst/va/gstvaallocator.h>
#include <gst/va/gstvavideoformat.h>
-
+#include <gst/video/video.h>
#include <va/va_drmcommon.h>
-#include "gstvaallocator.h"
#include "gstvacaps.h"
#include "gstvadisplay_priv.h"
-#include "vasurfaceimage.h"
struct _GstVaFilter
{
}
static gboolean
+_check_surface (GstVaDisplay * display, VASurfaceID surface)
+{
+ VADisplay dpy = gst_va_display_get_va_dpy (display);
+ VAStatus status;
+ VASurfaceStatus state;
+
+ status = vaQuerySurfaceStatus (dpy, surface, &state);
+
+ if (status != VA_STATUS_SUCCESS)
+ GST_ERROR ("vaQuerySurfaceStatus: %s", vaErrorStr (status));
+
+ GST_LOG ("surface %#x status %d", surface, state);
+
+ return (status == VA_STATUS_SUCCESS);
+}
+
+static gboolean
_fill_va_sample (GstVaFilter * self, GstVaSample * sample,
GstPadDirection direction)
{
/* @FIXME: in gallium vaQuerySurfaceStatus only seems to work with
* encoder's surfaces */
if (!GST_VA_DISPLAY_IS_IMPLEMENTATION (self->display, MESA_GALLIUM)) {
- if (!va_check_surface (self->display, sample->surface))
+ if (!_check_surface (self->display, sample->surface))
return FALSE;
}
#include "config.h"
#endif
-#include <gst/video/video.h>
-#include <va/va_drmcommon.h>
+#include "gstvah264enc.h"
#include <gst/codecparsers/gsth264bitwriter.h>
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvapool.h>
#include <gst/va/gstvautils.h>
+#include <gst/va/gstvavideoformat.h>
+#include <gst/video/video.h>
+#include <va/va_drmcommon.h>
#include "vacompat.h"
-#include "gstvah264enc.h"
#include "gstvaencoder.h"
-#include "gstvavideoformat.h"
-#include "gstvaallocator.h"
#include "gstvacaps.h"
#include "gstvaprofile.h"
#include "gstvadisplay_priv.h"
-#include "gstvapool.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_h264enc_debug);
#ifndef GST_DISABLE_GST_DEBUG
#include "gstvavpp.h"
#include <gst/video/video.h>
-
+#include <gst/va/gstvaallocator.h>
+#include <gst/va/gstvapool.h>
#include <va/va_drmcommon.h>
-#include "gstvaallocator.h"
#include "gstvabasetransform.h"
#include "gstvacaps.h"
#include "gstvadisplay_priv.h"
#include "gstvafilter.h"
-#include "gstvapool.h"
GST_DEBUG_CATEGORY_STATIC (gst_va_vpp_debug);
#define GST_CAT_DEFAULT gst_va_vpp_debug
va_sources = [
'plugin.c',
- 'gstvaallocator.c',
'gstvabasedec.c',
'gstvabasetransform.c',
'gstvacaps.c',
'gstvaencoder.c',
'gstvadevice.c',
'gstvadisplay_priv.c',
+ 'gstvaencoder.c',
'gstvafilter.c',
'gstvah264dec.c',
+ 'gstvah264enc.c',
'gstvah265dec.c',
- 'gstvapool.c',
+ 'gstvampeg2dec.c',
'gstvaprofile.c',
- 'gstvasurfacecopy.c',
'gstvavp8dec.c',
'gstvavp9dec.c',
- 'gstvampeg2dec.c',
'gstvavpp.c',
- 'gstvah264enc.c',
- 'vasurfaceimage.c'
]
if host_system != 'linux'
va_sources,
c_args : gst_plugins_bad_args + gstva_cargs,
include_directories : [configinc],
- dependencies : [gstvideo_dep, gstcodecs_dep, gstallocators_dep, gstva_dep, libgudev_dep] + extra_dep,
+ dependencies : [gstcodecs_dep, gstva_dep, libgudev_dep] + extra_dep,
install : true,
install_dir : plugins_install_dir,
)