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 E0DE7423EE for ; Tue, 15 Mar 2022 20:30:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1C7268B13C; Tue, 15 Mar 2022 22:30:32 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A518568B0FB for ; Tue, 15 Mar 2022 22:30:23 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 08273E4DF2; Tue, 15 Mar 2022 21:30:24 +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 I4mP-lMsEjb5; Tue, 15 Mar 2022 21:30:22 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D11ECE5C3D; Tue, 15 Mar 2022 21:30:22 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 21:30:12 +0100 Message-Id: <20220315203013.14304-3-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220315203013.14304-1-cus@passwd.hu> References: <20220315203013.14304-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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 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: Also use av_channel_layout_bprint directly for describing channel layout for extra channels. Signed-off-by: Marton Balint --- libavutil/channel_layout.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index fb2335a334..8406089fe0 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -702,29 +702,19 @@ 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); } return 0; -- 2.31.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".