From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 5A80045EC1 for ; Fri, 16 Jun 2023 12:22:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DD19868C075; Fri, 16 Jun 2023 15:22:41 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B4C7F68BFD2 for ; Fri, 16 Jun 2023 15:22:35 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 655AD48296 for ; Fri, 16 Jun 2023 14:22:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686918155; bh=qGyKGzaj5lCadpsc7MjIA8z//0Hjp4OIwMRBQeHXhiM=; h=Date:From:To:Subject:In-Reply-To:References:From; b=X0jf7lkW84n5FvdV1/TfB8D+/g2eedW98DDDONIF45qXLdAorijZp/jLnBdU7g9HB u8GLdz5oVWiq64jDJTCTfz06kZPP8HIQMfu4gmhRTCA0HejwgFT0lee2phrSRYxjYh c5migUPOvg7dK/Hfi/YXehlfsuQgXU/BicJd/89M= Date: Fri, 16 Jun 2023 14:22:34 +0200 Message-ID: <20230616142234.GB14937@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: References: <20230616092959.5247-1-ffmpeg@haasn.xyz> <20230616092959.5247-9-ffmpeg@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH 09/22] lavfi/vf_libplacebo: replace s->input by dynamic array X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Fri, 16 Jun 2023 14:09:56 +0200 Andreas Rheinhardt wrote: > Niklas Haas: > > From: Niklas Haas > > > > For now, hard-coded to 1 element. > > --- > > libavfilter/vf_libplacebo.c | 18 +++++++++++++----- > > 1 file changed, 13 insertions(+), 5 deletions(-) > > > > diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c > > index 408fb3918a..fbac1b0354 100644 > > --- a/libavfilter/vf_libplacebo.c > > +++ b/libavfilter/vf_libplacebo.c > > @@ -136,7 +136,8 @@ typedef struct LibplaceboContext { > > pl_tex tex[4]; > > > > /* input state */ > > - LibplaceboInput input; > > + LibplaceboInput *inputs; > > + int nb_inputs; > > > > /* settings */ > > char *out_format_string; > > @@ -660,7 +661,12 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct > > } > > > > /* Initialize inputs */ > > - RET(input_init(avctx, avctx->inputs[0], &s->input)); > > + s->nb_inputs = 1; > > + s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); > > + if (!s->inputs) > > + return AVERROR(ENOMEM); > > + for (int i = 0; i < s->nb_inputs; i++) > > + RET(input_init(avctx, avctx->inputs[i], &s->inputs[i])); > > > > /* fall through */ > > fail: > > @@ -677,7 +683,9 @@ static void libplacebo_uninit(AVFilterContext *avctx) > > pl_tex_destroy(s->gpu, &s->tex[i]); > > for (int i = 0; i < s->num_hooks; i++) > > pl_mpv_user_shader_destroy(&s->hooks[i]); > > - input_uninit(&s->input); > > + for (int i = 0; i < s->nb_inputs && s->inputs; i++) > > + input_uninit(&s->inputs[i]); > > + av_freep(&s->inputs); > > In case the allocation of s->inputs fails, nb_inputs is 1 and the above > loop will try to uninit a non-existant input. There's an extra `s->inputs` check in the loop condition. I'll make it more explicit. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".