diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.cpp index 2a7785a9cb..781fb86e47 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.cpp @@ -669,8 +669,6 @@ enum PROP_DEST_MASTERING_DISPLAY_INFO, PROP_DEST_CONTENT_LIGHT_LEVEL, PROP_VIDEO_DIRECTION, - PROP_SRC_ALPHA_MODE, - PROP_DEST_ALPHA_MODE, }; struct _GstD3D11ConverterPrivate @@ -890,14 +888,6 @@ gst_d3d11_converter_class_init (GstD3D11ConverterClass * klass) g_param_spec_enum ("video-direction", "Video Direction", "Video direction", GST_TYPE_VIDEO_ORIENTATION_METHOD, GST_VIDEO_ORIENTATION_IDENTITY, param_flags)); - g_object_class_install_property (object_class, PROP_SRC_ALPHA_MODE, - g_param_spec_enum ("src-alpha-mode", "Src Alpha Mode", - "Src alpha mode to use", GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, - GST_D3D11_CONVERTER_ALPHA_MODE_UNSPECIFIED, param_flags)); - g_object_class_install_property (object_class, PROP_DEST_ALPHA_MODE, - g_param_spec_enum ("dest-alpha-mode", "Dest Alpha Mode", - "Dest alpha mode to use", GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, - GST_D3D11_CONVERTER_ALPHA_MODE_UNSPECIFIED, param_flags)); GST_DEBUG_CATEGORY_INIT (gst_d3d11_converter_debug, "d3d11converter", 0, "d3d11converter"); @@ -1119,38 +1109,6 @@ gst_d3d11_converter_set_property (GObject * object, guint prop_id, } break; } - case PROP_SRC_ALPHA_MODE: - { - DWORD prev_premul = priv->const_data.in_premul_alpha; - priv->src_alpha_mode = (GstD3D11ConverterAlphaMode) - g_value_get_enum (value); - if (priv->src_alpha_mode == GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED) { - priv->const_data.in_premul_alpha = TRUE; - } else { - priv->const_data.in_premul_alpha = FALSE; - } - - if (prev_premul != priv->const_data.in_premul_alpha) { - priv->update_alpha = TRUE; - } - break; - } - case PROP_DEST_ALPHA_MODE: - { - DWORD prev_premul = priv->const_data.out_premul_alpha; - priv->dst_alpha_mode = (GstD3D11ConverterAlphaMode) - g_value_get_enum (value); - if (priv->dst_alpha_mode == GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED) { - priv->const_data.out_premul_alpha = TRUE; - } else { - priv->const_data.out_premul_alpha = FALSE; - } - - if (prev_premul != priv->const_data.out_premul_alpha) { - priv->update_alpha = TRUE; - } - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1232,12 +1190,6 @@ gst_d3d11_converter_get_property (GObject * object, guint prop_id, case PROP_VIDEO_DIRECTION: g_value_set_enum (value, priv->video_direction); break; - case PROP_SRC_ALPHA_MODE: - g_value_set_enum (value, priv->src_alpha_mode); - break; - case PROP_DEST_ALPHA_MODE: - g_value_set_enum (value, priv->dst_alpha_mode); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -3265,9 +3217,21 @@ gst_d3d11_converter_new (GstD3D11Device * device, const GstVideoInfo * in_info, gst_structure_get_enum (config, GST_D3D11_CONVERTER_OPT_SAMPLER_FILTER, GST_TYPE_D3D11_CONVERTER_SAMPLER_FILTER, (int *) &sampler_filter); + + gst_structure_get_enum (config, GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, (int *) &priv->src_alpha_mode); + gst_structure_get_enum (config, GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, (int *) &priv->dst_alpha_mode); + gst_structure_free (config); } + if (priv->src_alpha_mode == GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED) + priv->const_data.in_premul_alpha = TRUE; + + if (priv->dst_alpha_mode == GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED) + priv->const_data.out_premul_alpha = TRUE; + if (!wanted_backend) { wanted_backend = GST_D3D11_CONVERTER_BACKEND_SHADER | diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.h index 8fad01132c..25e3d84572 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter.h @@ -122,6 +122,26 @@ GST_D3D11_API GType gst_d3d11_converter_alpha_mode_get_type (void); #define GST_TYPE_D3D11_CONVERTER_ALPHA_MODE (gst_d3d11_converter_alpha_mode_get_type()) +/** + * GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE: + * + * Set the source alpha mode. + * Default is #GST_D3D11_CONVERTER_ALPHA_MODE_UNSPECIFIED. + * + * Since: 1.24 + */ +#define GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE "GstD3D11Converter.src-alpha-mode" + +/** + * GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE: + * + * Set the source alpha mode. + * Default is #GST_D3D11_CONVERTER_ALPHA_MODE_UNSPECIFIED. + * + * Since: 1.24 + */ +#define GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE "GstD3D11Converter.dest-alpha-mode" + /** * GstD3D11Converter: * diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp index 7fe8b3201b..8fbbc17dfc 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp @@ -1724,7 +1724,12 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter, GST_D3D11_CONVERTER_OPT_SAMPLER_FILTER, GST_TYPE_D3D11_CONVERTER_SAMPLER_FILTER, gst_d3d11_base_convert_sampling_method_to_filter - (self->active_sampling_method), nullptr); + (self->active_sampling_method), + GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, + self->src_alpha_mode, + GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, self->dst_alpha_mode, nullptr); self->converter = gst_d3d11_converter_new (filter->device, in_info, out_info, config); @@ -1769,9 +1774,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter, "dest-y", (gint) self->out_rect.top, "dest-width", (gint) (self->out_rect.right - self->out_rect.left), "dest-height", (gint) (self->out_rect.bottom - self->out_rect.top), - "video-direction", self->active_method, - "src-alpha-mode", self->src_alpha_mode, - "dest-alpha-mode", self->dst_alpha_mode, nullptr); + "video-direction", self->active_method, nullptr); if (self->borders_w > 0 || self->borders_h > 0) { g_object_set (self->converter, "fill-border", TRUE, "border-color", @@ -2245,9 +2248,10 @@ gst_d3d11_base_convert_set_src_alpha_mode (GstD3D11BaseConvert * self, { GstD3D11SRWLockGuard lk (&self->lock); - self->src_alpha_mode = mode; - if (self->converter) - g_object_set (self->converter, "src-alpha-mode", mode, nullptr); + if (self->src_alpha_mode != mode) { + self->src_alpha_mode = mode; + gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM_CAST (self)); + } } static void @@ -2256,9 +2260,10 @@ gst_d3d11_base_convert_set_dst_alpha_mode (GstD3D11BaseConvert * self, { GstD3D11SRWLockGuard lk (&self->lock); - self->dst_alpha_mode = mode; - if (self->converter) - g_object_set (self->converter, "dest-alpha-mode", mode, nullptr); + if (self->dst_alpha_mode != mode) { + self->dst_alpha_mode = mode; + gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM_CAST (self)); + } } /** diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11testsrc.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11testsrc.cpp index d11763663a..39443c9197 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11testsrc.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11testsrc.cpp @@ -1299,7 +1299,17 @@ gst_d3d11_test_src_setup_resource (GstD3D11TestSrc * self, GstCaps * caps) config = gst_structure_new ("converter-config", GST_D3D11_CONVERTER_OPT_BACKEND, GST_TYPE_D3D11_CONVERTER_BACKEND, - GST_D3D11_CONVERTER_BACKEND_SHADER, nullptr); + GST_D3D11_CONVERTER_BACKEND_SHADER, + GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, self->alpha_mode, nullptr); + + /* D2D uses premultiplied alpha */ + if (self->pattern == GST_D3D11_TEST_SRC_CIRCULAR || + self->pattern == GST_D3D11_TEST_SRC_BALL) { + gst_structure_set (config, GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, + GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); + } gst_video_info_set_format (&draw_info, GST_VIDEO_FORMAT_BGRA, self->info.width, self->info.height); @@ -1311,15 +1321,6 @@ gst_d3d11_test_src_setup_resource (GstD3D11TestSrc * self, GstCaps * caps) goto error; } - /* D2D uses premultiplied alpha */ - if (self->pattern == GST_D3D11_TEST_SRC_CIRCULAR || - self->pattern == GST_D3D11_TEST_SRC_BALL) { - g_object_set (self->converter, "src-alpha-mode", - GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); - } - - g_object_set (self->converter, "dest-alpha-mode", self->alpha_mode, nullptr); - draw_caps = gst_video_info_to_caps (&draw_info); params = gst_d3d11_allocation_params_new (self->device, &draw_info, GST_D3D11_ALLOCATION_FLAG_DEFAULT, diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp index 886a35241a..4017b1939b 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp @@ -755,6 +755,19 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, gst_video_info_apply_dxgi_color_space (swapchain_colorspace, &window->render_info); + if (GST_VIDEO_INFO_HAS_ALPHA (&window->info)) { + if (config) { + gst_structure_set (config, GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, + GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); + } else { + config = gst_structure_new ("convert-config", + GST_D3D11_CONVERTER_OPT_DEST_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, + GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); + } + } + window->converter = gst_d3d11_converter_new (device, &window->info, &window->render_info, config); @@ -765,11 +778,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, return GST_FLOW_ERROR; } - if (GST_VIDEO_INFO_HAS_ALPHA (&window->info)) { - g_object_set (window->converter, "dest-alpha-mode", - GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); - } - if (have_hdr10_meta) { g_object_set (window->converter, "src-mastering-display-info", mdcv_str, "src-content-light-level", cll_str, nullptr); diff --git a/subprojects/gst-plugins-bad/sys/dwrite/gstdwriteoverlayobject.cpp b/subprojects/gst-plugins-bad/sys/dwrite/gstdwriteoverlayobject.cpp index 832abc073e..589abf8ecc 100644 --- a/subprojects/gst-plugins-bad/sys/dwrite/gstdwriteoverlayobject.cpp +++ b/subprojects/gst-plugins-bad/sys/dwrite/gstdwriteoverlayobject.cpp @@ -234,7 +234,8 @@ is_subsampled_yuv (const GstVideoInfo * info) static GstD3D11Converter * gst_dwrite_overlay_object_create_converter (GstDWriteOverlayObject * self, - const GstVideoInfo * in_info, const GstVideoInfo * out_info) + const GstVideoInfo * in_info, const GstVideoInfo * out_info, + gboolean is_blend) { GstD3D11Converter *ret; GstDWriteOverlayObjectPrivate *priv = self->priv; @@ -249,6 +250,11 @@ gst_dwrite_overlay_object_create_converter (GstDWriteOverlayObject * self, GST_D3D11_CONVERTER_BACKEND_SHADER, GST_D3D11_CONVERTER_OPT_SAMPLER_FILTER, GST_TYPE_D3D11_CONVERTER_SAMPLER_FILTER, filter, nullptr); + if (is_blend) { + gst_structure_set (config, GST_D3D11_CONVERTER_OPT_SRC_ALPHA_MODE, + GST_TYPE_D3D11_CONVERTER_ALPHA_MODE, + GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, nullptr); + } ret = gst_d3d11_converter_new (priv->device, in_info, out_info, config); if (!ret) @@ -352,7 +358,7 @@ gst_dwrite_overlay_object_prepare_resource (GstDWriteOverlayObject * self) break; case GstDWriteBlendMode::BLEND: priv->blend_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->bgra_info, &priv->info); + &priv->bgra_info, &priv->info, TRUE); if (!priv->blend_conv) return FALSE; break; @@ -363,17 +369,17 @@ gst_dwrite_overlay_object_prepare_resource (GstDWriteOverlayObject * self) return FALSE; priv->pre_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->info, &priv->bgra_info); + &priv->info, &priv->bgra_info, FALSE); if (!priv->pre_conv) return FALSE; priv->blend_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->bgra_info, &priv->bgra_info); + &priv->bgra_info, &priv->bgra_info, TRUE); if (!priv->blend_conv) return FALSE; priv->post_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->bgra_info, &priv->info); + &priv->bgra_info, &priv->info, FALSE); if (!priv->blend_conv) return FALSE; break; @@ -389,17 +395,17 @@ gst_dwrite_overlay_object_prepare_resource (GstDWriteOverlayObject * self) return FALSE; priv->pre_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->info, &blend_info); + &priv->info, &blend_info, FALSE); if (!priv->pre_conv) return FALSE; priv->blend_conv = gst_dwrite_overlay_object_create_converter (self, - &priv->bgra_info, &blend_info); + &priv->bgra_info, &blend_info, TRUE); if (!priv->pre_conv) return FALSE; priv->post_conv = gst_dwrite_overlay_object_create_converter (self, - &blend_info, &priv->info); + &blend_info, &priv->info, FALSE); if (!priv->post_conv) return FALSE; @@ -433,9 +439,7 @@ gst_dwrite_overlay_object_prepare_resource (GstDWriteOverlayObject * self) return FALSE; } - g_object_set (priv->blend_conv, "blend-state", blend.Get (), - "src-alpha-mode", GST_D3D11_CONVERTER_ALPHA_MODE_PREMULTIPLIED, - nullptr); + g_object_set (priv->blend_conv, "blend-state", blend.Get (), nullptr); } return TRUE;