mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 12:15:19 +00:00
libs: use GstVaapiMiniObject for video object pools.
Port GstVaapiVideoPool, GstVaapiSurfacePool and GstVaapiImagePool to GstVaapiMiniObject. Drop gst_vaapi_video_pool_get_caps() since it was no longer used for a long time. Make object allocators static, i.e. local to the shared library.
This commit is contained in:
parent
98c7068937
commit
2e6ff64a34
11 changed files with 294 additions and 499 deletions
|
@ -20,7 +20,6 @@ GST_VAAPI_SURFACE_POOL_GET_CLASS
|
||||||
GstVaapiVideoPool
|
GstVaapiVideoPool
|
||||||
GstVaapiVideoPoolClass
|
GstVaapiVideoPoolClass
|
||||||
gst_vaapi_video_pool_get_display
|
gst_vaapi_video_pool_get_display
|
||||||
gst_vaapi_video_pool_get_caps
|
|
||||||
gst_vaapi_video_pool_get_object
|
gst_vaapi_video_pool_get_object
|
||||||
gst_vaapi_video_pool_put_object
|
gst_vaapi_video_pool_put_object
|
||||||
gst_vaapi_video_pool_add_object
|
gst_vaapi_video_pool_add_object
|
||||||
|
|
|
@ -117,6 +117,7 @@ libgstvaapi_source_priv_h = \
|
||||||
gstvaapisurfaceproxy_priv.h \
|
gstvaapisurfaceproxy_priv.h \
|
||||||
gstvaapiutils.h \
|
gstvaapiutils.h \
|
||||||
gstvaapiversion.h \
|
gstvaapiversion.h \
|
||||||
|
gstvaapivideopool_priv.h \
|
||||||
gstvaapiwindow_priv.h \
|
gstvaapiwindow_priv.h \
|
||||||
gstvaapiworkarounds.h \
|
gstvaapiworkarounds.h \
|
||||||
sysdeps.h \
|
sysdeps.h \
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "gstvaapisurface_priv.h"
|
#include "gstvaapisurface_priv.h"
|
||||||
#include "gstvaapisurfacepool.h"
|
#include "gstvaapisurfacepool.h"
|
||||||
#include "gstvaapisurfaceproxy.h"
|
#include "gstvaapisurfaceproxy.h"
|
||||||
|
#include "gstvaapivideopool_priv.h"
|
||||||
#include "gstvaapiimage.h"
|
#include "gstvaapiimage.h"
|
||||||
#include "gstvaapisubpicture.h"
|
#include "gstvaapisubpicture.h"
|
||||||
#include "gstvaapiutils.h"
|
#include "gstvaapiutils.h"
|
||||||
|
@ -414,7 +415,7 @@ gst_vaapi_context_destroy_surfaces(GstVaapiContext *context)
|
||||||
g_ptr_array_free(context->surfaces, TRUE);
|
g_ptr_array_free(context->surfaces, TRUE);
|
||||||
context->surfaces = NULL;
|
context->surfaces = NULL;
|
||||||
}
|
}
|
||||||
g_clear_object(&context->surfaces_pool);
|
gst_vaapi_video_pool_replace(&context->surfaces_pool, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -27,30 +27,29 @@
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "gstvaapiimagepool.h"
|
#include "gstvaapiimagepool.h"
|
||||||
|
#include "gstvaapivideopool_priv.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE(
|
/**
|
||||||
GstVaapiImagePool,
|
* GstVaapiImagePool:
|
||||||
gst_vaapi_image_pool,
|
*
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL)
|
* A pool of lazily allocated #GstVaapiImage objects.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiImagePool {
|
||||||
|
/*< private >*/
|
||||||
|
GstVaapiVideoPool parent_instance;
|
||||||
|
|
||||||
#define GST_VAAPI_IMAGE_POOL_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
|
||||||
GST_VAAPI_TYPE_IMAGE_POOL, \
|
|
||||||
GstVaapiImagePoolPrivate))
|
|
||||||
|
|
||||||
struct _GstVaapiImagePoolPrivate {
|
|
||||||
GstVaapiImageFormat format;
|
GstVaapiImageFormat format;
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
|
||||||
{
|
{
|
||||||
GstVaapiImagePoolPrivate * const priv = GST_VAAPI_IMAGE_POOL(pool)->priv;
|
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
|
@ -58,54 +57,31 @@ gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
||||||
gst_structure_get_int(structure, "width", &width);
|
gst_structure_get_int(structure, "width", &width);
|
||||||
gst_structure_get_int(structure, "height", &height);
|
gst_structure_get_int(structure, "height", &height);
|
||||||
|
|
||||||
priv->format = gst_vaapi_image_format_from_caps(caps);
|
pool->format = gst_vaapi_image_format_from_caps(caps);
|
||||||
priv->width = width;
|
pool->width = width;
|
||||||
priv->height = height;
|
pool->height = height;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
static gpointer
|
||||||
gst_vaapi_image_pool_alloc_object(
|
gst_vaapi_image_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||||
GstVaapiVideoPool *pool,
|
|
||||||
GstVaapiDisplay *display
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiImagePoolPrivate * const priv = GST_VAAPI_IMAGE_POOL(pool)->priv;
|
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||||
|
|
||||||
return gst_vaapi_image_new(display,
|
return gst_vaapi_image_new(base_pool->display, pool->format,
|
||||||
priv->format,
|
pool->width, pool->height);
|
||||||
priv->width,
|
|
||||||
priv->height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline const GstVaapiMiniObjectClass *
|
||||||
gst_vaapi_image_pool_finalize(GObject *object)
|
gst_vaapi_image_pool_class(void)
|
||||||
{
|
{
|
||||||
G_OBJECT_CLASS(gst_vaapi_image_pool_parent_class)->finalize(object);
|
static const GstVaapiVideoPoolClass GstVaapiImagePoolClass = {
|
||||||
}
|
{ sizeof(GstVaapiImagePool),
|
||||||
|
(GDestroyNotify)gst_vaapi_video_pool_finalize },
|
||||||
|
|
||||||
static void
|
.alloc_object = gst_vaapi_image_pool_alloc_object
|
||||||
gst_vaapi_image_pool_class_init(GstVaapiImagePoolClass *klass)
|
};
|
||||||
{
|
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiImagePoolClass);
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
|
||||||
GstVaapiVideoPoolClass * const pool_class = GST_VAAPI_VIDEO_POOL_CLASS(klass);
|
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GstVaapiImagePoolPrivate));
|
|
||||||
|
|
||||||
object_class->finalize = gst_vaapi_image_pool_finalize;
|
|
||||||
|
|
||||||
pool_class->set_caps = gst_vaapi_image_pool_set_caps;
|
|
||||||
pool_class->alloc_object = gst_vaapi_image_pool_alloc_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_image_pool_init(GstVaapiImagePool *pool)
|
|
||||||
{
|
|
||||||
GstVaapiImagePoolPrivate *priv = GST_VAAPI_IMAGE_POOL_GET_PRIVATE(pool);
|
|
||||||
|
|
||||||
pool->priv = priv;
|
|
||||||
priv->format = 0;
|
|
||||||
priv->width = 0;
|
|
||||||
priv->height = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,8 +97,22 @@ gst_vaapi_image_pool_init(GstVaapiImagePool *pool)
|
||||||
GstVaapiVideoPool *
|
GstVaapiVideoPool *
|
||||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||||
{
|
{
|
||||||
return g_object_new(GST_VAAPI_TYPE_IMAGE_POOL,
|
GstVaapiVideoPool *pool;
|
||||||
"display", display,
|
|
||||||
"caps", caps,
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
||||||
NULL);
|
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
|
||||||
|
|
||||||
|
pool = (GstVaapiVideoPool *)
|
||||||
|
gst_vaapi_mini_object_new(gst_vaapi_image_pool_class());
|
||||||
|
if (!pool)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
gst_vaapi_video_pool_init(pool, display);
|
||||||
|
if (!gst_vaapi_image_pool_set_caps(pool, caps))
|
||||||
|
goto error;
|
||||||
|
return pool;
|
||||||
|
|
||||||
|
error:
|
||||||
|
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,58 +28,13 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_IMAGE_POOL \
|
#define GST_VAAPI_IMAGE_POOL(obj) \
|
||||||
(gst_vaapi_image_pool_get_type())
|
((GstVaapiImagePool *)(obj))
|
||||||
|
|
||||||
#define GST_VAAPI_IMAGE_POOL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
|
||||||
GST_VAAPI_TYPE_IMAGE_POOL, \
|
|
||||||
GstVaapiImagePool))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IMAGE_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass), \
|
|
||||||
GST_VAAPI_TYPE_IMAGE_POOL, \
|
|
||||||
GstVaapiImagePoolClass))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IS_IMAGE_POOL(obj) \
|
#define GST_VAAPI_IS_IMAGE_POOL(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_IMAGE_POOL))
|
((obj) != NULL)
|
||||||
|
|
||||||
#define GST_VAAPI_IS_IMAGE_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_IMAGE_POOL))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IMAGE_POOL_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj), \
|
|
||||||
GST_VAAPI_TYPE_IMAGE_POOL, \
|
|
||||||
GstVaapiImagePoolClass))
|
|
||||||
|
|
||||||
typedef struct _GstVaapiImagePool GstVaapiImagePool;
|
typedef struct _GstVaapiImagePool GstVaapiImagePool;
|
||||||
typedef struct _GstVaapiImagePoolPrivate GstVaapiImagePoolPrivate;
|
|
||||||
typedef struct _GstVaapiImagePoolClass GstVaapiImagePoolClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiImagePool:
|
|
||||||
*
|
|
||||||
* A pool of lazily allocated #GstVaapiImage objects.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiImagePool {
|
|
||||||
/*< private >*/
|
|
||||||
GstVaapiVideoPool parent_instance;
|
|
||||||
|
|
||||||
GstVaapiImagePoolPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiImagePoolClass:
|
|
||||||
*
|
|
||||||
* A pool of lazily allocated #GstVaapiImage objects.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiImagePoolClass {
|
|
||||||
/*< private >*/
|
|
||||||
GstVaapiVideoPoolClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_vaapi_image_pool_get_type(void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GstVaapiVideoPool *
|
GstVaapiVideoPool *
|
||||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||||
|
|
|
@ -27,30 +27,29 @@
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "gstvaapisurfacepool.h"
|
#include "gstvaapisurfacepool.h"
|
||||||
|
#include "gstvaapivideopool_priv.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE(
|
/**
|
||||||
GstVaapiSurfacePool,
|
* GstVaapiSurfacePool:
|
||||||
gst_vaapi_surface_pool,
|
*
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL)
|
* A pool of lazily allocated #GstVaapiSurface objects.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiSurfacePool {
|
||||||
|
/*< private >*/
|
||||||
|
GstVaapiVideoPool parent_instance;
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_POOL_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_POOL, \
|
|
||||||
GstVaapiSurfacePoolPrivate))
|
|
||||||
|
|
||||||
struct _GstVaapiSurfacePoolPrivate {
|
|
||||||
GstVaapiChromaType chroma_type;
|
GstVaapiChromaType chroma_type;
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
|
||||||
{
|
{
|
||||||
GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL(pool)->priv;
|
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
|
@ -58,54 +57,31 @@ gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
||||||
gst_structure_get_int(structure, "width", &width);
|
gst_structure_get_int(structure, "width", &width);
|
||||||
gst_structure_get_int(structure, "height", &height);
|
gst_structure_get_int(structure, "height", &height);
|
||||||
|
|
||||||
priv->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||||
priv->width = width;
|
pool->width = width;
|
||||||
priv->height = height;
|
pool->height = height;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
static gpointer
|
||||||
gst_vaapi_surface_pool_alloc_object(
|
gst_vaapi_surface_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||||
GstVaapiVideoPool *pool,
|
|
||||||
GstVaapiDisplay *display
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL(pool)->priv;
|
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
||||||
|
|
||||||
return gst_vaapi_surface_new(display,
|
return gst_vaapi_surface_new(base_pool->display,
|
||||||
priv->chroma_type,
|
pool->chroma_type, pool->width, pool->height);
|
||||||
priv->width,
|
|
||||||
priv->height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline const GstVaapiMiniObjectClass *
|
||||||
gst_vaapi_surface_pool_finalize(GObject *object)
|
gst_vaapi_surface_pool_class(void)
|
||||||
{
|
{
|
||||||
G_OBJECT_CLASS(gst_vaapi_surface_pool_parent_class)->finalize(object);
|
static const GstVaapiVideoPoolClass GstVaapiSurfacePoolClass = {
|
||||||
}
|
{ sizeof(GstVaapiSurfacePool),
|
||||||
|
(GDestroyNotify)gst_vaapi_video_pool_finalize },
|
||||||
|
|
||||||
static void
|
.alloc_object = gst_vaapi_surface_pool_alloc_object
|
||||||
gst_vaapi_surface_pool_class_init(GstVaapiSurfacePoolClass *klass)
|
};
|
||||||
{
|
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiSurfacePoolClass);
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
|
||||||
GstVaapiVideoPoolClass * const pool_class = GST_VAAPI_VIDEO_POOL_CLASS(klass);
|
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GstVaapiSurfacePoolPrivate));
|
|
||||||
|
|
||||||
object_class->finalize = gst_vaapi_surface_pool_finalize;
|
|
||||||
|
|
||||||
pool_class->set_caps = gst_vaapi_surface_pool_set_caps;
|
|
||||||
pool_class->alloc_object = gst_vaapi_surface_pool_alloc_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_surface_pool_init(GstVaapiSurfacePool *pool)
|
|
||||||
{
|
|
||||||
GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL_GET_PRIVATE(pool);
|
|
||||||
|
|
||||||
pool->priv = priv;
|
|
||||||
priv->chroma_type = 0;
|
|
||||||
priv->width = 0;
|
|
||||||
priv->height = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,8 +97,22 @@ gst_vaapi_surface_pool_init(GstVaapiSurfacePool *pool)
|
||||||
GstVaapiVideoPool *
|
GstVaapiVideoPool *
|
||||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||||
{
|
{
|
||||||
return g_object_new(GST_VAAPI_TYPE_SURFACE_POOL,
|
GstVaapiVideoPool *pool;
|
||||||
"display", display,
|
|
||||||
"caps", caps,
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
||||||
NULL);
|
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
|
||||||
|
|
||||||
|
pool = (GstVaapiVideoPool *)
|
||||||
|
gst_vaapi_mini_object_new(gst_vaapi_surface_pool_class());
|
||||||
|
if (!pool)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
gst_vaapi_video_pool_init(pool, display);
|
||||||
|
if (!gst_vaapi_surface_pool_set_caps(pool, caps))
|
||||||
|
goto error;
|
||||||
|
return pool;
|
||||||
|
|
||||||
|
error:
|
||||||
|
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,58 +28,13 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_SURFACE_POOL \
|
#define GST_VAAPI_SURFACE_POOL(obj) \
|
||||||
(gst_vaapi_surface_pool_get_type())
|
((GstVaapiSurfacePool *)(obj))
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_POOL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_POOL, \
|
|
||||||
GstVaapiSurfacePool))
|
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_POOL, \
|
|
||||||
GstVaapiSurfacePoolClass))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IS_SURFACE_POOL(obj) \
|
#define GST_VAAPI_IS_SURFACE_POOL(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE_POOL))
|
((obj) != NULL)
|
||||||
|
|
||||||
#define GST_VAAPI_IS_SURFACE_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_SURFACE_POOL))
|
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_POOL_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_POOL, \
|
|
||||||
GstVaapiSurfacePoolClass))
|
|
||||||
|
|
||||||
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
|
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
|
||||||
typedef struct _GstVaapiSurfacePoolPrivate GstVaapiSurfacePoolPrivate;
|
|
||||||
typedef struct _GstVaapiSurfacePoolClass GstVaapiSurfacePoolClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiSurfacePool:
|
|
||||||
*
|
|
||||||
* A pool of lazily allocated #GstVaapiSurface objects.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiSurfacePool {
|
|
||||||
/*< private >*/
|
|
||||||
GstVaapiVideoPool parent_instance;
|
|
||||||
|
|
||||||
GstVaapiSurfacePoolPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiSurfacePoolClass:
|
|
||||||
*
|
|
||||||
* A pool of lazily allocated #GstVaapiSurface objects.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiSurfacePoolClass {
|
|
||||||
/*< private >*/
|
|
||||||
GstVaapiVideoPoolClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_vaapi_surface_pool_get_type(void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GstVaapiVideoPool *
|
GstVaapiVideoPool *
|
||||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "gstvaapisurfaceproxy.h"
|
#include "gstvaapisurfaceproxy.h"
|
||||||
#include "gstvaapisurfaceproxy_priv.h"
|
#include "gstvaapisurfaceproxy_priv.h"
|
||||||
|
#include "gstvaapivideopool_priv.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
@ -44,7 +45,7 @@ gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
|
||||||
gst_vaapi_object_unref(proxy->surface);
|
gst_vaapi_object_unref(proxy->surface);
|
||||||
proxy->surface = NULL;
|
proxy->surface = NULL;
|
||||||
}
|
}
|
||||||
g_clear_object(&proxy->pool);
|
gst_vaapi_video_pool_replace(&proxy->pool, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const GstVaapiMiniObjectClass *
|
static inline const GstVaapiMiniObjectClass *
|
||||||
|
@ -69,7 +70,7 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
|
||||||
if (!proxy)
|
if (!proxy)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
proxy->pool = g_object_ref(pool);
|
proxy->pool = gst_vaapi_video_pool_ref(pool);
|
||||||
proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
|
proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
|
||||||
if (!proxy->surface)
|
if (!proxy->surface)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -27,207 +27,92 @@
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "gstvaapivideopool.h"
|
#include "gstvaapivideopool.h"
|
||||||
|
#include "gstvaapivideopool_priv.h"
|
||||||
#include "gstvaapiobject.h"
|
#include "gstvaapiobject.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE(GstVaapiVideoPool, gst_vaapi_video_pool, G_TYPE_OBJECT)
|
/* Ensure those symbols are actually defined in the resulting libraries */
|
||||||
|
#undef gst_vaapi_video_pool_ref
|
||||||
|
#undef gst_vaapi_video_pool_unref
|
||||||
|
#undef gst_vaapi_video_pool_replace
|
||||||
|
|
||||||
#define GST_VAAPI_VIDEO_POOL_GET_PRIVATE(obj) \
|
#define GST_VAAPI_VIDEO_POOL_GET_CLASS(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
gst_vaapi_video_pool_get_class(GST_VAAPI_VIDEO_POOL(obj))
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL, \
|
|
||||||
GstVaapiVideoPoolPrivate))
|
|
||||||
|
|
||||||
struct _GstVaapiVideoPoolPrivate {
|
static inline const GstVaapiVideoPoolClass *
|
||||||
GstVaapiDisplay *display;
|
gst_vaapi_video_pool_get_class(GstVaapiVideoPool *pool)
|
||||||
GQueue free_objects;
|
{
|
||||||
GList *used_objects;
|
return GST_VAAPI_VIDEO_POOL_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(pool));
|
||||||
GstCaps *caps;
|
}
|
||||||
guint used_count;
|
|
||||||
guint capacity;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PROP_0,
|
|
||||||
|
|
||||||
PROP_DISPLAY,
|
|
||||||
PROP_CAPS,
|
|
||||||
PROP_CAPACITY
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps);
|
|
||||||
|
|
||||||
static inline gpointer
|
static inline gpointer
|
||||||
gst_vaapi_video_pool_alloc_object(GstVaapiVideoPool *pool)
|
gst_vaapi_video_pool_alloc_object(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPoolClass * const klass = GST_VAAPI_VIDEO_POOL_GET_CLASS(pool);
|
return GST_VAAPI_VIDEO_POOL_GET_CLASS(pool)->alloc_object(pool);
|
||||||
|
|
||||||
return klass->alloc_object(pool, pool->priv->display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
gst_vaapi_video_pool_clear(GstVaapiVideoPool *pool)
|
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool, GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPoolPrivate * const priv = pool->priv;
|
pool->display = g_object_ref(display);
|
||||||
gpointer object;
|
pool->used_objects = NULL;
|
||||||
GList *list, *next;
|
pool->used_count = 0;
|
||||||
|
pool->capacity = 0;
|
||||||
|
|
||||||
for (list = priv->used_objects; list; list = next) {
|
g_queue_init(&pool->free_objects);
|
||||||
next = list->next;
|
|
||||||
gst_vaapi_object_unref(list->data);
|
|
||||||
g_list_free_1(list);
|
|
||||||
}
|
|
||||||
priv->used_objects = NULL;
|
|
||||||
|
|
||||||
while ((object = g_queue_pop_head(&priv->free_objects)))
|
|
||||||
gst_vaapi_object_unref(object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
gst_vaapi_video_pool_destroy(GstVaapiVideoPool *pool)
|
gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPoolPrivate * const priv = pool->priv;
|
g_list_free_full(pool->used_objects, gst_vaapi_object_unref);
|
||||||
|
g_queue_free_full(&pool->free_objects, gst_vaapi_object_unref);
|
||||||
gst_vaapi_video_pool_clear(pool);
|
g_clear_object(&pool->display);
|
||||||
|
|
||||||
if (priv->caps) {
|
|
||||||
gst_caps_unref(priv->caps);
|
|
||||||
priv->caps = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object(&priv->display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/**
|
||||||
gst_vaapi_video_pool_finalize(GObject *object)
|
* gst_vaapi_video_pool_ref:
|
||||||
|
* @pool: a #GstVaapiVideoPool
|
||||||
|
*
|
||||||
|
* Atomically increases the reference count of the given @pool by one.
|
||||||
|
*
|
||||||
|
* Returns: The same @pool argument
|
||||||
|
*/
|
||||||
|
GstVaapiVideoPool *
|
||||||
|
gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
gst_vaapi_video_pool_destroy(GST_VAAPI_VIDEO_POOL(object));
|
return gst_vaapi_video_pool_ref_internal(pool);
|
||||||
|
|
||||||
G_OBJECT_CLASS(gst_vaapi_video_pool_parent_class)->finalize(object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/**
|
||||||
gst_vaapi_video_pool_set_property(
|
* gst_vaapi_video_pool_unref:
|
||||||
GObject *object,
|
* @pool: a #GstVaapiVideoPool
|
||||||
guint prop_id,
|
*
|
||||||
const GValue *value,
|
* Atomically decreases the reference count of the @pool by one. If
|
||||||
GParamSpec *pspec
|
* the reference count reaches zero, the pool will be free'd.
|
||||||
)
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPool * const pool = GST_VAAPI_VIDEO_POOL(object);
|
gst_vaapi_video_pool_unref_internal(pool);
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_DISPLAY:
|
|
||||||
pool->priv->display = g_object_ref(g_value_get_object(value));
|
|
||||||
break;
|
|
||||||
case PROP_CAPS:
|
|
||||||
gst_vaapi_video_pool_set_caps(pool, g_value_get_pointer(value));
|
|
||||||
break;
|
|
||||||
case PROP_CAPACITY:
|
|
||||||
gst_vaapi_video_pool_set_capacity(pool, g_value_get_uint(value));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/**
|
||||||
gst_vaapi_video_pool_get_property(
|
* gst_vaapi_video_pool_replace:
|
||||||
GObject *object,
|
* @old_pool_ptr: a pointer to a #GstVaapiVideoPool
|
||||||
guint prop_id,
|
* @new_pool: a #GstVaapiVideoPool
|
||||||
GValue *value,
|
*
|
||||||
GParamSpec *pspec
|
* Atomically replaces the pool pool held in @old_pool_ptr with
|
||||||
)
|
* @new_pool. This means that @old_pool_ptr shall reference a valid
|
||||||
|
* pool. However, @new_pool can be NULL.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
||||||
|
GstVaapiVideoPool *new_pool)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPool * const pool = GST_VAAPI_VIDEO_POOL(object);
|
gst_vaapi_video_pool_replace_internal(old_pool_ptr, new_pool);
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_DISPLAY:
|
|
||||||
g_value_set_object(value, gst_vaapi_video_pool_get_display(pool));
|
|
||||||
break;
|
|
||||||
case PROP_CAPS:
|
|
||||||
g_value_set_pointer(value, gst_vaapi_video_pool_get_caps(pool));
|
|
||||||
break;
|
|
||||||
case PROP_CAPACITY:
|
|
||||||
g_value_set_uint(value, gst_vaapi_video_pool_get_capacity(pool));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_pool_class_init(GstVaapiVideoPoolClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GstVaapiVideoPoolPrivate));
|
|
||||||
|
|
||||||
object_class->finalize = gst_vaapi_video_pool_finalize;
|
|
||||||
object_class->set_property = gst_vaapi_video_pool_set_property;
|
|
||||||
object_class->get_property = gst_vaapi_video_pool_get_property;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiVideoPool:display:
|
|
||||||
*
|
|
||||||
* The #GstVaapiDisplay this pool is bound to.
|
|
||||||
*/
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_DISPLAY,
|
|
||||||
g_param_spec_object("display",
|
|
||||||
"Display",
|
|
||||||
"The GstVaapiDisplay this pool is bound to",
|
|
||||||
GST_VAAPI_TYPE_DISPLAY,
|
|
||||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiVidePool:caps:
|
|
||||||
*
|
|
||||||
* The video object capabilities represented as a #GstCaps. This
|
|
||||||
* shall hold at least the "width" and "height" properties.
|
|
||||||
*/
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_CAPS,
|
|
||||||
g_param_spec_pointer("caps",
|
|
||||||
"caps",
|
|
||||||
"The video object capabilities",
|
|
||||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiVidePool:capacity:
|
|
||||||
*
|
|
||||||
* The maximum number of objects in the pool. Or zero, the pool
|
|
||||||
* will allocate as many objects as possible.
|
|
||||||
*/
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_CAPACITY,
|
|
||||||
g_param_spec_uint("capacity",
|
|
||||||
"capacity",
|
|
||||||
"The maximum number of objects in the pool",
|
|
||||||
0, G_MAXUINT32, 0,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool)
|
|
||||||
{
|
|
||||||
GstVaapiVideoPoolPrivate *priv = GST_VAAPI_VIDEO_POOL_GET_PRIVATE(pool);
|
|
||||||
|
|
||||||
pool->priv = priv;
|
|
||||||
priv->display = NULL;
|
|
||||||
priv->used_objects = NULL;
|
|
||||||
priv->caps = NULL;
|
|
||||||
priv->used_count = 0;
|
|
||||||
priv->capacity = 0;
|
|
||||||
|
|
||||||
g_queue_init(&priv->free_objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,42 +129,7 @@ gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
||||||
|
|
||||||
return pool->priv->display;
|
return pool->display;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vaapi_video_pool_get_caps:
|
|
||||||
* @pool: a #GstVaapiVideoPool
|
|
||||||
*
|
|
||||||
* Retrieves the #GstCaps the @pool was created with. The @pool owns
|
|
||||||
* the returned object and it shall not be unref'ed.
|
|
||||||
*
|
|
||||||
* Return value: the #GstCaps the @pool was created with
|
|
||||||
*/
|
|
||||||
GstCaps *
|
|
||||||
gst_vaapi_video_pool_get_caps(GstVaapiVideoPool *pool)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
|
||||||
|
|
||||||
return pool->priv->caps;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gst_vaapi_video_pool_set_caps:
|
|
||||||
* @pool: a #GstVaapiVideoPool
|
|
||||||
* @caps: a #GstCaps
|
|
||||||
*
|
|
||||||
* Binds new @caps to the @pool and notify the sub-classes.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gst_vaapi_video_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
|
||||||
{
|
|
||||||
GstVaapiVideoPoolClass * const klass = GST_VAAPI_VIDEO_POOL_GET_CLASS(pool);
|
|
||||||
|
|
||||||
pool->priv->caps = gst_caps_ref(caps);
|
|
||||||
|
|
||||||
if (klass->set_caps)
|
|
||||||
klass->set_caps(pool, caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,24 +146,22 @@ gst_vaapi_video_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
||||||
gpointer
|
gpointer
|
||||||
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPoolPrivate *priv;
|
|
||||||
gpointer object;
|
gpointer object;
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
||||||
|
|
||||||
priv = pool->priv;
|
if (pool->capacity && pool->used_count >= pool->capacity)
|
||||||
if (priv->capacity && priv->used_count >= priv->capacity)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
object = g_queue_pop_head(&priv->free_objects);
|
object = g_queue_pop_head(&pool->free_objects);
|
||||||
if (!object) {
|
if (!object) {
|
||||||
object = gst_vaapi_video_pool_alloc_object(pool);
|
object = gst_vaapi_video_pool_alloc_object(pool);
|
||||||
if (!object)
|
if (!object)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
++priv->used_count;
|
++pool->used_count;
|
||||||
priv->used_objects = g_list_prepend(priv->used_objects, object);
|
pool->used_objects = g_list_prepend(pool->used_objects, object);
|
||||||
return gst_vaapi_object_ref(object);
|
return gst_vaapi_object_ref(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,21 +178,19 @@ gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
||||||
void
|
void
|
||||||
gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object)
|
gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object)
|
||||||
{
|
{
|
||||||
GstVaapiVideoPoolPrivate *priv;
|
|
||||||
GList *elem;
|
GList *elem;
|
||||||
|
|
||||||
g_return_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool));
|
g_return_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool));
|
||||||
g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
|
g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
|
||||||
|
|
||||||
priv = pool->priv;
|
elem = g_list_find(pool->used_objects, object);
|
||||||
elem = g_list_find(priv->used_objects, object);
|
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gst_vaapi_object_unref(object);
|
gst_vaapi_object_unref(object);
|
||||||
--priv->used_count;
|
--pool->used_count;
|
||||||
priv->used_objects = g_list_delete_link(priv->used_objects, elem);
|
pool->used_objects = g_list_delete_link(pool->used_objects, elem);
|
||||||
g_queue_push_tail(&priv->free_objects, object);
|
g_queue_push_tail(&pool->free_objects, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,7 +210,7 @@ gst_vaapi_video_pool_add_object(GstVaapiVideoPool *pool, gpointer object)
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), FALSE);
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), FALSE);
|
||||||
|
|
||||||
g_queue_push_tail(&pool->priv->free_objects, gst_vaapi_object_ref(object));
|
g_queue_push_tail(&pool->free_objects, gst_vaapi_object_ref(object));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +253,7 @@ gst_vaapi_video_pool_get_size(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
||||||
|
|
||||||
return g_queue_get_length(&pool->priv->free_objects);
|
return g_queue_get_length(&pool->free_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -429,18 +275,18 @@ gst_vaapi_video_pool_reserve(GstVaapiVideoPool *pool, guint n)
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
||||||
|
|
||||||
num_allocated = gst_vaapi_video_pool_get_size(pool) + pool->priv->used_count;
|
num_allocated = gst_vaapi_video_pool_get_size(pool) + pool->used_count;
|
||||||
if (n < num_allocated)
|
if (n < num_allocated)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if ((n -= num_allocated) > pool->priv->capacity)
|
if ((n -= num_allocated) > pool->capacity)
|
||||||
n = pool->priv->capacity;
|
n = pool->capacity;
|
||||||
|
|
||||||
for (i = num_allocated; i < n; i++) {
|
for (i = num_allocated; i < n; i++) {
|
||||||
gpointer const object = gst_vaapi_video_pool_alloc_object(pool);
|
gpointer const object = gst_vaapi_video_pool_alloc_object(pool);
|
||||||
if (!object)
|
if (!object)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
g_queue_push_tail(&pool->priv->free_objects, object);
|
g_queue_push_tail(&pool->free_objects, object);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -459,7 +305,7 @@ gst_vaapi_video_pool_get_capacity(GstVaapiVideoPool *pool)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), 0);
|
||||||
|
|
||||||
return pool->priv->capacity;
|
return pool->capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,5 +320,5 @@ gst_vaapi_video_pool_set_capacity(GstVaapiVideoPool *pool, guint capacity)
|
||||||
{
|
{
|
||||||
g_return_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool));
|
g_return_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool));
|
||||||
|
|
||||||
pool->priv->capacity = capacity;
|
pool->capacity = capacity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,72 +29,27 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_VIDEO_POOL \
|
#define GST_VAAPI_VIDEO_POOL(obj) \
|
||||||
(gst_vaapi_video_pool_get_type())
|
((GstVaapiVideoPool *)(obj))
|
||||||
|
|
||||||
#define GST_VAAPI_VIDEO_POOL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL, \
|
|
||||||
GstVaapiVideoPool))
|
|
||||||
|
|
||||||
#define GST_VAAPI_VIDEO_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass), \
|
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL, \
|
|
||||||
GstVaapiVideoPoolClass))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IS_VIDEO_POOL(obj) \
|
#define GST_VAAPI_IS_VIDEO_POOL(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_POOL))
|
((obj) != NULL)
|
||||||
|
|
||||||
#define GST_VAAPI_IS_VIDEO_POOL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_POOL))
|
|
||||||
|
|
||||||
#define GST_VAAPI_VIDEO_POOL_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj), \
|
|
||||||
GST_VAAPI_TYPE_VIDEO_POOL, \
|
|
||||||
GstVaapiVideoPoolClass))
|
|
||||||
|
|
||||||
typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
||||||
typedef struct _GstVaapiVideoPoolPrivate GstVaapiVideoPoolPrivate;
|
|
||||||
typedef struct _GstVaapiVideoPoolClass GstVaapiVideoPoolClass;
|
|
||||||
|
|
||||||
/**
|
GstVaapiVideoPool *
|
||||||
* GstVaapiVideoPool:
|
gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool);
|
||||||
*
|
|
||||||
* A pool of lazily allocated video objects. e.g. surfaces, images.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiVideoPool {
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GstVaapiVideoPoolPrivate *priv;
|
void
|
||||||
};
|
gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool);
|
||||||
|
|
||||||
/**
|
void
|
||||||
* GstVaapiVideoPoolClass:
|
gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
||||||
* @set_caps: virtual function for notifying the subclass of the
|
GstVaapiVideoPool *new_pool);
|
||||||
* negotiated caps
|
|
||||||
* @alloc_object: virtual function for allocating a video pool object
|
|
||||||
*
|
|
||||||
* A pool base class used to hold video objects. e.g. surfaces, images.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiVideoPoolClass {
|
|
||||||
/*< private >*/
|
|
||||||
GObjectClass parent_class;
|
|
||||||
|
|
||||||
/*< public >*/
|
|
||||||
void (*set_caps) (GstVaapiVideoPool *pool, GstCaps *caps);
|
|
||||||
gpointer (*alloc_object)(GstVaapiVideoPool *pool, GstVaapiDisplay *display);
|
|
||||||
};
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_vaapi_video_pool_get_type(void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool);
|
gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool);
|
||||||
|
|
||||||
GstCaps *
|
|
||||||
gst_vaapi_video_pool_get_caps(GstVaapiVideoPool *pool);
|
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool);
|
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool);
|
||||||
|
|
||||||
|
|
102
gst-libs/gst/vaapi/gstvaapivideopool_priv.h
Normal file
102
gst-libs/gst/vaapi/gstvaapivideopool_priv.h
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* gstvaapivideopool_priv.h - Video object pool abstraction (private defs)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
||||||
|
* Copyright (C) 2012 Intel Corporation
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GST_VAAPI_VIDEO_POOL_PRIV_H
|
||||||
|
#define GST_VAAPI_VIDEO_POOL_PRIV_H
|
||||||
|
|
||||||
|
#include "gstvaapiminiobject.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_VAAPI_VIDEO_POOL_CLASS(klass) \
|
||||||
|
((GstVaapiVideoPoolClass *)(klass))
|
||||||
|
|
||||||
|
#define GST_VAAPI_IS_VIDEO_POOL_CLASS(klass) \
|
||||||
|
((klass) != NULL)
|
||||||
|
|
||||||
|
typedef struct _GstVaapiVideoPoolClass GstVaapiVideoPoolClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiVideoPool:
|
||||||
|
*
|
||||||
|
* A pool of lazily allocated video objects. e.g. surfaces, images.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiVideoPool {
|
||||||
|
/*< private >*/
|
||||||
|
GstVaapiMiniObject parent_instance;
|
||||||
|
|
||||||
|
GstVaapiDisplay *display;
|
||||||
|
GQueue free_objects;
|
||||||
|
GList *used_objects;
|
||||||
|
guint used_count;
|
||||||
|
guint capacity;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiVideoPoolClass:
|
||||||
|
* @alloc_object: virtual function for allocating a video pool object
|
||||||
|
*
|
||||||
|
* A pool base class used to hold video objects. e.g. surfaces, images.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiVideoPoolClass {
|
||||||
|
/*< private >*/
|
||||||
|
GstVaapiMiniObjectClass parent_class;
|
||||||
|
|
||||||
|
/*< public >*/
|
||||||
|
gpointer (*alloc_object)(GstVaapiVideoPool *pool);
|
||||||
|
};
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool, GstVaapiDisplay *display);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool);
|
||||||
|
|
||||||
|
/* Internal aliases */
|
||||||
|
|
||||||
|
#define gst_vaapi_video_pool_ref_internal(pool) \
|
||||||
|
((gpointer)gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(pool)))
|
||||||
|
|
||||||
|
#define gst_vaapi_video_pool_unref_internal(pool) \
|
||||||
|
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool))
|
||||||
|
|
||||||
|
#define gst_vaapi_video_pool_replace_internal(old_pool_ptr, new_pool) \
|
||||||
|
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_pool_ptr), \
|
||||||
|
GST_VAAPI_MINI_OBJECT(new_pool))
|
||||||
|
|
||||||
|
#undef gst_vaapi_video_pool_ref
|
||||||
|
#define gst_vaapi_video_pool_ref(pool) \
|
||||||
|
gst_vaapi_video_pool_ref_internal((pool))
|
||||||
|
|
||||||
|
#undef gst_vaapi_video_pool_unref
|
||||||
|
#define gst_vaapi_video_pool_unref(pool) \
|
||||||
|
gst_vaapi_video_pool_unref_internal((pool))
|
||||||
|
|
||||||
|
#undef gst_vaapi_video_pool_replace
|
||||||
|
#define gst_vaapi_video_pool_replace(old_pool_ptr, new_pool) \
|
||||||
|
gst_vaapi_video_pool_replace_internal((old_pool_ptr), (new_pool))
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GST_VAAPI_VIDEO_POOL_PRIV_H */
|
Loading…
Reference in a new issue