From d87161b80e151093b4f22afdb70ae2d09ea792fa Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 18 Feb 2022 15:25:17 -0500 Subject: [PATCH] tests: video: Add a unit test for stride extrapolation This is a minimal unit test the show that the stride extrapolation can work with all pixel format we support. This minimal verify that the extrapolation match the stride we set into GstVideoInfo with 320x240 for all the pixel format we support. The tiles formats are skipped, since their stride is set as two 16bit integers, and we also skip over palette planes. Part-of: --- .../gst-plugins-base/tests/check/libs/video.c | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/subprojects/gst-plugins-base/tests/check/libs/video.c b/subprojects/gst-plugins-base/tests/check/libs/video.c index 8dea48c..6ad4b0b 100644 --- a/subprojects/gst-plugins-base/tests/check/libs/video.c +++ b/subprojects/gst-plugins-base/tests/check/libs/video.c @@ -4004,6 +4004,43 @@ GST_START_TEST (test_video_make_raw_caps) GST_END_TEST; +GST_START_TEST (test_video_extrapolate_stride) +{ + guint num_formats = get_num_formats (); + GstVideoFormat format; + + for (format = 2; format < num_formats; format++) { + GstVideoInfo info; + guint p; + + /* + * Use an easy resolution, since GStreamer uses arbitrary padding which + * cannot be extrapolated. + */ + gst_video_info_set_format (&info, format, 320, 240); + + /* Skip over tiled formats, since stride meaning is different */ + if (GST_VIDEO_FORMAT_INFO_IS_TILED (info.finfo)) + continue; + + for (p = 0; p < GST_VIDEO_INFO_N_PLANES (&info); p++) { + guint stride; + + /* Skip over palette planes */ + if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (info.finfo) && + p >= GST_VIDEO_COMP_PALETTE) + break; + + stride = gst_video_format_info_extrapolate_stride (info.finfo, p, + info.stride[0]); + fail_unless (stride == info.stride[p]); + } + } +} + +GST_END_TEST; + + static Suite * video_suite (void) { @@ -4058,6 +4095,7 @@ video_suite (void) tcase_add_test (tc_chain, test_video_meta_align); tcase_add_test (tc_chain, test_video_flags); tcase_add_test (tc_chain, test_video_make_raw_caps); + tcase_add_test (tc_chain, test_video_extrapolate_stride); return s; } -- 2.7.4