d3d11converter: Fix for missing GRAY conversion
authorSeungha Yang <seungha@centricular.com>
Tue, 15 Feb 2022 17:23:58 +0000 (02:23 +0900)
committerSeungha Yang <seungha@centricular.com>
Tue, 15 Feb 2022 17:30:01 +0000 (02:30 +0900)
Add missing Y410 -> GRAY and GRAY -> semi-planar conversion

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1724>

subprojects/gst-plugins-bad/sys/d3d11/gstd3d11converter.cpp

index 499949a..39c8993 100644 (file)
@@ -313,6 +313,14 @@ static const gchar templ_YUV_to_GRAY_BODY[] =
     "  sample.a = 0.0;\n"
     "  output.Plane_0 = sample;\n";
 
+static const gchar templ_PACKED_YUV_TO_GRAY[] =
+    "  float4 sample;\n"
+    "  sample.x = shaderTexture[0].Sample(samplerState, input.Texture).%c;\n"
+    "  sample.y = 0.0;\n"
+    "  sample.z = 0.0;\n"
+    "  sample.a = 0.0;\n"
+    "  output.Plane_0 = sample;\n";
+
 static const gchar templ_GRAY_to_GRAY_BODY[] =
     "  float4 sample;\n"
     "  sample.x = shaderTexture[0].Sample(samplerState, input.Texture).x;\n"
@@ -1337,6 +1345,14 @@ setup_convert_info_yuv_to_gray (GstD3D11Converter * self,
       info->ps_body[0] = g_strdup_printf (templ_YUV_to_GRAY_BODY, scale);
       break;
     }
+    case GST_VIDEO_FORMAT_Y410:
+    {
+      gchar y, u, v;
+      get_packed_yuv_components (self, GST_VIDEO_FORMAT_Y410, &y, &u, &v);
+
+      info->ps_body[0] = g_strdup_printf (templ_PACKED_YUV_TO_GRAY, y);
+      break;
+    }
     default:
       GST_ERROR ("Unhandled input format %s",
           gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info)));
@@ -1434,6 +1450,7 @@ setup_convert_info_gray_to_yuv (GstD3D11Converter * self,
       info->ps_body[1] =
           g_strdup_printf (templ_GRAY_to_SEMI_PLANAR_CHROMA_BODY);
       info->ps_output[1] = HLSL_PS_OUTPUT_ONE_PLANE_BODY;
+      break;
     default:
       GST_ERROR ("Unhandled output format %s",
           gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (out_info)));