[vlc-commits] direct3d11: use P010 for all pixel formats with more than 8 bits per channel

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 15:27:40 2016 +0200| [6208f0af972a113dc7647742ef0c05dac6a18cc3] | committer: Jean-Baptiste Kempf

direct3d11: use P010 for all pixel formats with more than 8 bits per channel

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6208f0af972a113dc7647742ef0c05dac6a18cc3
---

 modules/video_chroma/chain.c            |  1 +
 modules/video_chroma/dxgi_fmt.c         |  2 +-
 modules/video_output/win32/common.c     |  3 ++-
 modules/video_output/win32/direct3d11.c | 42 +++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index acf8b30..131b9a7 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -63,6 +63,7 @@ static void EsFormatMergeSize( es_format_t *p_dst,
 static const vlc_fourcc_t pi_allowed_chromas[] = {
     VLC_CODEC_I420,
     VLC_CODEC_I422,
+    VLC_CODEC_I420_10L,
     VLC_CODEC_RGB32,
     VLC_CODEC_RGB24,
     0
diff --git a/modules/video_chroma/dxgi_fmt.c b/modules/video_chroma/dxgi_fmt.c
index 61f7a99..066bae4 100644
--- a/modules/video_chroma/dxgi_fmt.c
+++ b/modules/video_chroma/dxgi_fmt.c
@@ -60,6 +60,7 @@ static const dxgi_format_t dxgi_formats[] = {
 static const d3d_format_t d3d_formats[] = {
     { "NV12",     DXGI_FORMAT_NV12,           VLC_CODEC_NV12,              8, DXGI_FORMAT_R8_UNORM,       DXGI_FORMAT_R8G8_UNORM },
     { "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 },
 #ifdef BROKEN_PIXEL
     { "YUY2",     DXGI_FORMAT_YUY2,           VLC_CODEC_I422,          8, DXGI_FORMAT_R8G8B8A8_UNORM,     0 },
@@ -67,7 +68,6 @@ static const d3d_format_t d3d_formats[] = {
     { "Y416",     DXGI_FORMAT_Y416,           VLC_CODEC_I444_16L,     16, DXGI_FORMAT_R16G16B16A16_UINT,  0 },
 #endif
 #ifdef UNTESTED
-    { "P010",     DXGI_FORMAT_P010,           VLC_CODEC_P010,         10, DXGI_FORMAT_R16_UNORM,          DXGI_FORMAT_R16G16_UNORM },
     { "Y210",     DXGI_FORMAT_Y210,           VLC_CODEC_I422_10L,     10, DXGI_FORMAT_R16G16B16A16_UNORM, 0 },
     { "Y410",     DXGI_FORMAT_Y410,           VLC_CODEC_I444,         10, DXGI_FORMAT_R10G10B10A2_UNORM,  0 },
     { "NV11",     DXGI_FORMAT_NV11,           VLC_CODEC_I411,          8, DXGI_FORMAT_R8_UNORM,           DXGI_FORMAT_R8G8_UNORM },
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index c15a8f9..cbd236d 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -457,7 +457,8 @@ int CommonUpdatePicture(picture_t *picture, picture_t **fallback,
 
     /*  Fill chroma planes for biplanar YUV */
     if (picture->format.i_chroma == VLC_CODEC_NV12 ||
-        picture->format.i_chroma == VLC_CODEC_NV21) {
+        picture->format.i_chroma == VLC_CODEC_NV21 ||
+        picture->format.i_chroma == VLC_CODEC_P010) {
 
         for (int n = 1; n < picture->i_planes; n++) {
             const plane_t *o = &picture->p[n-1];
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 65f93a4..187ebb5 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1077,6 +1077,48 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
         }
     }
 
+    // look for any pixel format that we can handle with enough pixels per channel
+    if ( !fmt->i_chroma )
+    {
+        uint8_t bits_per_channel;
+        switch (i_src_chroma)
+        {
+        case VLC_CODEC_D3D11_OPAQUE:
+            bits_per_channel = 8;
+            break;
+        case VLC_CODEC_D3D11_OPAQUE_10B:
+            bits_per_channel = 10;
+            break;
+        default:
+            {
+                const vlc_chroma_description_t *p_format = vlc_fourcc_GetChromaDescription(i_src_chroma);
+                bits_per_channel = p_format == NULL || p_format->pixel_bits == 0 ? 8 : p_format->pixel_bits;
+            }
+            break;
+        }
+
+        for (const d3d_format_t *output_format = GetRenderFormatList();
+             output_format->name != NULL; ++output_format)
+        {
+            if( bits_per_channel <= output_format->bitsPerChannel )
+            {
+                if( SUCCEEDED( ID3D11Device_CheckFormatSupport(sys->d3ddevice,
+                                                               output_format->formatTexture,
+                                                               &i_formatSupport)) &&
+                        ( i_formatSupport & i_quadSupportFlags ) == i_quadSupportFlags )
+                {
+                    msg_Dbg( vd, "Using pixel format %s for chroma %4.4s", output_format->name,
+                                 (char *)&i_src_chroma );
+                    fmt->i_chroma = output_format->fourcc;
+                    DxgiFormatMask( output_format->formatTexture, fmt );
+                    sys->picQuadConfig.textureFormat      = output_format->formatTexture;
+                    sys->picQuadConfig.resourceFormatYRGB = output_format->formatY;
+                    sys->picQuadConfig.resourceFormatUV   = output_format->formatUV;
+                    break;
+                }
+            }
+        }
+    }
     // look for any pixel format that we can handle
     if ( !fmt->i_chroma )
     {



More information about the vlc-commits mailing list