From c6b867e470af756ac7c08ee879d708d74f2510a0 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 12 Sep 2023 13:05:43 +1000 Subject: [PATCH] vulkancolorconvert: actually support passthrough correctly e.g. passthrough of YUV (or RGB) formats should not modify any buffers. Part-of: --- .../ext/vulkan/vkcolorconvert.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkcolorconvert.c b/subprojects/gst-plugins-bad/ext/vulkan/vkcolorconvert.c index 54e885aa81..abf5911d60 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkcolorconvert.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkcolorconvert.c @@ -1113,6 +1113,36 @@ gst_vulkan_color_convert_start (GstBaseTransform * bt) return TRUE; } +static gboolean +vulkan_color_convert_can_passthrough_info (const GstVideoInfo * in, + const GstVideoInfo * out) +{ + gint i; + + if (GST_VIDEO_INFO_FORMAT (in) != GST_VIDEO_INFO_FORMAT (out)) + return FALSE; + if (GST_VIDEO_INFO_WIDTH (in) != GST_VIDEO_INFO_WIDTH (out)) + return FALSE; + if (GST_VIDEO_INFO_HEIGHT (in) != GST_VIDEO_INFO_HEIGHT (out)) + return FALSE; + if (GST_VIDEO_INFO_SIZE (in) != GST_VIDEO_INFO_SIZE (out)) + return FALSE; + + for (i = 0; i < in->finfo->n_planes; i++) { + if (in->stride[i] != out->stride[i]) + return FALSE; + if (in->offset[i] != out->offset[i]) + return FALSE; + } + + if (!gst_video_colorimetry_is_equal (&in->colorimetry, &out->colorimetry)) + return FALSE; + if (in->chroma_site != out->chroma_site) + return FALSE; + + return TRUE; +} + static gboolean gst_vulkan_color_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps, GstCaps * out_caps) @@ -1120,12 +1150,18 @@ gst_vulkan_color_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps, GstVulkanVideoFilter *vfilter = GST_VULKAN_VIDEO_FILTER (bt); GstVulkanColorConvert *conv = GST_VULKAN_COLOR_CONVERT (bt); GstVulkanHandle *vert, *frag; + gboolean passthrough; int i; if (!GST_BASE_TRANSFORM_CLASS (parent_class)->set_caps (bt, in_caps, out_caps)) return FALSE; + passthrough = + vulkan_color_convert_can_passthrough_info (&vfilter->in_info, + &vfilter->out_info); + gst_base_transform_set_passthrough (bt, passthrough); + if (!gst_vulkan_full_screen_quad_set_info (conv->quad, &vfilter->in_info, &vfilter->out_info)) return FALSE; @@ -1135,6 +1171,11 @@ gst_vulkan_color_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps, conv->current_shader = NULL; } + if (passthrough) { + conv->current_shader = NULL; + return TRUE; + } + for (i = 0; i < G_N_ELEMENTS (shader_infos); i++) { if (shader_infos[i].from != GST_VIDEO_INFO_FORMAT (&vfilter->in_info)) continue;