videoconvert,videoscale: Add alternate-field negotiation tests
authorVivia Nikolaidou <vivia@ahiru.eu>
Thu, 4 Feb 2021 16:51:27 +0000 (18:51 +0200)
committerVivia Nikolaidou <vivia@ahiru.eu>
Thu, 4 Feb 2021 19:47:27 +0000 (21:47 +0200)
Make sure buffers with alternate-field interlacing mode can be
negotiated

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1027>

tests/check/elements/videoconvert.c
tests/check/elements/videoscale.c

index 99a9574..015ce1d 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 
 #include <gst/check/gstcheck.h>
+#include <gst/check/gstharness.h>
 #include <gst/video/video.h>
 
 static guint
@@ -117,6 +118,47 @@ GST_START_TEST (test_template_formats)
 
 GST_END_TEST;
 
+GST_START_TEST (test_negotiate_alternate)
+{
+  GstHarness *h;
+  GstBuffer *buffer;
+  GstMapInfo map;
+
+  h = gst_harness_new ("videoconvert");
+
+  buffer = gst_buffer_new_and_alloc (4);
+  gst_buffer_map (buffer, &map, GST_MAP_WRITE);
+  map.data[0] = 0x0;
+  map.data[1] = 0x0;
+  map.data[2] = 0x0;
+  map.data[3] = 0x0;
+  gst_buffer_unmap (buffer, &map);
+
+  gst_harness_set_sink_caps_str (h,
+      "video/x-raw,interlace-mode=alternate,width=1,height=1,format=AYUV");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
+      GST_FLOW_NOT_NEGOTIATED);
+
+  gst_harness_set_sink_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=AYUV");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw,interlace-mode=alternate,width=1,height=1,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
+      GST_FLOW_NOT_NEGOTIATED);
+
+  gst_harness_set_sink_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=AYUV");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);
+
+  gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
 static Suite *
 videoconvert_suite (void)
 {
@@ -126,6 +168,7 @@ videoconvert_suite (void)
   suite_add_tcase (s, tc_chain);
 
   tcase_add_test (tc_chain, test_template_formats);
+  tcase_add_test (tc_chain, test_negotiate_alternate);
 
   return s;
 }
index 36543f3..71bb355 100644 (file)
@@ -24,6 +24,7 @@
 #include <gst/base/gstbasesink.h>
 
 #include <gst/check/gstcheck.h>
+#include <gst/check/gstharness.h>
 #include <string.h>
 
 /* kids, don't do this at home, skipping checks is *BAD* */
@@ -776,6 +777,45 @@ gst_test_reverse_negotiation_sink_init (GstTestReverseNegotiationSink * sink)
   sink->nbuffers = 0;
 }
 
+GST_START_TEST (test_negotiate_alternate)
+{
+  GstHarness *h;
+  GstBuffer *buffer;
+  GstMapInfo map;
+
+  h = gst_harness_new ("videoscale");
+
+  buffer = gst_buffer_new_and_alloc (4);
+  gst_buffer_map (buffer, &map, GST_MAP_WRITE);
+  map.data[0] = 0x0;
+  map.data[1] = 0x0;
+  map.data[2] = 0x0;
+  map.data[3] = 0x0;
+  gst_buffer_unmap (buffer, &map);
+
+  gst_harness_set_sink_caps_str (h, "video/x-raw,width=1,height=1,format=ARGB");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=2,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
+      GST_FLOW_NOT_NEGOTIATED);
+
+  gst_harness_set_sink_caps_str (h,
+      "video/x-raw(format:Interlaced),width=1,height=1,format=ARGB");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw,interlace-mode=alternate,width=1,height=2,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
+      GST_FLOW_NOT_NEGOTIATED);
+
+  gst_harness_set_sink_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=ARGB");
+  gst_harness_set_src_caps_str (h,
+      "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=2,format=ARGB");
+  fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);
+
+  gst_harness_teardown (h);
+}
+
+GST_END_TEST;
 #if 0
 static void
 _test_reverse_negotiation_message (GstBus * bus, GstMessage * message,
@@ -940,6 +980,7 @@ videoscale_suite (void)
   tcase_add_test (tc_chain, test_passthrough_method_2);
   tcase_add_test (tc_chain, test_passthrough_method_3);
   tcase_add_test (tc_chain, test_negotiation);
+  tcase_add_test (tc_chain, test_negotiate_alternate);
 #if 0
   tcase_add_test (tc_chain, test_reverse_negotiation);
 #endif