[vlc-devel] [PATCH] vt_utils: implements picture context copy

Rémi Denis-Courmont remi at remlab.net
Tue Jun 6 18:49:56 CEST 2017


Le tiistaina 6. kesäkuuta 2017, 11.53.53 EEST Thomas Guillem a écrit :
> ---
>  modules/codec/vt_utils.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
> index 3f2e79da93..3faf8598dd 100644
> --- a/modules/codec/vt_utils.c
> +++ b/modules/codec/vt_utils.c
> @@ -55,6 +55,18 @@ cvpxpic_destroy_cb(picture_context_t *opaque)
>      free(opaque);
>  }
> 
> +static picture_context_t *
> +cvpxpic_copy_cb(struct picture_context_t *opaque)
> +{
> +    struct cvpxpic_ctx *src_ctx = (struct cvpxpic_ctx *)opaque;
> +    struct cvpxpic_ctx *dst_ctx = malloc(sizeof(struct cvpxpic_ctx));
> +    if (dst_ctx == NULL)
> +        return NULL;
> +    *dst_ctx = *src_ctx;
> +    dst_ctx->cvpx = CVPixelBufferRetain(dst_ctx->cvpx);
> +    return &dst_ctx->s;
> +}

AFAICT, you don´t need to malloc() here. You can just increase the reference 
count and return the same object.

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list