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 8F04343A61 for ; Sat, 6 Aug 2022 11:39:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D7E868B70F; Sat, 6 Aug 2022 14:39:54 +0300 (EEST) Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0C4968B4F5 for ; Sat, 6 Aug 2022 14:39:47 +0300 (EEST) Received: by mail-vs1-f48.google.com with SMTP id b124so4741093vsc.9 for ; Sat, 06 Aug 2022 04:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc; bh=e/acxlhniUJekVvAA3q7G4C0ICgndknMH6rNmajp/GY=; b=Bu6lAxVXjkMw/BmeYyVvP/SAjAOgIHqDiBJLjU5qwlhkGN6l3vZjvtcSWbsTETQ0yp 8mOB0+865RFadb0dwaQppJg4S46gIdOAFN5EsAi1WSUYq5itEnQHdNIXbbIhGwo97GqT pHdubr9S8FER3qHYETUE2R1gubOnkqjyKUWEO2ZTvGUUHUsyq9+uW1EzGZ6Aqle9D/Db YsBOQov7CpCF5u8Mk4unlDcIOMdTKjnX2P7CyuGs/HPFoPTzSsDjJ77A9gVyESV0LsQJ /H6/UBwjXfSxJ6dbac0dHnRO8XFJ/Ewe1ReVjlOSRriuJASd9AKjcwAtzo7WOpAYpymA cJfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=e/acxlhniUJekVvAA3q7G4C0ICgndknMH6rNmajp/GY=; b=PvHqJA06f682fN5JrCLhzN9aCGLvBwdtjbIsny2uGgadH6BsMgTZtjJK+QHaqqTqBC 9x7PNQ53AtrXvE1/PjUImmzDyHJoRrbMhmnf/46vKYVY9Ck7Ijzj9pRBXAzy0y2MpK50 4qcA2PZ41ve+YTWVkm21248mwU1Zh24i4JeyPIRFTBJeKej0CmjnAwjX1A/RDBMBf6+0 P/MMW8NS/F8uq3P9Ya/X8lBTXRMVfOQRRGalBlTIYpiEUCSDT1bDk0JfGNmaARgu+atu tUXzvUKbz0npqkG4XmQY+CErYjU9ebZVQoRVGF83Nb0L+/55Kp3cR2gY3urrnnZQQfXb 3wRw== X-Gm-Message-State: ACgBeo2iYzVc+INammpA9S9amuyQCiVdjyNKzbMLC5sq4Mp+Mn0JXaZb l2GwFJmOIl2jQBqM/Wv7dwrTknrcGXc= X-Google-Smtp-Source: AA6agR55cYe6ZQMCwyP0j0h7i9HiUwqjVLMMqVjQ7gj6FK0sIy6keUhL/z6sSgb2RVMu2ShiC3hF5Q== X-Received: by 2002:a67:c39c:0:b0:388:1e6:6637 with SMTP id s28-20020a67c39c000000b0038801e66637mr3703813vsj.81.1659741494038; Fri, 05 Aug 2022 16:18:14 -0700 (PDT) Received: from localhost.localdomain ([186.136.131.204]) by smtp.gmail.com with ESMTPSA id k23-20020a67e3d7000000b0038855ac0416sm3720997vsm.7.2022.08.05.16.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 16:18:13 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Aug 2022 20:17:59 -0300 Message-Id: <20220805231759.2922-1-jamrial@gmail.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy 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: It's not modified, so we can simply use a const pointer to it. Also check the return value of the other copy in the function while at it. Signed-off-by: James Almer --- libavfilter/avfiltergraph.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index b7dbfc063b..53f468494d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -729,12 +729,12 @@ static int reduce_formats_on_filter(AVFilterContext *filter) /* reduce channel layouts */ for (i = 0; i < filter->nb_inputs; i++) { AVFilterLink *inlink = filter->inputs[i]; - AVChannelLayout fmt = { 0 }; + const AVChannelLayout *fmt; if (!inlink->outcfg.channel_layouts || inlink->outcfg.channel_layouts->nb_channel_layouts != 1) continue; - av_channel_layout_copy(&fmt, &inlink->outcfg.channel_layouts->channel_layouts[0]); + fmt = &inlink->outcfg.channel_layouts->channel_layouts[0]; for (j = 0; j < filter->nb_outputs; j++) { AVFilterLink *outlink = filter->outputs[j]; @@ -745,24 +745,25 @@ static int reduce_formats_on_filter(AVFilterContext *filter) continue; if (fmts->all_layouts && - (KNOWN(&fmt) || fmts->all_counts)) { + (KNOWN(fmt) || fmts->all_counts)) { /* Turn the infinite list into a singleton */ fmts->all_layouts = fmts->all_counts = 0; - if (ff_add_channel_layout(&outlink->incfg.channel_layouts, &fmt) < 0) + if (ff_add_channel_layout(&outlink->incfg.channel_layouts, fmt) < 0) ret = 1; break; } for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) { - if (!av_channel_layout_compare(&fmts->channel_layouts[k], &fmt)) { - av_channel_layout_copy(&fmts->channel_layouts[0], &fmt); + if (!av_channel_layout_compare(&fmts->channel_layouts[k], fmt)) { + ret = av_channel_layout_copy(&fmts->channel_layouts[0], fmt); + if (ret < 0) + return ret; fmts->nb_channel_layouts = 1; ret = 1; break; } } } - av_channel_layout_uninit(&fmt); } return ret; -- 2.37.1 _______________________________________________ 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".