mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
audio: avoid buffer copy when nothing is clipped
when nothing is clipped, return the input buffer instead of creating and returning an identical copy.
This commit is contained in:
parent
0b17c3747a
commit
94869bff38
1 changed files with 19 additions and 15 deletions
|
@ -832,7 +832,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
GstClockTime timestamp = GST_CLOCK_TIME_NONE, duration = GST_CLOCK_TIME_NONE;
|
GstClockTime timestamp = GST_CLOCK_TIME_NONE, duration = GST_CLOCK_TIME_NONE;
|
||||||
guint64 offset = GST_BUFFER_OFFSET_NONE, offset_end = GST_BUFFER_OFFSET_NONE;
|
guint64 offset = GST_BUFFER_OFFSET_NONE, offset_end = GST_BUFFER_OFFSET_NONE;
|
||||||
gsize trim, size;
|
gsize trim, size, osize;
|
||||||
gboolean change_duration = TRUE, change_offset = TRUE, change_offset_end =
|
gboolean change_duration = TRUE, change_offset = TRUE, change_offset_end =
|
||||||
TRUE;
|
TRUE;
|
||||||
|
|
||||||
|
@ -849,7 +849,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
|
||||||
* they won't be changed later though. */
|
* they won't be changed later though. */
|
||||||
|
|
||||||
trim = 0;
|
trim = 0;
|
||||||
size = gst_buffer_get_size (buffer);
|
osize = size = gst_buffer_get_size (buffer);
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
||||||
|
@ -953,6 +953,10 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim == 0 && size == osize) {
|
||||||
|
/* nothing changed */
|
||||||
|
ret = buffer;
|
||||||
|
} else {
|
||||||
/* Get a writable buffer and apply all changes */
|
/* Get a writable buffer and apply all changes */
|
||||||
GST_DEBUG ("trim %" G_GSIZE_FORMAT " size %" G_GSIZE_FORMAT, trim, size);
|
GST_DEBUG ("trim %" G_GSIZE_FORMAT " size %" G_GSIZE_FORMAT, trim, size);
|
||||||
ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, trim, size);
|
ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, trim, size);
|
||||||
|
@ -967,7 +971,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
|
||||||
GST_BUFFER_OFFSET (ret) = offset;
|
GST_BUFFER_OFFSET (ret) = offset;
|
||||||
if (change_offset_end)
|
if (change_offset_end)
|
||||||
GST_BUFFER_OFFSET_END (ret) = offset_end;
|
GST_BUFFER_OFFSET_END (ret) = offset_end;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue