diff --git a/girs/GstVulkan-1.0.gir b/girs/GstVulkan-1.0.gir index 30b77849fd..f37bb6d2a0 100644 --- a/girs/GstVulkan-1.0.gir +++ b/girs/GstVulkan-1.0.gir @@ -2531,6 +2531,23 @@ the error + + + + the GStreamer video format + + + + the Vulkan format with a single memory + + + + Vulkan formats for multiple memories + + + + + [0, 2^n - 1] -> [0.0, 1.0] @@ -7140,6 +7157,19 @@ properties. + + + + the #GstVulkanFormatMap matching with @format + + + + + the #GstVideoFormat to get + + + + diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c index 3e2453f9f7..87abbb5a5d 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.c @@ -431,11 +431,7 @@ gst_vulkan_format_get_aspect (VkFormat format) } /* *INDENT-OFF* */ -const static struct { - GstVideoFormat format; - VkFormat vkfrmt; - VkFormat vkfrmts[GST_VIDEO_MAX_PLANES]; -} vk_formats_map[] = { +const static GstVulkanFormatMap vk_formats_map[] = { /* RGB unsigned normalized format sRGB nonlinear encoding */ { GST_VIDEO_FORMAT_RGBA, VK_FORMAT_R8G8B8A8_UNORM, { VK_FORMAT_R8G8B8A8_SRGB, } }, { GST_VIDEO_FORMAT_RGBx, VK_FORMAT_R8G8B8A8_UNORM, { VK_FORMAT_R8G8B8A8_SRGB, } }, @@ -467,6 +463,28 @@ const static struct { }; /* *INDENT-ON* */ +/** + * gst_vulkan_format_get_map: (skip) + * @format: the #GstVideoFormat to get + * + * Returns: (nullable): the #GstVulkanFormatMap matching with @format + * + * Since: 1.26 + */ +const GstVulkanFormatMap * +gst_vulkan_format_get_map (GstVideoFormat format) +{ + guint i; + + for (i = 0; i < G_N_ELEMENTS (vk_formats_map); i++) { + if (vk_formats_map[i].format != format) + continue; + return &vk_formats_map[i]; + } + + return NULL; +} + /** * gst_vulkan_format_from_video_info: (skip) * @v_info: the #GstVideoInfo diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.h b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.h index 56d108b74f..2bf4a21f74 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkformat.h @@ -27,6 +27,7 @@ G_BEGIN_DECLS typedef struct _GstVulkanFormatInfo GstVulkanFormatInfo; +typedef struct _GstVulkanFormatMap GstVulkanFormatMap; /** * GST_VULKAN_MAX_COMPONENTS: @@ -130,9 +131,26 @@ struct _GstVulkanFormatInfo VkImageAspectFlags aspect; }; +/** + * GstVulkanFormatMap: + * @format: the GStreamer video format + * @vkfrmt: the Vulkan format with a single memory + * @vkfrmts: Vulkan formats for multiple memories + * + * Since: 1.26 + */ +struct _GstVulkanFormatMap { + GstVideoFormat format; + VkFormat vkfrmt; + VkFormat vkfrmts[GST_VIDEO_MAX_PLANES]; +}; + GST_VULKAN_API const GstVulkanFormatInfo * gst_vulkan_format_get_info (VkFormat format); +GST_VULKAN_API +const GstVulkanFormatMap * gst_vulkan_format_get_map (GstVideoFormat format); + GST_VULKAN_API guint gst_vulkan_format_get_aspect (VkFormat format);