[vlc-commits] dxva: move the decoder instance in each implementation

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep  2 09:18:50 2019 +0200| [6ae3b9b441e09f6bcc5f8d5220bb1d7806e6323f] | committer: Steve Lhomme

dxva: move the decoder instance in each implementation

The helper functions never use it anyway.

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

 modules/codec/avcodec/d3d11va.c        | 31 ++++++++++++++-----------------
 modules/codec/avcodec/directx_va.c     |  1 -
 modules/codec/avcodec/directx_va.h     |  1 -
 modules/codec/avcodec/dxva2.c          | 21 +++++++++------------
 modules/codec/avcodec/dxva_blacklist.c |  1 -
 5 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index d9a56aae25..ece5d01968 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_DecoderDevice   ID3D11VideoDevice
 #define D3D_DecoderSurface  ID3D11VideoDecoderOutputView
 #include "directx_va.h"
 
@@ -117,6 +116,7 @@ struct vlc_va_sys_t
 
     /* Video decoder */
     D3D11_VIDEO_DECODER_CONFIG   cfg;
+    ID3D11VideoDevice            *d3ddec;
 
     /* avcodec internals */
     struct AVD3D11VAContext      hw;
@@ -262,7 +262,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
                 viewDesc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
                 viewDesc.Texture2D.ArraySlice = p_sys->slice_index;
 
-                hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( sys->dx_sys.d3ddec,
+                hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( sys->d3ddec,
                                                                      p_sys->resource[KNOWN_DXGI_INDEX],
                                                                      &viewDesc,
                                                                      &p_sys->decoder );
@@ -468,8 +468,7 @@ static int D3dCreateDevice(vlc_va_t *va)
        ID3D11VideoContext_Release(sys->d3dvidctx);
        return VLC_EGENERIC;
     }
-    directx_sys_t *dx_sys = &sys->dx_sys;
-    dx_sys->d3ddec = d3dviddev;
+    sys->d3ddec = d3dviddev;
 
     return VLC_SUCCESS;
 }
@@ -480,8 +479,7 @@ static int D3dCreateDevice(vlc_va_t *va)
 static void D3dDestroyDevice(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
-    directx_sys_t *dx_sys = &sys->dx_sys;
-    ID3D11VideoDevice_Release(dx_sys->d3ddec);
+    ID3D11VideoDevice_Release(sys->d3ddec);
     ID3D11VideoContext_Release(sys->d3dvidctx);
     D3D11_ReleaseDevice( &sys->d3d_dev );
 }
