1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avutil/channel_layout: add specific text versions for unknown and unused channels

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2024-03-09 22:30:21 +01:00
parent a688fbfb88
commit a4fc331118
3 changed files with 18 additions and 1 deletions

View File

@ -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);

View File

@ -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");

View File

@ -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