Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marton Balint <cus@passwd.hu>
To: ffmpeg-devel@ffmpeg.org
Cc: Marton Balint <cus@passwd.hu>
Subject: [FFmpeg-devel] [PATCH 7/7] avutil/channel_layout: add specific text versions for unknown and unused channels
Date: Sat,  9 Mar 2024 22:54:14 +0100
Message-ID: <20240309215414.26699-7-cus@passwd.hu> (raw)
In-Reply-To: <20240309215414.26699-1-cus@passwd.hu>

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 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
-- 
2.35.3

_______________________________________________
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".

  parent reply	other threads:[~2024-03-09 21:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 21:54 [FFmpeg-devel] [PATCH 1/7] avutil/channel_layout: add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 2/7] avformat/mov_chan: simplify channel layout canonicalization Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 3/7] avutil/tests/channel_layout: make printing results part of the tests Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 4/7] avutil/tests/channel_layout: add some av_channel_from_string and av_channel_layout_from_string tests Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 5/7] avutil/channel_layout: factorize parsing list of channel names Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 6/7] avutil/channel_layout: fix some (un)initialization issues in av_channel_layout_from_string() Marton Balint
2024-03-09 21:54 ` Marton Balint [this message]
2024-03-16  8:34 ` [FFmpeg-devel] [PATCH 1/7] avutil/channel_layout: add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240309215414.26699-7-cus@passwd.hu \
    --to=cus@passwd.hu \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git