diff mbox series

[FFmpeg-devel,6/7] avutil/tests/channel_layout: Test av_channel_layout_copy()

Message ID AS8P250MB0744BC1E54892BA508E798138F0FA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 3fc8041b56c2c6a6937f74e3ebf71b6c114a9a91
Headers show
Series [FFmpeg-devel,1/7] avutil/bprint: Don't use value of AV_BPRINT_SIZE_AUTOMATIC directly | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 6, 2023, 10:13 a.m. UTC
Specifically, test copying a channel layout with custom order,
so that the allocation codepath of av_channel_layout_copy()
is executed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavutil/tests/channel_layout.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavutil/tests/channel_layout.c b/libavutil/tests/channel_layout.c
index 19f552f8bc..c537e7e710 100644
--- a/libavutil/tests/channel_layout.c
+++ b/libavutil/tests/channel_layout.c
@@ -150,7 +150,7 @@  static void channel_layout_from_string(AVChannelLayout *layout,
 int main(void)
 {
     const AVChannelLayout *playout;
-    AVChannelLayout layout = { 0 };
+    AVChannelLayout layout = { 0 }, layout2 = { 0 };
     AVBPrint bp;
     void *iter = NULL;
     uint64_t mask;
@@ -324,6 +324,15 @@  int main(void)
     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) {
+        printf("Copying channel layout \"FR+FL@Foo+USR63@Foo\" failed; "
+               "ret %d\n", ret);
+    }
+    ret = av_channel_layout_compare(&layout, &layout2);
+    if (ret)
+        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);
@@ -425,6 +434,7 @@  int main(void)
     printf("On \"ambisonic 2+stereo\" layout with AV_CH_LAYOUT_QUAD:    0x%"PRIx64"\n", mask);
 
     av_channel_layout_uninit(&layout);
+    av_channel_layout_uninit(&layout2);
     av_bprint_finalize(&bp, NULL);
 
     return 0;