for (i = 0; i < len && left > 0; i++) {
GstMemory *mem = GST_BUFFER_MEM_PTR (src, i);
- bsize = gst_memory_get_sizes (mem, NULL, NULL);
+ bsize = mem->size;
if (bsize <= skip) {
/* don't copy buffer */
GstMemory *
gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
{
- guint len;
-
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
- len = GST_BUFFER_MEM_LEN (buffer);
- g_return_val_if_fail (idx < len, NULL);
+ g_return_val_if_fail (idx < GST_BUFFER_MEM_LEN (buffer), NULL);
return GST_BUFFER_MEM_PTR (buffer, idx);
}
void
gst_buffer_remove_all_memory (GstBuffer * buffer)
{
- gst_buffer_remove_memory_range (buffer, 0, -1);
+ if (GST_BUFFER_MEM_LEN (buffer))
+ gst_buffer_remove_memory_range (buffer, 0, -1);
}
/**
gsize s;
mem = GST_BUFFER_MEM_PTR (buffer, i);
- s = gst_memory_get_sizes (mem, NULL, NULL);
+ s = mem->size;
if (s <= offset) {
/* block before offset, or empty block, skip */
gsize
gst_buffer_get_size (GstBuffer * buffer)
{
- return gst_buffer_get_sizes_range (buffer, 0, -1, NULL, NULL);
+ guint i;
+ gsize size, len;
+
+ g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
+
+ /* FAST PATH */
+ len = GST_BUFFER_MEM_LEN (buffer);
+ for (i = 0, size = 0; i < len; i++)
+ size += GST_BUFFER_MEM_PTR (buffer, i)->size;
+ return size;
}
/**
/* common case */
mem = GST_BUFFER_MEM_PTR (buffer, idx);
size = gst_memory_get_sizes (mem, offset, maxsize);
+ } else if (offset == NULL && maxsize == NULL) {
+ /* FAST PATH ! */
+ guint i, end;
+
+ size = 0;
+ end = idx + length;
+ for (i = idx; i < end; i++) {
+ mem = GST_BUFFER_MEM_PTR (buffer, i);
+ size += mem->size;
+ }
} else {
guint i, end;
gsize extra, offs;
gsize left, noffs;
mem = GST_BUFFER_MEM_PTR (buffer, i);
- bsize = gst_memory_get_sizes (mem, NULL, NULL);
+ bsize = mem->size;
noffs = 0;
/* last buffer always gets resized to the remaining size */