v4l2videoenc: always allocate CAPTURE buffer from our pool

The videoencoder base class always uses the negotiated allocator for allocating
coded buffers and ignores the negotiated buffer pool. Therefore, the
v4l2videoenc always has to copy buffers from the pool into the allocated
output buffers.

This breaks downstream elements that want to import the CAPTURE buffers of the
v4l2videoenc, since the v4l2videoenc copies the exported CAPTURE buffers and
sends the copies downstream.

Always use the CAPTURE buffer pool for acquiring CAPTURE buffers instead of
allocating the buffers in the base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4230>
This commit is contained in:
Michael Tretter 2023-01-31 15:52:42 +01:00 committed by GStreamer Marge Bot
parent 9ca194d8cc
commit 5de27e0620

View file

@ -635,31 +635,27 @@ static void
gst_v4l2_video_enc_loop (GstVideoEncoder * encoder)
{
GstV4l2VideoEnc *self = GST_V4L2_VIDEO_ENC (encoder);
GstBufferPool *pool = gst_v4l2_object_get_buffer_pool (self->v4l2capture);
GstV4l2BufferPool *cpool = GST_V4L2_BUFFER_POOL (pool);
GstVideoCodecFrame *frame;
GstBuffer *buffer = NULL;
GstFlowReturn ret;
GST_LOG_OBJECT (encoder, "Allocate output buffer");
buffer = gst_video_encoder_allocate_output_buffer (encoder,
self->v4l2capture->info.size);
if (NULL == buffer) {
ret = GST_FLOW_FLUSHING;
ret = gst_buffer_pool_acquire_buffer (pool, &buffer, NULL);
if (ret != GST_FLOW_OK) {
if (cpool)
gst_object_unref (cpool);
goto beach;
}
/* FIXME Check if buffer isn't the last one here */
GST_LOG_OBJECT (encoder, "Process output buffer");
{
GstV4l2BufferPool *cpool =
GST_V4L2_BUFFER_POOL (gst_v4l2_object_get_buffer_pool
(self->v4l2capture));
ret = gst_v4l2_buffer_pool_process (cpool, &buffer, NULL);
if (cpool)
gst_object_unref (cpool);
}
ret = gst_v4l2_buffer_pool_process (cpool, &buffer, NULL);
if (cpool)
gst_object_unref (cpool);
if (ret != GST_FLOW_OK)
goto beach;