@@ -494,10 +492,9 @@ static void ReleaseInputList(input_list_t *p_list)
 static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
 {
     vlc_va_sys_t *sys = va->sys;
-    directx_sys_t *dx_sys = &sys->dx_sys;
     HRESULT hr;
 
-    UINT input_count = ID3D11VideoDevice_GetVideoDecoderProfileCount(dx_sys->d3ddec);
+    UINT input_count = ID3D11VideoDevice_GetVideoDecoderProfileCount(sys->d3ddec);
 
     p_list->count = input_count;
     p_list->list = calloc(input_count, sizeof(*p_list->list));
@@ -507,7 +504,7 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
     p_list->pf_release = ReleaseInputList;
 
     for (unsigned i = 0; i < input_count; i++) {
-        hr = ID3D11VideoDevice_GetVideoDecoderProfile(dx_sys->d3ddec, i, &p_list->list[i]);
+        hr = ID3D11VideoDevice_GetVideoDecoderProfile(sys->d3ddec, i, &p_list->list[i]);
         if (FAILED(hr))
         {
             msg_Err(va, "GetVideoDecoderProfile %d failed. (hr=0x%lX)", i, hr);
@@ -531,7 +528,7 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
 #ifndef NDEBUG
     BOOL bSupported = false;
     for (int format = 0; format < 188; format++) {
-        hr = ID3D11VideoDevice_CheckVideoDecoderFormat(dx_sys->d3ddec, input, format, &bSupported);
+        hr = ID3D11VideoDevice_CheckVideoDecoderFormat(sys->d3ddec, input, format, &bSupported);
         if (SUCCEEDED(hr) && bSupported)
             msg_Dbg(va, "format %s is supported for output", DxgiFormatToStr(format));
     }
@@ -571,7 +568,7 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
     for (idx = 0; processorInput[idx] != DXGI_FORMAT_UNKNOWN; ++idx)
     {
         BOOL is_supported = false;
-        hr = ID3D11VideoDevice_CheckVideoDecoderFormat(dx_sys->d3ddec, input, processorInput[idx], &is_supported);
+        hr = ID3D11VideoDevice_CheckVideoDecoderFormat(sys->d3ddec, input, processorInput[idx], &is_supported);
         if (SUCCEEDED(hr) && is_supported)
             msg_Dbg(va, "%s output is supported for decoder %s.", DxgiFormatToStr(processorInput[idx]), psz_decoder_name);
         else
@@ -607,7 +604,7 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
         decoderDesc.OutputFormat = processorInput[idx];
 
         UINT cfg_count = 0;
-        hr = ID3D11VideoDevice_GetVideoDecoderConfigCount( dx_sys->d3ddec, &decoderDesc, &cfg_count );
+        hr = ID3D11VideoDevice_GetVideoDecoderConfigCount( sys->d3ddec, &decoderDesc, &cfg_count );
         if (FAILED(hr))
         {
             msg_Err( va, "Failed to get configuration for decoder %s. (hr=0x%lX)", psz_decoder_name, hr );
@@ -762,7 +759,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
 #endif
 
             viewDesc.Texture2D.ArraySlice = p_sys->slice_index;
-            hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( dx_sys->d3ddec,
+            hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( sys->d3ddec,
                                                                  p_sys->resource[KNOWN_DXGI_INDEX],
                                                                  &viewDesc,
                                                                  &p_sys->decoder );
@@ -830,7 +827,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
             sys->extern_pics[surface_idx] = NULL;
             viewDesc.Texture2D.ArraySlice = surface_idx;
 
-            hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( dx_sys->d3ddec,
+            hr = ID3D11VideoDevice_CreateVideoDecoderOutputView( sys->d3ddec,
                                                                  (ID3D11Resource*) p_texture,
                                                                  &viewDesc,
                                                                  &dx_sys->hw_surface[surface_idx] );
@@ -859,7 +856,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
     decoderDesc.OutputFormat = sys->render;
 
     UINT cfg_count;
-    hr = ID3D11VideoDevice_GetVideoDecoderConfigCount( dx_sys->d3ddec, &decoderDesc, &cfg_count );
+    hr = ID3D11VideoDevice_GetVideoDecoderConfigCount( sys->d3ddec, &decoderDesc, &cfg_count );
     if (FAILED(hr)) {
         msg_Err(va, "GetVideoDecoderConfigCount failed. (hr=0x%lX)", hr);
         return VLC_EGENERIC;
@@ -868,7 +865,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
     /* List all configurations available for the decoder */
     D3D11_VIDEO_DECODER_CONFIG cfg_list[cfg_count];
     for (unsigned i = 0; i < cfg_count; i++) {
-        hr = ID3D11VideoDevice_GetVideoDecoderConfig( dx_sys->d3ddec, &decoderDesc, i, &cfg_list[i] );
+        hr = ID3D11VideoDevice_GetVideoDecoderConfig( sys->d3ddec, &decoderDesc, i, &cfg_list[i] );
         if (FAILED(hr)) {
             msg_Err(va, "GetVideoDecoderConfig failed. (hr=0x%lX)", hr);
             return VLC_EGENERIC;
@@ -909,7 +906,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
 
     /* Create the decoder */
     ID3D11VideoDecoder *decoder;
-    hr = ID3D11VideoDevice_CreateVideoDecoder( dx_sys->d3ddec, &decoderDesc, &sys->cfg, &decoder );
+    hr = ID3D11VideoDevice_CreateVideoDecoder( sys->d3ddec, &decoderDesc, &sys->cfg, &decoder );
     if (FAILED(hr)) {
         msg_Err(va, "ID3D11VideoDevice_CreateVideoDecoder failed. (hr=0x%lX)", hr);
         dx_sys->decoder = NULL;
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index f2cb60e10b..731a093316 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_DecoderDevice   IUnknown
 #define D3D_DecoderSurface  IUnknown
 #include "directx_va.h"
 
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index e66ea87b05..ee41e16116 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -60,7 +60,6 @@ typedef struct
 
     /* Video service */
     GUID                   input;
-    D3D_DecoderDevice      *d3ddec;
 
     /* Video decoder */
     D3D_DecoderType        *decoder;
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index e09fe7d37e..5ad1b98d89 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_DecoderDevice   IDirectXVideoDecoderService
 #define D3D_DecoderSurface  IDirect3DSurface9
 #include "directx_va.h"
 
@@ -127,6 +126,7 @@ struct vlc_va_sys_t
 
     /* Video decoder */
     DXVA2_ConfigPictureDecode    cfg;
+    IDirectXVideoDecoderService  *d3ddec;
 
     /* avcodec internals */
     struct dxva_context hw;
@@ -399,8 +399,7 @@ static int D3dCreateDevice(vlc_va_t *va)
         IDirect3DDeviceManager9_Release(sys->devmng);
         return VLC_EGENERIC;
     }
-    directx_sys_t *dx_sys = &sys->dx_sys;
-    dx_sys->d3ddec = pv;
+    sys->d3ddec = pv;
 
     return VLC_SUCCESS;
 }
@@ -411,11 +410,10 @@ static int D3dCreateDevice(vlc_va_t *va)
 static void D3dDestroyDevice(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
-    directx_sys_t *dx_sys = &sys->dx_sys;
     HRESULT hr = IDirect3DDeviceManager9_CloseDeviceHandle(sys->devmng, sys->device);
     if (FAILED(hr))
         msg_Warn(va, "Failed to release device handle 0x%p. (hr=0x%lX)", sys->device, hr);
-    IDirectXVideoDecoderService_Release(dx_sys->d3ddec);
+    IDirectXVideoDecoderService_Release(sys->d3ddec);
     IDirect3DDeviceManager9_Release(sys->devmng);
     D3D9_ReleaseDevice(&sys->d3d_dev);
     D3D9_Destroy( &sys->hd3d );
@@ -429,10 +427,9 @@ static void ReleaseInputList(input_list_t *p_list)
 static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
 {
     vlc_va_sys_t *sys = va->sys;
-    directx_sys_t *dx_sys = &sys->dx_sys;
     UINT input_count = 0;
     GUID *input_list = NULL;
-    if (FAILED(IDirectXVideoDecoderService_GetDecoderDeviceGuids(dx_sys->d3ddec,
+    if (FAILED(IDirectXVideoDecoderService_GetDecoderDeviceGuids(sys->d3ddec,
                                                                  &input_count,
                                                                  &input_list))) {
         msg_Err(va, "IDirectXVideoDecoderService_GetDecoderDeviceGuids failed");
@@ -473,7 +470,7 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
     int err = VLC_EGENERIC;
     UINT      output_count = 0;
     D3DFORMAT *output_list = NULL;
-    if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(sys->dx_sys.d3ddec,
+    if (FAILED(IDirectXVideoDecoderService_GetDecoderRenderTargets(sys->d3ddec,
                                                                    input,
                                                                    &output_count,
                                                                    &output_list))) {
@@ -528,7 +525,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
     directx_sys_t *sys = &p_sys->dx_sys;
     HRESULT hr;
 
-    hr = IDirectXVideoDecoderService_CreateSurface(sys->d3ddec,
+    hr = IDirectXVideoDecoderService_CreateSurface(p_sys->d3ddec,
                                                          fmt->i_width,
                                                          fmt->i_height,
                                                          surface_count - 1,
@@ -546,7 +543,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
             surface_count, fmt->i_width, fmt->i_height);
 
     IDirect3DSurface9 *tstCrash;
-    hr = IDirectXVideoDecoderService_CreateSurface(sys->d3ddec,
+    hr = IDirectXVideoDecoderService_CreateSurface(p_sys->d3ddec,
                                                          fmt->i_width,
                                                          fmt->i_height,
                                                          0,
@@ -592,7 +589,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
     /* List all configurations available for the decoder */
     UINT                      cfg_count = 0;
     DXVA2_ConfigPictureDecode *cfg_list = NULL;
-    hr = IDirectXVideoDecoderService_GetDecoderConfigurations(sys->d3ddec,
+    hr = IDirectXVideoDecoderService_GetDecoderConfigurations(p_sys->d3ddec,
                                                               &sys->input,
                                                               &dsc,
                                                               NULL,
@@ -638,7 +635,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
     /* Create the decoder */
     IDirectXVideoDecoder *decoder;
     /* adds a reference on each decoder surface */
-    if (FAILED(IDirectXVideoDecoderService_CreateVideoDecoder(sys->d3ddec,
+    if (FAILED(IDirectXVideoDecoderService_CreateVideoDecoder(p_sys->d3ddec,
                                                               &sys->input,
                                                               &dsc,
                                                               &p_sys->cfg,
diff --git a/modules/codec/avcodec/dxva_blacklist.c b/modules/codec/avcodec/dxva_blacklist.c
index a037aeb41e..58b291c47f 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_DecoderDevice   IUnknown
 #define D3D_DecoderSurface  IUnknown
 
 #include "directx_va.h"



More information about the vlc-commits mailing list