From: Marton Balint <cus@passwd.hu> To: ffmpeg-devel@ffmpeg.org Cc: Marton Balint <cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/7] avutil/tests/channel_layout: make printing results part of the tests Date: Sat, 9 Mar 2024 22:54:10 +0100 Message-ID: <20240309215414.26699-3-cus@passwd.hu> (raw) In-Reply-To: <20240309215414.26699-1-cus@passwd.hu> Deduplicates a lot of code. Some minor differences (mostly white space and inconsistent use of quotes) are expected in the fate tests, there was no point aiming for exactly the same formatting. Signed-off-by: Marton Balint <cus@passwd.hu> --- libavutil/tests/channel_layout.c | 283 +++++++++++-------------------- tests/ref/fate/channel_layout | 176 +++++++++---------- 2 files changed, 186 insertions(+), 273 deletions(-) diff --git a/libavutil/tests/channel_layout.c b/libavutil/tests/channel_layout.c index 23bb6009fb..d62b69a5db 100644 --- a/libavutil/tests/channel_layout.c +++ b/libavutil/tests/channel_layout.c @@ -162,39 +162,50 @@ static const char *channel_layout_retype(AVChannelLayout *layout, AVBPrint *bp, } #define CHANNEL_NAME(x) \ - channel_name(&bp, (x)); + channel_name(&bp, (x)); \ + printf("With %-32s %14s\n", AV_STRINGIFY(x)":", bp.str) #define CHANNEL_DESCRIPTION(x) \ - channel_description(&bp, (x)); + channel_description(&bp, (x)); \ + printf("With %-23s %23s\n", AV_STRINGIFY(x)":", bp.str); + +#define CHANNEL_FROM_STRING(x) \ + printf("With %-38s %8d\n", AV_STRINGIFY(x)":", av_channel_from_string(x)) #define CHANNEL_LAYOUT_FROM_MASK(x) \ channel_layout_from_mask(&layout, &bp, (x)); #define CHANNEL_LAYOUT_FROM_STRING(x) \ - channel_layout_from_string(&layout, &bp, (x)); + channel_layout_from_string(&layout, &bp, (x)); \ + printf("With \"%s\":%*s %32s\n", x, strlen(x) > 32 ? 0 : 32 - (int)strlen(x), "", bp.str); -#define CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(x) \ +#define CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(l, x) \ ret = av_channel_layout_channel_from_index(&layout, x); \ if (ret < 0) \ - ret = -1 + ret = -1; \ + printf("On \"%s\" layout with %2d: %8d\n", l, x, ret) -#define CHANNEL_LAYOUT_SUBSET(x) \ - mask = av_channel_layout_subset(&layout, x) +#define CHANNEL_LAYOUT_SUBSET(l, xstr, x) \ + mask = av_channel_layout_subset(&layout, x); \ + printf("On \"%s\" layout with %-22s 0x%"PRIx64"\n", l, xstr, mask) -#define CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(x) \ +#define CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(l, x) \ ret = av_channel_layout_index_from_channel(&layout, x); \ if (ret < 0) \ - ret = -1 + ret = -1; \ + printf("On \"%s\" layout with %-23s %3d\n", l, AV_STRINGIFY(x)":", ret) -#define CHANNEL_LAYOUT_CHANNEL_FROM_STRING(x) \ +#define CHANNEL_LAYOUT_CHANNEL_FROM_STRING(l, x) \ ret = av_channel_layout_channel_from_string(&layout, x); \ if (ret < 0) \ - ret = -1 + ret = -1; \ + printf("On \"%s\" layout with %-21s %3d\n", bp.str, AV_STRINGIFY(x)":", ret); -#define CHANNEL_LAYOUT_INDEX_FROM_STRING(x) \ +#define CHANNEL_LAYOUT_INDEX_FROM_STRING(l, x) \ ret = av_channel_layout_index_from_string(&layout, x); \ if (ret < 0) \ - ret = -1 + ret = -1; \ + printf("On \"%s\" layout with %-20s %3d\n", l, AV_STRINGIFY(x)":", ret); int main(void) { @@ -226,152 +237,94 @@ int main(void) printf("\nTesting av_channel_name\n"); CHANNEL_NAME(AV_CHAN_FRONT_LEFT); - printf("With AV_CHAN_FRONT_LEFT: %27s\n", bp.str); CHANNEL_NAME(AV_CHAN_FRONT_RIGHT); - printf("With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str); CHANNEL_NAME(63); - printf("With 63: %43s\n", bp.str); CHANNEL_NAME(AV_CHAN_AMBISONIC_BASE); - printf("With AV_CHAN_AMBISONIC_BASE: %23s\n", bp.str); CHANNEL_NAME(AV_CHAN_AMBISONIC_END); - printf("With AV_CHAN_AMBISONIC_END: %24s\n", bp.str); printf("Testing av_channel_description\n"); CHANNEL_DESCRIPTION(AV_CHAN_FRONT_LEFT); - printf("With AV_CHAN_FRONT_LEFT: %27s\n", bp.str); CHANNEL_DESCRIPTION(AV_CHAN_FRONT_RIGHT); - printf("With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str); CHANNEL_DESCRIPTION(63); - printf("With 63: %43s\n", bp.str); CHANNEL_DESCRIPTION(AV_CHAN_AMBISONIC_BASE); - printf("With AV_CHAN_AMBISONIC_BASE: %23s\n", bp.str); CHANNEL_DESCRIPTION(AV_CHAN_AMBISONIC_END); - printf("With AV_CHAN_AMBISONIC_END: %24s\n", bp.str); printf("\nTesting av_channel_from_string\n"); - printf("With \"FL\": %41d\n", av_channel_from_string("FL")); - printf("With \"FR\": %41d\n", av_channel_from_string("FR")); - printf("With \"USR63\": %38d\n", av_channel_from_string("USR63")); - printf("With \"AMBI0\": %38d\n", av_channel_from_string("AMBI0")); - printf("With \"AMBI1023\": %35d\n", av_channel_from_string("AMBI1023")); + CHANNEL_FROM_STRING("FL"); + CHANNEL_FROM_STRING("FR"); + CHANNEL_FROM_STRING("USR63"); + CHANNEL_FROM_STRING("AMBI0"); + CHANNEL_FROM_STRING("AMBI1023"); printf("\n==Native layouts==\n"); printf("\nTesting av_channel_layout_from_string\n"); CHANNEL_LAYOUT_FROM_STRING("0x3f"); - printf("With \"0x3f\": %39s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("63"); - printf("With \"63\": %41s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("6c"); - printf("With \"6c\": %41s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("6C"); - printf("With \"6C\": %41s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("6 channels"); - printf("With \"6 channels\": %33s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("6 channels (FL+FR+FC+LFE+BL+BR)"); - printf("With \"6 channels (FL+FR+FC+LFE+BL+BR)\": %12s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("FL+FR+FC+LFE+BL+BR"); - printf("With \"FL+FR+FC+LFE+BL+BR\": %25s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("5.1"); - printf("With \"5.1\": %40s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("FL+FR+USR63"); - printf("With \"FL+FR+USR63\": %32s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("FL+FR+FC+LFE+SL+SR"); - printf("With \"FL+FR+FC+LFE+SL+SR\": %25s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("5.1(side)"); - printf("With \"5.1(side)\": %34s\n", bp.str); printf("\nTesting av_channel_layout_from_mask\n"); CHANNEL_LAYOUT_FROM_MASK(AV_CH_LAYOUT_5POINT1); printf("With AV_CH_LAYOUT_5POINT1: %25s\n", bp.str); printf("\nTesting av_channel_layout_channel_from_index\n"); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(0); - printf("On 5.1(side) layout with 0: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(1); - printf("On 5.1(side) layout with 1: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(2); - printf("On 5.1(side) layout with 2: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(3); - printf("On 5.1(side) layout with 3: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(4); - printf("On 5.1(side) layout with 4: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(5); - printf("On 5.1(side) layout with 5: %24d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(6); - printf("On 5.1(side) layout with 6: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 0); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 1); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 2); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 3); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 4); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 5); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 6); printf("\nTesting av_channel_layout_index_from_channel\n"); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_LEFT); - printf("On 5.1(side) layout with AV_CHAN_FRONT_LEFT: %7d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_RIGHT); - printf("On 5.1(side) layout with AV_CHAN_FRONT_RIGHT: %6d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_CENTER); - printf("On 5.1(side) layout with AV_CHAN_FRONT_CENTER: %5d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_LOW_FREQUENCY); - printf("On 5.1(side) layout with AV_CHAN_LOW_FREQUENCY: %4d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_SIDE_LEFT); - printf("On 5.1(side) layout with AV_CHAN_SIDE_LEFT: %8d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_SIDE_RIGHT); - printf("On 5.1(side) layout with AV_CHAN_SIDE_RIGHT: %7d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_BACK_CENTER); - printf("On 5.1(side) layout with AV_CHAN_BACK_CENTER: %6d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_LEFT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_RIGHT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_CENTER); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_LOW_FREQUENCY); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_SIDE_LEFT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_SIDE_RIGHT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_BACK_CENTER); printf("\nTesting av_channel_layout_channel_from_string\n"); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FL"); - printf("On 5.1(side) layout with \"FL\": %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FR"); - printf("On 5.1(side) layout with \"FR\": %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FC"); - printf("On 5.1(side) layout with \"FC\": %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("LFE"); - printf("On 5.1(side) layout with \"LFE\": %20d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("SL"); - printf("On 5.1(side) layout with \"SL\": %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("SR"); - printf("On 5.1(side) layout with \"SR\": %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("BC"); - printf("On 5.1(side) layout with \"BC\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FL"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FR"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FC"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "LFE"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "SL"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "SR"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "BC"); printf("\nTesting av_channel_layout_index_from_string\n"); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FL"); - printf("On 5.1(side) layout with \"FL\": %21d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FR"); - printf("On 5.1(side) layout with \"FR\": %21d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FC"); - printf("On 5.1(side) layout with \"FC\": %21d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("LFE"); - printf("On 5.1(side) layout with \"LFE\": %20d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("SL"); - printf("On 5.1(side) layout with \"SL\": %21d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("SR"); - printf("On 5.1(side) layout with \"SR\": %21d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("BC"); - printf("On 5.1(side) layout with \"BC\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FL"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FR"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FC"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "LFE"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "SL"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "SR"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "BC"); printf("\nTesting av_channel_layout_subset\n"); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_STEREO); - printf("On 5.1(side) layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64"\n", mask); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_2POINT1); - printf("On 5.1(side) layout with AV_CH_LAYOUT_2POINT1: 0x%"PRIx64"\n", mask); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_4POINT1); - printf("On 5.1(side) layout with AV_CH_LAYOUT_4POINT1: 0x%"PRIx64"\n", mask); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_STEREO:", AV_CH_LAYOUT_STEREO); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_2POINT1:", AV_CH_LAYOUT_2POINT1); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_4POINT1:", AV_CH_LAYOUT_4POINT1); printf("\n==Custom layouts==\n"); printf("\nTesting av_channel_layout_from_string\n"); CHANNEL_LAYOUT_FROM_STRING("FL+FR+FC+BL+BR+LFE"); - printf("With \"FL+FR+FC+BL+BR+LFE\": %34s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("2 channels (FR+FL)"); - printf("With \"2 channels (FR+FL)\": %34s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("ambisonic 1+FR+FL"); - printf("With \"ambisonic 1+FR+FL\": %35s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("ambisonic 2+FC@Foo"); - printf("With \"ambisonic 2+FC@Foo\": %34s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("FL@Foo+FR@Bar"); - printf("With \"FL@Foo+FR@Bar\": %39s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("FR+FL@Foo+USR63@Foo"); - printf("With \"FR+FL@Foo+USR63@Foo\": %33s\n", bp.str); ret = av_channel_layout_copy(&layout2, &layout); if (ret < 0) { @@ -383,104 +336,64 @@ int main(void) printf("Channel layout and its copy compare unequal; ret: %d\n", ret); printf("\nTesting av_channel_layout_index_from_string\n"); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FR"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FR\": %18d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FL"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FL\": %18d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("USR63"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63\": %15d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"Foo\": %17d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"@Foo\": %16d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FR@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FR@Foo\": %14d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("FL@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FL@Foo\": %14d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("USR63@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63@Foo\": %11d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_STRING("BC"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"BC\": %18d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FR"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FL"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "USR63"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "Foo"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "@Foo"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FR@Foo"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "FL@Foo"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "USR63@Foo"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(bp.str, "BC"); printf("\nTesting av_channel_layout_channel_from_string\n"); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FR"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FR\": %18d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FL"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FL\": %18d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("USR63"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63\": %15d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"Foo\": %17d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"@Foo\": %16d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FR@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FR@Foo\": %14d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("FL@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"FL@Foo\": %14d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("USR63@Foo"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63@Foo\": %11d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_STRING("BC"); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with \"BC\": %18d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FR"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FL"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "USR63"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "Foo"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "@Foo"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FR@Foo"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "FL@Foo"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "USR63@Foo"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(bp.str, "BC"); printf("\nTesting av_channel_layout_index_from_channel\n"); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_RIGHT); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_FRONT_RIGHT: %3d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_LEFT); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_FRONT_LEFT: %4d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(63); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with 63: %20d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_BACK_CENTER); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_BACK_CENTER: %3d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_RIGHT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_LEFT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, 63); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_BACK_CENTER); printf("\nTesting av_channel_layout_channel_from_index\n"); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(0); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with 0: %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(1); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with 1: %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(2); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with 2: %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(3); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with 3: %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 0); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 1); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 2); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 3); printf("\nTesting av_channel_layout_subset\n"); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_STEREO); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64"\n", mask); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_QUAD); - printf("On \"FR+FL@Foo+USR63@Foo\" layout with AV_CH_LAYOUT_QUAD: 0x%"PRIx64"\n", mask); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_STEREO:", AV_CH_LAYOUT_STEREO); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_QUAD:", AV_CH_LAYOUT_QUAD); printf("\n==Ambisonic layouts==\n"); printf("\nTesting av_channel_layout_from_string\n"); CHANNEL_LAYOUT_FROM_STRING("ambisonic 1"); - printf("With \"ambisonic 1\": %41s\n", bp.str); CHANNEL_LAYOUT_FROM_STRING("ambisonic 2+stereo"); - printf("With \"ambisonic 2+stereo\": %34s\n", bp.str); printf("\nTesting av_channel_layout_index_from_channel\n"); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_AMBISONIC_BASE); - printf("On \"ambisonic 2+stereo\" layout with AV_CHAN_AMBISONIC_BASE: %d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_LEFT); - printf("On \"ambisonic 2+stereo\" layout with AV_CHAN_FRONT_LEFT: %5d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_FRONT_RIGHT); - printf("On \"ambisonic 2+stereo\" layout with AV_CHAN_FRONT_RIGHT: %4d\n", ret); - CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(AV_CHAN_BACK_CENTER); - printf("On \"ambisonic 2+stereo\" layout with AV_CHAN_BACK_CENTER: %4d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_AMBISONIC_BASE); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_LEFT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_FRONT_RIGHT); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(bp.str, AV_CHAN_BACK_CENTER); printf("\nTesting av_channel_layout_channel_from_index\n"); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(0); - printf("On \"ambisonic 2+stereo\" layout with 0: %22d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(9); - printf("On \"ambisonic 2+stereo\" layout with 9: %22d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(10); - printf("On \"ambisonic 2+stereo\" layout with 10: %21d\n", ret); - CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(11); - printf("On \"ambisonic 2+stereo\" layout with 11: %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 0); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 9); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 10); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(bp.str, 11); printf("\nTesting av_channel_layout_subset\n"); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_STEREO); - printf("On \"ambisonic 2+stereo\" layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64"\n", mask); - CHANNEL_LAYOUT_SUBSET(AV_CH_LAYOUT_QUAD); - printf("On \"ambisonic 2+stereo\" layout with AV_CH_LAYOUT_QUAD: 0x%"PRIx64"\n", mask); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_STEREO:", AV_CH_LAYOUT_STEREO); + CHANNEL_LAYOUT_SUBSET(bp.str, "AV_CH_LAYOUT_QUAD:", AV_CH_LAYOUT_QUAD); av_channel_layout_uninit(&layout); av_channel_layout_uninit(&layout2); diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout index 466fa78d9e..b98ccdb0f0 100644 --- a/tests/ref/fate/channel_layout +++ b/tests/ref/fate/channel_layout @@ -60,131 +60,131 @@ With "AMBI1023": 2047 ==Native layouts== Testing av_channel_layout_from_string -With "0x3f": 5.1 -With "63": 5.1 -With "6c": 5.1 -With "6C": 6 channels -With "6 channels": 6 channels -With "6 channels (FL+FR+FC+LFE+BL+BR)": 5.1 -With "FL+FR+FC+LFE+BL+BR": 5.1 -With "5.1": 5.1 -With "FL+FR+USR63": 3 channels (FL+FR+USR63) -With "FL+FR+FC+LFE+SL+SR": 5.1(side) -With "5.1(side)": 5.1(side) +With "0x3f": 5.1 +With "63": 5.1 +With "6c": 5.1 +With "6C": 6 channels +With "6 channels": 6 channels +With "6 channels (FL+FR+FC+LFE+BL+BR)": 5.1 +With "FL+FR+FC+LFE+BL+BR": 5.1 +With "5.1": 5.1 +With "FL+FR+USR63": 3 channels (FL+FR+USR63) +With "FL+FR+FC+LFE+SL+SR": 5.1(side) +With "5.1(side)": 5.1(side) Testing av_channel_layout_from_mask With AV_CH_LAYOUT_5POINT1: 5.1(side) Testing av_channel_layout_channel_from_index -On 5.1(side) layout with 0: 0 -On 5.1(side) layout with 1: 1 -On 5.1(side) layout with 2: 2 -On 5.1(side) layout with 3: 3 -On 5.1(side) layout with 4: 9 -On 5.1(side) layout with 5: 10 -On 5.1(side) layout with 6: -1 +On "5.1(side)" layout with 0: 0 +On "5.1(side)" layout with 1: 1 +On "5.1(side)" layout with 2: 2 +On "5.1(side)" layout with 3: 3 +On "5.1(side)" layout with 4: 9 +On "5.1(side)" layout with 5: 10 +On "5.1(side)" layout with 6: -1 Testing av_channel_layout_index_from_channel -On 5.1(side) layout with AV_CHAN_FRONT_LEFT: 0 -On 5.1(side) layout with AV_CHAN_FRONT_RIGHT: 1 -On 5.1(side) layout with AV_CHAN_FRONT_CENTER: 2 -On 5.1(side) layout with AV_CHAN_LOW_FREQUENCY: 3 -On 5.1(side) layout with AV_CHAN_SIDE_LEFT: 4 -On 5.1(side) layout with AV_CHAN_SIDE_RIGHT: 5 -On 5.1(side) layout with AV_CHAN_BACK_CENTER: -1 +On "5.1(side)" layout with AV_CHAN_FRONT_LEFT: 0 +On "5.1(side)" layout with AV_CHAN_FRONT_RIGHT: 1 +On "5.1(side)" layout with AV_CHAN_FRONT_CENTER: 2 +On "5.1(side)" layout with AV_CHAN_LOW_FREQUENCY: 3 +On "5.1(side)" layout with AV_CHAN_SIDE_LEFT: 4 +On "5.1(side)" layout with AV_CHAN_SIDE_RIGHT: 5 +On "5.1(side)" layout with AV_CHAN_BACK_CENTER: -1 Testing av_channel_layout_channel_from_string -On 5.1(side) layout with "FL": 0 -On 5.1(side) layout with "FR": 1 -On 5.1(side) layout with "FC": 2 -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 "FL": 0 +On "5.1(side)" layout with "FR": 1 +On "5.1(side)" layout with "FC": 2 +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 Testing av_channel_layout_index_from_string -On 5.1(side) layout with "FL": 0 -On 5.1(side) layout with "FR": 1 -On 5.1(side) layout with "FC": 2 -On 5.1(side) layout with "LFE": 3 -On 5.1(side) layout with "SL": 4 -On 5.1(side) layout with "SR": 5 -On 5.1(side) layout with "BC": -1 +On "5.1(side)" layout with "FL": 0 +On "5.1(side)" layout with "FR": 1 +On "5.1(side)" layout with "FC": 2 +On "5.1(side)" layout with "LFE": 3 +On "5.1(side)" layout with "SL": 4 +On "5.1(side)" layout with "SR": 5 +On "5.1(side)" layout with "BC": -1 Testing av_channel_layout_subset -On 5.1(side) layout with AV_CH_LAYOUT_STEREO: 0x3 -On 5.1(side) layout with AV_CH_LAYOUT_2POINT1: 0xb -On 5.1(side) layout with AV_CH_LAYOUT_4POINT1: 0xf +On "5.1(side)" layout with AV_CH_LAYOUT_STEREO: 0x3 +On "5.1(side)" layout with AV_CH_LAYOUT_2POINT1: 0xb +On "5.1(side)" layout with AV_CH_LAYOUT_4POINT1: 0xf ==Custom layouts== 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 "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 "FR+FL@Foo+USR63@Foo": 3 channels (FR+FL@Foo+USR63@Foo) +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 "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 "FR+FL@Foo+USR63@Foo": 3 channels (FR+FL@Foo+USR63@Foo) Testing av_channel_layout_index_from_string -On "FR+FL@Foo+USR63@Foo" layout with "FR": 0 -On "FR+FL@Foo+USR63@Foo" layout with "FL": 1 -On "FR+FL@Foo+USR63@Foo" layout with "USR63": 2 -On "FR+FL@Foo+USR63@Foo" layout with "Foo": -1 -On "FR+FL@Foo+USR63@Foo" layout with "@Foo": 1 -On "FR+FL@Foo+USR63@Foo" layout with "FR@Foo": -1 -On "FR+FL@Foo+USR63@Foo" layout with "FL@Foo": 1 -On "FR+FL@Foo+USR63@Foo" layout with "USR63@Foo": 2 -On "FR+FL@Foo+USR63@Foo" layout with "BC": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FR": 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FL": 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "USR63": 2 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "Foo": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "@Foo": 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FR@Foo": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FL@Foo": 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "USR63@Foo": 2 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "BC": -1 Testing av_channel_layout_channel_from_string -On "FR+FL@Foo+USR63@Foo" layout with "FR": 1 -On "FR+FL@Foo+USR63@Foo" layout with "FL": 0 -On "FR+FL@Foo+USR63@Foo" layout with "USR63": 63 -On "FR+FL@Foo+USR63@Foo" layout with "Foo": -1 -On "FR+FL@Foo+USR63@Foo" layout with "@Foo": 0 -On "FR+FL@Foo+USR63@Foo" layout with "FR@Foo": -1 -On "FR+FL@Foo+USR63@Foo" layout with "FL@Foo": 0 -On "FR+FL@Foo+USR63@Foo" layout with "USR63@Foo": 63 -On "FR+FL@Foo+USR63@Foo" layout with "BC": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FR": 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FL": 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "USR63": 63 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "Foo": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "@Foo": 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FR@Foo": -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "FL@Foo": 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "USR63@Foo": 63 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with "BC": -1 Testing av_channel_layout_index_from_channel -On "FR+FL@Foo+USR63@Foo" layout with AV_CHAN_FRONT_RIGHT: 0 -On "FR+FL@Foo+USR63@Foo" layout with AV_CHAN_FRONT_LEFT: 1 -On "FR+FL@Foo+USR63@Foo" layout with 63: 2 -On "FR+FL@Foo+USR63@Foo" layout with AV_CHAN_BACK_CENTER: -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with AV_CHAN_FRONT_RIGHT: 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with AV_CHAN_FRONT_LEFT: 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with 63: 2 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with AV_CHAN_BACK_CENTER: -1 Testing av_channel_layout_channel_from_index -On "FR+FL@Foo+USR63@Foo" layout with 0: 1 -On "FR+FL@Foo+USR63@Foo" layout with 1: 0 -On "FR+FL@Foo+USR63@Foo" layout with 2: 63 -On "FR+FL@Foo+USR63@Foo" layout with 3: -1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with 0: 1 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with 1: 0 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with 2: 63 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with 3: -1 Testing av_channel_layout_subset -On "FR+FL@Foo+USR63@Foo" layout with AV_CH_LAYOUT_STEREO: 0x3 -On "FR+FL@Foo+USR63@Foo" layout with AV_CH_LAYOUT_QUAD: 0x3 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with AV_CH_LAYOUT_STEREO: 0x3 +On "3 channels (FR+FL@Foo+USR63@Foo)" layout with AV_CH_LAYOUT_QUAD: 0x3 ==Ambisonic layouts== Testing av_channel_layout_from_string -With "ambisonic 1": ambisonic 1 -With "ambisonic 2+stereo": ambisonic 2+stereo +With "ambisonic 1": ambisonic 1 +With "ambisonic 2+stereo": ambisonic 2+stereo Testing av_channel_layout_index_from_channel -On "ambisonic 2+stereo" layout with AV_CHAN_AMBISONIC_BASE: 0 -On "ambisonic 2+stereo" layout with AV_CHAN_FRONT_LEFT: 9 -On "ambisonic 2+stereo" layout with AV_CHAN_FRONT_RIGHT: 10 -On "ambisonic 2+stereo" layout with AV_CHAN_BACK_CENTER: -1 +On "ambisonic 2+stereo" layout with AV_CHAN_AMBISONIC_BASE: 0 +On "ambisonic 2+stereo" layout with AV_CHAN_FRONT_LEFT: 9 +On "ambisonic 2+stereo" layout with AV_CHAN_FRONT_RIGHT: 10 +On "ambisonic 2+stereo" layout with AV_CHAN_BACK_CENTER: -1 Testing av_channel_layout_channel_from_index -On "ambisonic 2+stereo" layout with 0: 1024 -On "ambisonic 2+stereo" layout with 9: 0 -On "ambisonic 2+stereo" layout with 10: 1 -On "ambisonic 2+stereo" layout with 11: -1 +On "ambisonic 2+stereo" layout with 0: 1024 +On "ambisonic 2+stereo" layout with 9: 0 +On "ambisonic 2+stereo" layout with 10: 1 +On "ambisonic 2+stereo" layout with 11: -1 Testing av_channel_layout_subset -On "ambisonic 2+stereo" layout with AV_CH_LAYOUT_STEREO: 0x3 -On "ambisonic 2+stereo" layout with AV_CH_LAYOUT_QUAD: 0x3 +On "ambisonic 2+stereo" layout with AV_CH_LAYOUT_STEREO: 0x3 +On "ambisonic 2+stereo" layout with AV_CH_LAYOUT_QUAD: 0x3 Testing av_channel_layout_retype With "FL@Boo": CUSTOM (1 channels (FL@Boo)) -- 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".
next prev parent reply other threads:[~2024-03-09 21:54 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 ` Marton Balint [this message] 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 ` [FFmpeg-devel] [PATCH 7/7] avutil/channel_layout: add specific text versions for unknown and unused channels Marton Balint 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-3-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