mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
meta: Add a new "clear" transform to avoid re-allocations
In the buffer pool, try to clear metas before freeing them so we avoid constant reallocations on every frame. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4962>
This commit is contained in:
parent
150adf6df4
commit
aa7333fe43
3 changed files with 33 additions and 0 deletions
|
@ -1217,6 +1217,14 @@ remove_meta_unpooled (GstBuffer * buffer, GstMeta ** meta, gpointer user_data)
|
|||
if (!GST_META_FLAG_IS_SET (*meta, GST_META_FLAG_POOLED)) {
|
||||
GST_META_FLAG_UNSET (*meta, GST_META_FLAG_LOCKED);
|
||||
*meta = NULL;
|
||||
} else {
|
||||
const GstMetaInfo *info = (*meta)->info;
|
||||
|
||||
/* If we can clear it, don't free it */
|
||||
if (info->transform_func) {
|
||||
info->transform_func (NULL, *meta, buffer, _gst_meta_transform_clear,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ static GHashTable *metainfo = NULL;
|
|||
static GRWLock lock;
|
||||
|
||||
GQuark _gst_meta_transform_copy;
|
||||
GQuark _gst_meta_transform_clear;
|
||||
GQuark _gst_meta_tag_memory;
|
||||
GQuark _gst_meta_tag_memory_reference;
|
||||
|
||||
|
@ -81,6 +82,7 @@ _priv_gst_meta_initialize (void)
|
|||
metainfo = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, free_info);
|
||||
|
||||
_gst_meta_transform_copy = g_quark_from_static_string ("gst-copy");
|
||||
_gst_meta_transform_clear = g_quark_from_static_string ("gst-clear");
|
||||
_gst_meta_tag_memory = g_quark_from_static_string ("memory");
|
||||
_gst_meta_tag_memory_reference =
|
||||
g_quark_from_static_string ("memory-reference");
|
||||
|
|
|
@ -80,6 +80,7 @@ typedef enum {
|
|||
* @flag: the #GstMetaFlags to clear.
|
||||
*
|
||||
* Clears a metadata flag.
|
||||
*
|
||||
*/
|
||||
#define GST_META_FLAG_UNSET(meta,flag) (GST_META_FLAGS (meta) &= ~(flag))
|
||||
|
||||
|
@ -189,6 +190,28 @@ typedef struct {
|
|||
gsize size;
|
||||
} GstMetaTransformCopy;
|
||||
|
||||
/**
|
||||
* gst_meta_transform_clear:
|
||||
*
|
||||
* GQuark for the "gst-clear" transform.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
|
||||
GST_API GQuark _gst_meta_transform_clear;
|
||||
|
||||
/**
|
||||
* GST_META_TRANSFORM_IS_CLEAR:
|
||||
* @type: a transform type
|
||||
*
|
||||
* Check if the transform type is clearing the content of the meta without
|
||||
* freeing it.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
#define GST_META_TRANSFORM_IS_CLEAR(type) ((type) == _gst_meta_transform_clear)
|
||||
|
||||
|
||||
/**
|
||||
* GstMetaTransformFunction:
|
||||
* @transbuf: a #GstBuffer
|
||||
|
|
Loading…
Reference in a new issue