From 3b1dfa5fec95b7f4e315b8ed8f5b2c96feb8020a Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 12 Jan 2006 16:07:50 +0000 Subject: [PATCH] gst/gstbuffer.c: gst_buffer_span should copy the timestamp of the first buffer if they were both originally overlappi... Original commit message from CVS: * gst/gstbuffer.c: (gst_buffer_span): gst_buffer_span should copy the timestamp of the first buffer if they were both originally overlapping subbuffers of the same parent, using the same logic as the 'slow copy' case. --- ChangeLog | 7 +++++++ gst/gstbuffer.c | 37 +++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb12dc0..cc398d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-12 Jan Schmidt + + * gst/gstbuffer.c: (gst_buffer_span): + gst_buffer_span should copy the timestamp of the first buffer + if they were both originally overlapping subbuffers of the + same parent, using the same logic as the 'slow copy' case. + 2006-01-11 Jan Schmidt * libs/gst/base/gstcollectpads.c: (gst_collect_pads_pop): diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 442126d..684ef8e 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -553,25 +553,26 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2, /* copy the second buffer's data across */ memcpy (newbuf->data + (buf1->size - offset), buf2->data, len - (buf1->size - offset)); - /* if the offset is 0, the new buffer has the same timestamp as buf1 */ - if (offset == 0) { - GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1); - GST_BUFFER_TIMESTAMP (newbuf) = GST_BUFFER_TIMESTAMP (buf1); - } } - /* if we completely merged the two buffers (appended), we can - * calculate the duration too. Also make sure we's not messing with - * invalid DURATIONS */ - if (offset == 0 && buf1->size + buf2->size == len) { - if (GST_BUFFER_DURATION_IS_VALID (buf1) && - GST_BUFFER_DURATION_IS_VALID (buf2)) { - /* add duration */ - GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + - GST_BUFFER_DURATION (buf2); - } - if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) { - /* add offset_end */ - GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_END (buf2); + /* if the offset is 0, the new buffer has the same timestamp as buf1 */ + if (offset == 0) { + GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1); + GST_BUFFER_TIMESTAMP (newbuf) = GST_BUFFER_TIMESTAMP (buf1); + + /* if we completely merged the two buffers (appended), we can + * calculate the duration too. Also make sure we's not messing with + * invalid DURATIONS */ + if (buf1->size + buf2->size == len) { + if (GST_BUFFER_DURATION_IS_VALID (buf1) && + GST_BUFFER_DURATION_IS_VALID (buf2)) { + /* add duration */ + GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + + GST_BUFFER_DURATION (buf2); + } + if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) { + /* add offset_end */ + GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_END (buf2); + } } } -- 2.7.4