From patchwork Sun Aug 9 15:57:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21553 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 9F38444B9EE for ; Sun, 9 Aug 2020 18:58:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7F38A68AAD8; Sun, 9 Aug 2020 18:58:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E430668A922 for ; Sun, 9 Aug 2020 18:58:23 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id a26so7010749ejc.2 for ; Sun, 09 Aug 2020 08:58:23 -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=Yc6A6SAIGynWLK4HmyDdKOWBgiHv/Db0hWLXsz4DzXQ=; b=qMqNvh95dajkJnWBekH1BndL0QvrgOIy6bdDSR3fmxxiFFK0tg6unXMbDC0aLJ6Wbl ofuebmJIGHLJ1yQzjAr/SDsAQiwjexNvDB5v+tEaRZv/hUUQl6Np1aqcjzJLOhTsRspA mSYF9YeqF2fbmrYTCNq3tiaCwm7qSD3oVrAiBoOcupStqFfqd4tWc7+mgCWh5PK/Dks8 IQrmTnE0z5ZPPRtY+xkhBZ/+pY8P443+YPci1QrltiFtFkyA+EU4iz3wKLIviocJY1NT n55D3du4FPbUWj1UZpzpRw3gFexgVS1R0op4TboA8Rmw3ELwyUVQH7XDOs4QZ6DtLCJQ 0IqA== 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=Yc6A6SAIGynWLK4HmyDdKOWBgiHv/Db0hWLXsz4DzXQ=; b=Hbtyh2l+pMUWfX7yOOIomi2J4E1hbTDQOgQxS+u9vp335CdOcrfecSSAuynnUVcOjw yCBhEjyH7bzfVLpcFEJiillL/uHfGg+EnGLguAAg+4CD6tIkMjjze1uTs1iuwZUo+p6y S+sTne8lqlTU9m8yTZ3LKb+f9Ed2oNvkLNJ0vuh1NwLi7aZ8tbJmsAveQbMOygZp6FUm ZY9Ye9lu/EhTHQPtTzdfEyvZZ6nV57+TeJqx20mbRN9953XQA0dAZzZkUZM/X5Fysfe/ NCI/dNhmz+CEjUY6rAjiUzKT8ooZrJoEg18xS+fqf8uZ74EIwWfDM0m/hFGmKz7CQBKc MFwQ== X-Gm-Message-State: AOAM530r0oPcCHAZjQ230lie27JxG0z5dIgwQXDW9u5IARjyDwfQ1lRT hN4eSfUV7Hq6QCGsnpjqRZpogxMx X-Google-Smtp-Source: ABdhPJxFnX7LxihRfgqVTxshQSU2c32WstifyVelHqv1QVQDxEOoEcN5xmvGYxkflQqEP29uMHOUbQ== X-Received: by 2002:a17:906:386:: with SMTP id b6mr17898051eja.538.1596988703125; Sun, 09 Aug 2020 08:58:23 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id g11sm5360290edv.95.2020.08.09.08.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 08:58:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Aug 2020 17:57:37 +0200 Message-Id: <20200809155748.30092-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200808140202.586-1-andreas.rheinhardt@gmail.com> References: <20200808140202.586-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/21] avfilter/af_amix: Don't needlessly reallocate table 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" Replace using ff_add_format() repeatedly by a single call to ff_make_format_list(). (Right now this also fixes a memleak: If the first ff_add_format() succeeds and a subsequent call fails, the list leaks.) Signed-off-by: Andreas Rheinhardt --- libavfilter/af_amix.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index 0826fc118c..6a4ef8d944 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { - AVFilterFormats *formats = NULL; + static const enum AVSampleFormat sample_fmts[] = { + AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP, + AV_SAMPLE_FMT_NONE + }; AVFilterChannelLayouts *layouts; int ret; @@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx) goto fail; } - if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 || - (ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 || - (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL )) < 0 || - (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP)) < 0 || - (ret = ff_set_common_formats (ctx, formats)) < 0 || + if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 0 || (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 || (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) goto fail;