mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
d3d11: Add an utility method for DXGI colorspace conversion
Add a method for DXGI_COLOR_SPACE_TYPE -> GstVideoColorimetry conversion Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2729>
This commit is contained in:
parent
f3d51ef235
commit
59d92ea62c
2 changed files with 154 additions and 0 deletions
|
@ -524,6 +524,157 @@ gst_d3d11_video_info_to_dxgi_color_space (const GstVideoInfo * info,
|
||||||
return gst_d3d11_video_info_to_dxgi_color_space_yuv (info, color_space);
|
return gst_d3d11_video_info_to_dxgi_color_space_yuv (info, color_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_d3d11_colorimetry_from_dxgi_color_space (DXGI_COLOR_SPACE_TYPE colorspace,
|
||||||
|
GstVideoColorimetry * colorimetry)
|
||||||
|
{
|
||||||
|
/* XXX: because of ancient MinGW header */
|
||||||
|
GST_DXGI_COLOR_SPACE_TYPE type = (GST_DXGI_COLOR_SPACE_TYPE) colorspace;
|
||||||
|
GstVideoColorimetry color;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SRGB;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_GAMMA10;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT709;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT2020_10;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT601;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT601;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT601;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT709;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT709;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT709;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT709;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT2020_10;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT2020_10;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SMPTE2084;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SMPTE2084;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_BT2020_10;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SMPTE2084;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SMPTE2084;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_ARIB_STD_B67;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_ARIB_STD_B67;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SRGB;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SRGB;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SRGB;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
||||||
|
break;
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020:
|
||||||
|
case GST_DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020:
|
||||||
|
color.range = GST_VIDEO_COLOR_RANGE_16_235;
|
||||||
|
color.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
|
color.transfer = GST_VIDEO_TRANSFER_SRGB;
|
||||||
|
color.primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*colorimetry = color;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_d3d11_find_swap_chain_color_space (const GstVideoInfo * info,
|
gst_d3d11_find_swap_chain_color_space (const GstVideoInfo * info,
|
||||||
IDXGISwapChain3 * swapchain, GstDxgiColorSpace * color_space)
|
IDXGISwapChain3 * swapchain, GstDxgiColorSpace * color_space)
|
||||||
|
|
|
@ -70,6 +70,9 @@ gboolean gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInf
|
||||||
gboolean gst_d3d11_video_info_to_dxgi_color_space (const GstVideoInfo * info,
|
gboolean gst_d3d11_video_info_to_dxgi_color_space (const GstVideoInfo * info,
|
||||||
GstDxgiColorSpace * color_space);
|
GstDxgiColorSpace * color_space);
|
||||||
|
|
||||||
|
gboolean gst_d3d11_colorimetry_from_dxgi_color_space (DXGI_COLOR_SPACE_TYPE colorspace,
|
||||||
|
GstVideoColorimetry * colorimetry);
|
||||||
|
|
||||||
gboolean gst_d3d11_find_swap_chain_color_space (const GstVideoInfo * info,
|
gboolean gst_d3d11_find_swap_chain_color_space (const GstVideoInfo * info,
|
||||||
IDXGISwapChain3 * swapchain,
|
IDXGISwapChain3 * swapchain,
|
||||||
GstDxgiColorSpace * color_space);
|
GstDxgiColorSpace * color_space);
|
||||||
|
|
Loading…
Reference in a new issue