From patchwork Sat Mar 9 21:54:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 46926 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dc95:b0:1a1:738b:6bc0 with SMTP id ky21csp442377pzb; Sat, 9 Mar 2024 13:55:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUFZp24HC+7asKlWnVXAYG21zXNUAeZo6SmekrOxHVG2IweS4yDQ7v2pYG+A7YeWvqZxiqWq0YHlBvnoslmO7BcosVNpNyVQrwx+A== X-Google-Smtp-Source: AGHT+IGZGQ0eFCoNo+Jwg1tyOCsMNMfckTJ76Z6Z8xZ9WtaTQwWBaOd9RGyBLj97i32Spa1GPrwc X-Received: by 2002:a50:c192:0:b0:568:1a8:58b with SMTP id m18-20020a50c192000000b0056801a8058bmr1634053edf.14.1710021326708; Sat, 09 Mar 2024 13:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1710021326; cv=none; d=google.com; s=arc-20160816; b=R4XaNzadzw0K2CGrGWkXNU32l52mKYS8BVImpr3NRIfCfoxbqaw71la09V4q8V/5xr EPw1Dg1YORaKF3mxleArdjO5/RKR9tjIOCjfRqrD3Fw9jnAJCxFOP9ofDyJTBPFzNhVR GaFLcLzICiMiIGOsLkYo4mnpJEifwZRdVbhuEVwOscmySuy/C8Khjpfkq4bXFKa+cZLe EX1Ol1qVjV7GhtB5O+sB9S8vrM1OsnE+hRzsy3RYCCjH0uiF6wTvRn31/4sXobIFF4t7 /SDlVP1hI8XZrPcJgU0ZjamvtNH8sOzj2DuV92g+REZ0KYgd6Pe7ok2HSGhP6WOyYdAK Q0Gg== 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=ZvR3ncJIuuhFenu3thizyZEjNbTyc1j0FNh9pEngJMQ=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=V/0lOWVBLlBrucCIVCBMRfudTg7AyziYeLr+iXsJvYyfTZCbEqofgUG5HbLJ+s3Q27 bVNL/u+RPnZcn2cQZuC9CWdkw+xEO/Anmo2bVG+XwCi5H8QjZRreGHGPaXkBSFUEb0rm 3Ui1XcLKd1q0CLVZHMEX/wrzhETh68W3NKPGiJ3Sq/fCoKiSRrR99z3JoW2AAebj6N0O iu7RL3jsBvhzYHA2mw+CF0Lt7zj1IL6aKMgsmEBEuaswWrzwLU+Cu93zcjpHRgv/XwML tLgd9OHhQ1MXX/LhBouvxk9NZLMUFXS6YrxkSsqWsUL4ooBpqGLdj6aZi/pQD/emcDdc H8mg==; dara=google.com 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 v1-20020a056402348100b005676553bc54si1038044edc.625.2024.03.09.13.55.26; Sat, 09 Mar 2024 13:55:26 -0800 (PST) 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 62E0568CF45; Sat, 9 Mar 2024 23:54:52 +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 DC1D268CDD9 for ; Sat, 9 Mar 2024 23:54:50 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9B040E98EB; Sat, 9 Mar 2024 22:54:50 +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 KCEGqTKpMLp6; Sat, 9 Mar 2024 22:54:49 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 66146E8EC5; Sat, 9 Mar 2024 22:54:47 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Mar 2024 22:54:14 +0100 Message-Id: <20240309215414.26699-7-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240309215414.26699-1-cus@passwd.hu> References: <20240309215414.26699-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] avutil/channel_layout: add specific text versions for unknown and unused 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: arH6U8cifdy6 Signed-off-by: Marton Balint --- libavutil/channel_layout.c | 13 +++++++++++++ libavutil/tests/channel_layout.c | 2 ++ tests/ref/fate/channel_layout | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 9e8a1c12e6..a83618bcc7 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -86,6 +86,10 @@ void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) av_bprintf(bp, "%s", channel_names[channel_id].name); else if (channel_id == AV_CHAN_NONE) av_bprintf(bp, "NONE"); + else if (channel_id == AV_CHAN_UNKNOWN) + av_bprintf(bp, "UNK"); + else if (channel_id == AV_CHAN_UNUSED) + av_bprintf(bp, "UNSD"); else av_bprintf(bp, "USR%d", channel_id); } @@ -115,6 +119,10 @@ void av_channel_description_bprint(AVBPrint *bp, enum AVChannel channel_id) av_bprintf(bp, "%s", channel_names[channel_id].description); else if (channel_id == AV_CHAN_NONE) av_bprintf(bp, "none"); + else if (channel_id == AV_CHAN_UNKNOWN) + av_bprintf(bp, "unknown"); + else if (channel_id == AV_CHAN_UNUSED) + av_bprintf(bp, "unused"); else av_bprintf(bp, "user %d", channel_id); } @@ -151,6 +159,11 @@ enum AVChannel av_channel_from_string(const char *str) if (channel_names[i].name && !strcmp(str, channel_names[i].name)) return i; } + if (!strcmp(str, "UNK")) + return AV_CHAN_UNKNOWN; + if (!strcmp(str, "UNSD")) + return AV_CHAN_UNUSED; + if (!strncmp(str, "USR", 3)) { const char *p = str + 3; id = strtol(p, &endptr, 0); diff --git a/libavutil/tests/channel_layout.c b/libavutil/tests/channel_layout.c index 14d36c71b5..8132b83434 100644 --- a/libavutil/tests/channel_layout.c +++ b/libavutil/tests/channel_layout.c @@ -348,6 +348,8 @@ int main(void) CHANNEL_LAYOUT_FROM_STRING("Dummy@FL"); CHANNEL_LAYOUT_FROM_STRING("FR+Dummy"); CHANNEL_LAYOUT_FROM_STRING("FR+Dummy@FL"); + CHANNEL_LAYOUT_FROM_STRING("UNK+UNSD"); + CHANNEL_LAYOUT_FROM_STRING("NONE"); CHANNEL_LAYOUT_FROM_STRING("FR+@FL"); CHANNEL_LAYOUT_FROM_STRING("FL+@"); CHANNEL_LAYOUT_FROM_STRING("FR+FL@Foo+USR63@Foo"); diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout index 117a5fd84d..0bcfefce3b 100644 --- a/tests/ref/fate/channel_layout +++ b/tests/ref/fate/channel_layout @@ -148,6 +148,8 @@ With "Dummy": fail With "Dummy@FL": fail With "FR+Dummy": fail With "FR+Dummy@FL": fail +With "UNK+UNSD": 2 channels (UNK+UNSD) +With "NONE": fail With "FR+@FL": fail With "FL+@": fail With "FR+FL@Foo+USR63@Foo": 3 channels (FR+FL@Foo+USR63@Foo) @@ -236,5 +238,5 @@ With "ambisonic 2+stereo": AMBI (ambisonic 2+stereo) With "2C": UNSPEC (2 channels) == UNSPEC (2 channels) != NATIVE - == CUSTOM (2 channels (USR768+USR768)) + == CUSTOM (2 channels (UNK+UNK)) != AMBI