[vlc-commits] d3d11: handle VLC_CODEC_D3D11_OPAQUE_10B upload/download

Thomas Guillem git at videolan.org
Fri Mar 16 16:08:31 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar  9 18:38:29 2018 +0100| [258d7340bbd9df07fb110398185d6fde0c56076f] | committer: Thomas Guillem

d3d11: handle VLC_CODEC_D3D11_OPAQUE_10B upload/download

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

 modules/hw/d3d11/d3d11_surface.c | 46 +++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index f6b59df86c..4ffcce533c 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -376,7 +376,8 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
         Copy420_P_to_P(dst, plane, pitch,
                        src->format.i_visible_height + src->format.i_y_offset,
                        &sys->cache);
-    } else if (desc.Format == DXGI_FORMAT_NV12) {
+    } else if (desc.Format == DXGI_FORMAT_NV12 ||
+               desc.Format == DXGI_FORMAT_P010) {
         const uint8_t *plane[2] = {
             lock.pData,
             (uint8_t*)lock.pData + lock.RowPitch * desc.Height
@@ -385,15 +386,20 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
             lock.RowPitch,
             lock.RowPitch,
         };
-        Copy420_SP_to_P(dst, plane, pitch,
-                        __MIN(desc.Height, src->format.i_y_offset + src->format.i_visible_height),
-                        &sys->cache);
+        if (desc.Format == DXGI_FORMAT_NV12)
+            Copy420_SP_to_P(dst, plane, pitch,
+                            __MIN(desc.Height, src->format.i_y_offset + src->format.i_visible_height),
+                            &sys->cache);
+        else
+            Copy420_16_SP_to_P(dst, plane, pitch,
+                               __MIN(desc.Height, src->format.i_y_offset + src->format.i_visible_height),
+                               6, &sys->cache);
         picture_SwapUV(dst);
     } else {
         msg_Err(p_filter, "Unsupported D3D11VA conversion from 0x%08X to YV12", desc.Format);
     }
 
-    if (dst->format.i_chroma == VLC_CODEC_I420)
+    if (dst->format.i_chroma == VLC_CODEC_I420 || dst->format.i_chroma == VLC_CODEC_I420_10L)
         picture_SwapUV( dst );
 
     /* */
@@ -490,7 +496,7 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
 
     ID3D11Texture2D_GetDesc(sys->staging, &desc);
 
-    if (desc.Format == DXGI_FORMAT_NV12) {
+    if (desc.Format == DXGI_FORMAT_NV12 || desc.Format == DXGI_FORMAT_P010) {
         const uint8_t *plane[2] = {
             lock.pData,
             (uint8_t*)lock.pData + lock.RowPitch * desc.Height
@@ -690,6 +696,7 @@ int D3D11OpenConverter( vlc_object_t *obj )
     filter_t *p_filter = (filter_t *)obj;
 
     if ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE &&
+         p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_10B && 
          p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_RGBA &&
          p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_BGRA )
         return VLC_EGENERIC;
@@ -698,25 +705,38 @@ int D3D11OpenConverter( vlc_object_t *obj )
          || p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width )
         return VLC_EGENERIC;
 
+    uint8_t pixel_bytes = 1;
     switch( p_filter->fmt_out.video.i_chroma ) {
     case VLC_CODEC_I420:
     case VLC_CODEC_YV12:
-        if (p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE)
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE )
+            return VLC_EGENERIC;
+        p_filter->pf_video_filter = D3D11_YUY2_Filter;
+        break;
+    case VLC_CODEC_I420_10L:
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_10B )
             return VLC_EGENERIC;
         p_filter->pf_video_filter = D3D11_YUY2_Filter;
+        pixel_bytes = 2;
         break;
     case VLC_CODEC_NV12:
-        if (p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE)
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE )
+            return VLC_EGENERIC;
+        p_filter->pf_video_filter = D3D11_NV12_Filter;
+        break;
+    case VLC_CODEC_P010:
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_10B )
             return VLC_EGENERIC;
         p_filter->pf_video_filter = D3D11_NV12_Filter;
+        pixel_bytes = 2;
         break;
     case VLC_CODEC_RGBA:
-        if (p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_RGBA)
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_RGBA )
             return VLC_EGENERIC;
         p_filter->pf_video_filter = D3D11_RGBA_Filter;
         break;
     case VLC_CODEC_BGRA:
-        if (p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_BGRA)
+        if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_BGRA )
             return VLC_EGENERIC;
         p_filter->pf_video_filter = D3D11_RGBA_Filter;
         break;
@@ -734,7 +754,7 @@ int D3D11OpenConverter( vlc_object_t *obj )
         return VLC_EGENERIC;
     }
 
-    CopyInitCache(&p_sys->cache, p_filter->fmt_in.video.i_width );
+    CopyInitCache(&p_sys->cache, p_filter->fmt_in.video.i_width * pixel_bytes);
     vlc_mutex_init(&p_sys->staging_lock);
     p_filter->p_sys = p_sys;
     return VLC_SUCCESS;
@@ -749,7 +769,8 @@ int D3D11OpenCPUConverter( vlc_object_t *obj )
     video_format_t fmt_staging;
     filter_sys_t *p_sys = NULL;
 
-    if ( p_filter->fmt_out.video.i_chroma != VLC_CODEC_D3D11_OPAQUE )
+    if ( p_filter->fmt_out.video.i_chroma != VLC_CODEC_D3D11_OPAQUE
+     &&  p_filter->fmt_out.video.i_chroma != VLC_CODEC_D3D11_OPAQUE_10B )
         return VLC_EGENERIC;
 
     if ( p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
@@ -758,6 +779,7 @@ int D3D11OpenCPUConverter( vlc_object_t *obj )
 
     switch( p_filter->fmt_in.video.i_chroma ) {
     case VLC_CODEC_I420:
+    case VLC_CODEC_I420_10L:
     case VLC_CODEC_YV12:
     case VLC_CODEC_NV12:
     case VLC_CODEC_P010:



More information about the vlc-commits mailing list