mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-06 14:32:31 +00:00
GstBuffer: Inline fast-path for merged memory
This commit is contained in:
parent
6c2dfe5ebe
commit
e3d2eb1f16
1 changed files with 57 additions and 50 deletions
|
@ -234,23 +234,14 @@ _is_span (GstMemory ** mem, gsize len, gsize * poffset, GstMemory ** parent)
|
|||
}
|
||||
|
||||
static GstMemory *
|
||||
_get_merged_memory (GstBuffer * buffer, guint idx, guint length)
|
||||
_actual_merged_memory (GstBuffer * buffer, guint idx, guint length)
|
||||
{
|
||||
GstMemory **mem, *result = NULL;
|
||||
|
||||
GST_CAT_LOG (GST_CAT_BUFFER, "buffer %p, idx %u, length %u", buffer, idx,
|
||||
length);
|
||||
|
||||
mem = GST_BUFFER_MEM_ARRAY (buffer);
|
||||
|
||||
if (G_UNLIKELY (length == 0)) {
|
||||
result = NULL;
|
||||
} else if (G_LIKELY (length == 1)) {
|
||||
result = gst_memory_ref (mem[idx]);
|
||||
} else {
|
||||
GstMemory *parent = NULL;
|
||||
gsize size, poffset = 0;
|
||||
|
||||
mem = GST_BUFFER_MEM_ARRAY (buffer);
|
||||
|
||||
size = gst_buffer_get_sizes_range (buffer, idx, length, NULL, NULL);
|
||||
|
||||
if (G_UNLIKELY (_is_span (mem + idx, length, &poffset, &parent))) {
|
||||
|
@ -296,10 +287,26 @@ _get_merged_memory (GstBuffer * buffer, guint idx, guint length)
|
|||
}
|
||||
gst_memory_unmap (result, &dinfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline GstMemory *
|
||||
_get_merged_memory (GstBuffer * buffer, guint idx, guint length)
|
||||
{
|
||||
GST_CAT_LOG (GST_CAT_BUFFER, "buffer %p, idx %u, length %u", buffer, idx,
|
||||
length);
|
||||
|
||||
if (G_UNLIKELY (length == 0))
|
||||
return NULL;
|
||||
|
||||
if (G_LIKELY (length == 1))
|
||||
return gst_memory_ref (GST_BUFFER_MEM_PTR (buffer, idx));
|
||||
|
||||
return _actual_merged_memory (buffer, idx, length);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_replace_memory (GstBuffer * buffer, guint len, guint idx, guint length,
|
||||
GstMemory * mem)
|
||||
|
|
Loading…
Reference in a new issue