diff options
author | Seungha Yang <seungha@centricular.com> | 2020-11-01 03:58:30 +0900 |
---|---|---|
committer | Seungha Yang <seungha@centricular.com> | 2020-11-02 18:48:58 +0900 |
commit | a52fc6deeda203add520cb59ae0026d109ecda95 (patch) | |
tree | 627e63510864238b06f297b67c77d5229b1227e0 /sys | |
parent | a3a7e21f8716c054ba175fd464411212302b5c03 (diff) | |
download | gstreamer-plugins-bad-a52fc6deeda203add520cb59ae0026d109ecda95.tar.gz |
d3d11decoder: Use D3D11/DXGI standard colorimetry
D3D11/DXGI supports smaller set of colorimetry than all possible
combination. This restriction would make more streams convertible
by using ID3D11VideoProcessor
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1743>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/d3d11/gstd3d11decoder.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/d3d11/gstd3d11decoder.c b/sys/d3d11/gstd3d11decoder.c index 28c3e6a50..093b81ef3 100644 --- a/sys/d3d11/gstd3d11decoder.c +++ b/sys/d3d11/gstd3d11decoder.c @@ -56,6 +56,7 @@ #include "gstd3d11bufferpool.h" #include "gstd3d11device.h" #include "gstd3d11colorconverter.h" +#include "gstd3d11format.h" #include <string.h> GST_DEBUG_CATEGORY (d3d11_decoder_debug); @@ -1408,6 +1409,7 @@ gst_d3d11_decoder_negotiate (GstVideoDecoder * decoder, { GstCaps *peer_caps; GstVideoCodecState *state; + GstVideoInfo out_info; g_return_val_if_fail (GST_IS_VIDEO_DECODER (decoder), FALSE); g_return_val_if_fail (input_state != NULL, FALSE); @@ -1419,7 +1421,43 @@ gst_d3d11_decoder_negotiate (GstVideoDecoder * decoder, state = gst_video_decoder_set_output_state (decoder, format, width, height, input_state); - state->caps = gst_video_info_to_caps (&state->info); + out_info = state->info; +#if (DXGI_HEADER_VERSION >= 4) + { + /* Supported DXGI colorspace by driver might be limited and + * decision criteria of default colorimetry doesn't look well fit + * with D3D11/DXGI colorspace preference. Apply our rule here */ + const GstDxgiColorSpace *colorspace; +#ifndef GST_DISABLE_GST_DEBUG + gchar *colorimetry; +#endif + + out_info.colorimetry = input_state->info.colorimetry; + colorspace = gst_d3d11_video_info_to_dxgi_color_space (&out_info); + +#ifndef GST_DISABLE_GST_DEBUG + colorimetry = gst_video_colorimetry_to_string (&out_info.colorimetry); + if (colorspace) { + GST_DEBUG_OBJECT (decoder, + "Use DXGI colorspace %d (input colorimetry %s)", + colorspace->dxgi_color_space_type, GST_STR_NULL (colorimetry)); + } else { + GST_WARNING_OBJECT (decoder, + "Cannot determin DXGI color space from input colorimetry %s", + GST_STR_NULL (colorimetry)); + } + g_free (colorimetry); +#endif + + if (colorspace) { + out_info.colorimetry.matrix = colorspace->matrix; + out_info.colorimetry.primaries = colorspace->primaries; + out_info.colorimetry.range = colorspace->range; + out_info.colorimetry.transfer = colorspace->transfer; + } + } +#endif + state->caps = gst_video_info_to_caps (&out_info); if (*output_state) gst_video_codec_state_unref (*output_state); |