mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
videopool: re-indent all GstVaapiVideoPool related source code.
This commit is contained in:
parent
f5af9d150e
commit
e4e43cd842
7 changed files with 289 additions and 284 deletions
|
@ -39,45 +39,45 @@
|
|||
*
|
||||
* A pool of lazily allocated #GstVaapiImage objects.
|
||||
*/
|
||||
struct _GstVaapiImagePool {
|
||||
/*< private >*/
|
||||
GstVaapiVideoPool parent_instance;
|
||||
struct _GstVaapiImagePool
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiVideoPool parent_instance;
|
||||
|
||||
GstVideoFormat format;
|
||||
guint width;
|
||||
guint height;
|
||||
GstVideoFormat format;
|
||||
guint width;
|
||||
guint height;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
image_pool_init(GstVaapiVideoPool *base_pool, const GstVideoInfo *vip)
|
||||
image_pool_init (GstVaapiVideoPool * base_pool, const GstVideoInfo * vip)
|
||||
{
|
||||
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||
GstVaapiImagePool *const pool = GST_VAAPI_IMAGE_POOL (base_pool);
|
||||
|
||||
pool->format = GST_VIDEO_INFO_FORMAT(vip);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(vip);
|
||||
return gst_vaapi_display_has_image_format(base_pool->display, pool->format);
|
||||
pool->format = GST_VIDEO_INFO_FORMAT (vip);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH (vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT (vip);
|
||||
return gst_vaapi_display_has_image_format (base_pool->display, pool->format);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gst_vaapi_image_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||
gst_vaapi_image_pool_alloc_object (GstVaapiVideoPool * base_pool)
|
||||
{
|
||||
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||
GstVaapiImagePool *const pool = GST_VAAPI_IMAGE_POOL (base_pool);
|
||||
|
||||
return gst_vaapi_image_new(base_pool->display, pool->format,
|
||||
pool->width, pool->height);
|
||||
return gst_vaapi_image_new (base_pool->display, pool->format,
|
||||
pool->width, pool->height);
|
||||
}
|
||||
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
gst_vaapi_image_pool_class(void)
|
||||
gst_vaapi_image_pool_class (void)
|
||||
{
|
||||
static const GstVaapiVideoPoolClass GstVaapiImagePoolClass = {
|
||||
{ sizeof(GstVaapiImagePool),
|
||||
(GDestroyNotify)gst_vaapi_video_pool_finalize },
|
||||
|
||||
.alloc_object = gst_vaapi_image_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiImagePoolClass);
|
||||
static const GstVaapiVideoPoolClass GstVaapiImagePoolClass = {
|
||||
{sizeof (GstVaapiImagePool),
|
||||
(GDestroyNotify) gst_vaapi_video_pool_finalize},
|
||||
.alloc_object = gst_vaapi_image_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS (&GstVaapiImagePoolClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,26 +91,26 @@ gst_vaapi_image_pool_class(void)
|
|||
* Return value: the newly allocated #GstVaapiVideoPool
|
||||
*/
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
||||
gst_vaapi_image_pool_new (GstVaapiDisplay * display, const GstVideoInfo * vip)
|
||||
{
|
||||
GstVaapiVideoPool *pool;
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(vip != NULL, NULL);
|
||||
g_return_val_if_fail (display != NULL, NULL);
|
||||
g_return_val_if_fail (vip != NULL, NULL);
|
||||
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_image_pool_class());
|
||||
if (!pool)
|
||||
return NULL;
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new (gst_vaapi_image_pool_class ());
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
gst_vaapi_video_pool_init(pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE);
|
||||
gst_vaapi_video_pool_init (pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE);
|
||||
|
||||
if (!image_pool_init(pool, vip))
|
||||
goto error;
|
||||
return pool;
|
||||
if (!image_pool_init (pool, vip))
|
||||
goto error;
|
||||
return pool;
|
||||
|
||||
error:
|
||||
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool));
|
||||
return NULL;
|
||||
gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (pool));
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_IMAGE_POOL(obj) \
|
||||
((GstVaapiImagePool *)(obj))
|
||||
((GstVaapiImagePool *)(obj))
|
||||
|
||||
typedef struct _GstVaapiImagePool GstVaapiImagePool;
|
||||
typedef struct _GstVaapiImagePool GstVaapiImagePool;
|
||||
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip);
|
||||
gst_vaapi_image_pool_new (GstVaapiDisplay * display, const GstVideoInfo * vip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -39,63 +39,64 @@
|
|||
*
|
||||
* A pool of lazily allocated #GstVaapiSurface objects.
|
||||
*/
|
||||
struct _GstVaapiSurfacePool {
|
||||
/*< private >*/
|
||||
GstVaapiVideoPool parent_instance;
|
||||
struct _GstVaapiSurfacePool
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiVideoPool parent_instance;
|
||||
|
||||
GstVaapiChromaType chroma_type;
|
||||
GstVideoFormat format;
|
||||
guint width;
|
||||
guint height;
|
||||
GstVaapiChromaType chroma_type;
|
||||
GstVideoFormat format;
|
||||
guint width;
|
||||
guint height;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
surface_pool_init(GstVaapiSurfacePool *pool, const GstVideoInfo *vip)
|
||||
surface_pool_init (GstVaapiSurfacePool * pool, const GstVideoInfo * vip)
|
||||
{
|
||||
pool->format = GST_VIDEO_INFO_FORMAT(vip);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(vip);
|
||||
pool->format = GST_VIDEO_INFO_FORMAT (vip);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH (vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT (vip);
|
||||
|
||||
if (pool->format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
return FALSE;
|
||||
if (pool->format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
if (pool->format == GST_VIDEO_FORMAT_ENCODED)
|
||||
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
else
|
||||
pool->chroma_type = gst_vaapi_video_format_get_chroma_type(pool->format);
|
||||
if (!pool->chroma_type)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
if (pool->format == GST_VIDEO_FORMAT_ENCODED)
|
||||
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
else
|
||||
pool->chroma_type = gst_vaapi_video_format_get_chroma_type (pool->format);
|
||||
if (!pool->chroma_type)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gst_vaapi_surface_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
||||
gst_vaapi_surface_pool_alloc_object (GstVaapiVideoPool * base_pool)
|
||||
{
|
||||
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
||||
GstVaapiSurfacePool *const pool = GST_VAAPI_SURFACE_POOL (base_pool);
|
||||
|
||||
/* Try to allocate a surface with an explicit pixel format first */
|
||||
if (pool->format != GST_VIDEO_FORMAT_ENCODED) {
|
||||
GstVaapiSurface * const surface = gst_vaapi_surface_new_with_format(
|
||||
base_pool->display, pool->format, pool->width, pool->height);
|
||||
if (surface)
|
||||
return surface;
|
||||
}
|
||||
/* Try to allocate a surface with an explicit pixel format first */
|
||||
if (pool->format != GST_VIDEO_FORMAT_ENCODED) {
|
||||
GstVaapiSurface *const surface =
|
||||
gst_vaapi_surface_new_with_format (base_pool->display, pool->format,
|
||||
pool->width, pool->height);
|
||||
if (surface)
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* Otherwise, fallback to the original interface, based on chroma format */
|
||||
return gst_vaapi_surface_new(base_pool->display,
|
||||
pool->chroma_type, pool->width, pool->height);
|
||||
/* Otherwise, fallback to the original interface, based on chroma format */
|
||||
return gst_vaapi_surface_new (base_pool->display,
|
||||
pool->chroma_type, pool->width, pool->height);
|
||||
}
|
||||
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
gst_vaapi_surface_pool_class(void)
|
||||
gst_vaapi_surface_pool_class (void)
|
||||
{
|
||||
static const GstVaapiVideoPoolClass GstVaapiSurfacePoolClass = {
|
||||
{ sizeof(GstVaapiSurfacePool),
|
||||
(GDestroyNotify)gst_vaapi_video_pool_finalize },
|
||||
|
||||
.alloc_object = gst_vaapi_surface_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiSurfacePoolClass);
|
||||
static const GstVaapiVideoPoolClass GstVaapiSurfacePoolClass = {
|
||||
{sizeof (GstVaapiSurfacePool),
|
||||
(GDestroyNotify) gst_vaapi_video_pool_finalize},
|
||||
.alloc_object = gst_vaapi_surface_pool_alloc_object
|
||||
};
|
||||
return GST_VAAPI_MINI_OBJECT_CLASS (&GstVaapiSurfacePoolClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,25 +110,25 @@ gst_vaapi_surface_pool_class(void)
|
|||
* Return value: the newly allocated #GstVaapiVideoPool
|
||||
*/
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
||||
gst_vaapi_surface_pool_new (GstVaapiDisplay * display, const GstVideoInfo * vip)
|
||||
{
|
||||
GstVaapiVideoPool *pool;
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(vip != NULL, NULL);
|
||||
g_return_val_if_fail (display != NULL, NULL);
|
||||
g_return_val_if_fail (vip != NULL, NULL);
|
||||
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_surface_pool_class());
|
||||
if (!pool)
|
||||
return NULL;
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new (gst_vaapi_surface_pool_class ());
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
gst_vaapi_video_pool_init(pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE);
|
||||
if (!surface_pool_init(GST_VAAPI_SURFACE_POOL(pool), vip))
|
||||
goto error;
|
||||
return pool;
|
||||
gst_vaapi_video_pool_init (pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE);
|
||||
if (!surface_pool_init (GST_VAAPI_SURFACE_POOL (pool), vip))
|
||||
goto error;
|
||||
return pool;
|
||||
|
||||
error:
|
||||
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool));
|
||||
return NULL;
|
||||
gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (pool));
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,12 +32,13 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_SURFACE_POOL(obj) \
|
||||
((GstVaapiSurfacePool *)(obj))
|
||||
((GstVaapiSurfacePool *)(obj))
|
||||
|
||||
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
|
||||
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
|
||||
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip);
|
||||
gst_vaapi_surface_pool_new (GstVaapiDisplay * display,
|
||||
const GstVideoInfo * vip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -41,42 +41,42 @@
|
|||
#undef gst_vaapi_video_pool_replace
|
||||
|
||||
#define GST_VAAPI_VIDEO_POOL_GET_CLASS(obj) \
|
||||
gst_vaapi_video_pool_get_class(GST_VAAPI_VIDEO_POOL(obj))
|
||||
gst_vaapi_video_pool_get_class (GST_VAAPI_VIDEO_POOL (obj))
|
||||
|
||||
static inline const GstVaapiVideoPoolClass *
|
||||
gst_vaapi_video_pool_get_class(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_class (GstVaapiVideoPool * pool)
|
||||
{
|
||||
return GST_VAAPI_VIDEO_POOL_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(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)
|
||||
gst_vaapi_video_pool_alloc_object (GstVaapiVideoPool * pool)
|
||||
{
|
||||
return GST_VAAPI_VIDEO_POOL_GET_CLASS(pool)->alloc_object(pool);
|
||||
return GST_VAAPI_VIDEO_POOL_GET_CLASS (pool)->alloc_object (pool);
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool, GstVaapiDisplay *display,
|
||||
gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display,
|
||||
GstVaapiVideoPoolObjectType object_type)
|
||||
{
|
||||
pool->object_type = object_type;
|
||||
pool->display = gst_vaapi_display_ref(display);
|
||||
pool->used_objects = NULL;
|
||||
pool->used_count = 0;
|
||||
pool->capacity = 0;
|
||||
pool->object_type = object_type;
|
||||
pool->display = gst_vaapi_display_ref (display);
|
||||
pool->used_objects = NULL;
|
||||
pool->used_count = 0;
|
||||
pool->capacity = 0;
|
||||
|
||||
g_queue_init(&pool->free_objects);
|
||||
g_mutex_init(&pool->mutex);
|
||||
g_queue_init (&pool->free_objects);
|
||||
g_mutex_init (&pool->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool)
|
||||
{
|
||||
g_list_free_full(pool->used_objects, gst_vaapi_object_unref);
|
||||
g_queue_foreach(&pool->free_objects, (GFunc)gst_vaapi_object_unref, NULL);
|
||||
g_queue_clear(&pool->free_objects);
|
||||
gst_vaapi_display_replace(&pool->display, NULL);
|
||||
g_mutex_clear(&pool->mutex);
|
||||
g_list_free_full (pool->used_objects, gst_vaapi_object_unref);
|
||||
g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL);
|
||||
g_queue_clear (&pool->free_objects);
|
||||
gst_vaapi_display_replace (&pool->display, NULL);
|
||||
g_mutex_clear (&pool->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,9 +88,9 @@ gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool)
|
|||
* Returns: The same @pool argument
|
||||
*/
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_ref (GstVaapiVideoPool * pool)
|
||||
{
|
||||
return gst_vaapi_video_pool_ref_internal(pool);
|
||||
return gst_vaapi_video_pool_ref_internal (pool);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,9 +101,9 @@ gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool)
|
|||
* the reference count reaches zero, the pool will be free'd.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_unref (GstVaapiVideoPool * pool)
|
||||
{
|
||||
gst_vaapi_video_pool_unref_internal(pool);
|
||||
gst_vaapi_video_pool_unref_internal (pool);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,10 +116,10 @@ gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool)
|
|||
* pool. However, @new_pool can be NULL.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
||||
GstVaapiVideoPool *new_pool)
|
||||
gst_vaapi_video_pool_replace (GstVaapiVideoPool ** old_pool_ptr,
|
||||
GstVaapiVideoPool * new_pool)
|
||||
{
|
||||
gst_vaapi_video_pool_replace_internal(old_pool_ptr, new_pool);
|
||||
gst_vaapi_video_pool_replace_internal (old_pool_ptr, new_pool);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,11 +132,11 @@ gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
|||
* Return value: the #GstVaapiDisplay the @pool is bound to
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_display (GstVaapiVideoPool * pool)
|
||||
{
|
||||
g_return_val_if_fail(pool != NULL, NULL);
|
||||
g_return_val_if_fail (pool != NULL, NULL);
|
||||
|
||||
return pool->display;
|
||||
return pool->display;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,11 +149,11 @@ gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool)
|
|||
* objects
|
||||
*/
|
||||
GstVaapiVideoPoolObjectType
|
||||
gst_vaapi_video_pool_get_object_type(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_object_type (GstVaapiVideoPool * pool)
|
||||
{
|
||||
g_return_val_if_fail(pool != NULL, (GstVaapiVideoPoolObjectType)0);
|
||||
g_return_val_if_fail (pool != NULL, (GstVaapiVideoPoolObjectType) 0);
|
||||
|
||||
return pool->object_type;
|
||||
return pool->object_type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,36 +168,36 @@ gst_vaapi_video_pool_get_object_type(GstVaapiVideoPool *pool)
|
|||
* Return value: a possibly newly allocated object, or %NULL on error
|
||||
*/
|
||||
static gpointer
|
||||
gst_vaapi_video_pool_get_object_unlocked(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool)
|
||||
{
|
||||
gpointer object;
|
||||
gpointer object;
|
||||
|
||||
if (pool->capacity && pool->used_count >= pool->capacity)
|
||||
return NULL;
|
||||
if (pool->capacity && pool->used_count >= pool->capacity)
|
||||
return NULL;
|
||||
|
||||
object = g_queue_pop_head(&pool->free_objects);
|
||||
if (!object) {
|
||||
object = gst_vaapi_video_pool_alloc_object(pool);
|
||||
if (!object)
|
||||
return NULL;
|
||||
}
|
||||
object = g_queue_pop_head (&pool->free_objects);
|
||||
if (!object) {
|
||||
object = gst_vaapi_video_pool_alloc_object (pool);
|
||||
if (!object)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
++pool->used_count;
|
||||
pool->used_objects = g_list_prepend(pool->used_objects, object);
|
||||
return gst_vaapi_object_ref(object);
|
||||
++pool->used_count;
|
||||
pool->used_objects = g_list_prepend (pool->used_objects, object);
|
||||
return gst_vaapi_object_ref (object);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_object (GstVaapiVideoPool * pool)
|
||||
{
|
||||
gpointer object;
|
||||
gpointer object;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, NULL);
|
||||
g_return_val_if_fail (pool != NULL, NULL);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
object = gst_vaapi_video_pool_get_object_unlocked(pool);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
return object;
|
||||
g_mutex_lock (&pool->mutex);
|
||||
object = gst_vaapi_video_pool_get_object_unlocked (pool);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,30 +211,30 @@ gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool)
|
|||
* behaviour.
|
||||
*/
|
||||
static void
|
||||
gst_vaapi_video_pool_put_object_unlocked(GstVaapiVideoPool *pool,
|
||||
gst_vaapi_video_pool_put_object_unlocked (GstVaapiVideoPool * pool,
|
||||
gpointer object)
|
||||
{
|
||||
GList *elem;
|
||||
GList *elem;
|
||||
|
||||
elem = g_list_find(pool->used_objects, object);
|
||||
if (!elem)
|
||||
return;
|
||||
elem = g_list_find (pool->used_objects, object);
|
||||
if (!elem)
|
||||
return;
|
||||
|
||||
gst_vaapi_object_unref(object);
|
||||
--pool->used_count;
|
||||
pool->used_objects = g_list_delete_link(pool->used_objects, elem);
|
||||
g_queue_push_tail(&pool->free_objects, object);
|
||||
gst_vaapi_object_unref (object);
|
||||
--pool->used_count;
|
||||
pool->used_objects = g_list_delete_link (pool->used_objects, elem);
|
||||
g_queue_push_tail (&pool->free_objects, object);
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object)
|
||||
gst_vaapi_video_pool_put_object (GstVaapiVideoPool * pool, gpointer object)
|
||||
{
|
||||
g_return_if_fail(pool != NULL);
|
||||
g_return_if_fail(object != NULL);
|
||||
g_return_if_fail (pool != NULL);
|
||||
g_return_if_fail (object != NULL);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
gst_vaapi_video_pool_put_object_unlocked(pool, object);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
g_mutex_lock (&pool->mutex);
|
||||
gst_vaapi_video_pool_put_object_unlocked (pool, object);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,25 +249,25 @@ gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object)
|
|||
* Return value: %TRUE on success.
|
||||
*/
|
||||
static inline gboolean
|
||||
gst_vaapi_video_pool_add_object_unlocked(GstVaapiVideoPool *pool,
|
||||
gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool,
|
||||
gpointer object)
|
||||
{
|
||||
g_queue_push_tail(&pool->free_objects, gst_vaapi_object_ref(object));
|
||||
return TRUE;
|
||||
g_queue_push_tail (&pool->free_objects, gst_vaapi_object_ref (object));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_add_object(GstVaapiVideoPool *pool, gpointer object)
|
||||
gst_vaapi_video_pool_add_object (GstVaapiVideoPool * pool, gpointer object)
|
||||
{
|
||||
gboolean success;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, FALSE);
|
||||
g_return_val_if_fail(object != NULL, FALSE);
|
||||
g_return_val_if_fail (pool != NULL, FALSE);
|
||||
g_return_val_if_fail (object != NULL, FALSE);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
success = gst_vaapi_video_pool_add_object_unlocked(pool, object);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
return success;
|
||||
g_mutex_lock (&pool->mutex);
|
||||
success = gst_vaapi_video_pool_add_object_unlocked (pool, object);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,30 +282,30 @@ gst_vaapi_video_pool_add_object(GstVaapiVideoPool *pool, gpointer object)
|
|||
* Return value: %TRUE on success.
|
||||
*/
|
||||
static gboolean
|
||||
gst_vaapi_video_pool_add_objects_unlocked(GstVaapiVideoPool *pool,
|
||||
GPtrArray *objects)
|
||||
gst_vaapi_video_pool_add_objects_unlocked (GstVaapiVideoPool * pool,
|
||||
GPtrArray * objects)
|
||||
{
|
||||
guint i;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < objects->len; i++) {
|
||||
gpointer const object = g_ptr_array_index(objects, i);
|
||||
if (!gst_vaapi_video_pool_add_object_unlocked(pool, object))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
for (i = 0; i < objects->len; i++) {
|
||||
gpointer const object = g_ptr_array_index (objects, i);
|
||||
if (!gst_vaapi_video_pool_add_object_unlocked (pool, object))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_add_objects(GstVaapiVideoPool *pool, GPtrArray *objects)
|
||||
gst_vaapi_video_pool_add_objects (GstVaapiVideoPool * pool, GPtrArray * objects)
|
||||
{
|
||||
gboolean success;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, FALSE);
|
||||
g_return_val_if_fail (pool != NULL, FALSE);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
success = gst_vaapi_video_pool_add_objects_unlocked(pool, objects);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
return success;
|
||||
g_mutex_lock (&pool->mutex);
|
||||
success = gst_vaapi_video_pool_add_objects_unlocked (pool, objects);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,16 +317,16 @@ gst_vaapi_video_pool_add_objects(GstVaapiVideoPool *pool, GPtrArray *objects)
|
|||
* Return value: number of free objects in the pool
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_video_pool_get_size(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_size (GstVaapiVideoPool * pool)
|
||||
{
|
||||
guint size;
|
||||
guint size;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, 0);
|
||||
g_return_val_if_fail (pool != NULL, 0);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
size = g_queue_get_length(&pool->free_objects);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
return size;
|
||||
g_mutex_lock (&pool->mutex);
|
||||
size = g_queue_get_length (&pool->free_objects);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,37 +342,37 @@ gst_vaapi_video_pool_get_size(GstVaapiVideoPool *pool)
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
static gboolean
|
||||
gst_vaapi_video_pool_reserve_unlocked(GstVaapiVideoPool *pool, guint n)
|
||||
gst_vaapi_video_pool_reserve_unlocked (GstVaapiVideoPool * pool, guint n)
|
||||
{
|
||||
guint i, num_allocated;
|
||||
guint i, num_allocated;
|
||||
|
||||
num_allocated = gst_vaapi_video_pool_get_size(pool) + pool->used_count;
|
||||
if (n < num_allocated)
|
||||
return TRUE;
|
||||
|
||||
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->free_objects, object);
|
||||
}
|
||||
num_allocated = gst_vaapi_video_pool_get_size (pool) + pool->used_count;
|
||||
if (n < num_allocated)
|
||||
return TRUE;
|
||||
|
||||
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->free_objects, object);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_reserve(GstVaapiVideoPool *pool, guint n)
|
||||
gst_vaapi_video_pool_reserve (GstVaapiVideoPool * pool, guint n)
|
||||
{
|
||||
gboolean success;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, 0);
|
||||
g_return_val_if_fail (pool != NULL, 0);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
success = gst_vaapi_video_pool_reserve_unlocked(pool, n);
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
return success;
|
||||
g_mutex_lock (&pool->mutex);
|
||||
success = gst_vaapi_video_pool_reserve_unlocked (pool, n);
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -385,17 +385,17 @@ gst_vaapi_video_pool_reserve(GstVaapiVideoPool *pool, guint n)
|
|||
* Return value: the capacity of the pool
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_video_pool_get_capacity(GstVaapiVideoPool *pool)
|
||||
gst_vaapi_video_pool_get_capacity (GstVaapiVideoPool * pool)
|
||||
{
|
||||
guint capacity;
|
||||
guint capacity;
|
||||
|
||||
g_return_val_if_fail(pool != NULL, 0);
|
||||
g_return_val_if_fail (pool != NULL, 0);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
capacity = pool->capacity;
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
g_mutex_lock (&pool->mutex);
|
||||
capacity = pool->capacity;
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
|
||||
return capacity;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,11 +406,11 @@ gst_vaapi_video_pool_get_capacity(GstVaapiVideoPool *pool)
|
|||
* Sets the maximum number of objects that can be allocated in the pool.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_video_pool_set_capacity(GstVaapiVideoPool *pool, guint capacity)
|
||||
gst_vaapi_video_pool_set_capacity (GstVaapiVideoPool * pool, guint capacity)
|
||||
{
|
||||
g_return_if_fail(pool != NULL);
|
||||
g_return_if_fail (pool != NULL);
|
||||
|
||||
g_mutex_lock(&pool->mutex);
|
||||
pool->capacity = capacity;
|
||||
g_mutex_unlock(&pool->mutex);
|
||||
g_mutex_lock (&pool->mutex);
|
||||
pool->capacity = capacity;
|
||||
g_mutex_unlock (&pool->mutex);
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_VIDEO_POOL(obj) \
|
||||
((GstVaapiVideoPool *)(obj))
|
||||
((GstVaapiVideoPool *)(obj))
|
||||
|
||||
typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
||||
typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
||||
|
||||
/**
|
||||
* GstVaapiVideoPoolObjectType:
|
||||
|
@ -43,51 +43,53 @@ typedef struct _GstVaapiVideoPool GstVaapiVideoPool;
|
|||
*
|
||||
* The set of all supported #GstVaapiVideoPool object types.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE = 1,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE = 1,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER
|
||||
} GstVaapiVideoPoolObjectType;
|
||||
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_video_pool_ref(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_ref (GstVaapiVideoPool * pool);
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_unref(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_unref (GstVaapiVideoPool * pool);
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_replace(GstVaapiVideoPool **old_pool_ptr,
|
||||
GstVaapiVideoPool *new_pool);
|
||||
gst_vaapi_video_pool_replace (GstVaapiVideoPool ** old_pool_ptr,
|
||||
GstVaapiVideoPool * new_pool);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_video_pool_get_display(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_get_display (GstVaapiVideoPool * pool);
|
||||
|
||||
GstVaapiVideoPoolObjectType
|
||||
gst_vaapi_video_pool_get_object_type(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_get_object_type (GstVaapiVideoPool * pool);
|
||||
|
||||
gpointer
|
||||
gst_vaapi_video_pool_get_object(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_get_object (GstVaapiVideoPool * pool);
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_put_object(GstVaapiVideoPool *pool, gpointer object);
|
||||
gst_vaapi_video_pool_put_object (GstVaapiVideoPool * pool, gpointer object);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_add_object(GstVaapiVideoPool *pool, gpointer object);
|
||||
gst_vaapi_video_pool_add_object (GstVaapiVideoPool * pool, gpointer object);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_add_objects(GstVaapiVideoPool *pool, GPtrArray *objects);
|
||||
gst_vaapi_video_pool_add_objects (GstVaapiVideoPool * pool,
|
||||
GPtrArray * objects);
|
||||
|
||||
guint
|
||||
gst_vaapi_video_pool_get_size(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_get_size (GstVaapiVideoPool * pool);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_pool_reserve(GstVaapiVideoPool *pool, guint n);
|
||||
gst_vaapi_video_pool_reserve (GstVaapiVideoPool * pool, guint n);
|
||||
|
||||
guint
|
||||
gst_vaapi_video_pool_get_capacity(GstVaapiVideoPool *pool);
|
||||
gst_vaapi_video_pool_get_capacity (GstVaapiVideoPool * pool);
|
||||
|
||||
void
|
||||
gst_vaapi_video_pool_set_capacity(GstVaapiVideoPool *pool, guint capacity);
|
||||
gst_vaapi_video_pool_set_capacity (GstVaapiVideoPool * pool, guint capacity);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -30,29 +30,29 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_VIDEO_POOL_CLASS(klass) \
|
||||
((GstVaapiVideoPoolClass *)(klass))
|
||||
((GstVaapiVideoPoolClass *)(klass))
|
||||
#define GST_VAAPI_IS_VIDEO_POOL_CLASS(klass) \
|
||||
((klass) != NULL)
|
||||
|
||||
#define GST_VAAPI_IS_VIDEO_POOL_CLASS(klass) \
|
||||
((klass) != NULL)
|
||||
|
||||
typedef struct _GstVaapiVideoPoolClass GstVaapiVideoPoolClass;
|
||||
typedef struct _GstVaapiVideoPoolClass GstVaapiVideoPoolClass;
|
||||
|
||||
/**
|
||||
* GstVaapiVideoPool:
|
||||
*
|
||||
* A pool of lazily allocated video objects. e.g. surfaces, images.
|
||||
*/
|
||||
struct _GstVaapiVideoPool {
|
||||
/*< private >*/
|
||||
GstVaapiMiniObject parent_instance;
|
||||
struct _GstVaapiVideoPool
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObject parent_instance;
|
||||
|
||||
guint object_type;
|
||||
GstVaapiDisplay *display;
|
||||
GQueue free_objects;
|
||||
GList *used_objects;
|
||||
guint used_count;
|
||||
guint capacity;
|
||||
GMutex mutex;
|
||||
guint object_type;
|
||||
GstVaapiDisplay *display;
|
||||
GQueue free_objects;
|
||||
GList *used_objects;
|
||||
guint used_count;
|
||||
guint capacity;
|
||||
GMutex mutex;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -61,46 +61,47 @@ struct _GstVaapiVideoPool {
|
|||
*
|
||||
* A pool base class used to hold video objects. e.g. surfaces, images.
|
||||
*/
|
||||
struct _GstVaapiVideoPoolClass {
|
||||
/*< private >*/
|
||||
GstVaapiMiniObjectClass parent_class;
|
||||
struct _GstVaapiVideoPoolClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
gpointer (*alloc_object)(GstVaapiVideoPool *pool);
|
||||
/*< public >*/
|
||||
gpointer (*alloc_object) (GstVaapiVideoPool * pool);
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_video_pool_init(GstVaapiVideoPool *pool, GstVaapiDisplay *display,
|
||||
gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display,
|
||||
GstVaapiVideoPoolObjectType object_type);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool);
|
||||
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)))
|
||||
((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))
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
gst_vaapi_video_pool_replace_internal ((old_pool_ptr), (new_pool))
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue