videoscale: fix videoscale test for new methods

Not all scaling methods are supported for all formats, so
can't just iterate over the template caps.
This commit is contained in:
Tim-Philipp Müller 2012-02-26 17:46:24 +00:00
parent 5db562f13b
commit 92ebd6bd2a

View file

@ -30,20 +30,20 @@
#define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING #define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
static GstCaps ** static GstCaps **
videoscale_get_allowed_caps (void) videoscale_get_allowed_caps_for_method (int method)
{ {
GstElement *scale = gst_element_factory_make ("videoscale", "scale"); GstElement *scale;
GstPadTemplate *templ;
GstCaps *caps, **ret; GstCaps *caps, **ret;
GstPad *pad;
GstStructure *s; GstStructure *s;
gint i, n; gint i, n;
templ = scale = gst_element_factory_make ("videoscale", "vscale");
gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (scale), g_object_set (scale, "method", method, NULL);
"sink"); pad = gst_element_get_static_pad (scale, "sink");
fail_unless (templ != NULL); caps = gst_pad_get_caps (pad);
gst_object_unref (pad);
caps = gst_pad_template_get_caps (templ); gst_object_unref (scale);
n = gst_caps_get_size (caps); n = gst_caps_get_size (caps);
ret = g_new0 (GstCaps *, n + 1); ret = g_new0 (GstCaps *, n + 1);
@ -52,10 +52,10 @@ videoscale_get_allowed_caps (void)
s = gst_caps_get_structure (caps, i); s = gst_caps_get_structure (caps, i);
ret[i] = gst_caps_new_empty (); ret[i] = gst_caps_new_empty ();
gst_caps_append_structure (ret[i], gst_structure_copy (s)); gst_caps_append_structure (ret[i], gst_structure_copy (s));
GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
} }
gst_object_unref (scale); gst_caps_unref (caps);
return ret; return ret;
} }
@ -206,20 +206,19 @@ on_src_handoff_passthrough (GstElement * element, GstBuffer * buffer,
*list = g_list_prepend (*list, gst_buffer_ref (buffer)); *list = g_list_prepend (*list, gst_buffer_ref (buffer));
} }
GST_START_TEST (test_passthrough) static void
test_passthrough (int method)
{ {
GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL; GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL;
GstCaps **allowed_caps = NULL, **p; GstCaps **allowed_caps = NULL, **p;
gint method;
static const gint src_width = 640, src_height = 480; static const gint src_width = 640, src_height = 480;
static const gint dest_width = 640, dest_height = 480; static const gint dest_width = 640, dest_height = 480;
p = allowed_caps = videoscale_get_allowed_caps (); p = allowed_caps = videoscale_get_allowed_caps_for_method (method);
while (*p) { while (*p) {
GstCaps *caps = *p; GstCaps *caps = *p;
for (method = 0; method < 3; method++) {
/* skip formats that ffmpegcolorspace can't handle */ /* skip formats that ffmpegcolorspace can't handle */
if (caps_are_64bpp (caps)) if (caps_are_64bpp (caps))
continue; continue;
@ -251,7 +250,6 @@ GST_START_TEST (test_passthrough)
src_buffers = NULL; src_buffers = NULL;
g_list_free (sink_buffers); g_list_free (sink_buffers);
sink_buffers = NULL; sink_buffers = NULL;
}
gst_caps_unref (caps); gst_caps_unref (caps);
p++; p++;
@ -259,6 +257,25 @@ GST_START_TEST (test_passthrough)
g_free (allowed_caps); g_free (allowed_caps);
} }
GST_START_TEST (test_passthrough_method_0)
{
test_passthrough (0);
}
GST_END_TEST;
GST_START_TEST (test_passthrough_method_1)
{
test_passthrough (1);
}
GST_END_TEST;
GST_START_TEST (test_passthrough_method_2)
{
test_passthrough (2);
}
GST_END_TEST; GST_END_TEST;
#define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \ #define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \
@ -266,7 +283,7 @@ GST_START_TEST (name) \
{ \ { \
GstCaps **allowed_caps = NULL, **p; \ GstCaps **allowed_caps = NULL, **p; \
\ \
p = allowed_caps = videoscale_get_allowed_caps (); \ p = allowed_caps = videoscale_get_allowed_caps_for_method (method); \
\ \
while (*p) { \ while (*p) { \
GstCaps *caps = *p; \ GstCaps *caps = *p; \
@ -642,8 +659,7 @@ gst_test_reverse_negotiation_sink_base_init (gpointer g_class)
"Test Reverse Negotiation Sink", "Test Reverse Negotiation Sink",
"Sink", "Sink",
"Some test sink", "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); "Some test sink", "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
gst_element_class_add_static_pad_template (gstelement_class, gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
&sinktemplate);
} }
static void static void
@ -818,7 +834,9 @@ videoscale_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_set_timeout (tc_chain, 180); tcase_set_timeout (tc_chain, 180);
tcase_add_test (tc_chain, test_passthrough); tcase_add_test (tc_chain, test_passthrough_method_0);
tcase_add_test (tc_chain, test_passthrough_method_1);
tcase_add_test (tc_chain, test_passthrough_method_2);
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0); tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0);
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1); tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1);
tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2); tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2);