mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
buffer: re-enable _span offset calculations
when we _span two complete buffers, we can copy offsets and timestamps.
This commit is contained in:
parent
a080b81808
commit
a137002ef1
1 changed files with 7 additions and 9 deletions
|
@ -1445,19 +1445,19 @@ gst_buffer_span (GstBuffer * buf1, gsize offset, GstBuffer * buf2, gsize size)
|
||||||
GstBuffer *newbuf;
|
GstBuffer *newbuf;
|
||||||
GstMemory *span;
|
GstMemory *span;
|
||||||
GstMemory **mem[2];
|
GstMemory **mem[2];
|
||||||
gsize len[2], len1, len2;
|
gsize len[2], size1, size2;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buf1), NULL);
|
g_return_val_if_fail (GST_IS_BUFFER (buf1), NULL);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buf2), NULL);
|
g_return_val_if_fail (GST_IS_BUFFER (buf2), NULL);
|
||||||
g_return_val_if_fail (buf1->mini_object.refcount > 0, NULL);
|
g_return_val_if_fail (buf1->mini_object.refcount > 0, NULL);
|
||||||
g_return_val_if_fail (buf2->mini_object.refcount > 0, NULL);
|
g_return_val_if_fail (buf2->mini_object.refcount > 0, NULL);
|
||||||
len1 = gst_buffer_get_size (buf1);
|
size1 = gst_buffer_get_size (buf1);
|
||||||
len2 = gst_buffer_get_size (buf2);
|
size2 = gst_buffer_get_size (buf2);
|
||||||
g_return_val_if_fail (len1 + len2 > offset, NULL);
|
g_return_val_if_fail (size1 + size2 > offset, NULL);
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
size = len1 + len2 - offset;
|
size = size1 + size2 - offset;
|
||||||
else
|
else
|
||||||
g_return_val_if_fail (size <= len1 + len2 - offset, NULL);
|
g_return_val_if_fail (size <= size1 + size2 - offset, NULL);
|
||||||
|
|
||||||
mem[0] = GST_BUFFER_MEM_ARRAY (buf1);
|
mem[0] = GST_BUFFER_MEM_ARRAY (buf1);
|
||||||
len[0] = GST_BUFFER_MEM_LEN (buf1);
|
len[0] = GST_BUFFER_MEM_LEN (buf1);
|
||||||
|
@ -1469,7 +1469,6 @@ gst_buffer_span (GstBuffer * buf1, gsize offset, GstBuffer * buf2, gsize size)
|
||||||
newbuf = gst_buffer_new ();
|
newbuf = gst_buffer_new ();
|
||||||
_memory_add (newbuf, -1, span);
|
_memory_add (newbuf, -1, span);
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* if the offset is 0, the new buffer has the same timestamp as buf1 */
|
/* if the offset is 0, the new buffer has the same timestamp as buf1 */
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1);
|
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1);
|
||||||
|
@ -1479,7 +1478,7 @@ gst_buffer_span (GstBuffer * buf1, gsize offset, GstBuffer * buf2, gsize size)
|
||||||
/* if we completely merged the two buffers (appended), we can
|
/* if we completely merged the two buffers (appended), we can
|
||||||
* calculate the duration too. Also make sure we's not messing with
|
* calculate the duration too. Also make sure we's not messing with
|
||||||
* invalid DURATIONS */
|
* invalid DURATIONS */
|
||||||
if (buf1->size + buf2->size == len) {
|
if (size1 + size2 == size) {
|
||||||
if (GST_BUFFER_DURATION_IS_VALID (buf1) &&
|
if (GST_BUFFER_DURATION_IS_VALID (buf1) &&
|
||||||
GST_BUFFER_DURATION_IS_VALID (buf2)) {
|
GST_BUFFER_DURATION_IS_VALID (buf2)) {
|
||||||
/* add duration */
|
/* add duration */
|
||||||
|
@ -1492,7 +1491,6 @@ gst_buffer_span (GstBuffer * buf1, gsize offset, GstBuffer * buf2, gsize size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return newbuf;
|
return newbuf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue