summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2019-03-23 12:27:24 +0000
committerTim-Philipp Müller <tim@centricular.com>2019-03-24 16:39:30 +0000
commit3288093c75d0ff34e1a86cc0c5c0e71c036b83ee (patch)
tree251dc92d8e7217bb0c1814f258ca0f993e7408e3
parentb05e70ea94c699743c655f5f0b5b050652dc4fde (diff)
downloadgstreamer-plugins-base-3288093c75d0ff34e1a86cc0c5c0e71c036b83ee.tar.gz
tests: video: speed up test_video_color_convert
This test takes a long time. It tests ca. 8900 conversion combinations, and then it also runs each conversion for at least 100ms in order to come up with some kind of benchmark. Remove the benchmarking from the unit test, we have a separate benchmarking tool for that now. Also split the conversions into groups and run those as separate checks, which allows better parallelisation at the runner level (normal runs and when using valgrind).
-rw-r--r--tests/check/libs/video.c119
1 files changed, 75 insertions, 44 deletions
diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c
index 948dbf849..005494946 100644
--- a/tests/check/libs/video.c
+++ b/tests/check/libs/video.c
@@ -2387,20 +2387,39 @@ GST_START_TEST (test_video_scaler)
GST_END_TEST;
+typedef enum
+{
+ RGB,
+ YUV,
+ OTHER
+} ColorType;
+
#define WIDTH 320
#define HEIGHT 240
-#define TIME 0.01
-GST_START_TEST (test_video_color_convert)
+static gboolean
+check_video_format_is_type (GstVideoFormat fmt, ColorType fmt_type)
{
- GstVideoFormat infmt, outfmt;
- GTimer *timer;
- gint num_formats, i;
- GArray *array;
-
- array = g_array_new (FALSE, FALSE, sizeof (ConvertResult));
+ const GstVideoFormatInfo *info = gst_video_format_get_info (fmt);
+ gboolean is_rgb = GST_VIDEO_FORMAT_INFO_IS_RGB (info);
+ gboolean is_yuv = GST_VIDEO_FORMAT_INFO_IS_YUV (info);
+
+ switch (fmt_type) {
+ case RGB:
+ return is_rgb;
+ case YUV:
+ return is_yuv;
+ case OTHER:
+ break;
+ }
+ return !is_rgb && !is_yuv;
+}
- timer = g_timer_new ();
+static void
+run_video_color_convert (ColorType in_type, ColorType out_type)
+{
+ GstVideoFormat infmt, outfmt;
+ gint num_formats;
num_formats = get_num_formats ();
@@ -2409,6 +2428,9 @@ GST_START_TEST (test_video_color_convert)
GstVideoFrame inframe;
GstBuffer *inbuffer;
+ if (!check_video_format_is_type (infmt, in_type))
+ continue;
+
fail_unless (gst_video_info_set_format (&ininfo, infmt, WIDTH, HEIGHT));
inbuffer = gst_buffer_new_and_alloc (ininfo.size);
gst_buffer_memset (inbuffer, 0, 0, -1);
@@ -2419,38 +2441,20 @@ GST_START_TEST (test_video_color_convert)
GstVideoFrame outframe;
GstBuffer *outbuffer;
GstVideoConverter *convert;
- gdouble elapsed;
- gint count;
- ConvertResult res;
+
+ if (!check_video_format_is_type (outfmt, out_type))
+ continue;
+
+ GST_LOG ("%s -> %s @ %ux%u", gst_video_format_to_string (infmt),
+ gst_video_format_to_string (outfmt), WIDTH, HEIGHT);
fail_unless (gst_video_info_set_format (&outinfo, outfmt, WIDTH, HEIGHT));
outbuffer = gst_buffer_new_and_alloc (outinfo.size);
gst_video_frame_map (&outframe, &outinfo, outbuffer, GST_MAP_WRITE);
convert = gst_video_converter_new (&ininfo, &outinfo, NULL);
- /* warmup */
- gst_video_converter_frame (convert, &inframe, &outframe);
-
- count = 0;
- g_timer_start (timer);
- while (TRUE) {
- gst_video_converter_frame (convert, &inframe, &outframe);
-
- count++;
- elapsed = g_timer_elapsed (timer, NULL);
- if (elapsed >= TIME)
- break;
- }
- res.infmt = infmt;
- res.outfmt = outfmt;
- res.convert_sec = count / elapsed;
-
- GST_DEBUG ("%f conversions/sec %s->%s, %d/%f", res.convert_sec,
- gst_video_format_to_string (infmt),
- gst_video_format_to_string (outfmt), count, elapsed);
-
- g_array_append_val (array, res);
+ gst_video_converter_frame (convert, &inframe, &outframe);
gst_video_converter_free (convert);
@@ -2460,20 +2464,43 @@ GST_START_TEST (test_video_color_convert)
gst_video_frame_unmap (&inframe);
gst_buffer_unref (inbuffer);
}
+}
- g_array_sort (array, compare_result);
+GST_START_TEST (test_video_color_convert_rgb_rgb)
+{
+ run_video_color_convert (RGB, RGB);
+}
- for (i = 0; i < array->len; i++) {
- ConvertResult *res = &g_array_index (array, ConvertResult, i);
+GST_END_TEST;
- GST_DEBUG ("%f conversions/sec %s->%s", res->convert_sec,
- gst_video_format_to_string (res->infmt),
- gst_video_format_to_string (res->outfmt));
- }
+GST_START_TEST (test_video_color_convert_rgb_yuv)
+{
+ run_video_color_convert (RGB, YUV);
+}
- g_array_free (array, TRUE);
+GST_END_TEST;
- g_timer_destroy (timer);
+GST_START_TEST (test_video_color_convert_yuv_yuv)
+{
+ run_video_color_convert (YUV, YUV);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_video_color_convert_yuv_rgb)
+{
+ run_video_color_convert (YUV, RGB);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_video_color_convert_other)
+{
+ run_video_color_convert (OTHER, RGB);
+ run_video_color_convert (RGB, OTHER);
+ run_video_color_convert (OTHER, YUV);
+ run_video_color_convert (YUV, OTHER);
+ run_video_color_convert (OTHER, OTHER);
}
GST_END_TEST;
@@ -3030,7 +3057,11 @@ video_suite (void)
tcase_add_test (tc_chain, test_video_pack_unpack2);
tcase_add_test (tc_chain, test_video_chroma);
tcase_add_test (tc_chain, test_video_scaler);
- tcase_add_test (tc_chain, test_video_color_convert);
+ tcase_add_test (tc_chain, test_video_color_convert_rgb_rgb);
+ tcase_add_test (tc_chain, test_video_color_convert_rgb_yuv);
+ tcase_add_test (tc_chain, test_video_color_convert_yuv_yuv);
+ tcase_add_test (tc_chain, test_video_color_convert_yuv_rgb);
+ tcase_add_test (tc_chain, test_video_color_convert_other);
tcase_add_test (tc_chain, test_video_size_convert);
tcase_add_test (tc_chain, test_video_convert);
tcase_add_test (tc_chain, test_video_transfer);