[vlc-commits] dxva: move the surface table allocation in each implementation

Steve Lhomme git at videolan.org
Mon Sep 2 15:43:14 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep  2 09:24:43 2019 +0200| [c8674120c8c8b04804557c2a887368462c2f87e4] | committer: Steve Lhomme

dxva: move the surface table allocation in each implementation

The helper functions never use it anyway.

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

 modules/codec/avcodec/d3d11va.c        | 25 +++++++++++++------------
 modules/codec/avcodec/directx_va.c     |  1 -
 modules/codec/avcodec/directx_va.h     |  3 ---
 modules/codec/avcodec/dxva2.c          | 16 +++++++++-------
 modules/codec/avcodec/dxva_blacklist.c |  1 -
 5 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index ece5d01968..8bf6c7da03 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -54,7 +54,6 @@ typedef picture_sys_d3d11_t VA_PICSYS;
 #include "va_surface.h"
 
 #define D3D_DecoderType     ID3D11VideoDecoder
-#define D3D_DecoderSurface  ID3D11VideoDecoderOutputView
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
@@ -121,6 +120,9 @@ struct vlc_va_sys_t
     /* avcodec internals */
     struct AVD3D11VAContext      hw;
 
+    /* pool */
+    ID3D11VideoDecoderOutputView *hw_surface[MAX_SURFACE_COUNT];
+
     ID3D11ShaderResourceView     *renderSrc[MAX_SURFACE_COUNT * D3D11_MAX_SHADER_VIEW];
 };
 
@@ -143,7 +145,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys)
     sys->hw.decoder = dx_sys->decoder;
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface_count = dx_sys->va_pool.surface_count;
-    sys->hw.surface = dx_sys->hw_surface;
+    sys->hw.surface = sys->hw_surface;
     sys->hw.context_mutex = sys->d3d_dev.context_mutex;
 
     if (IsEqualGUID(&dx_sys->input, &DXVA_Intel_H264_NoFGT_ClearVideo))
@@ -214,8 +216,7 @@ done:
 static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_index)
 {
     vlc_va_sys_t *sys = va->sys;
-    directx_sys_t *dx_sys = &sys->dx_sys;
-    ID3D11VideoDecoderOutputView *surface = dx_sys->hw_surface[surface_index];
+    ID3D11VideoDecoderOutputView *surface = sys->hw_surface[surface_index];
     ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW];
     ID3D11Resource *p_resource;
     ID3D11VideoDecoderOutputView_GetResource(surface, &p_resource);
