mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
buffer: add option to deep copy a buffer
Add a buffer copy flag to force a memory copy in all cases.
This commit is contained in:
parent
6c7573226e
commit
1fcef378bd
2 changed files with 17 additions and 8 deletions
|
@ -402,6 +402,9 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
|
||||||
if (flags & GST_BUFFER_COPY_MEMORY) {
|
if (flags & GST_BUFFER_COPY_MEMORY) {
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
gsize skip, left, len, i, bsize;
|
gsize skip, left, len, i, bsize;
|
||||||
|
gboolean deep;
|
||||||
|
|
||||||
|
deep = flags & GST_BUFFER_COPY_DEEP;
|
||||||
|
|
||||||
len = GST_BUFFER_MEM_LEN (src);
|
len = GST_BUFFER_MEM_LEN (src);
|
||||||
left = size;
|
left = size;
|
||||||
|
@ -419,8 +422,9 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
|
||||||
gsize tocopy;
|
gsize tocopy;
|
||||||
|
|
||||||
tocopy = MIN (bsize - skip, left);
|
tocopy = MIN (bsize - skip, left);
|
||||||
if (GST_MEMORY_IS_NO_SHARE (mem)) {
|
if (deep || GST_MEMORY_IS_NO_SHARE (mem)) {
|
||||||
/* no share, always copy then */
|
/* deep copy or we're not allowed to share this memory
|
||||||
|
* between buffers, always copy then */
|
||||||
mem = gst_memory_copy (mem, skip, tocopy);
|
mem = gst_memory_copy (mem, skip, tocopy);
|
||||||
skip = 0;
|
skip = 0;
|
||||||
} else if (tocopy < bsize) {
|
} else if (tocopy < bsize) {
|
||||||
|
|
|
@ -376,13 +376,17 @@ gst_buffer_copy (const GstBuffer * buf)
|
||||||
* @GST_BUFFER_COPY_NONE: copy nothing
|
* @GST_BUFFER_COPY_NONE: copy nothing
|
||||||
* @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
|
* @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
|
||||||
* @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer pts, dts,
|
* @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer pts, dts,
|
||||||
* duration, offset and offset_end should be copied
|
* duration, offset and offset_end should be copied
|
||||||
* @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be copied
|
* @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be reffed
|
||||||
* and appended to already existing memory
|
* and appended to already existing memory. Unless the memory is marked as
|
||||||
|
* NO_SHARE, no actual copy of the memory is made but it is simply reffed.
|
||||||
|
* Add @GST_BUFFER_COPY_DEEP to force a real copy.
|
||||||
* @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be
|
* @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be
|
||||||
* merged
|
* merged
|
||||||
* @GST_BUFFER_COPY_META: flag indicating that buffer meta should be
|
* @GST_BUFFER_COPY_META: flag indicating that buffer meta should be
|
||||||
* copied
|
* copied
|
||||||
|
* @GST_BUFFER_COPY_DEEP: flag indicating that memory should always be
|
||||||
|
* copied instead of reffed.
|
||||||
*
|
*
|
||||||
* A set of flags that can be provided to the gst_buffer_copy_into()
|
* A set of flags that can be provided to the gst_buffer_copy_into()
|
||||||
* function to specify which items should be copied.
|
* function to specify which items should be copied.
|
||||||
|
@ -393,7 +397,8 @@ typedef enum {
|
||||||
GST_BUFFER_COPY_TIMESTAMPS = (1 << 1),
|
GST_BUFFER_COPY_TIMESTAMPS = (1 << 1),
|
||||||
GST_BUFFER_COPY_META = (1 << 2),
|
GST_BUFFER_COPY_META = (1 << 2),
|
||||||
GST_BUFFER_COPY_MEMORY = (1 << 3),
|
GST_BUFFER_COPY_MEMORY = (1 << 3),
|
||||||
GST_BUFFER_COPY_MERGE = (1 << 4)
|
GST_BUFFER_COPY_MERGE = (1 << 4),
|
||||||
|
GST_BUFFER_COPY_DEEP = (1 << 5)
|
||||||
} GstBufferCopyFlags;
|
} GstBufferCopyFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue