mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
vaapivideomemory: add real GstVaapiDmaBufAllocator
Instead of defining GstVaapiDmaBufAllocator as a hackish decorator of GstDmaBufAllocator, now, since the expose of the GstDmaBufAllocator's GType, GstVaapiDmaBufAllocator is a full feature GstAllocator inherited from GstDmaBufAllocator. https://bugzilla.gnome.org/show_bug.cgi?id=755072 Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
This commit is contained in:
parent
bb4dc645f0
commit
952b20a893
2 changed files with 68 additions and 10 deletions
|
@ -889,7 +889,8 @@ gst_vaapi_buffer_proxy_quark_get (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
GstMemory *
|
GstMemory *
|
||||||
gst_vaapi_dmabuf_memory_new (GstAllocator * allocator, GstVaapiVideoMeta * meta)
|
gst_vaapi_dmabuf_memory_new (GstAllocator * base_allocator,
|
||||||
|
GstVaapiVideoMeta * meta)
|
||||||
{
|
{
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
|
@ -899,11 +900,13 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * allocator, GstVaapiVideoMeta * meta)
|
||||||
gint dmabuf_fd;
|
gint dmabuf_fd;
|
||||||
const GstVideoInfo *vip;
|
const GstVideoInfo *vip;
|
||||||
guint flags;
|
guint flags;
|
||||||
|
GstVaapiDmaBufAllocator *const allocator =
|
||||||
|
GST_VAAPI_DMABUF_ALLOCATOR_CAST (base_allocator);
|
||||||
|
|
||||||
g_return_val_if_fail (allocator != NULL, NULL);
|
g_return_val_if_fail (allocator != NULL, NULL);
|
||||||
g_return_val_if_fail (meta != NULL, NULL);
|
g_return_val_if_fail (meta != NULL, NULL);
|
||||||
|
|
||||||
vip = gst_allocator_get_vaapi_video_info (allocator, &flags);
|
vip = gst_allocator_get_vaapi_video_info (base_allocator, &flags);
|
||||||
if (!vip)
|
if (!vip)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -934,7 +937,7 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * allocator, GstVaapiVideoMeta * meta)
|
||||||
if (dmabuf_fd < 0 || (dmabuf_fd = dup (dmabuf_fd)) < 0)
|
if (dmabuf_fd < 0 || (dmabuf_fd = dup (dmabuf_fd)) < 0)
|
||||||
goto error_create_dmabuf_handle;
|
goto error_create_dmabuf_handle;
|
||||||
|
|
||||||
mem = gst_dmabuf_allocator_alloc (allocator, dmabuf_fd,
|
mem = gst_dmabuf_allocator_alloc (base_allocator, dmabuf_fd,
|
||||||
gst_vaapi_buffer_proxy_get_size (dmabuf_proxy));
|
gst_vaapi_buffer_proxy_get_size (dmabuf_proxy));
|
||||||
if (!mem)
|
if (!mem)
|
||||||
goto error_create_dmabuf_memory;
|
goto error_create_dmabuf_memory;
|
||||||
|
@ -982,11 +985,28 @@ error_create_dmabuf_memory:
|
||||||
/* --- GstVaapiDmaBufAllocator --- */
|
/* --- GstVaapiDmaBufAllocator --- */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GstVaapiDmaBufAllocator,
|
||||||
|
gst_vaapi_dmabuf_allocator, GST_TYPE_DMABUF_ALLOCATOR);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_dmabuf_allocator_class_init (GstVaapiDmaBufAllocatorClass * klass)
|
||||||
|
{
|
||||||
|
_init_vaapi_video_memory_debug ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_dmabuf_allocator_init (GstVaapiDmaBufAllocator * allocator)
|
||||||
|
{
|
||||||
|
GstAllocator *const base_allocator = GST_ALLOCATOR_CAST (allocator);
|
||||||
|
|
||||||
|
base_allocator->mem_type = GST_VAAPI_DMABUF_ALLOCATOR_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
GstAllocator *
|
GstAllocator *
|
||||||
gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
||||||
const GstVideoInfo * vip, guint flags)
|
const GstVideoInfo * vip, guint flags)
|
||||||
{
|
{
|
||||||
GstAllocator *allocator = NULL;
|
GstVaapiDmaBufAllocator *allocator = NULL;
|
||||||
GstVaapiSurface *surface = NULL;
|
GstVaapiSurface *surface = NULL;
|
||||||
GstVaapiImage *image = NULL;
|
GstVaapiImage *image = NULL;
|
||||||
GstVideoInfo alloc_info;
|
GstVideoInfo alloc_info;
|
||||||
|
@ -994,8 +1014,6 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
||||||
g_return_val_if_fail (display != NULL, NULL);
|
g_return_val_if_fail (display != NULL, NULL);
|
||||||
g_return_val_if_fail (vip != NULL, NULL);
|
g_return_val_if_fail (vip != NULL, NULL);
|
||||||
|
|
||||||
_init_vaapi_video_memory_debug ();
|
|
||||||
|
|
||||||
surface = gst_vaapi_surface_new_full (display, vip, flags);
|
surface = gst_vaapi_surface_new_full (display, vip, flags);
|
||||||
if (!surface)
|
if (!surface)
|
||||||
goto error_no_surface;
|
goto error_no_surface;
|
||||||
|
@ -1011,15 +1029,16 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
||||||
gst_video_info_update_from_image (&alloc_info, image);
|
gst_video_info_update_from_image (&alloc_info, image);
|
||||||
gst_vaapi_image_unmap (image);
|
gst_vaapi_image_unmap (image);
|
||||||
|
|
||||||
allocator = gst_dmabuf_allocator_new ();
|
allocator = g_object_new (GST_VAAPI_TYPE_DMABUF_ALLOCATOR, NULL);
|
||||||
if (!allocator)
|
if (!allocator)
|
||||||
goto error_no_allocator;
|
goto error_no_allocator;
|
||||||
gst_allocator_set_vaapi_video_info (allocator, &alloc_info, flags);
|
gst_allocator_set_vaapi_video_info (GST_ALLOCATOR_CAST (allocator),
|
||||||
|
&alloc_info, flags);
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
gst_vaapi_object_replace (&image, NULL);
|
gst_vaapi_object_replace (&image, NULL);
|
||||||
gst_vaapi_object_replace (&surface, NULL);
|
gst_vaapi_object_replace (&surface, NULL);
|
||||||
return allocator;
|
return GST_ALLOCATOR_CAST (allocator);
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error_no_surface:
|
error_no_surface:
|
||||||
|
@ -1168,7 +1187,7 @@ gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_ALLOCATOR (allocator), FALSE);
|
g_return_val_if_fail (GST_IS_ALLOCATOR (allocator), FALSE);
|
||||||
|
|
||||||
if (g_strcmp0 (allocator->mem_type, GST_ALLOCATOR_DMABUF) != 0)
|
if (g_strcmp0 (allocator->mem_type, GST_VAAPI_DMABUF_ALLOCATOR_NAME) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
st = g_object_get_qdata (G_OBJECT (allocator), GST_VAAPI_VIDEO_INFO_QUARK);
|
st = g_object_get_qdata (G_OBJECT (allocator), GST_VAAPI_VIDEO_INFO_QUARK);
|
||||||
return (st != NULL);
|
return (st != NULL);
|
||||||
|
|
|
@ -35,6 +35,8 @@ G_BEGIN_DECLS
|
||||||
typedef struct _GstVaapiVideoMemory GstVaapiVideoMemory;
|
typedef struct _GstVaapiVideoMemory GstVaapiVideoMemory;
|
||||||
typedef struct _GstVaapiVideoAllocator GstVaapiVideoAllocator;
|
typedef struct _GstVaapiVideoAllocator GstVaapiVideoAllocator;
|
||||||
typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
|
typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
|
||||||
|
typedef struct _GstVaapiDmaBufAllocator GstVaapiDmaBufAllocator;
|
||||||
|
typedef struct _GstVaapiDmaBufAllocatorClass GstVaapiDmaBufAllocatorClass;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* --- GstVaapiVideoMemory --- */
|
/* --- GstVaapiVideoMemory --- */
|
||||||
|
@ -220,6 +222,43 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * allocator,
|
||||||
/* --- GstVaapiDmaBufAllocator --- */
|
/* --- GstVaapiDmaBufAllocator --- */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
#define GST_VAAPI_DMABUF_ALLOCATOR_CAST(allocator) \
|
||||||
|
((GstVaapiDmaBufAllocator *) (allocator))
|
||||||
|
|
||||||
|
#define GST_VAAPI_TYPE_DMABUF_ALLOCATOR \
|
||||||
|
(gst_vaapi_dmabuf_allocator_get_type ())
|
||||||
|
#define GST_VAAPI_DMABUF_ALLOCATOR(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_DMABUF_ALLOCATOR, \
|
||||||
|
GstVaapiDmaBufAllocator))
|
||||||
|
#define GST_VAAPI_IS_DMABUF_ALLOCATOR(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_DMABUF_ALLOCATOR))
|
||||||
|
|
||||||
|
#define GST_VAAPI_DMABUF_ALLOCATOR_NAME "GstVaapiDmaBufAllocator"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiDmaBufAllocator:
|
||||||
|
*
|
||||||
|
* A VA dmabuf memory allocator object.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiDmaBufAllocator
|
||||||
|
{
|
||||||
|
GstDmaBufAllocator parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiDmaBufoAllocatorClass:
|
||||||
|
*
|
||||||
|
* A VA dmabuf memory allocator class.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiDmaBufAllocatorClass
|
||||||
|
{
|
||||||
|
GstDmaBufAllocatorClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GType
|
||||||
|
gst_vaapi_dmabuf_allocator_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GstAllocator *
|
GstAllocator *
|
||||||
gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
|
||||||
|
|
Loading…
Reference in a new issue