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 DDBB8410D2 for ; Tue, 15 Mar 2022 22:29:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A8B4A68AF8F; Wed, 16 Mar 2022 00:29:05 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E57C68AF2A for ; Wed, 16 Mar 2022 00:28:59 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D5EE7E5BB0 for ; Tue, 15 Mar 2022 23:28:59 +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 ecYblscCyBi1 for ; Tue, 15 Mar 2022 23:28:58 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 1803AE5B6A for ; Tue, 15 Mar 2022 23:28:58 +0100 (CET) Date: Tue, 15 Mar 2022 23:28:58 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <50127ba7-4120-d7af-702e-824f2110062a@gmail.com> Message-ID: <22cb3d2e-f48f-a6d-c449-764d2361551@passwd.hu> References: <1382f5bd-673f-f429-0ce9-ce39c3f9b586@gmail.com> <20220315211858.26800-1-cus@passwd.hu> <20220315211858.26800-3-cus@passwd.hu> <50127ba7-4120-d7af-702e-824f2110062a@gmail.com> MIME-Version: 1.0 Subject: Re: [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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 15 Mar 2022, James Almer wrote: > On 3/15/2022 6:18 PM, Marton Balint wrote: >> 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; > > LGTM. Thanks, applied the series (although in different order, because it turned out that this patch depends on the next). Thanks, Marton _______________________________________________ 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".