From patchwork Tue Mar 15 21:18:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 34787 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp3356481nkb; Tue, 15 Mar 2022 14:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0ygbB4IWiaPBXhMMJ6GufO0tlTcHd3NIFJCbRl5cHZDJJXiS0rZ9xZjCNssbxm3gdBsp3 X-Received: by 2002:a17:906:a1c2:b0:6d6:d54d:4fb1 with SMTP id bx2-20020a170906a1c200b006d6d54d4fb1mr25865055ejb.490.1647379178017; Tue, 15 Mar 2022 14:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647379178; cv=none; d=google.com; s=arc-20160816; b=gY/KD0iIDRc2dz1TbPDJVjoxx0akta11628DO6xv4tjH16th4oOHSCLGcTDvrN+bmh Fr0y7oTmgRyDzRLRNEeuT4avynufA/E9DwKAdL80qDGKfsq+5N8Me0leh23+bU4iKKBx lyG6KgPIF6hDjRVES8+bo8UDf5ZBK2PCAwvmFWCXiUA+WPSiheSWbRZdEzIJOLpbmW2O 7rAFbHTr+lIpAcvsHttQvI59tVyCQ+ySah4EF/Gx7Nr5XHSf9JxGrMgPaBAtaEAwPU1z Z7vR7a16DSL1F8VmvXSdsZIptrr20VjpgC8Nc/OlhUJysWNR+o9ud5NpLQvIg9HGjAWa xSLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=NZ9eO6MS9+kJzfhP2vcXK2F4vc53Py/fyCPXZuS95+U=; b=NnoHCmc6C4A5aaS3WRbJBeU7OpwG1UEUa79NrDqS8ThmDfTLD9eI5PVce/TMnx5oyk DmuEHWZNxxZUg9lErhXCtkeGri7rISjSXDI0cwNQgPZYVsYzNlFh2CYntzQD/aO8Zt7D k0f7LJ50xmJSCbevco1pTN7S2Vsd54QJP1MFJGh6usIUPLDgptNwmrPqsb1Rt2JuUfUq 84WWQtroLYBxXt2hvSrjBp0Cpd8324xSepD7u6rr1HJeDHnDF4nB5/JclnS7dRTeyUiZ ZYLjbCK9Y2tps4UjDM/8X6uC305YmWTb9UZbRglFy3u+pVuMaUP+ntScv6frd2R5dvie XPhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hs35-20020a1709073ea300b006cec3e62ab8si74441ejc.459.2022.03.15.14.19.37; Tue, 15 Mar 2022 14:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4BAF068B19A; Tue, 15 Mar 2022 23:19:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E992C68B120 for ; Tue, 15 Mar 2022 23:19:15 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4D74CE5C27; Tue, 15 Mar 2022 22:19:16 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zYvMiZKERjvW; Tue, 15 Mar 2022 22:19:15 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id ECA5BE4F6F; Tue, 15 Mar 2022 22:19:14 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 22:18:57 +0100 Message-Id: <20220315211858.26800-3-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220315211858.26800-1-cus@passwd.hu> References: <1382f5bd-673f-f429-0ce9-ce39c3f9b586@gmail.com> <20220315211858.26800-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/4] avutil/channel_layout: do not copy alloc new map for extra channel layout 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VRo3tkNs4A0V Also use av_channel_layout_bprint directly for describing channel layout for extra channels. Signed-off-by: Marton Balint --- libavutil/channel_layout.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 0069c6257b..fb1f72737f 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -704,29 +704,20 @@ static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout *channel_l nb_ambi_channels = (order + 1) * (order + 1); if (nb_ambi_channels < channel_layout->nb_channels) { AVChannelLayout extra = { 0 }; - char buf[128]; if (channel_layout->order == AV_CHANNEL_ORDER_AMBISONIC) { extra.order = AV_CHANNEL_ORDER_NATIVE; extra.nb_channels = av_popcount64(channel_layout->u.mask); extra.u.mask = channel_layout->u.mask; } else { - const AVChannelCustom *map = channel_layout->u.map; - extra.order = AV_CHANNEL_ORDER_CUSTOM; extra.nb_channels = channel_layout->nb_channels - nb_ambi_channels; - extra.u.map = av_calloc(extra.nb_channels, sizeof(*extra.u.map)); - if (!extra.u.map) - return AVERROR(ENOMEM); - - memcpy(extra.u.map, &map[nb_ambi_channels], - sizeof(*extra.u.map) * extra.nb_channels); + extra.u.map = channel_layout->u.map + nb_ambi_channels; } - av_channel_layout_describe(&extra, buf, sizeof(buf)); - av_channel_layout_uninit(&extra); - - av_bprintf(bp, "+%s", buf); + av_bprint_chars(bp, '+', 1); + av_channel_layout_describe_bprint(&extra, bp); + /* Not calling uninit here on extra because we don't own the u.map pointer */ } return 0;