mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
v4l2bufferpool: Restore original GstMemory in buffer if it has been changed
https://bugzilla.gnome.org/show_bug.cgi?id=706083
This commit is contained in:
parent
adf5d96044
commit
141a1fc296
1 changed files with 22 additions and 9 deletions
|
@ -682,9 +682,9 @@ gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf)
|
||||||
meta->vbuffer.bytesused = gst_buffer_get_size (buf);
|
meta->vbuffer.bytesused = gst_buffer_get_size (buf);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool,
|
GST_LOG_OBJECT (pool,
|
||||||
"enqueue buffer %p, index:%d, queued:%d, flags:%08x used:%d",
|
"enqueue buffer %p, index:%d, queued:%d, flags:%08x mem:%p used:%d",
|
||||||
buf, index, pool->num_queued, meta->vbuffer.flags,
|
buf, index, pool->num_queued, meta->vbuffer.flags,
|
||||||
meta->vbuffer.bytesused);
|
meta->mem, meta->vbuffer.bytesused);
|
||||||
|
|
||||||
if (pool->buffers[index] != NULL)
|
if (pool->buffers[index] != NULL)
|
||||||
goto already_queued;
|
goto already_queued;
|
||||||
|
@ -720,6 +720,7 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer)
|
||||||
struct v4l2_buffer vbuffer;
|
struct v4l2_buffer vbuffer;
|
||||||
GstV4l2Object *obj = pool->obj;
|
GstV4l2Object *obj = pool->obj;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
GstV4l2Meta *meta;
|
||||||
|
|
||||||
if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK)
|
if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK)
|
||||||
goto poll_error;
|
goto poll_error;
|
||||||
|
@ -750,10 +751,13 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer)
|
||||||
|
|
||||||
timestamp = GST_TIMEVAL_TO_TIME (vbuffer.timestamp);
|
timestamp = GST_TIMEVAL_TO_TIME (vbuffer.timestamp);
|
||||||
|
|
||||||
|
meta = GST_V4L2_META_GET (outbuf);
|
||||||
|
g_assert (meta != NULL);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool,
|
GST_LOG_OBJECT (pool,
|
||||||
"dequeued buffer %p seq:%d (ix=%d), used %d, flags %08x, ts %"
|
"dequeued buffer %p seq:%d (ix=%d), mem %p used %d, flags %08x, ts %"
|
||||||
GST_TIME_FORMAT ", pool-queued=%d, buffer=%p", outbuf, vbuffer.sequence,
|
GST_TIME_FORMAT ", pool-queued=%d, buffer=%p", outbuf, vbuffer.sequence,
|
||||||
vbuffer.index, vbuffer.bytesused, vbuffer.flags,
|
vbuffer.index, meta->mem, vbuffer.bytesused, vbuffer.flags,
|
||||||
GST_TIME_ARGS (timestamp), pool->num_queued, outbuf);
|
GST_TIME_ARGS (timestamp), pool->num_queued, outbuf);
|
||||||
|
|
||||||
/* set top/bottom field first if v4l2_buffer has the information */
|
/* set top/bottom field first if v4l2_buffer has the information */
|
||||||
|
@ -764,9 +768,17 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer)
|
||||||
GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
|
GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this can change at every frame, esp. with jpeg */
|
/* The size can change at every frame, esp. with jpeg. The GstMemory
|
||||||
if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
* inside the GstBuffer could have been changed by some other
|
||||||
gst_buffer_resize (outbuf, 0, vbuffer.bytesused);
|
* element, so just put back the original one. We always set it as
|
||||||
|
* no share, so if it's not there, it's not used at all.
|
||||||
|
*/
|
||||||
|
if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
||||||
|
gst_buffer_remove_all_memory (outbuf);
|
||||||
|
gst_buffer_append_memory (outbuf,
|
||||||
|
gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE,
|
||||||
|
meta->mem, vbuffer.length, 0, vbuffer.bytesused, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||||
|
|
||||||
|
@ -882,8 +894,9 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* copy the memory */
|
/* copy the buffer */
|
||||||
copy = gst_buffer_copy (*buffer);
|
copy = gst_buffer_copy_region (*buffer,
|
||||||
|
GST_BUFFER_COPY_ALL | GST_BUFFER_COPY_DEEP, 0, -1);
|
||||||
GST_LOG_OBJECT (pool, "copy buffer %p->%p", *buffer, copy);
|
GST_LOG_OBJECT (pool, "copy buffer %p->%p", *buffer, copy);
|
||||||
|
|
||||||
/* and requeue so that we can continue capturing */
|
/* and requeue so that we can continue capturing */
|
||||||
|
|
Loading…
Reference in a new issue