[vlc-devel] [PATCH 4/6] nvdec: add NVDEC_PICCONTEXT_FROM_PICCTX macro

quentin.chateau at deepskycorp.com quentin.chateau at deepskycorp.com
Mon Mar 30 11:26:53 CEST 2020


From: Quentin Chateau <quentin.chateau at deepskycorp.com>

---
 modules/hw/nvdec/nvdec.c     | 7 +++----
 modules/hw/nvdec/nvdec_fmt.h | 3 +++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index b66b9eeb74..d163f5f59b 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -115,7 +115,6 @@ typedef struct nvdec_ctx {
 #define CALL_CUVID(func, ...)    CudaCheckErr(VLC_OBJECT(p_dec),  p_sys->devsys->cudaFunctions, p_sys->cuvidFunctions->func(__VA_ARGS__), #func)
 #define CALL_CUDA_POOL(func, ...) pool->nvdec_dev->cudaFunctions->func(__VA_ARGS__)
 
-
 static void NVDecCtxDestroy(struct picture_context_t *picctx);
 static struct picture_context_t *NVDecCtxClone(struct picture_context_t *srcctx);
 
@@ -406,7 +405,7 @@ static int CUDAAPI HandlePictureDecode(void *p_opaque, CUVIDPICPARAMS *p_picpara
 
 static void NVDecCtxDestroy(struct picture_context_t *picctx)
 {
-    pic_context_nvdec_t *srcpic = container_of(picctx, pic_context_nvdec_t, ctx);
+    pic_context_nvdec_t *srcpic = NVDEC_PICCONTEXT_FROM_PICCTX(picctx);
     free(srcpic);
 }
 
@@ -415,7 +414,7 @@ static struct picture_context_t *NVDecCtxClone(struct picture_context_t *srcctx)
     pic_context_nvdec_t *clonectx = malloc(sizeof(*clonectx));
     if (unlikely(clonectx == NULL))
         return NULL;
-    pic_context_nvdec_t *srcpic = container_of(srcctx, pic_context_nvdec_t, ctx);
+    pic_context_nvdec_t *srcpic = NVDEC_PICCONTEXT_FROM_PICCTX(srcctx);
 
     *clonectx = *srcpic;
     vlc_video_context_Hold(clonectx->ctx.vctx);
@@ -442,7 +441,7 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
         p_pic = nvdec_pool_Wait(p_sys->out_pool);
         if (unlikely(p_pic == NULL))
             return 0;
-        pic_context_nvdec_t *picctx = container_of(p_pic->context, pic_context_nvdec_t, ctx);
+        pic_context_nvdec_t *picctx = NVDEC_PICCONTEXT_FROM_PICCTX(p_pic->context);
 
         result = CALL_CUDA_DEC(cuCtxPushCurrent, p_sys->devsys->cuCtx);
         if (unlikely(result != VLC_SUCCESS))
diff --git a/modules/hw/nvdec/nvdec_fmt.h b/modules/hw/nvdec/nvdec_fmt.h
index 25784cca6d..4ac4e7577c 100644
--- a/modules/hw/nvdec/nvdec_fmt.h
+++ b/modules/hw/nvdec/nvdec_fmt.h
@@ -69,4 +69,7 @@ typedef struct
     unsigned int bufferHeight;
 } pic_context_nvdec_t;
 
+#define NVDEC_PICCONTEXT_FROM_PICCTX(pic_ctx)  \
+    container_of(pic_ctx, pic_context_nvdec_t, ctx)
+
 #endif /* include-guard */
-- 
2.17.1



More information about the vlc-devel mailing list