[vlc-commits] d3d9: use a helper to get the proper type of the D3D9 decoder device
Steve Lhomme
git at videolan.org
Fri Sep 20 13:54:10 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Sep 20 09:29:57 2019 +0200| [22969b60ac5e7033a0bb4c53432c5af1d00d1087] | committer: Steve Lhomme
d3d9: use a helper to get the proper type of the D3D9 decoder device
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=22969b60ac5e7033a0bb4c53432c5af1d00d1087
---
modules/video_chroma/d3d9_fmt.h | 22 ++++++++++++++++++++++
modules/video_output/win32/direct3d9.c | 9 +++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index 94fe506405..eef89fa3c4 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -24,6 +24,7 @@
#define VLC_VIDEOCHROMA_D3D9_FMT_H_
#include <vlc_picture.h>
+#include <vlc_codec.h>
#define COBJMACROS
#include <d3d9.h>
@@ -84,6 +85,27 @@ static inline bool is_d3d9_opaque(vlc_fourcc_t chroma)
}
}
+static inline d3d9_decoder_device_t *GetD3D9OpaqueDevice(vlc_decoder_device *device)
+{
+ if (device == NULL || device->type != VLC_DECODER_DEVICE_DXVA2)
+ return NULL;
+ return device->opaque;
+}
+
+static inline d3d9_decoder_device_t *GetD3D9OpaqueContext(vlc_video_context *vctx)
+{
+ vlc_decoder_device *device = vctx ? vctx->device : NULL;
+ if (unlikely(device == NULL))
+ return NULL;
+ d3d9_decoder_device_t *res = NULL;
+ if (device->type == VLC_DECODER_DEVICE_DXVA2)
+ {
+ assert(device->opaque != NULL);
+ res = GetD3D9OpaqueDevice(device);
+ }
+ return res;
+}
+
static inline void AcquireD3D9PictureSys(picture_sys_d3d9_t *p_sys)
{
IDirect3DSurface9_AddRef(p_sys->surface);
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 1a3e3db8e1..23d2c067bb 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -41,7 +41,6 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
-#include <vlc_codec.h>
#include <vlc_vout_display.h>
#include <vlc/libvlc.h>
@@ -1655,9 +1654,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
sys->startEndRenderingCb = NULL;
}
- d3d9_decoder_device_t *d3d9_decoder = NULL;
- if ( context && context->device->type == VLC_DECODER_DEVICE_DXVA2 )
- d3d9_decoder = context->device->opaque;
+ d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueContext(context);
if ( d3d9_decoder == NULL )
{
// No d3d9 device, we create one
@@ -1922,9 +1919,9 @@ GLConvOpen(vlc_object_t *obj)
HRESULT hr;
int adapter = -1;
- if (tc->dec_device->type == VLC_DECODER_DEVICE_DXVA2)
+ d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueDevice( tc->dec_device );
+ if ( d3d9_decoder != NULL )
{
- d3d9_decoder_device_t *d3d9_decoder = tc->dec_device->opaque;
D3D9_CloneExternal(&priv->hd3d, d3d9_decoder->device);
adapter = d3d9_decoder->adapter;
}
More information about the vlc-commits
mailing list