buffer: fix subbuffers

This commit is contained in:
Wim Taymans 2011-03-28 19:19:44 +02:00
parent 9ff103b3a5
commit 121b82ce27
3 changed files with 13 additions and 7 deletions

View file

@ -205,7 +205,9 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
g_warn_if_fail (gst_buffer_is_writable (dest));
#endif
GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p", src, dest);
GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p, offset %" G_GSIZE_FORMAT
"-%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT, src, dest, offset, size,
bufsize);
if (flags & GST_BUFFER_COPY_FLAGS) {
guint mask;
@ -222,7 +224,7 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
if (offset == 0) {
GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src);
GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src);
if (size == gst_buffer_get_size (src)) {
if (size == bufsize) {
GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src);
GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src);
}
@ -594,6 +596,9 @@ gst_buffer_trim (GstBuffer * buffer, gsize offset, gsize size)
gsize bsize;
GstMemory *mem;
GST_CAT_LOG (GST_CAT_BUFFER, "trim %p %" G_GSIZE_FORMAT "-%" G_GSIZE_FORMAT,
buffer, offset, size);
g_return_if_fail (gst_buffer_is_writable (buffer));
arr = (GPtrArray *) buffer->memory;
@ -926,7 +931,8 @@ gst_buffer_create_sub (GstBuffer * buffer, gsize offset, gsize size)
/* create the new buffer */
subbuffer = gst_buffer_new ();
GST_CAT_LOG (GST_CAT_BUFFER, "new subbuffer %p of %p", subbuffer, buffer);
GST_CAT_LOG (GST_CAT_BUFFER, "new subbuffer %p of %p %" G_GSIZE_FORMAT
"-%" G_GSIZE_FORMAT, subbuffer, buffer, offset, size);
gst_buffer_copy_into (subbuffer, buffer, GST_BUFFER_COPY_ALL, offset, size);

View file

@ -116,7 +116,7 @@ _default_mem_get_sizes (GstMemoryDefault * mem, gsize * maxsize)
static void
_default_mem_trim (GstMemoryDefault * mem, gsize offset, gsize size)
{
g_return_if_fail (size + mem->offset + offset > mem->maxsize);
g_return_if_fail (size + mem->offset + offset <= mem->maxsize);
mem->offset += offset;
mem->size = size;
@ -198,7 +198,7 @@ static void
_default_mem_extract (GstMemoryDefault * mem, gsize offset, gpointer dest,
gsize size)
{
g_return_if_fail (size + mem->offset + offset > mem->maxsize);
g_return_if_fail (size + mem->offset + offset <= mem->maxsize);
memcpy (dest, mem->data + mem->offset + offset, size);
}

View file

@ -1539,7 +1539,7 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
/* no valid buffer yet, make one, metadata is writable */
*out_buf = gst_buffer_new_and_alloc (outsize);
gst_buffer_copy_into (*out_buf, in_buf,
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, 0);
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
} else {
GST_DEBUG_OBJECT (trans, "reuse input buffer");
*out_buf = in_buf;
@ -1608,7 +1608,7 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
gst_buffer_set_caps (*out_buf, outcaps);
if (copymeta)
gst_buffer_copy_into (*out_buf, in_buf,
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, 0);
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
/* clear the GAP flag when the subclass does not understand it */
if (!trans->priv->gap_aware)
GST_BUFFER_FLAG_UNSET (*out_buf, GST_BUFFER_FLAG_GAP);