From 3ec1feb88ff4f8472bca75195fbdc8a216f2f988 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 18 Dec 2024 15:13:17 -0500 Subject: [PATCH] v4l2: pool: Adjust pool behaviour when DMA_DRM is used We disable the copy threshold and always add GstVideoMeta. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c | 15 ++++++++++----- .../gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c index 98c7dbe084..55ae3d8607 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c @@ -526,15 +526,19 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config) gboolean updated = FALSE; gboolean ret; - pool->add_videometa = - gst_buffer_pool_config_has_option (config, - GST_BUFFER_POOL_OPTION_VIDEO_META); - /* parse the config and keep around */ if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers)) goto wrong_config; + pool->add_videometa = + gst_buffer_pool_config_has_option (config, + GST_BUFFER_POOL_OPTION_VIDEO_META); + + /* Always enable VideoMeta when we negotiate memory:DMABuf */ + pool->have_dma_drm_caps = gst_video_is_dma_drm_caps (caps); + pool->add_videometa |= pool->have_dma_drm_caps; + if (!gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms)) goto wrong_config; @@ -2258,7 +2262,8 @@ void gst_v4l2_buffer_pool_copy_at_threshold (GstV4l2BufferPool * pool, gboolean copy) { GST_OBJECT_LOCK (pool); - pool->enable_copy_threshold = copy; + /* Ignore copy threashold when memory:DMABuf caps features is in used */ + pool->enable_copy_threshold = copy && !pool->have_dma_drm_caps; GST_OBJECT_UNLOCK (pool); } diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h index db8c554306..517e45f821 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h @@ -76,6 +76,7 @@ struct _GstV4l2BufferPool GstBufferPool *other_pool; guint size; GstVideoInfo caps_info; /* Default video information */ + gboolean have_dma_drm_caps; /* If the configured caps have memory:DMABuf */ gboolean add_videometa; /* set if video meta should be added */ gboolean enable_copy_threshold; /* If copy_threshold should be set */