avutil/tests/channel_layout: add some av_channel_from_string and av_channel_layout_from_string tests

We lacked tests which supposed to fail, and there are some which should fail
but right now it does not. This will be fixed in a later commit.

Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Marton Balint 2024-03-09 00:13:43 +01:00 committed by Paul B Mahol
parent 869bcb1760
commit d1a3a48638
2 changed files with 52 additions and 0 deletions

View File

@ -255,6 +255,11 @@ int main(void)
CHANNEL_FROM_STRING("USR63");
CHANNEL_FROM_STRING("AMBI0");
CHANNEL_FROM_STRING("AMBI1023");
CHANNEL_FROM_STRING("AMBI1024");
CHANNEL_FROM_STRING("Dummy");
CHANNEL_FROM_STRING("FL@Foo");
CHANNEL_FROM_STRING("Foo@FL");
CHANNEL_FROM_STRING("@FL");
printf("\n==Native layouts==\n");
@ -301,6 +306,9 @@ int main(void)
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "SL");
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "SR");
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "BC");
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "@");
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "@Foo");
CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FL@Foo");
printf("\nTesting av_channel_layout_index_from_string\n");
CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FL");
@ -321,9 +329,27 @@ int main(void)
printf("\nTesting av_channel_layout_from_string\n");
CHANNEL_LAYOUT_FROM_STRING("FL+FR+FC+BL+BR+LFE");
CHANNEL_LAYOUT_FROM_STRING("2 channels (FR+FL)");
CHANNEL_LAYOUT_FROM_STRING("2 channels (AMBI1023+FL)");
CHANNEL_LAYOUT_FROM_STRING("3 channels (FR+FL)");
CHANNEL_LAYOUT_FROM_STRING("-3 channels (FR+FL)");
CHANNEL_LAYOUT_FROM_STRING("0 channels ()");
CHANNEL_LAYOUT_FROM_STRING("2 channels (FL+FR");
CHANNEL_LAYOUT_FROM_STRING("ambisonic 1+FR+FL");
CHANNEL_LAYOUT_FROM_STRING("ambisonic 2+FC@Foo");
CHANNEL_LAYOUT_FROM_STRING("FL@Foo+FR@Bar");
CHANNEL_LAYOUT_FROM_STRING("FL+stereo");
CHANNEL_LAYOUT_FROM_STRING("stereo+stereo");
CHANNEL_LAYOUT_FROM_STRING("stereo@Boo");
CHANNEL_LAYOUT_FROM_STRING("");
CHANNEL_LAYOUT_FROM_STRING("@");
CHANNEL_LAYOUT_FROM_STRING("@Dummy");
CHANNEL_LAYOUT_FROM_STRING("@FL");
CHANNEL_LAYOUT_FROM_STRING("Dummy");
CHANNEL_LAYOUT_FROM_STRING("Dummy@FL");
CHANNEL_LAYOUT_FROM_STRING("FR+Dummy");
CHANNEL_LAYOUT_FROM_STRING("FR+Dummy@FL");
CHANNEL_LAYOUT_FROM_STRING("FR+@FL");
CHANNEL_LAYOUT_FROM_STRING("FL+@");
CHANNEL_LAYOUT_FROM_STRING("FR+FL@Foo+USR63@Foo");
ret = av_channel_layout_copy(&layout2, &layout);

View File

@ -56,6 +56,11 @@ With "FR": 1
With "USR63": 63
With "AMBI0": 1024
With "AMBI1023": 2047
With "AMBI1024": -1
With "Dummy": -1
With "FL@Foo": -1
With "Foo@FL": -1
With "@FL": -1
==Native layouts==
@ -101,6 +106,9 @@ On "5.1(side)" layout with "LFE": 3
On "5.1(side)" layout with "SL": 9
On "5.1(side)" layout with "SR": 10
On "5.1(side)" layout with "BC": -1
On "5.1(side)" layout with "@": -1
On "5.1(side)" layout with "@Foo": -1
On "5.1(side)" layout with "FL@Foo": -1
Testing av_channel_layout_index_from_string
On "5.1(side)" layout with "FL": 0
@ -121,9 +129,27 @@ On "5.1(side)" layout with AV_CH_LAYOUT_4POINT1: 0xf
Testing av_channel_layout_from_string
With "FL+FR+FC+BL+BR+LFE": 6 channels (FL+FR+FC+BL+BR+LFE)
With "2 channels (FR+FL)": 2 channels (FR+FL)
With "2 channels (AMBI1023+FL)": fail
With "3 channels (FR+FL)": fail
With "-3 channels (FR+FL)": fail
With "0 channels ()": fail
With "2 channels (FL+FR": fail
With "ambisonic 1+FR+FL": ambisonic 1+2 channels (FR+FL)
With "ambisonic 2+FC@Foo": ambisonic 2+1 channels (FC@Foo)
With "FL@Foo+FR@Bar": 2 channels (FL@Foo+FR@Bar)
With "FL+stereo": fail
With "stereo+stereo": fail
With "stereo@Boo": fail
With "": fail
With "@": fail
With "@Dummy": fail
With "@FL": 1 channels (FL)
With "Dummy": fail
With "Dummy@FL": fail
With "FR+Dummy": fail
With "FR+Dummy@FL": 1 channels (FR)
With "FR+@FL": 2 channels (FR+FL@FL)
With "FL+@": fail
With "FR+FL@Foo+USR63@Foo": 3 channels (FR+FL@Foo+USR63@Foo)
Testing av_channel_layout_index_from_string