Commit 5d8684b8 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

direct3d11: add support for YUY2/YUYV 4:2:2 rendering

parent 938f50d4
......@@ -62,8 +62,8 @@ static const d3d_format_t d3d_formats[] = {
{ "VA_NV12", DXGI_FORMAT_NV12, VLC_CODEC_D3D11_OPAQUE, 8, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM },
{ "P010", DXGI_FORMAT_P010, VLC_CODEC_P010, 10, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM },
{ "VA_P010", DXGI_FORMAT_P010, VLC_CODEC_D3D11_OPAQUE_10B, 10, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM },
{ "YUY2", DXGI_FORMAT_YUY2, VLC_CODEC_YUYV, 8, DXGI_FORMAT_R8G8B8A8_UNORM, 0 },
#ifdef BROKEN_PIXEL
{ "YUY2", DXGI_FORMAT_YUY2, VLC_CODEC_I422, 8, DXGI_FORMAT_R8G8B8A8_UNORM, 0 },
{ "AYUV", DXGI_FORMAT_AYUV, VLC_CODEC_YUVA, 8, DXGI_FORMAT_R8G8B8A8_UNORM, 0 },
{ "Y416", DXGI_FORMAT_Y416, VLC_CODEC_I444_16L, 16, DXGI_FORMAT_R16G16B16A16_UINT, 0 },
#endif
......
......@@ -269,6 +269,64 @@ static const char *globPixelShaderBiplanarYUV_BT709_2RGB = "\
}\
";
static const char *globPixelShaderBiplanarYUYV_BT709_2RGB = "\
Texture2D shaderTextureYUYV;\
SamplerState SampleType;\
\
struct PS_INPUT\
{\
float4 Position : SV_POSITION;\
float2 Texture : TEXCOORD0;\
float Opacity : OPACITY;\
};\
\
float4 PS( PS_INPUT In ) : SV_TARGET\
{\
float3 yuv;\
float4 rgba;\
yuv.x = shaderTextureYUYV.Sample(SampleType, In.Texture).x;\
yuv.y = shaderTextureYUYV.Sample(SampleType, In.Texture).y;\
yuv.z = shaderTextureYUYV.Sample(SampleType, In.Texture).a;\
yuv.x = 1.164383561643836 * (yuv.x-0.0625);\
yuv.y = yuv.y - 0.5;\
yuv.z = yuv.z - 0.5;\
rgba.x = saturate(yuv.x + 1.792741071428571 * yuv.z);\
rgba.y = saturate(yuv.x - 0.532909328559444 * yuv.z - 0.21324861427373 * yuv.y);\
rgba.z = saturate(yuv.x + 2.112401785714286 * yuv.y);\
rgba.a = In.Opacity;\
return rgba;\
}\
";
static const char *globPixelShaderBiplanarYUYV_BT601_2RGB = "\
Texture2D shaderTextureYUYV;\
SamplerState SampleType;\
\
struct PS_INPUT\
{\
float4 Position : SV_POSITION;\
float2 Texture : TEXCOORD0;\
float Opacity : OPACITY;\
};\
\
float4 PS( PS_INPUT In ) : SV_TARGET\
{\
float3 yuv;\
float4 rgba;\
yuv.x = shaderTextureYUYV.Sample(SampleType, In.Texture).x;\
yuv.y = shaderTextureYUYV.Sample(SampleType, In.Texture).y;\
yuv.z = shaderTextureYUYV.Sample(SampleType, In.Texture).a;\
yuv.x = 1.164383561643836 * (yuv.x-0.0625);\
yuv.y = yuv.y - 0.5;\
yuv.z = yuv.z - 0.5;\
rgba.x = saturate(yuv.x + 1.596026785714286 * yuv.z);\
rgba.y = saturate(yuv.x - 0.812967647237771 * yuv.z - 0.391762290094914 * yuv.y);\
rgba.z = saturate(yuv.x + 2.017232142857142 * yuv.y);\
rgba.a = In.Opacity;\
return rgba;\
}\
";
#if !VLC_WINSTORE_APP
static int OpenHwnd(vout_display_t *vd)
{
......@@ -1175,6 +1233,14 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
else
sys->d3dPxShader = globPixelShaderBiplanarYUV_BT601_2RGB;
}
else
if (fmt->i_chroma == VLC_CODEC_YUYV)
{
if( fmt->i_height > 576 )
sys->d3dPxShader = globPixelShaderBiplanarYUYV_BT709_2RGB;
else
sys->d3dPxShader = globPixelShaderBiplanarYUYV_BT601_2RGB;
}
else
sys->d3dPxShader = globPixelShaderDefault;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment