From patchwork Tue Mar 15 21:18:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 34784 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp3356546nkb; Tue, 15 Mar 2022 14:19:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWc79VY4qqvjcmA1SFKWvk9Eo2yjdcMoUQrMDLZRUIAzabpnii5eS89PBaW8lHJkJR6DjD X-Received: by 2002:a50:da8b:0:b0:415:a122:d7ad with SMTP id q11-20020a50da8b000000b00415a122d7admr26975702edj.123.1647379186582; Tue, 15 Mar 2022 14:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647379186; cv=none; d=google.com; s=arc-20160816; b=Yb61j3TLal9GjAfqNB4rQ/PSOZSadMnE+2smivqVT7VsbAfa+mlz/G7sghDNVtHEW1 rF9ZXKccISv5Mw49lJJKiogde86XnR/bkk3vZWW9IzLIV1GbQM6EFLrQpG/qa/qQofBJ Z1HKNK8BtFKLRbXF2uqTiJ3hxLxME8+pf7UR5UOWAh6fPOMzbtXvAyZ9Po7pFr+xtRne eoUAX1dr0W5BT0URlYqT7K2yHcCAPLDE/zmtrxaIXEQvG0I5wkCSrLwnMwGX0aFzXKMg uFa47CJ6SEBcIyG4e1XTyLHBQiF7k66cqyAMUYgWosKVqmX6ghjnaA1JB5O1oXkq6Cby Ph5Q== 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=//xjXQ6QGuHMWmpxZYB9xPo7A6pmkDhXGhqmWgOvSzU=; b=oKRasFqsl3KE0tdVvb05DKtmzayCr+yPxaw5E+hfOg/yf2IOfSYRXS3qwKwpMV230D U6bYTetXt7zzGYjxh0IQTjDpTB9PDEGikXMxQtROoG7mKLMBIkDiz6uIOk2hsy/VLrwD n/2veN94EnLIBns0bNRg79fb64EetRQg35QQVbx9j1tzML5vGOUBhBTx+2nhm2tU+vHs n75D2AnFUd7BN8+vNtPsXnjY5zLKuoN640KpSkrEMy64NO6ZbafzFrIH45Dyk3m8VYic ZcDSCowSes8pRXcDmXif9DzGeOjhPeKa/VjWs4TQj93I1oq38S3ym7D8w2jLypGPhzvT tvsQ== 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 g5-20020a170906520500b006d6dbea1f24si79582ejm.570.2022.03.15.14.19.46; Tue, 15 Mar 2022 14:19:46 -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 3606568B1AD; Tue, 15 Mar 2022 23:19:24 +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 5082E68B180 for ; Tue, 15 Mar 2022 23:19:17 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A98E1E4F6F; Tue, 15 Mar 2022 22:19:17 +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 f8ECmjBVpOdU; Tue, 15 Mar 2022 22:19:16 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B9C24E4FAF; Tue, 15 Mar 2022 22:19:15 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 22:18:58 +0100 Message-Id: <20220315211858.26800-4-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 4/4] avutil/channel_layout: fix av_channel_layout_describe_bprint with custom and ambisonic channels 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: gOOSnnJecL92 bp->len cannot be used to detect if try_describe_ambisonic was successful because the bprint buffer might contain other data as well. Also describing an invalid ambisonic layout should not return 0 but AVERROR(EINVAL) instead, so change try_describe_ambisonic to actually return error on invalid ambisonics. This also allows us to fix the first issue. Signed-off-by: Marton Balint --- libavutil/channel_layout.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index fb1f72737f..1a141d4a6a 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -689,14 +689,14 @@ static int ambisonic_order(const AVChannelLayout *channel_layout) /** * If the custom layout is n-th order standard-order ambisonic, with optional * extra non-diegetic channels at the end, write its string description in bp. - * Return a negative error code on error. + * Return a negative error code otherwise. */ static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout *channel_layout) { int nb_ambi_channels; int order = ambisonic_order(channel_layout); if (order < 0) - return 0; + return order; av_bprintf(bp, "ambisonic %d", order); @@ -739,8 +739,8 @@ int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, case AV_CHANNEL_ORDER_CUSTOM: if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM) { int res = try_describe_ambisonic(bp, channel_layout); - if (res < 0 || bp->len) - return res; + if (res >= 0) + return 0; } if (channel_layout->nb_channels) av_bprintf(bp, "%d channels (", channel_layout->nb_channels);