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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1567>
This commit is contained in:
Nicolas Dufresne 2022-02-18 15:25:17 -05:00 committed by GStreamer Marge Bot
parent 8883809ef9
commit d87161b80e

View file

@ -4004,6 +4004,43 @@ GST_START_TEST (test_video_make_raw_caps)
GST_END_TEST; 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 * static Suite *
video_suite (void) 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_meta_align);
tcase_add_test (tc_chain, test_video_flags); 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_make_raw_caps);
tcase_add_test (tc_chain, test_video_extrapolate_stride);
return s; return s;
} }