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 9E6BD423EF for ; Tue, 15 Mar 2022 20:39:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3551168B098; Tue, 15 Mar 2022 22:39:55 +0200 (EET) Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A28B68AFCC for ; Tue, 15 Mar 2022 22:39:46 +0200 (EET) Received: by mail-oi1-f181.google.com with SMTP id n7so559515oif.5 for ; Tue, 15 Mar 2022 13:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=wlsMBnEe8yx5bfuBHXxlqToTNIqExR5ouXLR2EISONI=; b=QX6HPO/dtDQsxXXgcmjiWqThg9Tj7LxEqsUD1q5cfG9cZpHTgz6+NXj3i5BPnAxxvF lg/oGLH9kmBBMEkqfykk/Y3eBqtBZcfTcw8SzKXz2pMsagEdkecyuj7XaDupInxnDmGi w/6nBKclbhtiHU/40IS6G9bkG+buIQ/5byE3Bo2MMbf26NchhHrf5+XAxU2s36wx7zIh 855qeg/6zy6iqzFFni4+dhu9JdF3J03yNxIRfiRYcqqp7RkFnb/UTHd1CfvBD8dc5fFI bkpt6A0TtHuu2VumwP8Mjw8JEWpg2VGwWj37BE4foZ66qg5P/uB/fJLnKR/W24Kt7ZKM cZhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=wlsMBnEe8yx5bfuBHXxlqToTNIqExR5ouXLR2EISONI=; b=Ey8SQ5c2r3xQdvYTm1DkxjUuSLDPmnjXeC1/GeSBJ3NxEKYGkkHbAtb8LriikJEN86 Uarv343OT6PoTiJEqdkgz2xN6Bo+b5BkSk9Mo7cv4t6fQTd+j6QUzMLTOsdM0E+ai7fx lgV7dZbKsm4XSVGx2NXvYvZQlxmrnLWg72aB9b219V+8I0n0X2wTASbeNHlN5c9fGjmp ijdyvR4EyBX0DS9ffVQ9Lw+zM39tJiTb1yS+r7X2VgHfAdZjv4vZBkyW2f525piwJoIG XU2OLBT6YyFiKKiOkRB5jWy9c5Od2Z5clolosb06Kz0KVZ80tdofYM6GF232b6PlIV5W u1bA== X-Gm-Message-State: AOAM531ydnLakB2p27nqFNs0crXA+pA4pkzrg/f7kNz9+rT76fJCKNEs RdhWjOp/c7geCSfq86mIk7c4BuOj32QoOA== X-Google-Smtp-Source: ABdhPJyP1BqaEI5ffdyCFESjzsKTaiugjNd0UbQs6/IUQdkUTjkyE875Kk73qn8nNjGQ6IvzTYEZVQ== X-Received: by 2002:a54:4d02:0:b0:2ec:94a4:f0a9 with SMTP id v2-20020a544d02000000b002ec94a4f0a9mr2614547oix.200.1647376784314; Tue, 15 Mar 2022 13:39:44 -0700 (PDT) Received: from [192.168.0.13] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id 1-20020a056870104100b000dd9a2eb20asm812274oaj.21.2022.03.15.13.39.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Mar 2022 13:39:43 -0700 (PDT) Message-ID: <8217ac3b-1d58-e772-9767-193d3eea48f4@gmail.com> Date: Tue, 15 Mar 2022 17:39:42 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220315203013.14304-1-cus@passwd.hu> <20220315203013.14304-3-cus@passwd.hu> From: James Almer In-Reply-To: <20220315203013.14304-3-cus@passwd.hu> Subject: Re: [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 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 3/15/2022 5:30 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 | 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); Maybe add a comment that you're not calling uninit on extra because it doesn't own its AVChannelMap pointer. > - > - av_bprintf(bp, "+%s", buf); > + av_bprint_chars(bp, '+', 1); > + av_channel_layout_describe_bprint(&extra, bp); > } > > return 0; _______________________________________________ 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".