[vlc-devel] [PATCH 4/6] nvdec: add NVDEC_PICCTX_FROM_PICCTX macro
Steve Lhomme
robux4 at ycbcr.xyz
Thu Mar 26 11:19:40 CET 2020
I think you mean something like NVDEC_PICCONTEXT_FROM_PICCTX otherwise
it's not very clear what the macro is doing.
On 2020-03-25 18:57, quentin.chateau at deepskycorp.com wrote:
> 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 22660d222b..23889e3510 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);
>
> @@ -409,7 +408,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_PICCTX_FROM_PICCTX(picctx);
> free(srcpic);
> }
>
> @@ -418,7 +417,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_PICCTX_FROM_PICCTX(srcctx);
>
> *clonectx = *srcpic;
> vlc_video_context_Hold(clonectx->ctx.vctx);
> @@ -445,7 +444,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_PICCTX_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..5c597623eb 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_PICCTX_FROM_PICCTX(pic_ctx) \
> + container_of(pic_ctx, pic_context_nvdec_t, ctx)
> +
> #endif /* include-guard */
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list