[vlc-commits] hw:d3d11: make assert_ProcessorInput() generic

Steve Lhomme git at videolan.org
Mon May 28 13:25:03 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Nov 30 12:07:35 2017 +0100| [ad485d9f61b5a9a6eaf96661eac26a13a8b1408e] | committer: Steve Lhomme

hw:d3d11: make assert_ProcessorInput() generic

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

 modules/hw/d3d11/d3d11_deinterlace.c | 37 +++------------------------
 modules/hw/d3d11/d3d11_filters.c     | 31 +----------------------
 modules/hw/d3d11/d3d11_processor.c   | 26 +++++++++++++++++++
 modules/hw/d3d11/d3d11_processor.h   |  3 +++
 modules/hw/d3d11/d3d11_surface.c     | 48 +++++-------------------------------
 5 files changed, 40 insertions(+), 105 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index b0d6d87e21..c26f1c322a 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -84,35 +84,6 @@ static struct filter_mode_t filter_mode [] = {
                  { true,  true,  false, false } },
 };
 
-static int assert_ProcessorInput(filter_t *p_filter, picture_sys_t *p_sys_src)
-{
-    filter_sys_t *p_sys = p_filter->p_sys;
-    if (!p_sys_src->processorInput)
-    {
-        D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inDesc = {
-            .FourCC = 0,
-            .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
-            .Texture2D.MipSlice = 0,
-            .Texture2D.ArraySlice = p_sys_src->slice_index,
-        };
-        HRESULT hr;
-
-        hr = ID3D11VideoDevice_CreateVideoProcessorInputView(p_sys->d3d_proc.d3dviddev,
-                                                             p_sys_src->resource[KNOWN_DXGI_INDEX],
-                                                             p_sys->d3d_proc.procEnumerator,
-                                                             &inDesc,
-                                                             &p_sys_src->processorInput);
-        if (FAILED(hr))
-        {
-#ifndef NDEBUG
-            msg_Dbg(p_filter,"Failed to create processor input for slice %d. (hr=0x%lX)", p_sys_src->slice_index, hr);
-#endif
-            return VLC_EGENERIC;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 static void Flush(filter_t *filter)
 {
     filter_sys_t *p_sys = filter->p_sys;
@@ -145,17 +116,17 @@ static int RenderPic( filter_t *p_filter, picture_t *p_outpic, picture_t *p_pic,
     if( p_cur && p_next )
     {
         picture_sys_t *picsys_next = ActivePictureSys(p_next);
-        if ( unlikely(!picsys_next) || assert_ProcessorInput(p_filter, picsys_next) )
+        if ( unlikely(!picsys_next) || FAILED(D3D11_Assert_ProcessorInput(p_filter, &p_sys->d3d_proc, picsys_next) ))
             return VLC_EGENERIC;
 
         picture_sys_t *picsys_cur = ActivePictureSys(p_cur);
-        if ( unlikely(!picsys_cur) || assert_ProcessorInput(p_filter, picsys_cur) )
+        if ( unlikely(!picsys_cur) || FAILED( D3D11_Assert_ProcessorInput(p_filter, &p_sys->d3d_proc, picsys_cur) ))
             return VLC_EGENERIC;
 
         if ( p_prev )
         {
             picture_sys_t *picsys_prev = ActivePictureSys(p_prev);
-            if ( unlikely(!picsys_prev) || assert_ProcessorInput(p_filter, picsys_prev) )
+            if ( unlikely(!picsys_prev) || FAILED( D3D11_Assert_ProcessorInput(p_filter, &p_sys->d3d_proc, picsys_prev) ))
                 return VLC_EGENERIC;
 
             stream.pInputSurface    = picsys_cur->processorInput;
@@ -176,7 +147,7 @@ static int RenderPic( filter_t *p_filter, picture_t *p_outpic, picture_t *p_pic,
     else
     {
         picture_sys_t *p_sys_src = ActivePictureSys(p_pic);
-        if ( unlikely(!p_sys_src) || assert_ProcessorInput(p_filter, p_sys_src) )
+        if ( unlikely(!p_sys_src) || FAILED( D3D11_Assert_ProcessorInput(p_filter, &p_sys->d3d_proc, p_sys_src) ))
             return VLC_EGENERIC;
 
         /* first single frame */
diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index a594c2b342..7dd801e39c 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -100,35 +100,6 @@ static const char *const ppsz_filter_options[] = {
     "brightness-threshold", NULL
 };
 
-static int assert_ProcessorInput(filter_t *p_filter, picture_sys_t *p_sys_src)
-{
-    filter_sys_t *p_sys = p_filter->p_sys;
-    if (!p_sys_src->processorInput)
-    {
-        D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inDesc = {
-            .FourCC = 0,
-            .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
-            .Texture2D.MipSlice = 0,
-            .Texture2D.ArraySlice = p_sys_src->slice_index,
-        };
-        HRESULT hr;
-
-        hr = ID3D11VideoDevice_CreateVideoProcessorInputView(p_sys->d3d_proc.d3dviddev,
-                                                             p_sys_src->resource[KNOWN_DXGI_INDEX],
-                                                             p_sys->d3d_proc.procEnumerator,
-                                                             &inDesc,
-                                                             &p_sys_src->processorInput);
-        if (FAILED(hr))
-        {
-#ifndef NDEBUG
-            msg_Dbg(p_filter,"Failed to create processor input for slice %d. (hr=0x%lX)", p_sys_src->slice_index, hr);
-#endif
-            return VLC_EGENERIC;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 static bool ApplyFilter( filter_sys_t *p_sys,
                          D3D11_VIDEO_PROCESSOR_FILTER filter,
                          struct filter_level *p_level,
@@ -220,7 +191,7 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic)
     filter_sys_t *p_sys = p_filter->p_sys;
 
     picture_sys_t *p_src_sys = ActivePictureSys(p_pic);
-    if ( assert_ProcessorInput(p_filter, ActivePictureSys(p_pic) ) )
+    if (FAILED( D3D11_Assert_ProcessorInput(p_filter, &p_sys->d3d_proc, p_src_sys) ))
     {
         picture_Release( p_pic );
         return NULL;
diff --git a/modules/hw/d3d11/d3d11_processor.c b/modules/hw/d3d11/d3d11_processor.c
index 2688077a71..d1a29b91e4 100644
--- a/modules/hw/d3d11/d3d11_processor.c
+++ b/modules/hw/d3d11/d3d11_processor.c
@@ -143,4 +143,30 @@ void D3D11_ReleaseProcessor(d3d11_processor_t *out)
         out->d3dvidctx = NULL;
     }
 }
+
+#undef D3D11_Assert_ProcessorInput
+HRESULT D3D11_Assert_ProcessorInput(vlc_object_t *o, d3d11_processor_t *d3d_proc, picture_sys_t *p_sys)
+{
+    if (p_sys->processorInput)
+        return S_OK;
+
+    D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inDesc = {
+        .FourCC = 0,
+        .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
+        .Texture2D.MipSlice = 0,
+        .Texture2D.ArraySlice = p_sys->slice_index,
+    };
+    HRESULT hr;
+
+    hr = ID3D11VideoDevice_CreateVideoProcessorInputView(d3d_proc->d3dviddev,
+                                                         p_sys->resource[KNOWN_DXGI_INDEX],
+                                                         d3d_proc->procEnumerator,
+                                                         &inDesc,
+                                                         &p_sys->processorInput);
+#ifndef NDEBUG
+    if (FAILED(hr))
+        msg_Dbg(o,"Failed to create processor input for slice %d. (hr=0x%lX)", p_sys->slice_index, hr);
+#endif
+    return hr;
+}
 #endif
diff --git a/modules/hw/d3d11/d3d11_processor.h b/modules/hw/d3d11/d3d11_processor.h
index 17fae1d92c..b4bd124b03 100644
--- a/modules/hw/d3d11/d3d11_processor.h
+++ b/modules/hw/d3d11/d3d11_processor.h
@@ -43,6 +43,9 @@ int D3D11_CreateProcessor(vlc_object_t *, d3d11_device_t *,
 #define D3D11_CreateProcessor(a,b,c,d,e,f) D3D11_CreateProcessor(VLC_OBJECT(a),b,c,d,e,f)
 
 void D3D11_ReleaseProcessor(d3d11_processor_t *);
+
+HRESULT D3D11_Assert_ProcessorInput(vlc_object_t *, d3d11_processor_t *, picture_sys_t *);
+#define D3D11_Assert_ProcessorInput(a,b,c) D3D11_Assert_ProcessorInput(VLC_OBJECT(a),b,c)
 #endif
 
 #endif /* VLC_D3D11_PROCESSOR_H */
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 31a3d0201b..373b445829 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -262,28 +262,10 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
     if (sys->d3d_proc.procEnumerator)
     {
         HRESULT hr;
-        if (!p_sys->processorInput)
-        {
-            D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inDesc = {
-                .FourCC = 0,
-                .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
-                .Texture2D.MipSlice = 0,
-                .Texture2D.ArraySlice = viewDesc.Texture2D.ArraySlice,
-            };
+        assert(p_sys->slice_index == viewDesc.Texture2D.ArraySlice);
+        if (FAILED( D3D11_Assert_ProcessorInput(p_filter, &sys->d3d_proc, p_sys) ))
+            return;
 
-            hr = ID3D11VideoDevice_CreateVideoProcessorInputView(sys->d3d_proc.d3dviddev,
-                                                                 p_sys->resource[KNOWN_DXGI_INDEX],
-                                                                 sys->d3d_proc.procEnumerator,
-                                                                 &inDesc,
-                                                                 &p_sys->processorInput);
-            if (FAILED(hr))
-            {
-#ifndef NDEBUG
-                msg_Dbg(p_filter,"Failed to create processor input for slice %d. (hr=0x%lX)", p_sys->slice_index, hr);
-#endif
-                return;
-            }
-        }
         D3D11_VIDEO_PROCESSOR_STREAM stream = {
             .Enable = TRUE,
             .pInputSurface = p_sys->processorInput,
@@ -404,28 +386,10 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
     if (sys->d3d_proc.procEnumerator)
     {
         HRESULT hr;
-        if (!p_sys->processorInput)
-        {
-            D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inDesc = {
-                .FourCC = 0,
-                .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
-                .Texture2D.MipSlice = 0,
-                .Texture2D.ArraySlice = viewDesc.Texture2D.ArraySlice,
-            };
+        assert(p_sys->slice_index == viewDesc.Texture2D.ArraySlice);
+        if (FAILED( D3D11_Assert_ProcessorInput(p_filter, &sys->d3d_proc, p_sys) ))
+            return;
 
-            hr = ID3D11VideoDevice_CreateVideoProcessorInputView(sys->d3d_proc.d3dviddev,
-                                                                 p_sys->resource[KNOWN_DXGI_INDEX],
-                                                                 sys->d3d_proc.procEnumerator,
-                                                                 &inDesc,
-                                                                 &p_sys->processorInput);
-            if (FAILED(hr))
-            {
-#ifndef NDEBUG
-                msg_Dbg(p_filter,"Failed to create processor input for slice %d. (hr=0x%lX)", p_sys->slice_index, hr);
-#endif
-                return;
-            }
-        }
         D3D11_VIDEO_PROCESSOR_STREAM stream = {
             .Enable = TRUE,
             .pInputSurface = p_sys->processorInput,



More information about the vlc-commits mailing list