We may need some colorspace information for returning sRGB vs no sRGB.
for (i = 0; i < *n_descriptions; i++) {
/* *INDENT-OFF* */
color_attachments[i] = (VkAttachmentDescription) {
- .format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->out_info), i),
+ .format = gst_vulkan_format_from_video_info (&render->out_info, i),
.samples = VK_SAMPLE_COUNT_1_BIT,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
/* we need a scratch buffer because framebuffers can only output to
* attachments of at least the same size which means no sub-sampled
* rendering */
- GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&render->out_info);
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
VkFormat vk_format;
GstMemory *mem;
- vk_format = gst_vulkan_format_from_video_format (v_format, i);
+ vk_format = gst_vulkan_format_from_video_info (&render->out_info, i);
mem = gst_vulkan_image_memory_alloc (render->device,
vk_format, GST_VIDEO_INFO_WIDTH (&render->out_info),
color_attachments = g_new0 (VkAttachmentDescription, *n_descriptions);
/* *INDENT-OFF* */
color_attachments[0] = (VkAttachmentDescription) {
- .format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->in_info), 0),
+ .format = gst_vulkan_format_from_video_info (&render->in_info, 0),
.samples = VK_SAMPLE_COUNT_1_BIT,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
out_height = GST_VIDEO_INFO_HEIGHT (&raw->out_info);
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&raw->out_info); i++) {
- GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&raw->out_info);
GstVulkanImageMemory *img_mem;
VkFormat vk_format;
- vk_format = gst_vulkan_format_from_video_format (v_format, i);
+ vk_format = gst_vulkan_format_from_video_info (&raw->out_info, i);
img_mem = (GstVulkanImageMemory *)
gst_vulkan_image_memory_alloc (raw->upload->device, vk_format,
for (i = 0; i < *n_descriptions; i++) {
/* *INDENT-OFF* */
color_attachments[i] = (VkAttachmentDescription) {
- .format = gst_vulkan_format_from_video_format (GST_VIDEO_INFO_FORMAT (&render->out_info), i),
+ .format = gst_vulkan_format_from_video_info (&render->out_info, i),
.samples = VK_SAMPLE_COUNT_1_BIT,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
/* get the size of the buffer to allocate */
priv->v_info.size = 0;
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) {
- GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info);
GstVulkanImageMemory *img_mem;
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
guint width, height;
VkFormat vk_format;
- vk_format = gst_vulkan_format_from_video_format (v_format, i);
+ vk_format = gst_vulkan_format_from_video_info (&priv->v_info, i);
width = GST_VIDEO_INFO_COMP_WIDTH (&priv->v_info, i);
height = GST_VIDEO_INFO_COMP_HEIGHT (&priv->v_info, i);
if (priv->raw_caps)
}
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) {
- GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info);
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
VkFormat vk_format;
GstMemory *mem;
- vk_format = gst_vulkan_format_from_video_format (v_format, i);
+ vk_format = gst_vulkan_format_from_video_info (&priv->v_info, i);
if (priv->raw_caps)
tiling = VK_IMAGE_TILING_LINEAR;
static GstAllocator *_vulkan_image_memory_allocator;
/**
- * gst_vulkan_format_from_video_format: (skip)
- * @v_format: the #GstVideoFormat
+ * gst_vulkan_format_from_video_info: (skip)
+ * @v_info: the #GstVideoInfo
* @plane: the plane
*
* Returns: the VkFormat to use for @v_format and @plane
* Since: 1.18
*/
VkFormat
-gst_vulkan_format_from_video_format (GstVideoFormat v_format, guint plane)
+gst_vulkan_format_from_video_info (GstVideoInfo * v_info, guint plane)
{
guint n_plane_components;
- switch (v_format) {
+ switch (GST_VIDEO_INFO_FORMAT (v_info)) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_RGBA:
- return VK_FORMAT_R8G8B8A8_UNORM;
+ if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
+ GST_VIDEO_TRANSFER_SRGB)
+ return VK_FORMAT_R8G8B8A8_UNORM;
+ else
+ return VK_FORMAT_R8G8B8A8_SRGB;
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_BGRA:
- return VK_FORMAT_B8G8R8A8_UNORM;
+ if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
+ GST_VIDEO_TRANSFER_SRGB)
+ return VK_FORMAT_B8G8R8A8_UNORM;
+ else
+ return VK_FORMAT_B8G8R8A8_SRGB;
case GST_VIDEO_FORMAT_xRGB:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_ABGR:
+ if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
+ GST_VIDEO_TRANSFER_SRGB)
+ n_plane_components = 4;
+ else
+ return VK_FORMAT_UNDEFINED;
case GST_VIDEO_FORMAT_AYUV:
n_plane_components = 4;
break;
GstVulkanImageView * view);
GST_VULKAN_API
-VkFormat gst_vulkan_format_from_video_format (GstVideoFormat v_format,
+VkFormat gst_vulkan_format_from_video_info (GstVideoInfo * v_info,
guint plane);
G_END_DECLS
switch (format) {
/* double check endianness */
case VK_FORMAT_R8G8B8A8_UNORM:
- case VK_FORMAT_R8G8B8A8_SRGB:
return GST_VIDEO_FORMAT_RGBA;
case VK_FORMAT_R8G8B8_UNORM:
- case VK_FORMAT_R8G8B8_SRGB:
return GST_VIDEO_FORMAT_RGB;
case VK_FORMAT_B8G8R8A8_UNORM:
- case VK_FORMAT_B8G8R8A8_SRGB:
return GST_VIDEO_FORMAT_BGRA;
case VK_FORMAT_B8G8R8_UNORM:
- case VK_FORMAT_B8G8R8_SRGB:
return GST_VIDEO_FORMAT_BGR;
default:
return GST_VIDEO_FORMAT_UNKNOWN;
}
}
-static VkFormat
-_vk_format_from_video_info (GstVideoInfo * v_info)
-{
- switch (GST_VIDEO_INFO_FORMAT (v_info)) {
- case GST_VIDEO_FORMAT_RGBA:
- if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
- GST_VIDEO_TRANSFER_SRGB)
- return VK_FORMAT_R8G8B8A8_SRGB;
- else
- return VK_FORMAT_R8G8B8A8_UNORM;
- case GST_VIDEO_FORMAT_RGB:
- if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
- GST_VIDEO_TRANSFER_SRGB)
- return VK_FORMAT_R8G8B8_SRGB;
- else
- return VK_FORMAT_R8G8B8_UNORM;
- case GST_VIDEO_FORMAT_BGRA:
- if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
- GST_VIDEO_TRANSFER_SRGB)
- return VK_FORMAT_B8G8R8A8_SRGB;
- else
- return VK_FORMAT_B8G8R8A8_UNORM;
- case GST_VIDEO_FORMAT_BGR:
- if (GST_VIDEO_INFO_COLORIMETRY (v_info).transfer ==
- GST_VIDEO_TRANSFER_SRGB)
- return VK_FORMAT_B8G8R8_SRGB;
- else
- return VK_FORMAT_B8G8R8_UNORM;
- default:
- return VK_FORMAT_UNDEFINED;
- }
-}
-
static VkColorSpaceKHR
_vk_color_space_from_video_info (GstVideoInfo * v_info)
{
preTransform = swapper->priv->surf_props.currentTransform;
}
- format = _vk_format_from_video_info (&swapper->priv->v_info);
+ format = gst_vulkan_format_from_video_info (&swapper->priv->v_info, 0);
color_space = _vk_color_space_from_video_info (&swapper->priv->v_info);
if ((swapper->priv->surf_props.supportedCompositeAlpha &