From patchwork Thu Sep 10 23:49:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22272 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 638A344A710 for ; Fri, 11 Sep 2020 02:49:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E61268B9BA; Fri, 11 Sep 2020 02:49:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 789F568B821 for ; Fri, 11 Sep 2020 02:49:18 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id j2so9440648wrx.7 for ; Thu, 10 Sep 2020 16:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=skjx759WTWlycURijklfs+Y+aK8Lp4ULaDkLPjBxsaw=; b=SJJkAtOE2jxXeyT4OfTK1kOpPTsjU5DZL7vg9rqdQfnhlD8+ylHLFqI7do+nQalGZC bJMbZQ0YWrneX35CPfuXoIsiGYfTcgxdG7C0J5z62D8nDxbkbjksN+AT8nDRofXF91p3 ffam/mmTj2OuZFCoNVh3lmXJGpvaseDyiGZwnM5nX6cd+rr5z/M1D/LlPlu6K5i2JTEP sCVOB/8o7TFjunphH2QH3kO/iy1a9nRR//WHN+DofJvMepXgcRpap60U3VZIRrrUMoew sK9lGl86NBz31rtz1TFwoKdYvZ7qaPm8p/7pY8Lj5ssmOBf5DUtbwUfIOXekBM5KysbP fvKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=skjx759WTWlycURijklfs+Y+aK8Lp4ULaDkLPjBxsaw=; b=EmxqGa+fMAkAeiUc8moSAm3wV1LtnrGRj4noHKtg/ygeJD2Xt2nGl2HiuJ9Go/b0e8 RlqKCCnxKHGdia3Ds8l7n+Z45jXd/im99pG6pr4EvvEtTV9cNAA9Q9YqrBmfTn8ju0Fx UNXRwSkIu+WmE+T9wEoAKSs9k0r2AV/wnh87ftX03R1tdKaJKi+JTQRd06QDK3UchR/7 +b1tLJoYenO9WuVu8rcDDcUzIgD8VhOT6Y0n2nHOR0EZ31d9LgWXBs5WBwVTG5imZDES vapuON3x1XQYKV4d+fqw4tPDE5XmQEEbYtqdhbz/fq+fI9JVMbP7aHQbQWn2aUyzOfVm DY6g== X-Gm-Message-State: AOAM533A3qgIDjjr3EPOQH5Zfv86lQGcTzXle1HErx1x9WPp5V24up4d VudP0JrhyEgbec7TxSJ1cC4d6si4Ds4= X-Google-Smtp-Source: ABdhPJzHzSabj+cSm8SHNUBF5AKvaRjY/bnFMaV2/Iq1S9ujL6UZvkLr+AjBh3vi3rLtvhCxUuAhng== X-Received: by 2002:a5d:568d:: with SMTP id f13mr11067922wrv.303.1599781757530; Thu, 10 Sep 2020 16:49:17 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id j135sm586592wmj.20.2020.09.10.16.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 16:49:16 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Sep 2020 01:49:09 +0200 Message-Id: <20200910234911.12891-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/formats: Don't typedef structure a second time X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Before commit 2f76476549a01ae2c4ec2a440e4b14c5aba64869, avfilter.h contained no typedef for AVFilterChannelLayouts; all references to it were done using its struct tag. formats.h meanwhile contained the definition of the struct and a typedef for it. Said commit now added a typedef in avfilter.h, too, bringing it in line with AVFilterFormats; yet this means that there are two typedefs for AVFilterChannelLayouts (in contrast to AVFilterFormats which is only typedef'ed in avfilter.h). The problem is that older versions of GCC don't like this and error out: http://fate.ffmpeg.org/history.cgi?slot=x86_64-openbsd5.6-gcc4.2-conf2 is one of the FATE boxes that now fail to compile. So just remove the typedef in formats.h. Signed-off-by: Andreas Rheinhardt --- libavfilter/formats.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 8378be4b9b..0520bf42a9 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -83,7 +83,7 @@ struct AVFilterFormats { * channel count with unknown disposition with the same number of channels * (e.g. AV_CH_LAYOUT_STEREO and FF_COUNT2LAYOUT(2). */ -typedef struct AVFilterChannelLayouts { +struct AVFilterChannelLayouts { uint64_t *channel_layouts; ///< list of channel layouts int nb_channel_layouts; ///< number of channel layouts char all_layouts; ///< accept any known channel layout @@ -91,7 +91,7 @@ typedef struct AVFilterChannelLayouts { unsigned refcount; ///< number of references to this list struct AVFilterChannelLayouts ***refs; ///< references to this list -} AVFilterChannelLayouts; +}; /** * Encode a channel count as a channel layout. From patchwork Thu Sep 10 23:49:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22273 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8708344A710 for ; Fri, 11 Sep 2020 02:49:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 66EEB68B9D7; Fri, 11 Sep 2020 02:49:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3ED9468B9CB for ; Fri, 11 Sep 2020 02:49:34 +0300 (EEST) Received: by mail-wr1-f41.google.com with SMTP id j2so9441446wrx.7 for ; Thu, 10 Sep 2020 16:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cNn1xNjJuYYXEKRjM1SFSHnP5LR8Wo4vhqy8jGFBjkI=; b=Lm5q1YzfDMAKoUK05zDvLq/bDucWqOOOjOv72UDU9EWi8zELAg+nSWrSCK9UsnWK5a ULPJAJwn6u4phGB7aPQU47fjvaJHH9r15FJbeQgMJCGubjOhWqiVb7Y3IpgrHkrX/ZVi aKyDFbTPnH/322eB0PhvRdHnf+TfNHhFoOg8J6+FCsTP22WdnOs2MU/UYJlIXFCxEMPK N9rVjSm/hAPoHVzISeCQ/utJlhnHX7JJ+bKjNLpPyn+3SnKzUgvTo0ioM9CXaDg15jm3 dADjJXUCyWFImfVQqj4ki3ezCt5/iEL5+Me+a4iic6AfuFx5W5XnyBBROokFHpZxmVR0 fklg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cNn1xNjJuYYXEKRjM1SFSHnP5LR8Wo4vhqy8jGFBjkI=; b=k6EG53pDqDw2sBTxav9CxZcNEN73ihvzSHnQSiWPiLBVyuKMmSMyFktrj4ZRTZ6x/k DfiWMtMEm3dgThBigTB8vrK2jzvDrxTWgdkGvbRjOMt1yV4gjSbj2v7/4jWPWWWPNTtP fB3prYuwTp9GkShwCKnHx7H1oiu2iVf/FO7cJfRR1XVhoS7tBQOs2P7B2ZISWkiQ7D2X aqmdc0rKJJmYIXSkqiYvlhfaRVgyZhG3Ycz7718MKw+iwUfdv9Hw58fv6CZCX9BysKvu GL8AjHFGlsaqbkNqInLdWDWeJ53CEt8vBFMXcGWqKU/vaxoi0ANcInvQLbOPLrbXQkue 0sfg== X-Gm-Message-State: AOAM5331c48rwd9b9ZqihcinaDG892k2VMwlfDaSRUmBBT7QvV4d3wih zFHiS5xpL+k0qZLTnERJAMr03CCW47E= X-Google-Smtp-Source: ABdhPJznQ0OXeozcG84bQYmd/Yn/R6Sj9qrhtXASUqnBs1pmWdeFgAvJQQydzcTM3fOjEvI2f4DBvw== X-Received: by 2002:a05:6000:118a:: with SMTP id g10mr11619665wrx.67.1599781773166; Thu, 10 Sep 2020 16:49:33 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id j135sm586592wmj.20.2020.09.10.16.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 16:49:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Sep 2020 01:49:10 +0200 Message-Id: <20200910234911.12891-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200910234911.12891-1-andreas.rheinhardt@gmail.com> References: <20200910234911.12891-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avfilter/af_aformat, formats: Unify freeing AVFilterFormatsConfig X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" AVFilterFormats and AVFilterChannelLayouts always exist together, namely in the aformat filter as well as in AVFilterLinks. Now that they are grouped together in a single structure in AVFilterLinks, the same can be done in aformat and then this structure can be freed on its own, replacing the freeing functions for AVFilterFormats and AVFilterChannelLayouts structures (which still exist as static functions in formats.c). Signed-off-by: Andreas Rheinhardt --- Btw: There are several quite common combinations of functions like e.g. ff_make_format_list() and ff_formats_ref(). Should they be factored out in new functions or not? libavfilter/af_aformat.c | 26 ++++----- libavfilter/avfilter.c | 8 +-- libavfilter/avfiltergraph.c | 8 +-- libavfilter/formats.c | 105 +++++++++++++++++++----------------- libavfilter/formats.h | 13 ++--- 5 files changed, 76 insertions(+), 84 deletions(-) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index e669f2de83..a8dbdd8147 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -36,9 +36,7 @@ typedef struct AFormatContext { const AVClass *class; - AVFilterFormats *formats; - AVFilterFormats *sample_rates; - AVFilterChannelLayouts *channel_layouts; + AVFilterFormatsConfig config; char *formats_str; char *sample_rates_str; @@ -100,11 +98,11 @@ static av_cold int init(AVFilterContext *ctx) { AFormatContext *s = ctx->priv; - PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, + PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->config.formats, ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); - PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, + PARSE_FORMATS(s->sample_rates_str, int, s->config.samplerates, ff_add_format, get_sample_rate, 0, "sample rate"); - PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, + PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->config.channel_layouts, ff_add_channel_layout, av_get_channel_layout, 0, "channel layout"); @@ -115,9 +113,7 @@ static av_cold void uninit(AVFilterContext *ctx) { AFormatContext *s = ctx->priv; - ff_formats_unref(&s->formats); - ff_formats_unref(&s->sample_rates); - ff_channel_layouts_unref(&s->channel_layouts); + ff_filter_formats_config_unref(&s->config); } static int query_formats(AVFilterContext *ctx) @@ -125,19 +121,19 @@ static int query_formats(AVFilterContext *ctx) AFormatContext *s = ctx->priv; int ret; - ret = ff_set_common_formats(ctx, s->formats ? s->formats : + ret = ff_set_common_formats(ctx, s->config.formats ? s->config.formats : ff_all_formats(AVMEDIA_TYPE_AUDIO)); - s->formats = NULL; + s->config.formats = NULL; if (ret < 0) return ret; - ret = ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates : + ret = ff_set_common_samplerates(ctx, s->config.samplerates ? s->config.samplerates : ff_all_samplerates()); - s->sample_rates = NULL; + s->config.samplerates = NULL; if (ret < 0) return ret; - ret = ff_set_common_channel_layouts(ctx, s->channel_layouts ? s->channel_layouts : + ret = ff_set_common_channel_layouts(ctx, s->config.channel_layouts ? s->config.channel_layouts : ff_all_channel_counts()); - s->channel_layouts = NULL; + s->config.channel_layouts = NULL; return ret; } diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 8ff22c71e3..06cf564270 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -746,12 +746,8 @@ static void free_link(AVFilterLink *link) av_buffer_unref(&link->hw_frames_ctx); - ff_formats_unref(&link->incfg.formats); - ff_formats_unref(&link->outcfg.formats); - ff_formats_unref(&link->incfg.samplerates); - ff_formats_unref(&link->outcfg.samplerates); - ff_channel_layouts_unref(&link->incfg.channel_layouts); - ff_channel_layouts_unref(&link->outcfg.channel_layouts); + ff_filter_formats_config_unref(&link->incfg); + ff_filter_formats_config_unref(&link->outcfg); avfilter_link_free(&link); } diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index f6b572b3de..831fc2b985 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -727,12 +727,8 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) link->channels = av_get_channel_layout_nb_channels(link->channel_layout); } - ff_formats_unref(&link->incfg.formats); - ff_formats_unref(&link->outcfg.formats); - ff_formats_unref(&link->incfg.samplerates); - ff_formats_unref(&link->outcfg.samplerates); - ff_channel_layouts_unref(&link->incfg.channel_layouts); - ff_channel_layouts_unref(&link->outcfg.channel_layouts); + ff_filter_formats_config_unref(&link->incfg); + ff_filter_formats_config_unref(&link->outcfg); return 0; } diff --git a/libavfilter/formats.c b/libavfilter/formats.c index c54aff688f..98ff82a887 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -255,6 +255,55 @@ int ff_merge_channel_layouts(AVFilterChannelLayouts *a, return 1; } +#define FIND_REF_INDEX(ref, idx) \ +do { \ + int i; \ + for (i = 0; i < (*ref)->refcount; i ++) \ + if((*ref)->refs[i] == ref) { \ + idx = i; \ + break; \ + } \ +} while (0) + +#define FORMATS_UNREF(ref, list) \ +do { \ + int idx = -1; \ + \ + if (!ref || !*ref) \ + return; \ + \ + FIND_REF_INDEX(ref, idx); \ + \ + if (idx >= 0) { \ + memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \ + sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \ + --(*ref)->refcount; \ + } \ + if (!(*ref)->refcount) { \ + av_free((*ref)->list); \ + av_free((*ref)->refs); \ + av_free(*ref); \ + } \ + *ref = NULL; \ +} while (0) + +static void formats_unref(AVFilterFormats **ref) +{ + FORMATS_UNREF(ref, formats); +} + +static void channel_layouts_unref(AVFilterChannelLayouts **ref) +{ + FORMATS_UNREF(ref, channel_layouts); +} + +void ff_filter_formats_config_unref(AVFilterFormatsConfig *cfg) +{ + formats_unref(&cfg->formats); + formats_unref(&cfg->samplerates); + channel_layouts_unref(&cfg->channel_layouts); +} + int ff_fmt_is_in(int fmt, const int *fmts) { const int *p; @@ -332,14 +381,14 @@ do { \ int ff_add_format(AVFilterFormats **avff, int64_t fmt) { - ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats); + ADD_FORMAT(avff, fmt, formats_unref, int, formats, nb_formats); return 0; } int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) { av_assert1(!(*l && (*l)->all_layouts)); - ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, uint64_t, channel_layouts, nb_channel_layouts); + ADD_FORMAT(l, channel_layout, channel_layouts_unref, uint64_t, channel_layouts, nb_channel_layouts); return 0; } @@ -461,54 +510,12 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref) { - FORMATS_REF(f, ref, ff_channel_layouts_unref); + FORMATS_REF(f, ref, channel_layouts_unref); } int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) { - FORMATS_REF(f, ref, ff_formats_unref); -} - -#define FIND_REF_INDEX(ref, idx) \ -do { \ - int i; \ - for (i = 0; i < (*ref)->refcount; i ++) \ - if((*ref)->refs[i] == ref) { \ - idx = i; \ - break; \ - } \ -} while (0) - -#define FORMATS_UNREF(ref, list) \ -do { \ - int idx = -1; \ - \ - if (!ref || !*ref) \ - return; \ - \ - FIND_REF_INDEX(ref, idx); \ - \ - if (idx >= 0) { \ - memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \ - sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \ - --(*ref)->refcount; \ - } \ - if (!(*ref)->refcount) { \ - av_free((*ref)->list); \ - av_free((*ref)->refs); \ - av_free(*ref); \ - } \ - *ref = NULL; \ -} while (0) - -void ff_formats_unref(AVFilterFormats **ref) -{ - FORMATS_UNREF(ref, formats); -} - -void ff_channel_layouts_unref(AVFilterChannelLayouts **ref) -{ - FORMATS_UNREF(ref, channel_layouts); + FORMATS_REF(f, ref, formats_unref); } #define FORMATS_CHANGEREF(oldref, newref) \ @@ -570,14 +577,14 @@ int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts) { SET_COMMON_FORMATS(ctx, channel_layouts, - ff_channel_layouts_ref, ff_channel_layouts_unref); + ff_channel_layouts_ref, channel_layouts_unref); } int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates) { SET_COMMON_FORMATS(ctx, samplerates, - ff_formats_ref, ff_formats_unref); + ff_formats_ref, formats_unref); } /** @@ -588,7 +595,7 @@ int ff_set_common_samplerates(AVFilterContext *ctx, int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) { SET_COMMON_FORMATS(ctx, formats, - ff_formats_ref, ff_formats_unref); + ff_formats_ref, formats_unref); } int ff_default_query_formats(AVFilterContext *ctx) diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 0520bf42a9..8a7dbb2f97 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -191,11 +191,6 @@ av_warn_unused_result int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref); -/** - * Remove a reference to a channel layouts list. - */ -void ff_channel_layouts_unref(AVFilterChannelLayouts **ref); - void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref); @@ -261,9 +256,11 @@ av_warn_unused_result int ff_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); /** - * If *ref is non-NULL, remove *ref as a reference to the format list + * If cfg->formats is non-NULL, remove it as a reference to the format list * it currently points to, deallocates that list if this was the last - * reference, and sets *ref to NULL. + * reference, and sets cfg->formats to NULL. + * + * Also does the same for cfg->sample_rates and cfg->channel_layouts. * * Before After * ________ ________ NULL @@ -275,7 +272,7 @@ int ff_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); * | |____| | | |____| | |____| | | |____| * |________| |_____________________ |________| |_____________________ */ -void ff_formats_unref(AVFilterFormats **ref); +void ff_filter_formats_config_unref(AVFilterFormatsConfig *cfg); /** * Before After From patchwork Thu Sep 10 23:49:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22274 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 889BC44A710 for ; Fri, 11 Sep 2020 02:49:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 707DD68B9D3; Fri, 11 Sep 2020 02:49:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F25E68B9CB for ; Fri, 11 Sep 2020 02:49:35 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id e17so2616708wme.0 for ; Thu, 10 Sep 2020 16:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=80uIFdNDieBqzKmLzy6xClbLWgvk524THnTq8Hsp4fc=; b=SyOGGHBShnaEgTs2JqMK4veKh59dDHixwWabeAW6993b9nwaoPJpzCQWzhLTN1KraB N3edIqPyYeGLb0YPfCJWRp5uBvGA+cMnNRTnlOWZbfJQU2TqNI9vBenDxSdRmim5jNJO Nb2/IJyqg3rhOH8sQUOSlNzIVanTpfbEc0z+lGk95qji0OLGZY3JURursR83T9Sk/FaM 3FqZnnmkE5lDlp1in4E99iyBELsq81TVw5OUyiSVlZ9KEICo76UoA+vlRtjO0R6UVgJc +xtp8AlSq35efILkHnQ1lsVyg8gdKiFe/FwMPQe7PqNdu7MnNVASGckZry8285LOOjmL 5d3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=80uIFdNDieBqzKmLzy6xClbLWgvk524THnTq8Hsp4fc=; b=HIIbJIvJ1pv5WQyRrZpXL/Qik2+yGV9fwR0Q2mj/rzXwGUOByUhrU7rdd6FGAyOF7f 3XA0HcG/jYcPVTk9gcBqZZRb0e9npGtFxeHcZvMOY4xytrLq2oSYxp5KIuhAuoka1vXI L0Zl2XfvykYJZ/3MJUn71sfHNwFJS7oZdSG9sT2YVGYAJcb4fatrUGO6UoxVIUJYKu0q al145RWyuBnt98zRgIfZYq5I1cKDmvQaqnOo0RTbZykOMvkN9L7w2rOGyXcPb+7lxtSA phKvWDD9rripvV9bl4raBPtdUHZUpdzq6aklpYdUbwzDXB5tYKmcD3LxK/NpVtj/42yn W+6A== X-Gm-Message-State: AOAM533MF6vwOWRdMx2AVIkuR8fyyvyzUZfIHmeDPCvfEinnAZQ4+t+t 1/TCOuFQ2TZ7+6Ihyxes1mRNeHmYAdk= X-Google-Smtp-Source: ABdhPJy1HbUsC7pH/7vxbupcb3OQT4yHZpjYORKwwUBDhtEOizA8gKjWyY48ac4K+iBrz/zBu6gGqQ== X-Received: by 2002:a1c:cc0d:: with SMTP id h13mr2322123wmb.44.1599781774329; Thu, 10 Sep 2020 16:49:34 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id j135sm586592wmj.20.2020.09.10.16.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 16:49:33 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Sep 2020 01:49:11 +0200 Message-Id: <20200910234911.12891-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200910234911.12891-1-andreas.rheinhardt@gmail.com> References: <20200910234911.12891-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avfilter/formats: Remove pointless checks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ff_formats_ref() takes a pointer to an AVFilterFormats and a pointer to a pointer to an AVFilterFormats as arguments and adds the latter as an owner to the list pointed to by the former; the latter is hereby always the address of a list contained in an AVFilterFormatsConfig and can therefore not be NULL. So remove the check for whether it is NULL; also do the same for ff_channel_layouts_ref(). Also do the same for the unref functions where argument is never NULL because it is always the address of an existing lvalue. Signed-off-by: Andreas Rheinhardt --- libavfilter/formats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 98ff82a887..43c90b9a27 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -269,7 +269,7 @@ do { \ do { \ int idx = -1; \ \ - if (!ref || !*ref) \ + if (!*ref) \ return; \ \ FIND_REF_INDEX(ref, idx); \ @@ -495,7 +495,7 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) #define FORMATS_REF(f, ref, unref_fn) \ void *tmp; \ \ - if (!f || !ref) \ + if (!f) \ return AVERROR(ENOMEM); \ \ tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \