diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11bufferpool.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11bufferpool.cpp index 7428f8bbe4..91d64a98bc 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11bufferpool.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11bufferpool.cpp @@ -299,8 +299,7 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config) gst_memory_unref (mem); } - g_assert (priv->d3d11_params->d3d11_format != NULL); - format = priv->d3d11_params->d3d11_format; + format = &priv->d3d11_params->d3d11_format; /* single texture semi-planar formats */ if (format->dxgi_format != DXGI_FORMAT_UNKNOWN && GST_VIDEO_INFO_N_PLANES (&info) == 2) { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp index 24e26a07f0..35525e8278 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp @@ -1419,30 +1419,40 @@ gst_d3d11_device_unlock (GstD3D11Device * device) } /** - * gst_d3d11_device_format_from_gst: + * gst_d3d11_device_get_format: * @device: a #GstD3D11Device * @format: a #GstVideoFormat + * @device_format: (out caller-allocates) (nullable): a #GstD3D11Format * - * Returns: (transfer none) (nullable): a pointer to #GstD3D11Format - * or %NULL if @format is not supported by @device + * Converts @format to #GstD3D11Format if the @format is supported + * by device * - * Since: 1.20 + * Returns: %TRUE if @format is supported by @device + * + * Since: 1.22 */ -const GstD3D11Format * -gst_d3d11_device_format_from_gst (GstD3D11Device * device, - GstVideoFormat format) +gboolean +gst_d3d11_device_get_format (GstD3D11Device * device, GstVideoFormat format, + GstD3D11Format * device_format) { GstD3D11DevicePrivate *priv; - guint i; - g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL); + g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE); priv = device->priv; - for (i = 0; i < G_N_ELEMENTS (priv->format_table); i++) { - if (priv->format_table[i].format == format) - return &priv->format_table[i]; + for (guint i = 0; i < G_N_ELEMENTS (priv->format_table); i++) { + if (priv->format_table[i].format != format) + continue; + + if (device_format) + *device_format = priv->format_table[i]; + + return TRUE; } - return NULL; + if (device_format) + gst_d3d11_format_init (device_format); + + return FALSE; } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.h index cad6b2d131..bcce6d3400 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.h @@ -91,8 +91,9 @@ GST_D3D11_API void gst_d3d11_device_unlock (GstD3D11Device * device); GST_D3D11_API -const GstD3D11Format * gst_d3d11_device_format_from_gst (GstD3D11Device * device, - GstVideoFormat format); +gboolean gst_d3d11_device_get_format (GstD3D11Device * device, + GstVideoFormat format, + GstD3D11Format * device_format); G_END_DECLS diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.cpp index ae2a19d4c1..538b0ea4f8 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.cpp @@ -192,3 +192,19 @@ gst_d3d11_dxgi_format_to_gst (DXGI_FORMAT format) return GST_VIDEO_FORMAT_UNKNOWN; } + +/** + * gst_d3d11_format_init: + * @format: (out caller-allocates): a #GstD3D11Format + * + * Initialize @format with default values. + * + * Since: 1.22 + */ +void +gst_d3d11_format_init (GstD3D11Format * format) +{ + g_return_if_fail (format != nullptr); + + memset (format, 0, sizeof (GstD3D11Format)); +} diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.h index 2c7e93556a..01935954e5 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11format.h @@ -73,6 +73,9 @@ gboolean gst_d3d11_dxgi_format_get_size (DXGI_FORMAT format, GST_D3D11_API GstVideoFormat gst_d3d11_dxgi_format_to_gst (DXGI_FORMAT format); +GST_D3D11_API +void gst_d3d11_format_init (GstD3D11Format * format); + G_END_DECLS #endif /* __GST_D3D11_FORMAT_H__ */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp index f1f55ab2e6..a457373dd2 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp @@ -61,14 +61,13 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info, GstD3D11AllocationFlags flags, guint bind_flags) { GstD3D11AllocationParams *ret; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; guint i; g_return_val_if_fail (info != NULL, NULL); - d3d11_format = gst_d3d11_device_format_from_gst (device, - GST_VIDEO_INFO_FORMAT (info)); - if (!d3d11_format) { + if (!gst_d3d11_device_get_format (device, GST_VIDEO_INFO_FORMAT (info), + &d3d11_format)) { GST_WARNING ("Couldn't get d3d11 format"); return NULL; } @@ -93,15 +92,15 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info, */ /* If corresponding dxgi format is undefined, use resource format instead */ - if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) { + if (d3d11_format.dxgi_format == DXGI_FORMAT_UNKNOWN) { for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) { - g_assert (d3d11_format->resource_format[i] != DXGI_FORMAT_UNKNOWN); + g_assert (d3d11_format.resource_format[i] != DXGI_FORMAT_UNKNOWN); ret->desc[i].Width = GST_VIDEO_INFO_COMP_WIDTH (info, i); ret->desc[i].Height = GST_VIDEO_INFO_COMP_HEIGHT (info, i); ret->desc[i].MipLevels = 1; ret->desc[i].ArraySize = 1; - ret->desc[i].Format = d3d11_format->resource_format[i]; + ret->desc[i].Format = d3d11_format.resource_format[i]; ret->desc[i].SampleDesc.Count = 1; ret->desc[i].SampleDesc.Quality = 0; ret->desc[i].Usage = D3D11_USAGE_DEFAULT; @@ -112,7 +111,7 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info, ret->desc[0].Height = GST_VIDEO_INFO_HEIGHT (info); ret->desc[0].MipLevels = 1; ret->desc[0].ArraySize = 1; - ret->desc[0].Format = d3d11_format->dxgi_format; + ret->desc[0].Format = d3d11_format.dxgi_format; ret->desc[0].SampleDesc.Count = 1; ret->desc[0].SampleDesc.Quality = 0; ret->desc[0].Usage = D3D11_USAGE_DEFAULT; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.h index 841188c786..d3be11227a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.h @@ -128,7 +128,7 @@ struct _GstD3D11AllocationParams GstVideoInfo info; GstVideoInfo aligned_info; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; GstD3D11AllocationFlags flags; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11stagingbufferpool.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11stagingbufferpool.cpp index 92d3a9c98b..9bab4d5192 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11stagingbufferpool.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11stagingbufferpool.cpp @@ -126,7 +126,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, GstCaps *caps = nullptr; guint min_buffers, max_buffers; D3D11_TEXTURE2D_DESC *desc; - const GstD3D11Format *format; + GstD3D11Format format; gsize offset = 0; if (!gst_buffer_pool_config_get_params (config, &caps, nullptr, &min_buffers, @@ -140,10 +140,10 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, if (!gst_video_info_from_caps (&info, caps)) goto wrong_caps; - format = gst_d3d11_device_format_from_gst (self->device, - GST_VIDEO_INFO_FORMAT (&info)); - if (!format) + if (!gst_d3d11_device_get_format (self->device, GST_VIDEO_INFO_FORMAT (&info), + &format)) { goto wrong_caps; + } GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height, caps); @@ -154,7 +154,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, memset (priv->offset, 0, sizeof (priv->offset)); memset (priv->desc, 0, sizeof (priv->desc)); - if (format->dxgi_format == DXGI_FORMAT_UNKNOWN) { + if (format.dxgi_format == DXGI_FORMAT_UNKNOWN) { for (guint i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++) { desc = &priv->desc[i]; @@ -162,7 +162,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, desc->Height = GST_VIDEO_INFO_COMP_HEIGHT (&info, i); desc->MipLevels = 1; desc->ArraySize = 1; - desc->Format = format->resource_format[i]; + desc->Format = format.resource_format[i]; desc->SampleDesc.Count = 1; desc->Usage = D3D11_USAGE_STAGING; desc->CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; @@ -176,7 +176,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, height = GST_VIDEO_INFO_HEIGHT (&info); /* resolution of semi-planar formats must be multiple of 2 */ - switch (format->dxgi_format) { + switch (format.dxgi_format) { case DXGI_FORMAT_NV12: case DXGI_FORMAT_P010: case DXGI_FORMAT_P016: @@ -191,7 +191,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, desc->Height = height; desc->MipLevels = 1; desc->ArraySize = 1; - desc->Format = format->dxgi_format; + desc->Format = format.dxgi_format; desc->SampleDesc.Count = 1; desc->Usage = D3D11_USAGE_STAGING; desc->CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; @@ -247,7 +247,7 @@ gst_d3d11_staging_buffer_pool_set_config (GstBufferPool * pool, } /* single texture semi-planar formats */ - if (format->dxgi_format != DXGI_FORMAT_UNKNOWN && + if (format.dxgi_format != DXGI_FORMAT_UNKNOWN && GST_VIDEO_INFO_N_PLANES (&info) == 2) { priv->stride[1] = priv->stride[0]; priv->offset[1] = priv->stride[0] * priv->desc[0].Height; diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp index 8dfe7dab3c..01954524ed 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11convert.cpp @@ -56,8 +56,8 @@ struct _GstD3D11BaseConvert { GstD3D11BaseFilter parent; - const GstD3D11Format *in_d3d11_format; - const GstD3D11Format *out_d3d11_format; + GstD3D11Format in_d3d11_format; + GstD3D11Format out_d3d11_format; ID3D11Texture2D *in_texture[GST_VIDEO_MAX_PLANES]; ID3D11ShaderResourceView *shader_resource_view[GST_VIDEO_MAX_PLANES]; @@ -1168,7 +1168,7 @@ gst_d3d11_base_convert_propose_allocation (GstBaseTransform * trans, GstStructure *config; guint size; GstD3D11AllocationParams *d3d11_params; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; guint bind_flags = D3D11_BIND_SHADER_RESOURCE; DXGI_FORMAT dxgi_format = DXGI_FORMAT_UNKNOWN; UINT supported = 0; @@ -1193,17 +1193,16 @@ gst_d3d11_base_convert_propose_allocation (GstBaseTransform * trans, return FALSE; } - d3d11_format = gst_d3d11_device_format_from_gst (filter->device, - GST_VIDEO_INFO_FORMAT (&info)); - if (!d3d11_format) { + if (!gst_d3d11_device_get_format (filter->device, + GST_VIDEO_INFO_FORMAT (&info), &d3d11_format)) { GST_ERROR_OBJECT (filter, "Unknown format caps %" GST_PTR_FORMAT, caps); return FALSE; } - if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) { - dxgi_format = d3d11_format->resource_format[0]; + if (d3d11_format.dxgi_format == DXGI_FORMAT_UNKNOWN) { + dxgi_format = d3d11_format.resource_format[0]; } else { - dxgi_format = d3d11_format->dxgi_format; + dxgi_format = d3d11_format.dxgi_format; } device_handle = gst_d3d11_device_get_device_handle (filter->device); @@ -1292,7 +1291,7 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans, gboolean update_pool = FALSE; GstVideoInfo info; guint i; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; guint bind_flags = D3D11_BIND_RENDER_TARGET; DXGI_FORMAT dxgi_format = DXGI_FORMAT_UNKNOWN; UINT supported = 0; @@ -1309,17 +1308,16 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans, return FALSE; } - d3d11_format = gst_d3d11_device_format_from_gst (filter->device, - GST_VIDEO_INFO_FORMAT (&info)); - if (!d3d11_format) { + if (!gst_d3d11_device_get_format (filter->device, + GST_VIDEO_INFO_FORMAT (&info), &d3d11_format)) { GST_ERROR_OBJECT (filter, "Unknown format caps %" GST_PTR_FORMAT, outcaps); return FALSE; } - if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) { - dxgi_format = d3d11_format->resource_format[0]; + if (d3d11_format.dxgi_format == DXGI_FORMAT_UNKNOWN) { + dxgi_format = d3d11_format.resource_format[0]; } else { - dxgi_format = d3d11_format->dxgi_format; + dxgi_format = d3d11_format.dxgi_format; } device_handle = gst_d3d11_device_get_device_handle (filter->device); @@ -1787,18 +1785,14 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter, gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE); } - self->in_d3d11_format = - gst_d3d11_device_format_from_gst (filter->device, - GST_VIDEO_INFO_FORMAT (in_info)); - if (!self->in_d3d11_format) { + if (!gst_d3d11_device_get_format (filter->device, + GST_VIDEO_INFO_FORMAT (in_info), &self->in_d3d11_format)) { unknown_info = in_info; goto format_unknown; } - self->out_d3d11_format = - gst_d3d11_device_format_from_gst (filter->device, - GST_VIDEO_INFO_FORMAT (out_info)); - if (!self->out_d3d11_format) { + if (!gst_d3d11_device_get_format (filter->device, + GST_VIDEO_INFO_FORMAT (out_info), &self->out_d3d11_format)) { unknown_info = out_info; goto format_unknown; } @@ -1812,8 +1806,8 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter, } /* If both input and output formats are native DXGI format */ - if (self->in_d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN && - self->out_d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN) { + if (self->in_d3d11_format.dxgi_format != DXGI_FORMAT_UNKNOWN && + self->out_d3d11_format.dxgi_format != DXGI_FORMAT_UNKNOWN) { gboolean hardware = FALSE; GstD3D11VideoProcessor *processor = NULL; @@ -1832,8 +1826,8 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter, out_color_space = gst_d3d11_video_info_to_dxgi_color_space (out_info); if (in_color_space && out_color_space) { - DXGI_FORMAT in_dxgi_format = self->in_d3d11_format->dxgi_format; - DXGI_FORMAT out_dxgi_format = self->out_d3d11_format->dxgi_format; + DXGI_FORMAT in_dxgi_format = self->in_d3d11_format.dxgi_format; + DXGI_FORMAT out_dxgi_format = self->out_d3d11_format.dxgi_format; DXGI_COLOR_SPACE_TYPE in_dxgi_color_space = (DXGI_COLOR_SPACE_TYPE) in_color_space->dxgi_color_space_type; DXGI_COLOR_SPACE_TYPE out_dxgi_color_space = @@ -2079,7 +2073,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans, /* Ensure shader resource views */ if (!gst_d3d11_buffer_get_shader_resource_view (inbuf, resource_view)) { if (!create_shader_input_resource (self, device, - self->in_d3d11_format, &filter->in_info)) { + &self->in_d3d11_format, &filter->in_info)) { GST_ERROR_OBJECT (self, "Failed to configure fallback input texture"); goto fallback_failed; } @@ -2115,7 +2109,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans, /* Ensure render target views */ if (!gst_d3d11_buffer_get_render_target_view (outbuf, render_view)) { if (!create_shader_output_resource (self, device, - self->out_d3d11_format, &filter->out_info)) { + &self->out_d3d11_format, &filter->out_info)) { GST_ERROR_OBJECT (self, "Failed to configure fallback output texture"); goto fallback_failed; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11converter.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11converter.cpp index 39c8993ec1..0772f6b4a3 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11converter.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11converter.cpp @@ -424,9 +424,6 @@ struct _GstD3D11Converter GstVideoInfo out_info; gdouble alpha; - const GstD3D11Format *in_d3d11_format; - const GstD3D11Format *out_d3d11_format; - guint num_input_view; guint num_output_view; @@ -717,18 +714,16 @@ get_packed_yuv_components (GstD3D11Converter * self, GstVideoFormat switch (format) { case GST_VIDEO_FORMAT_YUY2: { - const GstD3D11Format *d3d11_format = - gst_d3d11_device_format_from_gst (self->device, - GST_VIDEO_FORMAT_YUY2); + GstD3D11Format d3d11_format; - g_assert (d3d11_format != NULL); + gst_d3d11_device_get_format (self->device, GST_VIDEO_FORMAT_YUY2, + &d3d11_format); - if (d3d11_format->resource_format[0] == DXGI_FORMAT_R8G8B8A8_UNORM) { + if (d3d11_format.resource_format[0] == DXGI_FORMAT_R8G8B8A8_UNORM) { *y = 'x'; *u = 'y'; *v = 'a'; - } else if (d3d11_format->resource_format[0] == - DXGI_FORMAT_G8R8_G8B8_UNORM) { + } else if (d3d11_format.resource_format[0] == DXGI_FORMAT_G8R8_G8B8_UNORM) { *y = 'y'; *u = 'x'; *v = 'z'; @@ -1804,8 +1799,8 @@ gst_d3d11_converter_new (GstD3D11Device * device, GstVideoInfo * in_info, GstVideoInfo * out_info, GstStructure * config) { const GstVideoInfo *unknown_info; - const GstD3D11Format *in_d3d11_format; - const GstD3D11Format *out_d3d11_format; + GstD3D11Format in_d3d11_format; + GstD3D11Format out_d3d11_format; gboolean is_supported = FALSE; MatrixData matrix; GstD3D11Converter *converter = NULL; @@ -1820,18 +1815,14 @@ gst_d3d11_converter_new (GstD3D11Device * device, gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info)), gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (out_info))); - in_d3d11_format = - gst_d3d11_device_format_from_gst (device, - GST_VIDEO_INFO_FORMAT (in_info)); - if (!in_d3d11_format) { + if (!gst_d3d11_device_get_format (device, GST_VIDEO_INFO_FORMAT (in_info), + &in_d3d11_format)) { unknown_info = in_info; goto format_unknown; } - out_d3d11_format = - gst_d3d11_device_format_from_gst (device, - GST_VIDEO_INFO_FORMAT (out_info)); - if (!out_d3d11_format) { + if (!gst_d3d11_device_get_format (device, GST_VIDEO_INFO_FORMAT (out_info), + &out_d3d11_format)) { unknown_info = out_info; goto format_unknown; } diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp index dce514564f..23329a0f4f 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp @@ -712,7 +712,7 @@ gst_d3d11_decoder_configure (GstD3D11Decoder * decoder, GstVideoCodecState * input_state, GstVideoInfo * info, gint coded_width, gint coded_height, guint dpb_size) { - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE); g_return_val_if_fail (info != NULL, FALSE); @@ -723,9 +723,9 @@ gst_d3d11_decoder_configure (GstD3D11Decoder * decoder, gst_d3d11_decoder_reset (decoder); - d3d11_format = gst_d3d11_device_format_from_gst (decoder->device, - GST_VIDEO_INFO_FORMAT (info)); - if (!d3d11_format || d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) { + if (!gst_d3d11_device_get_format (decoder->device, + GST_VIDEO_INFO_FORMAT (info), &d3d11_format) || + d3d11_format.dxgi_format == DXGI_FORMAT_UNKNOWN) { GST_ERROR_OBJECT (decoder, "Could not determine dxgi format from %s", gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (info))); return FALSE; @@ -736,7 +736,7 @@ gst_d3d11_decoder_configure (GstD3D11Decoder * decoder, decoder->coded_width = coded_width; decoder->coded_height = coded_height; decoder->dpb_size = dpb_size; - decoder->decoder_format = d3d11_format->dxgi_format; + decoder->decoder_format = d3d11_format.dxgi_format; decoder->configured = TRUE; diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp index 08c04e5409..81c36fd2ce 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp @@ -599,7 +599,7 @@ gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer, gsize offset[GST_VIDEO_MAX_PLANES] = { 0, }; guint i; gsize size = 0; - const GstD3D11Format *format; + GstD3D11Format format; D3D11_TEXTURE2D_DESC desc; for (i = 0; i < gst_buffer_n_memory (buffer); i++) { @@ -614,9 +614,8 @@ gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer, dmem = (GstD3D11Memory *) gst_buffer_peek_memory (buffer, 0); device = dmem->device; - format = gst_d3d11_device_format_from_gst (device, - GST_VIDEO_INFO_FORMAT (info)); - if (!format) { + if (!gst_d3d11_device_get_format (device, GST_VIDEO_INFO_FORMAT (info), + &format)) { GST_ERROR ("Unknown d3d11 format"); return NULL; } @@ -660,7 +659,7 @@ gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer, } /* single texture semi-planar formats */ - if (format->dxgi_format != DXGI_FORMAT_UNKNOWN && + if (format.dxgi_format != DXGI_FORMAT_UNKNOWN && GST_VIDEO_INFO_N_PLANES (info) == 2) { stride[1] = stride[0]; offset[1] = stride[0] * desc.Height; diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11upload.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11upload.cpp index b9b286da1b..05b0b3bcef 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11upload.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11upload.cpp @@ -299,7 +299,7 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query) GstStructure *config; gboolean update_pool = FALSE; GstVideoInfo vinfo; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; GstD3D11AllocationParams *d3d11_params; guint bind_flags = 0; guint i; @@ -315,17 +315,16 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query) gst_video_info_from_caps (&vinfo, outcaps); - d3d11_format = gst_d3d11_device_format_from_gst (filter->device, - GST_VIDEO_INFO_FORMAT (&vinfo)); - if (!d3d11_format) { + if (!gst_d3d11_device_get_format (filter->device, + GST_VIDEO_INFO_FORMAT (&vinfo), &d3d11_format)) { GST_ERROR_OBJECT (filter, "Unknown format caps %" GST_PTR_FORMAT, outcaps); return FALSE; } - if (d3d11_format->dxgi_format == DXGI_FORMAT_UNKNOWN) { - dxgi_format = d3d11_format->resource_format[0]; + if (d3d11_format.dxgi_format == DXGI_FORMAT_UNKNOWN) { + dxgi_format = d3d11_format.resource_format[0]; } else { - dxgi_format = d3d11_format->dxgi_format; + dxgi_format = d3d11_format.dxgi_format; } device_handle = gst_d3d11_device_get_device_handle (filter->device); diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp index 3f90dd7987..d0cba93586 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp @@ -664,14 +664,16 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, if (chosen_colorspace) { const GstDxgiColorSpace *in_color_space = gst_d3d11_video_info_to_dxgi_color_space (&window->info); - const GstD3D11Format *in_format = - gst_d3d11_device_format_from_gst (window->device, - GST_VIDEO_INFO_FORMAT (&window->info)); + GstD3D11Format in_format; gboolean hardware = FALSE; GstD3D11VideoProcessor *processor = NULL; + DXGI_FORMAT in_dxgi_format; - if (in_color_space && in_format && - in_format->dxgi_format != DXGI_FORMAT_UNKNOWN) { + gst_d3d11_device_get_format (window->device, + GST_VIDEO_INFO_FORMAT (&window->info), &in_format); + in_dxgi_format = in_format.dxgi_format; + + if (in_color_space && in_format.dxgi_format != DXGI_FORMAT_UNKNOWN) { g_object_get (window->device, "hardware", &hardware, NULL); } @@ -683,7 +685,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width, } if (processor) { - DXGI_FORMAT in_dxgi_format = in_format->dxgi_format; DXGI_FORMAT out_dxgi_format = chosen_format->dxgi_format; DXGI_COLOR_SPACE_TYPE in_dxgi_color_space = (DXGI_COLOR_SPACE_TYPE) in_color_space->dxgi_color_space_type; diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_dummy.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_dummy.cpp index a4e1715019..7cffb5bdbb 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_dummy.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_dummy.cpp @@ -117,9 +117,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window, { const GstDxgiColorSpace *in_color_space = gst_d3d11_video_info_to_dxgi_color_space (&window->info); - const GstD3D11Format *in_format = - gst_d3d11_device_format_from_gst (window->device, - GST_VIDEO_INFO_FORMAT (&window->info)); + GstD3D11Format in_format; gboolean hardware = FALSE; GstD3D11VideoProcessor *processor = NULL; guint i; @@ -128,9 +126,13 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM }; + DXGI_FORMAT in_dxgi_format; - if (in_color_space && in_format && - in_format->dxgi_format != DXGI_FORMAT_UNKNOWN) { + gst_d3d11_device_get_format (window->device, + GST_VIDEO_INFO_FORMAT (&window->info), &in_format); + in_dxgi_format = in_format.dxgi_format; + + if (in_color_space && in_format.dxgi_format != DXGI_FORMAT_UNKNOWN) { g_object_get (window->device, "hardware", &hardware, NULL); } @@ -143,7 +145,6 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window, /* Check if video processor can support all possible output dxgi formats */ for (i = 0; i < G_N_ELEMENTS (formats_to_check) && processor; i++) { - DXGI_FORMAT in_dxgi_format = in_format->dxgi_format; DXGI_FORMAT out_dxgi_format = formats_to_check[i]; DXGI_COLOR_SPACE_TYPE in_dxgi_color_space = (DXGI_COLOR_SPACE_TYPE) in_color_space->dxgi_color_space_type; diff --git a/subprojects/gst-plugins-bad/sys/mediafoundation/plugin.cpp b/subprojects/gst-plugins-bad/sys/mediafoundation/plugin.cpp index bb65508e43..70c477fe32 100644 --- a/subprojects/gst-plugins-bad/sys/mediafoundation/plugin.cpp +++ b/subprojects/gst-plugins-bad/sys/mediafoundation/plugin.cpp @@ -122,7 +122,7 @@ get_d3d11_devices (void) for (i = 0; i < 12; i++) { GstD3D11Device *device; gboolean is_hardware = FALSE; - const GstD3D11Format *d3d11_format; + GstD3D11Format d3d11_format; ID3D11Device *device_handle; D3D11_FEATURE_DATA_D3D11_OPTIONS4 options = { 0, }; UINT supported = 0; @@ -141,9 +141,9 @@ get_d3d11_devices (void) } /* device can support NV12 format? */ - d3d11_format = - gst_d3d11_device_format_from_gst (device, GST_VIDEO_FORMAT_NV12); - if (!d3d11_format || d3d11_format->dxgi_format != DXGI_FORMAT_NV12) { + if (!gst_d3d11_device_get_format (device, + GST_VIDEO_FORMAT_NV12, &d3d11_format) || + d3d11_format.dxgi_format != DXGI_FORMAT_NV12) { GST_DEBUG_OBJECT (device, "Given d3d11 device cannot support NV12 format"); gst_object_unref (device);