From patchwork Tue Mar 15 20:30:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 34782 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp3328186nkb; Tue, 15 Mar 2022 13:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw62K9K2HKYalSajMOE8M9bN5XUD30+3gvQ1i7xSBPFa4XFA6XG5vKF+Uis0ykUILMYU2nf X-Received: by 2002:a17:906:4fd0:b0:6db:2639:6640 with SMTP id i16-20020a1709064fd000b006db26396640mr23711804ejw.313.1647376260289; Tue, 15 Mar 2022 13:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647376260; cv=none; d=google.com; s=arc-20160816; b=mQLLqOh/RoD/KUQB6cdEl50kUZlczI+XdapMJNG4IFFihGTJTxdAmVs6nIojEWPdZp 5/l5izpwAI5EuDqXbfwEl28Ztv+RXT3pMiFxhod4JfsoFoY38Bj6SO1Zhz+z7LEkYHS+ iehm0ei548rDJ8AVvcki+9QoiKeQzv+Z0Xoc4tGtnDy6qB7tCUDqjsJ7yn81NUT3XkPj 27kcRPACSw192um5HYxuj3SNitvY/qjvD1rWzTNBLd4C6OmF2gEY+HRAE8zzlQPgl+Yj koXqDo6I+tUaT1qCYcapgoq/l21T13f854NdSgpkeeXXiEvcb+GDd1mRlqlQXiRZgyKQ 90SA== 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=NazXnc2y/B8VWsWNoguUZRZr3fczrO0zbJcDrgVGatA=; b=kAhgWssil5+GBhzXsHwjHTXxjiZMPLZhR5YFmWDl71lwnNvif/wyWEsCB7HjsxzSdA Gdi5/gpZKlZoAeqeWkSVeKuMhC/XOlxxctSMqZJLHchpB1xyUbFw5VhvqYIKcvqQgSru tH6mGESLyqbI78rM+GI8EQMozI/peCBIFQKNRRn1G0BY/t30PYdcgNAxmLWQEd30Wawb ONrUQOcQLej3qkLIV1WIj+6klaNznno+4X8fIbge1lTK54vgm5G1KKbvlXi+xMrBywPK vuCWn/U5oOzUBNGKxSWutg/0lUEH3GIR0QSTysB69JOBLaWnOmwAUuhhVDpWV1/6oAda jBdA== 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 l9-20020a056402254900b004167de7ce21si55767edb.363.2022.03.15.13.30.59; Tue, 15 Mar 2022 13:31:00 -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 3877A68012B; Tue, 15 Mar 2022 22:30:41 +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 5ED7268B168 for ; Tue, 15 Mar 2022 22:30:33 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BF8BFE4DF2; Tue, 15 Mar 2022 21:30:33 +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 7EyS8f3gjL05; Tue, 15 Mar 2022 21:30:32 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 24E10E134B; Tue, 15 Mar 2022 21:30:32 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 21:30:13 +0100 Message-Id: <20220315203013.14304-4-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 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: 1UXUOd9FlpSc 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 8406089fe0..be511dcf68 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -687,14 +687,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); @@ -736,7 +736,7 @@ 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) + if (res >= 0) return res; } if (channel_layout->nb_channels)