From patchwork Tue Aug 25 14:09:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21918 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 87F6144B6CA for ; Tue, 25 Aug 2020 17:10:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70EAB68B017; Tue, 25 Aug 2020 17:10:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0DDC68AD9A for ; Tue, 25 Aug 2020 17:10:18 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id oz20so11775639ejb.5 for ; Tue, 25 Aug 2020 07:10: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdqCCZBtFGxmlF8nJTjLbW4DDmHV+6Skw1zQTkVO8wE=; b=nM0WXiAYP+JyPCYACCN2U5WnqKXq/d7rcX4aYBWVLQUFfuvXMckENk31KY9QOoc4mP TpSasfDB1MgoaQNmsgkQHjOv3RaFkEWaWFs7zPoVItZ8lUg/2QrR3/ioRImzgRA+1eXm l7ELNuax73mBfCwWOkMiwvh/Q0yqSsq14Kp2wfmnDUxAEr9e1qauzCeOSjLbMJ3sIUVI 9UVL7jiWj/XhacxOXM1bzymWExK96ypMX5U72b88IaBhhnYh2h1316LsoofqdjAq/If2 BWrFLJ8ElTSYeMnaGTRfc2q1LRNeXoQw2bXqlLIBZU5KhzHDK6xE9OWLwedU7dcqYtGg Rmgw== 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=EdqCCZBtFGxmlF8nJTjLbW4DDmHV+6Skw1zQTkVO8wE=; b=FTyuc1WneRhu5k7nPeYkQnN7ioAxDBbYxfNMmIU5f9+xmZJCVBJu/2WWTzKq2Csr8p NtwwSW2m1xj5vYlRTN8pzbtDRwLSlzyW8rr5OViUaIgen0pulBcLD7Mf+DdfU0TPneZb nN3+To0hd7OE1JFvHVkuifZXD7HxHD7XH5w/bdDYByaKkNVPZxHLV4Pbt7QgY/8QkSB3 aosKg1uWCDAAFVi9fTuwsNYTyz05NxbgAMGfiQfr67CxGVCbgK4e9OeaAIQQsGd+JKdE B9RKXtG99GHHNlYi2rk9bBU0nOSoBFinW21GXcHErIZJ8tSjhtPZ0Qp1jcVMYG/9ooEn /hdw== X-Gm-Message-State: AOAM533q2tN0hDFmPR+fbmiwxvRoEKxDk5a0ho5L2pv1BcVDxZSCumet fg+ebVzdZphuTBaMmFH6/YCB0zQ4Bkk= X-Google-Smtp-Source: ABdhPJyBsZgmZE1LvuEqtD1UAAIduWbXrvkAn46BZB9h9h7BRgHQsMv9en9vSjCVaUTeVYHqhArrlg== X-Received: by 2002:a17:906:e59:: with SMTP id q25mr4006734eji.143.1598364617834; Tue, 25 Aug 2020 07:10:17 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id k25sm10169806edx.96.2020.08.25.07.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:17 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:20 +0200 Message-Id: <20200825140927.16433-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> References: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/19] avfilter/af_afir: Avoid allocating AVFilterPad names 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" If the names are always the same, they need not be duplicated; doing so saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_afir.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 4e76bda4a3..d128f4bce7 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -800,11 +800,9 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&s->ir[i]); } - for (int i = 0; i < ctx->nb_inputs; i++) + for (unsigned i = 1; i < ctx->nb_inputs; i++) av_freep(&ctx->input_pads[i].name); - for (int i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); av_frame_free(&s->video); } @@ -842,18 +840,13 @@ static av_cold int init(AVFilterContext *ctx) int ret; pad = (AVFilterPad) { - .name = av_strdup("main"), + .name = "main", .type = AVMEDIA_TYPE_AUDIO, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_inpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } for (int n = 0; n < s->nb_irs; n++) { pad = (AVFilterPad) { @@ -872,34 +865,25 @@ static av_cold int init(AVFilterContext *ctx) } pad = (AVFilterPad) { - .name = av_strdup("default"), + .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } if (s->response) { vpad = (AVFilterPad){ - .name = av_strdup("filter_response"), + .name = "filter_response", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video, }; - if (!vpad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 1, &vpad); - if (ret < 0) { - av_freep(&vpad.name); + if (ret < 0) return ret; - } } s->fdsp = avpriv_float_dsp_alloc(0);