[FFmpeg-devel] [PATCH] avfilter/vf_lut3d: allocate 3d lut dynamically

James Almer jamrial at gmail.com
Thu Oct 24 18:04:19 EEST 2019


On 10/24/2019 8:54 AM, Paul B Mahol wrote:
> +static int allocate_3dlut(AVFilterContext *ctx, int lutsize)
> +{
> +    LUT3DContext *lut3d = ctx->priv;
> +
> +    if (lutsize < 2 || lutsize > MAX_LEVEL) {
> +        av_log(ctx, AV_LOG_ERROR, "Too large or invalid 3D LUT size\n");
> +        return AVERROR(EINVAL);
> +    }
> +
> +    lut3d->lutsize = lutsize;
> +    lut3d->lutsize2 = lutsize * lutsize;
> +    lut3d->lut = av_malloc_array(lutsize * lutsize * lutsize, sizeof(*lut3d->lut));
> +    if (!lut3d->lut)
> +        return AVERROR(ENOMEM);
> +    return 0;
> +}

If this is allocated several times per frame/stream and the size doesn't
change (Or rarely does), then you could use a buffer pool instead.


More information about the ffmpeg-devel mailing list