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

Thomas Guillem git at videolan.org
Mon Mar 19 12:15:37 CET 2018


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

d3d11: handle VLC_CODEC_D3D11_OPAQUE_10B upload/download

(cherry picked from commit 258d7340bbd9df07fb110398185d6fde0c56076f)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/hw/d3d11/d3d11_surface.c | 44 ++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 2298097c47..7f360f3135 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -379,7 +379,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
@@ -388,15 +389,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) {
         uint8_t *tmp = dst->p[1].p_pixels;
         dst->p[1].p_pixels = dst->p[2].p_pixels;
         dst->p[2].p_pixels = tmp;
@@ -496,7 +502,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
@@ -650,20 +656,38 @@ 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 )
+    if ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_D3D11_OPAQUE &&
+         p_filter->fmt_in.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
          || 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 )
+            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 )
+            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;
     default:
         return VLC_EGENERIC;
@@ -679,7 +703,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;
@@ -693,7 +717,8 @@ int D3D11OpenCPUConverter( vlc_object_t *obj )
     filter_t *p_cpu_filter = NULL;
     video_format_t fmt_staging;
 
-    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
@@ -702,6 +727,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