mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +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
|
||||
GstVaapiVideoPoolClass
|
||||
gst_vaapi_video_pool_get_display
|
||||
gst_vaapi_video_pool_get_caps
|
||||
gst_vaapi_video_pool_get_object
|
||||
gst_vaapi_video_pool_put_object
|
||||
gst_vaapi_video_pool_add_object
|
||||
|
|
|
@ -117,6 +117,7 @@ libgstvaapi_source_priv_h = \
|
|||
gstvaapisurfaceproxy_priv.h \
|
||||
gstvaapiutils.h \
|
||||
gstvaapiversion.h \
|
||||
gstvaapivideopool_priv.h \
|
||||
gstvaapiwindow_priv.h \
|
||||
gstvaapiworkarounds.h \
|
||||
sysdeps.h \
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "gstvaapisurface_priv.h"
|
||||
#include "gstvaapisurfacepool.h"
|
||||
#include "gstvaapisurfaceproxy.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
#include "gstvaapiimage.h"
|
||||
#include "gstvaapisubpicture.h"
|
||||
#include "gstvaapiutils.h"
|
||||
|
@ -414,7 +415,7 @@ gst_vaapi_context_destroy_surfaces(GstVaapiContext *context)
|
|||
g_ptr_array_free(context->surfaces, TRUE);
|
||||
context->surfaces = NULL;
|
||||
}
|
||||
g_clear_object(&context->surfaces_pool);
|
||||
gst_vaapi_video_pool_replace(&context->surfaces_pool, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -27,30 +27,29 @@
|
|||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapiimagepool.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
G_DEFINE_TYPE(
|
||||
GstVaapiImagePool,
|
||||
gst_vaapi_image_pool,
|
||||
GST_VAAPI_TYPE_VIDEO_POOL)
|
||||
/**
|
||||
* GstVaapiImagePool:
|
||||
*
|
||||
* 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;
|
||||
guint width;
|
||||
guint height;
|
||||
};
|
||||
|
||||
static void
|
||||
gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
||||
static gboolean
|
||||
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;
|
||||
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, "height", &height);
|
||||
|
||||
priv->format = gst_vaapi_image_format_from_caps(caps);
|
||||
priv->width = width;
|
||||
priv->height = height;
|
||||
pool->format = gst_vaapi_image_format_from_caps(caps);
|
||||
pool->width = width;
|
||||
pool->height = height;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gst_vaapi_image_pool_alloc_object(
|
||||
GstVaapiVideoPool *pool,
|
||||
GstVaapiDisplay *display
|
||||
)
|
||||
static gpointer
|
||||
gst_vaapi_image_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||
{
|
||||
GstVaapiImagePoolPrivate * const priv = GST_VAAPI_IMAGE_POOL(pool)->priv;
|
||||
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||
|
||||
return gst_vaapi_image_new(display,
|
||||
priv->format,
|
||||
priv->width,
|
||||
priv->height);
|
||||
return gst_vaapi_image_new(base_pool->display, pool->format,
|
||||
pool->width, pool->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_image_pool_finalize(GObject *object)
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
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
|
||||
gst_vaapi_image_pool_class_init(GstVaapiImagePoolClass *klass)
|
||||
{
|
||||
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;
|
||||
.alloc_object = gst_vaapi_image_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiImagePoolClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,8 +97,22 @@ gst_vaapi_image_pool_init(GstVaapiImagePool *pool)
|
|||
GstVaapiVideoPool *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||
{
|
||||
return g_object_new(GST_VAAPI_TYPE_IMAGE_POOL,
|
||||
"display", display,
|
||||
"caps", caps,
|
||||
NULL);
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 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
|
||||
|
||||
#define GST_VAAPI_TYPE_IMAGE_POOL \
|
||||
(gst_vaapi_image_pool_get_type())
|
||||
|
||||
#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_IMAGE_POOL(obj) \
|
||||
((GstVaapiImagePool *)(obj))
|
||||
|
||||
#define GST_VAAPI_IS_IMAGE_POOL(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_IMAGE_POOL))
|
||||
|
||||
#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))
|
||||
((obj) != NULL)
|
||||
|
||||
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 *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||
|
|
|
@ -27,30 +27,29 @@
|
|||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapisurfacepool.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
G_DEFINE_TYPE(
|
||||
GstVaapiSurfacePool,
|
||||
gst_vaapi_surface_pool,
|
||||
GST_VAAPI_TYPE_VIDEO_POOL)
|
||||
/**
|
||||
* GstVaapiSurfacePool:
|
||||
*
|
||||
* 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;
|
||||
guint width;
|
||||
guint height;
|
||||
};
|
||||
|
||||
static void
|
||||
gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
||||
static gboolean
|
||||
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;
|
||||
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, "height", &height);
|
||||
|
||||
priv->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
priv->width = width;
|
||||
priv->height = height;
|
||||
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
pool->width = width;
|
||||
pool->height = height;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gst_vaapi_surface_pool_alloc_object(
|
||||
GstVaapiVideoPool *pool,
|
||||
GstVaapiDisplay *display
|
||||
)
|
||||
static gpointer
|
||||
gst_vaapi_surface_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||
{
|
||||
GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL(pool)->priv;
|
||||
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
||||
|
||||
return gst_vaapi_surface_new(display,
|
||||
priv->chroma_type,
|
||||
priv->width,
|
||||
priv->height);
|
||||
return gst_vaapi_surface_new(base_pool->display,
|
||||
pool->chroma_type, pool->width, pool->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_surface_pool_finalize(GObject *object)
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
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
|
||||
gst_vaapi_surface_pool_class_init(GstVaapiSurfacePoolClass *klass)
|
||||
{
|
||||
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;
|
||||
.alloc_object = gst_vaapi_surface_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiSurfacePoolClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,8 +97,22 @@ gst_vaapi_surface_pool_init(GstVaapiSurfacePool *pool)
|
|||
GstVaapiVideoPool *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||
{
|
||||
return g_object_new(GST_VAAPI_TYPE_SURFACE_POOL,
|
||||
"display", display,
|
||||
"caps", caps,
|
||||
NULL);
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 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
|
||||
|
||||
#define GST_VAAPI_TYPE_SURFACE_POOL \
|
||||
(gst_vaapi_surface_pool_get_type())
|
||||
|
||||
#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_SURFACE_POOL(obj) \
|
||||
((GstVaapiSurfacePool *)(obj))
|
||||
|
||||
#define GST_VAAPI_IS_SURFACE_POOL(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE_POOL))
|
||||
|
||||
#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))
|
||||
((obj) != NULL)
|
||||
|
||||
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 *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "gstvaapisurfaceproxy.h"
|
||||
#include "gstvaapisurfaceproxy_priv.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -44,7 +45,7 @@ gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
|
|||
gst_vaapi_object_unref(proxy->surface);
|
||||
proxy->surface = NULL;
|
||||
}
|
||||
g_clear_object(&proxy->pool);
|
||||
gst_vaapi_video_pool_replace(&proxy->pool, NULL);
|
||||
}
|
||||
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
|
@ -69,7 +70,7 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
|
|||
if (!proxy)
|
||||
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);
|
||||
if (!proxy->surface)
|
||||
goto error;
|
||||
|
|
|
@ -27,207 +27,92 @@
|
|||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapivideopool.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
#include "gstvaapiobject.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#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) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
||||
GST_VAAPI_TYPE_VIDEO_POOL, \
|
||||
GstVaapiVideoPoolPrivate))
|
||||
#define GST_VAAPI_VIDEO_POOL_GET_CLASS(obj) \
|
||||
gst_vaapi_video_pool_get_class(GST_VAAPI_VIDEO_POOL(obj))
|
||||
|
||||
struct _GstVaapiVideoPoolPrivate {
|
||||
GstVaapiDisplay *display;
|
||||
GQueue free_objects;
|
||||
GList *used_objects;
|
||||
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 const GstVaapiVideoPoolClass *
|
||||
gst_vaapi_video_pool_get_class(GstVaapiVideoPool *pool)
|
||||
{
|
||||
return GST_VAAPI_VIDEO_POOL_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(pool));
|
||||
}
|
||||
|
||||
static inline gpointer
|
||||
gst_vaapi_video_pool_alloc_object(GstVaapiVideoPool *pool)
|
||||
{
|
||||
GstVaapiVideoPoolClass * const klass = GST_VAAPI_VIDEO_POOL_GET_CLASS(pool);
|
||||
|
||||
return klass->alloc_object(pool, pool->priv->display);
|
||||
return GST_VAAPI_VIDEO_POOL_GET_CLASS(pool)->alloc_object(pool);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_pool_clear(GstVaapiVideoPool *pool)
|
||||
void
|
||||
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool, GstVaapiDisplay *display)
|
||||
{
|
||||
GstVaapiVideoPoolPrivate * const priv = pool->priv;
|
||||
gpointer object;
|
||||
GList *list, *next;
|
||||
pool->display = g_object_ref(display);
|
||||
pool->used_objects = NULL;
|
||||
pool->used_count = 0;
|
||||
pool->capacity = 0;
|
||||
|
||||
for (list = priv->used_objects; list; list = next) {
|
||||
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);
|
||||
g_queue_init(&pool->free_objects);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_pool_destroy(GstVaapiVideoPool *pool)
|
||||
void
|
||||
gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool)
|
||||
{
|
||||
GstVaapiVideoPoolPrivate * const priv = pool->priv;
|
||||
|
||||
gst_vaapi_video_pool_clear(pool);
|
||||
|
||||
if (priv->caps) {
|
||||
gst_caps_unref(priv->caps);
|
||||
priv->caps = NULL;
|
||||
}
|
||||
|
||||
g_clear_object(&priv->display);
|
||||
g_list_free_full(pool->used_objects, gst_vaapi_object_unref);
|
||||
g_queue_free_full(&pool->free_objects, gst_vaapi_object_unref);
|
||||
g_clear_object(&pool->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));
|
||||
|
||||
G_OBJECT_CLASS(gst_vaapi_video_pool_parent_class)->finalize(object);
|
||||
return gst_vaapi_video_pool_ref_internal(pool);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_pool_set_property(
|
||||
GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec
|
||||
)
|
||||
/**
|
||||
* gst_vaapi_video_pool_unref:
|
||||
* @pool: a #GstVaapiVideoPool
|
||||
*
|
||||
* Atomically decreases the reference count of the @pool by one. If
|
||||
* 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);
|
||||
|
||||
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;
|
||||
}
|
||||
gst_vaapi_video_pool_unref_internal(pool);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_pool_get_property(
|
||||
GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec
|
||||
)
|
||||
/**
|
||||
* gst_vaapi_video_pool_replace:
|
||||
* @old_pool_ptr: a pointer to a #GstVaapiVideoPool
|
||||
* @new_pool: a #GstVaapiVideoPool
|
||||
*
|
||||
* 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);
|
||||
|
||||
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);
|
||||
gst_vaapi_video_pool_replace_internal(old_pool_ptr, new_pool);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,42 +129,7 @@ gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool)
|
|||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
||||
|
||||
return pool->priv->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);
|
||||
return pool->display;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,24 +146,22 @@ gst_vaapi_video_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
|
|||
gpointer
|
||||
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
||||
{
|
||||
GstVaapiVideoPoolPrivate *priv;
|
||||
gpointer object;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
|
||||
|
||||
priv = pool->priv;
|
||||
if (priv->capacity && priv->used_count >= priv->capacity)
|
||||
if (pool->capacity && pool->used_count >= pool->capacity)
|
||||
return NULL;
|
||||
|
||||
object = g_queue_pop_head(&priv->free_objects);
|
||||
object = g_queue_pop_head(&pool->free_objects);
|
||||
if (!object) {
|
||||
object = gst_vaapi_video_pool_alloc_object(pool);
|
||||
if (!object)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
++priv->used_count;
|
||||
priv->used_objects = g_list_prepend(priv->used_objects, object);
|
||||
++pool->used_count;
|
||||
pool->used_objects = g_list_prepend(pool->used_objects, object);
|
||||
return gst_vaapi_object_ref(object);
|
||||
}
|
||||
|
||||
|
@ -330,21 +178,19 @@ gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
|||
void
|
||||
gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object)
|
||||
{
|
||||
GstVaapiVideoPoolPrivate *priv;
|
||||
GList *elem;
|
||||
|
||||
g_return_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool));
|
||||
g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
|
||||
|
||||
priv = pool->priv;
|
||||
elem = g_list_find(priv->used_objects, object);
|
||||
elem = g_list_find(pool->used_objects, object);
|
||||
if (!elem)
|
||||
return;
|
||||
|
||||
gst_vaapi_object_unref(object);
|
||||
--priv->used_count;
|
||||
priv->used_objects = g_list_delete_link(priv->used_objects, elem);
|
||||
g_queue_push_tail(&priv->free_objects, object);
|
||||
--pool->used_count;
|
||||
pool->used_objects = g_list_delete_link(pool->used_objects, elem);
|
||||
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_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;
|
||||
}
|
||||
|
||||
|
@ -407,7 +253,7 @@ gst_vaapi_video_pool_get_size(GstVaapiVideoPool *pool)
|
|||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
return TRUE;
|
||||
|
||||
if ((n -= num_allocated) > pool->priv->capacity)
|
||||
n = pool->priv->capacity;
|
||||
if ((n -= num_allocated) > pool->capacity)
|
||||
n = pool->capacity;
|
||||
|
||||
for (i = num_allocated; i < n; i++) {
|
||||
gpointer const object = gst_vaapi_video_pool_alloc_object(pool);
|
||||
if (!object)
|
||||
return FALSE;
|
||||
g_queue_push_tail(&pool->priv->free_objects, object);
|
||||
g_queue_push_tail(&pool->free_objects, object);
|
||||
}
|
||||
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);
|
||||
|
||||
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));
|
||||
|
||||
pool->priv->capacity = capacity;
|
||||
pool->capacity = capacity;
|
||||
}
|
||||
|
|
|
@ -29,72 +29,27 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_TYPE_VIDEO_POOL \
|
||||
(gst_vaapi_video_pool_get_type())
|
||||
|
||||
#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_VIDEO_POOL(obj) \
|
||||
((GstVaapiVideoPool *)(obj))
|
||||
|
||||
#define GST_VAAPI_IS_VIDEO_POOL(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_POOL))
|
||||
|
||||
#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))
|
||||
((obj) != NULL)
|
||||
|
||||
typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
||||
typedef struct _GstVaapiVideoPoolPrivate GstVaapiVideoPoolPrivate;
|
||||
typedef struct _GstVaapiVideoPoolClass GstVaapiVideoPoolClass;
|
||||
|
||||
/**
|
||||
* GstVaapiVideoPool:
|
||||
*
|
||||
* A pool of lazily allocated video objects. e.g. surfaces, images.
|
||||
*/
|
||||
struct _GstVaapiVideoPool {
|
||||
/*< private >*/
|
||||
GObject parent_instance;
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool);
|
||||
|
||||
GstVaapiVideoPoolPrivate *priv;
|
||||
};
|
||||
void
|
||||
gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool);
|
||||
|
||||
/**
|
||||
* GstVaapiVideoPoolClass:
|
||||
* @set_caps: virtual function for notifying the subclass of the
|
||||
* 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;
|
||||
void
|
||||
gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
||||
GstVaapiVideoPool *new_pool);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool);
|
||||
|
||||
GstCaps *
|
||||
gst_vaapi_video_pool_get_caps(GstVaapiVideoPool *pool);
|
||||
|
||||
gpointer
|
||||
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