[vlc-commits] direct3d11: add support for YUY2/YUYV 4:2:2 rendering
Steve Lhomme
git at videolan.org
Fri Jul 29 00:35:47 CEST 2016
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Jul 28 17:20:04 2016 +0200| [5d8684b808eff1290daeb52b09dd703ee7e45353] | committer: Jean-Baptiste Kempf
direct3d11: add support for YUY2/YUYV 4:2:2 rendering
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5d8684b808eff1290daeb52b09dd703ee7e45353
---
modules/video_chroma/dxgi_fmt.c | 2 +-
modules/video_output/win32/direct3d11.c | 66 +++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/modules/video_chroma/dxgi_fmt.c b/modules/video_chroma/dxgi_fmt.c
index 066bae4..bd8cef0 100644
--- a/modules/video_chroma/dxgi_fmt.c
+++ b/modules/video_chroma/dxgi_fmt.c
@@ -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
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 187ebb5..160b58d 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -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)
{
@@ -1176,6 +1234,14 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
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;
if (sys->d3dregion_format != DXGI_FORMAT_UNKNOWN)
More information about the vlc-commits
mailing list