[vlc-commits] dxva: move the decoder instance in each implementation
Steve Lhomme
git at videolan.org
Mon Sep 2 15:43:15 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep 2 09:33:58 2019 +0200| [5eabbd753a6c47bf6e914b33162b3227b2f5203c] | 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=5eabbd753a6c47bf6e914b33162b3227b2f5203c
---
modules/codec/avcodec/d3d11va.c | 15 ++++++---------
modules/codec/avcodec/directx_va.c | 1 -
modules/codec/avcodec/directx_va.h | 3 ---
modules/codec/avcodec/dxva2.c | 25 ++++++++++---------------
modules/codec/avcodec/dxva_blacklist.c | 2 --
5 files changed, 16 insertions(+), 30 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 8bf6c7da03..f204226c29 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -53,7 +53,6 @@
typedef picture_sys_d3d11_t VA_PICSYS;
#include "va_surface.h"
-#define D3D_DecoderType ID3D11VideoDecoder
#include "directx_va.h"
static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
@@ -116,6 +115,7 @@ struct vlc_va_sys_t
/* Video decoder */
D3D11_VIDEO_DECODER_CONFIG cfg;
ID3D11VideoDevice *d3ddec;
+ ID3D11VideoDecoder *dxdecoder;
/* avcodec internals */
struct AVD3D11VAContext hw;
@@ -142,7 +142,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys)
directx_sys_t *dx_sys = &sys->dx_sys;
sys->hw.video_context = sys->d3dvidctx;
- sys->hw.decoder = dx_sys->decoder;
+ sys->hw.decoder = sys->dxdecoder;
sys->hw.cfg = &sys->cfg;
sys->hw.surface_count = dx_sys->va_pool.surface_count;
sys->hw.surface = sys->hw_surface;
@@ -910,10 +910,10 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
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;
+ sys->dxdecoder = NULL;
return VLC_EGENERIC;
}
- dx_sys->decoder = decoder;
+ sys->dxdecoder = decoder;
msg_Dbg(va, "DxCreateDecoderSurfaces succeed");
return VLC_SUCCESS;
@@ -937,9 +937,6 @@ static void DxDestroySurfaces(vlc_va_sys_t *sys)
ID3D11ShaderResourceView_Release(sys->renderSrc[i*D3D11_MAX_SHADER_VIEW + j]);
}
}
- if (dx_sys->decoder)
- {
- ID3D11VideoDecoder_Release(dx_sys->decoder);
- dx_sys->decoder = NULL;
- }
+ if (sys->dxdecoder)
+ ID3D11VideoDecoder_Release(sys->dxdecoder);
}
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 028f2431e7..49a4d2f513 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -35,7 +35,6 @@
#define COBJMACROS
-#define D3D_DecoderType 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 2f6a92fe0b..3e8e957d6c 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -58,9 +58,6 @@ typedef struct
/* Video service */
GUID input;
- /* Video decoder */
- D3D_DecoderType *decoder;
-
/**
* Read the list of possible input GUIDs
*/
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 134a9c9b13..b353066699 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -40,7 +40,6 @@
typedef picture_sys_d3d9_t VA_PICSYS;
#include "va_surface.h"
-#define D3D_DecoderType IDirectXVideoDecoder
#include "directx_va.h"
static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
@@ -126,6 +125,7 @@ struct vlc_va_sys_t
/* Video decoder */
DXVA2_ConfigPictureDecode cfg;
IDirectXVideoDecoderService *d3ddec;
+ IDirectXVideoDecoder *dxdecoder;
/* pool */
IDirect3DSurface9 *hw_surface[MAX_SURFACE_COUNT];
@@ -150,7 +150,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys)
{
directx_sys_t *dx_sys = &sys->dx_sys;
- sys->hw.decoder = dx_sys->decoder;
+ sys->hw.decoder = sys->dxdecoder;
sys->hw.cfg = &sys->cfg;
sys->hw.surface_count = dx_sys->va_pool.surface_count;
sys->hw.surface = sys->hw_surface;
@@ -198,8 +198,8 @@ 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(va->sys->hw_surface[surface_index], dx_sys->decoder);
+ vlc_va_sys_t *sys = va->sys;
+ struct va_pic_context *pic_ctx = CreatePicContext(sys->hw_surface[surface_index], sys->dxdecoder);
if (unlikely(pic_ctx==NULL))
return NULL;
/* all the resources are acquired during surfaces init, and a second time in
@@ -635,7 +635,6 @@ 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(p_sys->d3ddec,
&sys->input,
@@ -643,11 +642,10 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
&p_sys->cfg,
p_sys->hw_surface,
surface_count,
- &decoder))) {
+ &p_sys->dxdecoder))) {
msg_Err(va, "IDirectXVideoDecoderService_CreateVideoDecoder failed");
goto error;
}
- sys->decoder = decoder;
msg_Dbg(va, "IDirectXVideoDecoderService_CreateVideoDecoder succeed");
return VLC_SUCCESS;
@@ -660,12 +658,9 @@ error:
static void DxDestroyVideoDecoder(vlc_va_sys_t *sys)
{
directx_sys_t *dx_sys = &sys->dx_sys;
- if (dx_sys->decoder)
- {
- /* releases a reference on each decoder surface */
- IDirectXVideoDecoder_Release(dx_sys->decoder);
- dx_sys->decoder = NULL;
- for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
- IDirect3DSurface9_Release(sys->hw_surface[i]);
- }
+ /* releases a reference on each decoder surface */
+ if (sys->dxdecoder)
+ IDirectXVideoDecoder_Release(sys->dxdecoder);
+ for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
+ IDirect3DSurface9_Release(sys->hw_surface[i]);
}
diff --git a/modules/codec/avcodec/dxva_blacklist.c b/modules/codec/avcodec/dxva_blacklist.c
index 9f34481c49..ef86d1479f 100644
--- a/modules/codec/avcodec/dxva_blacklist.c
+++ b/modules/codec/avcodec/dxva_blacklist.c
@@ -29,8 +29,6 @@
#include "../../video_chroma/dxgi_fmt.h"
-#define D3D_DecoderType IUnknown
-
#include "directx_va.h"
extern const GUID DXVA2_ModeMPEG2_VLD;
More information about the vlc-commits
mailing list