[vlc-commits] nvdec: use a helper to get the proper type of the NVDEC decoder device
Steve Lhomme
git at videolan.org
Fri Sep 20 13:54:11 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Sep 20 11:35:22 2019 +0200| [66a8a0a92c6968c0edb9741fa6a07c650237980c] | committer: Steve Lhomme
nvdec: use a helper to get the proper type of the NVDEC decoder device
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=66a8a0a92c6968c0edb9741fa6a07c650237980c
---
modules/hw/nvdec/nvdec.c | 2 +-
modules/hw/nvdec/nvdec_fmt.h | 7 +++++++
modules/hw/nvdec/nvdec_gl.c | 10 +++++-----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index 00cab2ed46..b0f46f83b6 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -930,7 +930,7 @@ static void CloseDecoder(vlc_object_t *p_this)
/** Decoder Device **/
static void DecoderContextClose(vlc_decoder_device *device)
{
- decoder_device_nvdec_t *p_sys = device->opaque;
+ decoder_device_nvdec_t *p_sys = GetNVDECOpaqueDevice(device);
if (p_sys->cuCtx)
CALL_CUDA_DEV(cuCtxDestroy, p_sys->cuCtx);
cuda_free_functions(&p_sys->cudaFunctions);
diff --git a/modules/hw/nvdec/nvdec_fmt.h b/modules/hw/nvdec/nvdec_fmt.h
index 3db633e2a5..1668ad3696 100644
--- a/modules/hw/nvdec/nvdec_fmt.h
+++ b/modules/hw/nvdec/nvdec_fmt.h
@@ -32,6 +32,13 @@ typedef struct {
} decoder_device_nvdec_t;
+static inline decoder_device_nvdec_t *GetNVDECOpaqueDevice(vlc_decoder_device *device)
+{
+ if (device == NULL || device->type != VLC_DECODER_DEVICE_NVDEC)
+ return NULL;
+ return device->opaque;
+}
+
static inline int CudaCheckErr(vlc_object_t *obj, CudaFunctions *cudaFunctions, CUresult result, const char *psz_func)
{
if (unlikely(result != CUDA_SUCCESS)) {
diff --git a/modules/hw/nvdec/nvdec_gl.c b/modules/hw/nvdec/nvdec_gl.c
index 9c16122a3b..6ebf845597 100644
--- a/modules/hw/nvdec/nvdec_gl.c
+++ b/modules/hw/nvdec/nvdec_gl.c
@@ -62,8 +62,8 @@ static int tc_nvdec_gl_allocate_texture(const opengl_tex_converter_t *tc, GLuint
const GLsizei *tex_width, const GLsizei *tex_height)
{
converter_sys_t *p_sys = tc->priv;
- vlc_decoder_device *device = tc->dec_device;
- decoder_device_nvdec_t *devsys = device->opaque;
+ vlc_decoder_device *device = p_sys->device;
+ decoder_device_nvdec_t *devsys = GetNVDECOpaqueDevice(device);
int result;
result = CALL_CUDA(cuCtxPushCurrent, p_sys->cuConverterCtx ? p_sys->cuConverterCtx : devsys->cuCtx);
@@ -104,8 +104,8 @@ tc_nvdec_gl_update(opengl_tex_converter_t const *tc, GLuint textures[],
VLC_UNUSED(textures);
converter_sys_t *p_sys = tc->priv;
- vlc_decoder_device *device = tc->dec_device;
- decoder_device_nvdec_t *devsys = device->opaque;
+ vlc_decoder_device *device = p_sys->device;
+ decoder_device_nvdec_t *devsys = GetNVDECOpaqueDevice(device);
pic_context_nvdec_t *srcpic = container_of(pic->context, pic_context_nvdec_t, ctx);
int result;
@@ -169,7 +169,7 @@ static int Open(vlc_object_t *obj)
p_sys->cuConverterCtx = NULL;
p_sys->device = device;
- decoder_device_nvdec_t *devsys = device->opaque;
+ decoder_device_nvdec_t *devsys = GetNVDECOpaqueDevice(device);
int result;
CUdevice cuDecDevice = 0;
unsigned int device_count;
More information about the vlc-commits
mailing list