From 1c7ce208bd54861d6c8551cd4885dcf85afa14f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 13 Dec 2023 11:31:12 +0100 Subject: [PATCH] vapluginsutils: add helper gst_va_create_other_pool() This helper function creates a software-based buffer pool, where if size is zero, its value is retrieved from the canonical size. Part-of: --- .../gst-plugins-bad/sys/va/gstvapluginutils.c | 26 +++++++++++++++++++ .../gst-plugins-bad/sys/va/gstvapluginutils.h | 5 ++++ 2 files changed, 31 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.c b/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.c index 020d04ce62..41555f8024 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.c @@ -73,3 +73,29 @@ gst_va_create_feature_name (GstVaDevice * device, if (*rank > 0) *rank -= 1; } + +GstBufferPool * +gst_va_create_other_pool (GstAllocator * allocator, + GstAllocationParams * params, GstCaps * caps, guint size) +{ + GstBufferPool *pool = NULL; + GstStructure *config; + + if (size == 0) { + GstVideoInfo info; + + if (!gst_video_info_from_caps (&info, caps)) + return NULL; + size = GST_VIDEO_INFO_SIZE (&info); + } + + pool = gst_video_buffer_pool_new (); + config = gst_buffer_pool_get_config (pool); + + gst_buffer_pool_config_set_params (config, caps, size, 0, 0); + gst_buffer_pool_config_set_allocator (config, allocator, params); + if (!gst_buffer_pool_set_config (pool, config)) + gst_clear_object (&pool); + + return pool; +} diff --git a/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.h b/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.h index 58f6ad314c..04e54cfcfc 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvapluginutils.h @@ -45,4 +45,9 @@ void gst_va_create_feature_name (GstVaDevice * device, gchar ** desc, guint * rank); +GstBufferPool * gst_va_create_other_pool (GstAllocator * allocator, + GstAllocationParams * params, + GstCaps * caps, + guint size); + G_END_DECLS