/* FIXME, there is room for improvement here: We could only try to merge
* 2 buffers to make some room. If we can't efficiently merge 2 buffers we
* could try to only merge the two smallest buffers to avoid memcpy, etc. */
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "memory array overflow in buffer %p",
+ buffer);
_replace_memory (buffer, _span_memory (buffer, 0, -1, FALSE));
/* we now have 1 single spanned buffer */
len = 1;
/* if the buffer is writable, replace the memory */
if (writable)
_replace_memory (buffer, gst_memory_ref (mem));
+ else if (GST_BUFFER_MEM_LEN (buffer) > 1) {
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE,
+ "temporary mapping for memory %p in buffer %p", mem, buffer);
+ }
return TRUE;
cannot_map:
{
GST_DEBUG_OBJECT (buffer, "cannot map memory");
- gst_memory_unref (mem);
return FALSE;
}
}
if (!writable
&& _gst_buffer_arr_is_span_fast (mem, len, n, &poffset, &parent)) {
- if (parent->flags & GST_MEMORY_FLAG_NO_SHARE)
+ if (parent->flags & GST_MEMORY_FLAG_NO_SHARE) {
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy for span %p", parent);
span = gst_memory_copy (parent, offset + poffset, size);
- else
+ } else {
span = gst_memory_share (parent, offset + poffset, size);
+ }
} else {
gsize count, left;
GstMapInfo dinfo;
gst_memory_map (cmem[i], &sinfo, GST_MAP_READ);
tocopy = MIN (sinfo.size, left);
if (tocopy > offset) {
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE,
+ "memcpy for span %p from memory %p", span, cmem[i]);
memcpy (ptr, (guint8 *) sinfo.data + offset, tocopy - offset);
left -= tocopy;
ptr += tocopy;
_default_mem_new_block (mem->mem.maxsize, 0, mem->mem.offset + offset,
size);
memcpy (copy->data, mem->data, mem->mem.maxsize);
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy memory %p -> %p", mem, copy);
return copy;
}
}
memcpy (dinfo.data, sinfo.data + offset, size);
+ GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy memory %p -> %p", mem, copy);
gst_memory_unmap (copy, &dinfo);
gst_memory_unmap (mem, &sinfo);