@@ -734,7 +735,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
         for (surface_idx = 0; surface_idx < surface_count; surface_idx++) {
             picture_t *pic = decoder_NewPicture( (decoder_t*) vlc_object_parent(va) );
             sys->extern_pics[surface_idx] = pic;
-            dx_sys->hw_surface[surface_idx] = NULL;
+            sys->hw_surface[surface_idx] = NULL;
             if (pic==NULL)
             {
                 msg_Warn(va, "not enough decoder pictures %d out of %d", surface_idx, surface_count);
@@ -771,17 +772,17 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
 
             D3D11_AllocateResourceView(va, sys->d3d_dev.d3ddevice, textureFmt, pic->p_sys->texture, pic->p_sys->slice_index, pic->p_sys->renderSrc);
 
-            dx_sys->hw_surface[surface_idx] = p_sys->decoder;
+            sys->hw_surface[surface_idx] = p_sys->decoder;
         }
 
         if (!dx_sys->can_extern_pool)
         {
             for (size_t i = 0; i < surface_idx; ++i)
             {
-                if (dx_sys->hw_surface[i])
+                if (sys->hw_surface[i])
                 {
-                    ID3D11VideoDecoderOutputView_Release(dx_sys->hw_surface[i]);
-                    dx_sys->hw_surface[i] = NULL;
+                    ID3D11VideoDecoderOutputView_Release(sys->hw_surface[i]);
+                    sys->hw_surface[i] = NULL;
                 }
                 if (sys->extern_pics[i])
                 {
@@ -830,7 +831,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
             hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( sys->d3ddec,
                                                                  (ID3D11Resource*) p_texture,
                                                                  &viewDesc,
-                                                                 &dx_sys->hw_surface[surface_idx] );
+                                                                 &sys->hw_surface[surface_idx] );
             if (FAILED(hr)) {
                 msg_Err(va, "CreateVideoDecoderOutputView %d failed. (hr=0x%lX)", surface_idx, hr);
                 ID3D11Texture2D_Release(p_texture);
@@ -923,13 +924,13 @@ static void DxDestroySurfaces(vlc_va_sys_t *sys)
     directx_sys_t *dx_sys = &sys->dx_sys;
     if (dx_sys->va_pool.surface_count && !dx_sys->can_extern_pool) {
         ID3D11Resource *p_texture;
-        ID3D11VideoDecoderOutputView_GetResource( dx_sys->hw_surface[0], &p_texture );
+        ID3D11VideoDecoderOutputView_GetResource( sys->hw_surface[0], &p_texture );
         ID3D11Resource_Release(p_texture);
         ID3D11Resource_Release(p_texture);
     }
     for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
     {
-        ID3D11VideoDecoderOutputView_Release( dx_sys->hw_surface[i] );
+        ID3D11VideoDecoderOutputView_Release( sys->hw_surface[i] );
         for (int j = 0; j < D3D11_MAX_SHADER_VIEW; j++)
         {
             if (sys->renderSrc[i*D3D11_MAX_SHADER_VIEW + j])
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 731a093316..028f2431e7 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -36,7 +36,6 @@
 #define COBJMACROS
 
 #define D3D_DecoderType     IUnknown
-#define D3D_DecoderSurface  IUnknown
 #include "directx_va.h"
 
 #include "avcodec.h"
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index ee41e16116..2f6a92fe0b 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -55,9 +55,6 @@ typedef struct
     va_pool_t             va_pool;
     bool                  can_extern_pool;
 
-    /* for pre allocation */
-    D3D_DecoderSurface     *hw_surface[MAX_SURFACE_COUNT];
-
     /* Video service */
     GUID                   input;
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 5ad1b98d89..134a9c9b13 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -41,7 +41,6 @@ typedef picture_sys_d3d9_t VA_PICSYS;
 #include "va_surface.h"
 
 #define D3D_DecoderType     IDirectXVideoDecoder
-#define D3D_DecoderSurface  IDirect3DSurface9
 #include "directx_va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
@@ -128,6 +127,9 @@ struct vlc_va_sys_t
     DXVA2_ConfigPictureDecode    cfg;
     IDirectXVideoDecoderService  *d3ddec;
 
+    /* pool */
+    IDirect3DSurface9   *hw_surface[MAX_SURFACE_COUNT];
+
     /* avcodec internals */
     struct dxva_context hw;
 };
@@ -151,7 +153,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys)
     sys->hw.decoder = dx_sys->decoder;
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface_count = dx_sys->va_pool.surface_count;
-    sys->hw.surface = dx_sys->hw_surface;
+    sys->hw.surface = sys->hw_surface;
 
     if (IsEqualGUID(&dx_sys->input, &DXVA_Intel_H264_NoFGT_ClearVideo))
         sys->hw.workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
@@ -197,7 +199,7 @@ static struct va_pic_context *CreatePicContext(IDirect3DSurface9 *surface, IDire
 static struct va_pic_context* NewSurfacePicContext(vlc_va_t *va, int surface_index)
 {
     directx_sys_t *dx_sys = &va->sys->dx_sys;
-    struct va_pic_context *pic_ctx = CreatePicContext(dx_sys->hw_surface[surface_index], dx_sys->decoder);
+    struct va_pic_context *pic_ctx = CreatePicContext(va->sys->hw_surface[surface_index], dx_sys->decoder);
     if (unlikely(pic_ctx==NULL))
         return NULL;
     /* all the resources are acquired during surfaces init, and a second time in
@@ -533,7 +535,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
                                                          D3DPOOL_DEFAULT,
                                                          0,
                                                          DXVA2_VideoDecoderRenderTarget,
-                                                         sys->hw_surface,
+                                                         p_sys->hw_surface,
                                                          NULL);
     if (FAILED(hr)) {
         msg_Err(va, "IDirectXVideoAccelerationService_CreateSurface %d failed (hr=0x%lX)", surface_count - 1, hr);
@@ -639,7 +641,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
                                                               &sys->input,
                                                               &dsc,
                                                               &p_sys->cfg,
-                                                              sys->hw_surface,
+                                                              p_sys->hw_surface,
                                                               surface_count,
                                                               &decoder))) {
         msg_Err(va, "IDirectXVideoDecoderService_CreateVideoDecoder failed");
@@ -651,7 +653,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
     return VLC_SUCCESS;
 error:
     for (unsigned i = 0; i < surface_count; i++)
-        IDirect3DSurface9_Release( sys->hw_surface[i] );
+        IDirect3DSurface9_Release( p_sys->hw_surface[i] );
     return VLC_EGENERIC;
 }
 
@@ -664,6 +666,6 @@ static void DxDestroyVideoDecoder(vlc_va_sys_t *sys)
         IDirectXVideoDecoder_Release(dx_sys->decoder);
         dx_sys->decoder = NULL;
         for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
-            IDirect3DSurface9_Release(dx_sys->hw_surface[i]);
+            IDirect3DSurface9_Release(sys->hw_surface[i]);
     }
 }
diff --git a/modules/codec/avcodec/dxva_blacklist.c b/modules/codec/avcodec/dxva_blacklist.c
index 58b291c47f..9f34481c49 100644
--- a/modules/codec/avcodec/dxva_blacklist.c
+++ b/modules/codec/avcodec/dxva_blacklist.c
@@ -30,7 +30,6 @@
 #include "../../video_chroma/dxgi_fmt.h"
 
 #define D3D_DecoderType     IUnknown
-#define D3D_DecoderSurface  IUnknown
 
 #include "directx_va.h"
 



More information about the vlc-commits mailing list