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 C9F19462DC for ; Thu, 11 May 2023 18:12:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4BA7768C059; Thu, 11 May 2023 21:12:08 +0300 (EEST) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E3CD68B4FE for ; Thu, 11 May 2023 21:12:01 +0300 (EEST) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-55a1c5976d0so10475167b3.1 for ; Thu, 11 May 2023 11:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683828720; x=1686420720; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=IBh13Wtl3JjWSi/0OFtb+hq8/PuIOU+JeVkd59VcoVM=; b=nDjOkCHvz1cy5ilwb7LNDnmHoUCwp6sIiAuRoeom7oCx4jHWYKJpNZHttYfGFTZ70/ qTGfbVI/gnXFFmB3J7cXPbR3tCDrPEVsg//Fm2BYw9U0NwJFsyxBAMdHMClMwbqTLi3k qD2kL0hTgsod6kBYK6jgvAD4UK5rm2zMAPrX7oPygWApL48QMErOjBNVnmMDHz/IsBRz bxvdapUaCePOTrS4Ip+Kj+AQGgF/MI09uLxtehNpOjrBBN3PB953eeaflspO6RIoOb1i NXsWbbD+mibx3lUTJgNY2sl5v6GUnQOdvVFhTP4Myw0W5FtHrjF5Nkt4mESol/WPCoMN /vfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683828720; x=1686420720; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IBh13Wtl3JjWSi/0OFtb+hq8/PuIOU+JeVkd59VcoVM=; b=VTWya02jcE031pDRbXdnjYm7RN6P+hoM1ZctyyulyOTRVr0vnddA5YHapP7XBbqBGY 2fm8gG00wot3TB3sj2MVKJSRsSELIOjuYESCTxCMVODjdCZwU60DnRTaxMrumtHVeJl6 b69/5D0Zvp0maK1gPpeIa7uPHSYFy14qvOnNQUxtMVhoJo55gmGuawBwPtWVCb2vO9hK +gk7y8JPBGb3R7HK17DC87j5j4YCQXrCKvJvZNYuA06Hf6pYhkT3m8BDxw11Q1nNEaQC zDx+1V0AVh/X97pICAInwlhO49ctB0kWIglXLgtp5DdZTBO8ABohTiOHXEojZ8ooz7Us THag== X-Gm-Message-State: AC+VfDxWEBw6d03CffsE+O1zMp3cyS5z0ZmUQIxxGW81prE0mTB0IJzd FsjjAEZOSrmXJODIxftvgAqPhvkyfJc= X-Google-Smtp-Source: ACHHUZ723c+BqvlXxwu5Lo3FduwJP6FUU0lJN6/93xYZHbM4MEJcl9vSMCVWIKjudWRnnwwNa+36/A== X-Received: by 2002:a81:1b94:0:b0:55d:a393:a2bc with SMTP id b142-20020a811b94000000b0055da393a2bcmr21441347ywb.4.1683828720197; Thu, 11 May 2023 11:12:00 -0700 (PDT) Received: from [192.168.1.35] (c-98-224-219-15.hsd1.mi.comcast.net. [98.224.219.15]) by smtp.gmail.com with ESMTPSA id l62-20020a0de241000000b00560c2e3ec63sm2153231ywe.77.2023.05.11.11.11.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 May 2023 11:11:59 -0700 (PDT) Message-ID: Date: Thu, 11 May 2023 14:11:57 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 To: ffmpeg-devel@ffmpeg.org References: <20230511180334.14965-1-jamrial@gmail.com> Content-Language: en-US-large From: Leo Izen In-Reply-To: <20230511180334.14965-1-jamrial@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/ccfifo: remove unnecessary context allocations 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 5/11/23 14:03, James Almer wrote: > This is not public API, no it has no need for an alloc() and free() > functions. The struct can reside on stack. > > Signed-off-by: James Almer > --- > libavfilter/ccfifo.c | 49 ++++++++++++------------------------- > libavfilter/ccfifo.h | 42 ++++++++++++++++++------------- > libavfilter/tinterlace.h | 2 +- > libavfilter/vf_bwdif.c | 8 +++--- > libavfilter/vf_ccrepack.c | 13 +++++----- > libavfilter/vf_fps.c | 13 +++++----- > libavfilter/vf_tinterlace.c | 18 +++++++------- > libavfilter/vf_yadif.c | 8 +++--- > libavfilter/vf_yadif_cuda.c | 6 ++--- > libavfilter/yadif.h | 2 +- > libavfilter/yadif_common.c | 6 ++--- > 11 files changed, 81 insertions(+), 86 deletions(-) > > diff --git a/libavfilter/ccfifo.c b/libavfilter/ccfifo.c > index 5fb68ce04c..a3c6a09698 100644 > --- a/libavfilter/ccfifo.c > +++ b/libavfilter/ccfifo.c > @@ -23,18 +23,6 @@ > > #include "ccfifo.h" > > -struct AVCCFifo { > - AVFifo *cc_608_fifo; > - AVFifo *cc_708_fifo; > - AVRational framerate; > - int expected_cc_count; > - int expected_608; > - int cc_detected; > - int passthrough; > - int passthrough_warning; > - void *log_ctx; > -}; > - > #define MAX_CC_ELEMENTS 128 > #define CC_BYTES_PER_ENTRY 3 > > @@ -55,25 +43,18 @@ const static struct cc_lookup cc_lookup_vals[] = { > { 60000, 1001, 10, 1}, > }; > > -void ff_ccfifo_freep(AVCCFifo **ccf) > +void ff_ccfifo_uninit(CCFifo *ccf) > { > - AVCCFifo *tmp = *ccf; > - if (tmp) { > - av_fifo_freep2(&tmp->cc_608_fifo); > - av_fifo_freep2(&tmp->cc_708_fifo); > - } > - av_freep(ccf); > + av_fifo_freep2(&ccf->cc_608_fifo); > + av_fifo_freep2(&ccf->cc_708_fifo); > + memset(&ccf, 0, sizeof(ccf)); See later comment about memset, I have the same question. ccf is a pointer. > } > > -AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx) > +int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx) > { > - AVCCFifo *ccf; > int i; > > - ccf = av_mallocz(sizeof(*ccf)); > - if (!ccf) > - return NULL; > - > + memset(&ccf, 0, sizeof(ccf)); > ccf->log_ctx = log_ctx; > ccf->framerate = framerate; I'm confused by this memset, why isn't it: memset(ccf, 0, sizeof(CCFifo)); As written it appears to be equivalent to: ccf = NULL; Unless I'm missing something here, this should immediately pop a null dereference. - Leo Izen (Traneptora / thebombzen) _______________________________________________ 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".