1 /* GStreamer
2 *
3 * unit test for videoscale
4 *
5 * Copyright (C) <2009,2010> Sebastian Dröge <sebastian.droege@collabora.co.uk>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #include <gst/video/video.h>
24 #include <gst/base/gstbasesink.h>
25
26 #include <gst/check/gstcheck.h>
27 #include <gst/check/gstharness.h>
28 #include <string.h>
29
30 /* kids, don't do this at home, skipping checks is *BAD* */
31 #define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
32
33 #ifndef VSCALE_TEST_GROUP
34
35 static guint
get_num_formats(void)36 get_num_formats (void)
37 {
38 guint i = 2;
39
40 while (gst_video_format_to_string ((GstVideoFormat) i) != NULL)
41 ++i;
42
43 return i;
44 }
45
46 static void
check_pad_template(GstPadTemplate * tmpl)47 check_pad_template (GstPadTemplate * tmpl)
48 {
49 const GValue *list_val, *fmt_val;
50 GstStructure *s;
51 gboolean *formats_supported;
52 GstCaps *caps;
53 guint i, num_formats;
54
55 num_formats = get_num_formats ();
56 formats_supported = g_new0 (gboolean, num_formats);
57
58 caps = gst_pad_template_get_caps (tmpl);
59
60 /* If this fails, we need to update this unit test */
61 fail_unless_equals_int (gst_caps_get_size (caps), 2);
62 /* Remove the ANY caps features structure */
63 caps = gst_caps_truncate (caps);
64 s = gst_caps_get_structure (caps, 0);
65
66 fail_unless (gst_structure_has_name (s, "video/x-raw"));
67
68 list_val = gst_structure_get_value (s, "format");
69 fail_unless (list_val != NULL);
70 /* If this fails, we need to update this unit test */
71 fail_unless (GST_VALUE_HOLDS_LIST (list_val));
72
73 for (i = 0; i < gst_value_list_get_size (list_val); ++i) {
74 GstVideoFormat fmt;
75 const gchar *fmt_str;
76
77 fmt_val = gst_value_list_get_value (list_val, i);
78 fail_unless (G_VALUE_HOLDS_STRING (fmt_val));
79 fmt_str = g_value_get_string (fmt_val);
80 GST_LOG ("format string: '%s'", fmt_str);
81 fmt = gst_video_format_from_string (fmt_str);
82 if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
83 g_error ("Unknown raw format '%s' in pad template caps", fmt_str);
84 formats_supported[(guint) fmt] = TRUE;
85 }
86
87 gst_caps_unref (caps);
88
89 for (i = 2; i < num_formats; ++i) {
90 if (!formats_supported[i]) {
91 const gchar *fmt_str = gst_video_format_to_string ((GstVideoFormat) i);
92
93 switch (i) {
94 case GST_VIDEO_FORMAT_v210:
95 case GST_VIDEO_FORMAT_v216:
96 case GST_VIDEO_FORMAT_NV12:
97 case GST_VIDEO_FORMAT_NV16:
98 case GST_VIDEO_FORMAT_NV21:
99 case GST_VIDEO_FORMAT_NV24:
100 case GST_VIDEO_FORMAT_UYVP:
101 case GST_VIDEO_FORMAT_A420:
102 case GST_VIDEO_FORMAT_YUV9:
103 case GST_VIDEO_FORMAT_YVU9:
104 case GST_VIDEO_FORMAT_IYU1:
105 case GST_VIDEO_FORMAT_r210:{
106 static gboolean shown_fixme[100] = { FALSE, };
107
108 if (!shown_fixme[i]) {
109 GST_FIXME ("FIXME: add %s support to videoscale", fmt_str);
110 shown_fixme[i] = TRUE;
111 }
112 break;
113 }
114 case GST_VIDEO_FORMAT_BGR16:
115 case GST_VIDEO_FORMAT_BGR15:
116 case GST_VIDEO_FORMAT_RGB8P:
117 case GST_VIDEO_FORMAT_I420_10BE:
118 case GST_VIDEO_FORMAT_I420_10LE:
119 case GST_VIDEO_FORMAT_I422_10BE:
120 case GST_VIDEO_FORMAT_I422_10LE:
121 case GST_VIDEO_FORMAT_Y444_10BE:
122 case GST_VIDEO_FORMAT_Y444_10LE:
123 case GST_VIDEO_FORMAT_GBR:
124 case GST_VIDEO_FORMAT_GBR_10BE:
125 case GST_VIDEO_FORMAT_GBR_10LE:
126 case GST_VIDEO_FORMAT_NV12_64Z32:
127 case GST_VIDEO_FORMAT_NV12_4L4:
128 case GST_VIDEO_FORMAT_NV12_32L32:
129 GST_LOG ("Ignoring lack of support for format %s", fmt_str);
130 break;
131 default:
132 g_error ("videoscale doesn't support format '%s'", fmt_str);
133 break;
134 }
135 }
136 }
137
138 g_free (formats_supported);
139 }
140
GST_START_TEST(test_template_formats)141 GST_START_TEST (test_template_formats)
142 {
143 GstElementFactory *f;
144 GstPadTemplate *t;
145 const GList *pad_templates;
146
147 f = gst_element_factory_find ("videoscale");
148 fail_unless (f != NULL);
149
150 pad_templates = gst_element_factory_get_static_pad_templates (f);
151 fail_unless_equals_int (g_list_length ((GList *) pad_templates), 2);
152
153 t = gst_static_pad_template_get (pad_templates->data);
154 check_pad_template (GST_PAD_TEMPLATE (t));
155 gst_object_unref (t);
156 t = gst_static_pad_template_get (pad_templates->next->data);
157 check_pad_template (GST_PAD_TEMPLATE (t));
158 gst_object_unref (t);
159
160 gst_object_unref (f);
161 }
162
163 GST_END_TEST;
164
165 #endif /* !defined(VSCALE_TEST_GROUP) */
166
167 static GstCaps **
videoscale_get_allowed_caps_for_method(int method)168 videoscale_get_allowed_caps_for_method (int method)
169 {
170 GstElement *scale;
171 GstCaps *caps, **ret;
172 GstPad *pad;
173 GstStructure *s;
174 gint i, n;
175
176 scale = gst_element_factory_make ("videoscale", "vscale");
177 g_object_set (scale, "method", method, NULL);
178 pad = gst_element_get_static_pad (scale, "sink");
179 caps = gst_pad_query_caps (pad, NULL);
180 gst_object_unref (pad);
181 gst_object_unref (scale);
182
183 caps = gst_caps_normalize (caps);
184 n = gst_caps_get_size (caps);
185 ret = g_new0 (GstCaps *, n + 1);
186
187 for (i = 0; i < n; i++) {
188 s = gst_caps_get_structure (caps, i);
189 ret[i] = gst_caps_new_empty ();
190 gst_caps_append_structure (ret[i], gst_structure_copy (s));
191 GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
192 }
193
194 gst_caps_unref (caps);
195
196 return ret;
197 }
198
199 static void
on_sink_handoff(GstElement * element,GstBuffer * buffer,GstPad * pad,gpointer user_data)200 on_sink_handoff (GstElement * element, GstBuffer * buffer, GstPad * pad,
201 gpointer user_data)
202 {
203 guint *n_buffers = user_data;
204
205 *n_buffers = *n_buffers + 1;
206 }
207
208 static gboolean
videoconvert_supports_caps(const GstCaps * caps)209 videoconvert_supports_caps (const GstCaps * caps)
210 {
211 GST_DEBUG ("have caps %" GST_PTR_FORMAT, caps);
212 return TRUE;
213 }
214
215 static void
run_test(const GstCaps * caps,gint src_width,gint src_height,gint dest_width,gint dest_height,gint method,GCallback src_handoff,gpointer src_handoff_user_data,GCallback sink_handoff,gpointer sink_handoff_user_data)216 run_test (const GstCaps * caps, gint src_width, gint src_height,
217 gint dest_width, gint dest_height, gint method,
218 GCallback src_handoff, gpointer src_handoff_user_data,
219 GCallback sink_handoff, gpointer sink_handoff_user_data)
220 {
221 GstElement *pipeline;
222 GstElement *src, *videoconvert, *capsfilter1, *identity, *scale,
223 *capsfilter2, *sink;
224 GstMessage *msg;
225 GstBus *bus;
226 GstCaps *copy;
227 guint n_buffers = 0;
228
229 /* skip formats that videoconvert can't handle */
230 if (!videoconvert_supports_caps (caps))
231 return;
232
233 pipeline = gst_element_factory_make ("pipeline", "pipeline");
234 fail_unless (pipeline != NULL);
235
236 src = gst_element_factory_make ("videotestsrc", "src");
237 fail_unless (src != NULL);
238 g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);
239
240 videoconvert = gst_element_factory_make ("videoconvert", "csp");
241 fail_unless (videoconvert != NULL);
242
243 capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
244 fail_unless (capsfilter1 != NULL);
245 copy = gst_caps_copy (caps);
246 gst_caps_set_simple (copy, "width", G_TYPE_INT, src_width, "height",
247 G_TYPE_INT, src_height, "framerate", GST_TYPE_FRACTION, 30, 1, NULL);
248 g_object_set (G_OBJECT (capsfilter1), "caps", copy, NULL);
249 gst_caps_unref (copy);
250
251 identity = gst_element_factory_make ("identity", "identity");
252 fail_unless (identity != NULL);
253 if (src_handoff) {
254 g_object_set (G_OBJECT (identity), "signal-handoffs", TRUE, NULL);
255 g_signal_connect (identity, "handoff", G_CALLBACK (src_handoff),
256 src_handoff_user_data);
257 }
258
259 scale = gst_element_factory_make ("videoscale", "scale");
260 fail_unless (scale != NULL);
261 g_object_set (G_OBJECT (scale), "method", method, NULL);
262
263 capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
264 fail_unless (capsfilter2 != NULL);
265 copy = gst_caps_copy (caps);
266 gst_caps_set_simple (copy, "width", G_TYPE_INT, dest_width, "height",
267 G_TYPE_INT, dest_height, NULL);
268 g_object_set (G_OBJECT (capsfilter2), "caps", copy, NULL);
269 gst_caps_unref (copy);
270
271 sink = gst_element_factory_make ("fakesink", "sink");
272 fail_unless (sink != NULL);
273 g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, "async", FALSE, NULL);
274 g_signal_connect (sink, "handoff", G_CALLBACK (on_sink_handoff), &n_buffers);
275 if (sink_handoff) {
276 g_signal_connect (sink, "handoff", G_CALLBACK (sink_handoff),
277 sink_handoff_user_data);
278 }
279
280 gst_bin_add_many (GST_BIN (pipeline), src, videoconvert, capsfilter1,
281 identity, scale, capsfilter2, sink, NULL);
282
283 fail_unless (gst_element_link_pads_full (src, "src", videoconvert, "sink",
284 LINK_CHECK_FLAGS));
285 fail_unless (gst_element_link_pads_full (videoconvert, "src", capsfilter1,
286 "sink", LINK_CHECK_FLAGS));
287 fail_unless (gst_element_link_pads_full (capsfilter1, "src", identity, "sink",
288 LINK_CHECK_FLAGS));
289 fail_unless (gst_element_link_pads_full (identity, "src", scale, "sink",
290 LINK_CHECK_FLAGS));
291 fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
292 LINK_CHECK_FLAGS));
293 fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
294 LINK_CHECK_FLAGS));
295
296 bus = gst_element_get_bus (pipeline);
297 fail_unless (bus != NULL);
298
299 fail_unless (gst_element_set_state (pipeline,
300 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
301
302 msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
303 GST_MESSAGE_EOS | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING);
304
305 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);
306
307 fail_unless (gst_element_set_state (pipeline,
308 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
309
310 fail_unless (n_buffers == 1);
311
312 gst_object_unref (pipeline);
313 gst_message_unref (msg);
314 gst_object_unref (bus);
315 }
316
317 #ifndef VSCALE_TEST_GROUP
318
319 static void
on_sink_handoff_passthrough(GstElement * element,GstBuffer * buffer,GstPad * pad,gpointer user_data)320 on_sink_handoff_passthrough (GstElement * element, GstBuffer * buffer,
321 GstPad * pad, gpointer user_data)
322 {
323 GList **list = user_data;
324
325 *list = g_list_prepend (*list, gst_buffer_ref (buffer));
326 }
327
328 static void
on_src_handoff_passthrough(GstElement * element,GstBuffer * buffer,gpointer user_data)329 on_src_handoff_passthrough (GstElement * element, GstBuffer * buffer,
330 gpointer user_data)
331 {
332 GList **list = user_data;
333
334 *list = g_list_prepend (*list, gst_buffer_ref (buffer));
335 }
336
337 static void
test_passthrough(int method)338 test_passthrough (int method)
339 {
340 GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL;
341 GstCaps **allowed_caps = NULL, **p;
342 static const gint src_width = 640, src_height = 480;
343 static const gint dest_width = 640, dest_height = 480;
344
345 p = allowed_caps = videoscale_get_allowed_caps_for_method (method);
346
347 while (*p) {
348 GstCaps *caps = *p;
349
350 /* skip formats that videoconvert can't handle */
351 if (!videoconvert_supports_caps (caps))
352 goto next;
353
354 GST_DEBUG ("Running test for caps '%" GST_PTR_FORMAT "'"
355 " from %dx%u to %dx%d with method %d", caps, src_width, src_height,
356 dest_width, dest_height, method);
357 run_test (caps, src_width, src_height,
358 dest_width, dest_height, method,
359 G_CALLBACK (on_src_handoff_passthrough), &src_buffers,
360 G_CALLBACK (on_sink_handoff_passthrough), &sink_buffers);
361
362 fail_unless (src_buffers && sink_buffers);
363 fail_unless_equals_int (g_list_length (src_buffers),
364 g_list_length (sink_buffers));
365
366 for (l1 = src_buffers, l2 = sink_buffers; l1 && l2;
367 l1 = l1->next, l2 = l2->next) {
368 GstBuffer *a = l1->data;
369 GstBuffer *b = l2->data;
370 GstMapInfo mapa, mapb;
371
372 gst_buffer_map (a, &mapa, GST_MAP_READ);
373 gst_buffer_map (b, &mapb, GST_MAP_READ);
374 fail_unless_equals_int (mapa.size, mapb.size);
375 fail_unless (mapa.data == mapb.data);
376 gst_buffer_unmap (b, &mapb);
377 gst_buffer_unmap (a, &mapa);
378
379 gst_buffer_unref (a);
380 gst_buffer_unref (b);
381 }
382 g_list_free (src_buffers);
383 src_buffers = NULL;
384 g_list_free (sink_buffers);
385 sink_buffers = NULL;
386
387 next:
388 gst_caps_unref (caps);
389 p++;
390 }
391 g_free (allowed_caps);
392 }
393
GST_START_TEST(test_passthrough_method_0)394 GST_START_TEST (test_passthrough_method_0)
395 {
396 test_passthrough (0);
397 }
398
399 GST_END_TEST;
400
GST_START_TEST(test_passthrough_method_1)401 GST_START_TEST (test_passthrough_method_1)
402 {
403 test_passthrough (1);
404 }
405
406 GST_END_TEST;
407
GST_START_TEST(test_passthrough_method_2)408 GST_START_TEST (test_passthrough_method_2)
409 {
410 test_passthrough (2);
411 }
412
413 GST_END_TEST;
414
GST_START_TEST(test_passthrough_method_3)415 GST_START_TEST (test_passthrough_method_3)
416 {
417 test_passthrough (3);
418 }
419
420 GST_END_TEST;
421 #endif /* !defined(VSCALE_TEST_GROUP) */
422
423 #define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \
424 GST_START_TEST (name) \
425 { \
426 GstCaps **allowed_caps = NULL, **p; \
427 \
428 p = allowed_caps = videoscale_get_allowed_caps_for_method (method); \
429 \
430 while (*p) { \
431 GstCaps *caps = *p; \
432 \
433 GST_DEBUG ("Running test for caps '%" GST_PTR_FORMAT "'" \
434 " from %dx%u to %dx%d with method %d", caps, src_width, src_height, \
435 dest_width, dest_height, method); \
436 run_test (caps, src_width, src_height, \
437 dest_width, dest_height, method, \
438 NULL, NULL, NULL, NULL); \
439 gst_caps_unref (caps); \
440 p++; \
441 } \
442 g_free (allowed_caps); \
443 } \
444 \
445 GST_END_TEST;
446
447 #if defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 1
448 CREATE_TEST (test_downscale_640x480_320x240_method_0, 0, 640, 480, 320, 240);
449 CREATE_TEST (test_downscale_640x480_320x240_method_1, 1, 640, 480, 320, 240);
450 CREATE_TEST (test_downscale_640x480_320x240_method_2, 2, 640, 480, 320, 240);
451 CREATE_TEST (test_downscale_640x480_320x240_method_3, 3, 640, 480, 320, 240);
452 CREATE_TEST (test_upscale_320x240_640x480_method_0, 0, 320, 240, 640, 480);
453 CREATE_TEST (test_upscale_320x240_640x480_method_1, 1, 320, 240, 640, 480);
454 CREATE_TEST (test_upscale_320x240_640x480_method_2, 2, 320, 240, 640, 480);
455 CREATE_TEST (test_upscale_320x240_640x480_method_3, 3, 320, 240, 640, 480);
456 #elif defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 2
457 CREATE_TEST (test_downscale_640x480_1x1_method_0, 0, 640, 480, 1, 1);
458 CREATE_TEST (test_downscale_640x480_1x1_method_1, 1, 640, 480, 1, 1);
459 CREATE_TEST (test_downscale_640x480_1x1_method_2, 2, 640, 480, 1, 1);
460 CREATE_TEST (test_downscale_640x480_1x1_method_3, 3, 640, 480, 1, 1);
461 CREATE_TEST (test_upscale_1x1_640x480_method_0, 0, 1, 1, 640, 480);
462 CREATE_TEST (test_upscale_1x1_640x480_method_1, 1, 1, 1, 640, 480);
463 CREATE_TEST (test_upscale_1x1_640x480_method_2, 2, 1, 1, 640, 480);
464 CREATE_TEST (test_upscale_1x1_640x480_method_3, 3, 1, 1, 640, 480);
465 #elif defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 3
466 CREATE_TEST (test_downscale_641x481_111x30_method_0, 0, 641, 481, 111, 30);
467 CREATE_TEST (test_downscale_641x481_111x30_method_1, 1, 641, 481, 111, 30);
468 CREATE_TEST (test_downscale_641x481_111x30_method_2, 2, 641, 481, 111, 30);
469 CREATE_TEST (test_downscale_641x481_111x30_method_3, 3, 641, 481, 111, 30);
470 CREATE_TEST (test_upscale_111x30_641x481_method_0, 0, 111, 30, 641, 481);
471 CREATE_TEST (test_upscale_111x30_641x481_method_1, 1, 111, 30, 641, 481);
472 CREATE_TEST (test_upscale_111x30_641x481_method_2, 2, 111, 30, 641, 481);
473 CREATE_TEST (test_upscale_111x30_641x481_method_3, 2, 111, 30, 641, 481);
474 #elif defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 4
475 CREATE_TEST (test_downscale_641x481_30x111_method_0, 0, 641, 481, 30, 111);
476 CREATE_TEST (test_downscale_641x481_30x111_method_1, 1, 641, 481, 30, 111);
477 CREATE_TEST (test_downscale_641x481_30x111_method_2, 2, 641, 481, 30, 111);
478 CREATE_TEST (test_downscale_641x481_30x111_method_3, 3, 641, 481, 30, 111);
479 CREATE_TEST (test_upscale_30x111_641x481_method_0, 0, 30, 111, 641, 481);
480 CREATE_TEST (test_upscale_30x111_641x481_method_1, 1, 30, 111, 641, 481);
481 CREATE_TEST (test_upscale_30x111_641x481_method_2, 2, 30, 111, 641, 481);
482 CREATE_TEST (test_upscale_30x111_641x481_method_3, 3, 30, 111, 641, 481);
483 #elif defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 5
484 CREATE_TEST (test_downscale_640x480_320x1_method_0, 0, 640, 480, 320, 1);
485 CREATE_TEST (test_downscale_640x480_320x1_method_1, 1, 640, 480, 320, 1);
486 CREATE_TEST (test_downscale_640x480_320x1_method_2, 2, 640, 480, 320, 1);
487 CREATE_TEST (test_downscale_640x480_320x1_method_3, 3, 640, 480, 320, 1);
488 CREATE_TEST (test_upscale_320x1_640x480_method_0, 0, 320, 1, 640, 480);
489 CREATE_TEST (test_upscale_320x1_640x480_method_1, 1, 320, 1, 640, 480);
490 CREATE_TEST (test_upscale_320x1_640x480_method_2, 2, 320, 1, 640, 480);
491 CREATE_TEST (test_upscale_320x1_640x480_method_3, 3, 320, 1, 640, 480);
492 #elif defined(VSCALE_TEST_GROUP) && VSCALE_TEST_GROUP == 6
493 CREATE_TEST (test_downscale_640x480_1x240_method_0, 0, 640, 480, 1, 240);
494 CREATE_TEST (test_downscale_640x480_1x240_method_1, 1, 640, 480, 1, 240);
495 CREATE_TEST (test_downscale_640x480_1x240_method_2, 2, 640, 480, 1, 240);
496 CREATE_TEST (test_downscale_640x480_1x240_method_3, 3, 640, 480, 1, 240);
497 CREATE_TEST (test_upscale_1x240_640x480_method_0, 0, 1, 240, 640, 480);
498 CREATE_TEST (test_upscale_1x240_640x480_method_1, 1, 1, 240, 640, 480);
499 CREATE_TEST (test_upscale_1x240_640x480_method_2, 2, 1, 240, 640, 480);
500 CREATE_TEST (test_upscale_1x240_640x480_method_3, 3, 1, 240, 640, 480);
501 #endif
502
503 #ifndef VSCALE_TEST_GROUP
504
505 static void
_test_negotiation(const gchar * src_templ,const gchar * sink_templ,gint width,gint height,gint par_n,gint par_d)506 _test_negotiation (const gchar * src_templ, const gchar * sink_templ,
507 gint width, gint height, gint par_n, gint par_d)
508 {
509 GstElement *pipeline;
510 GstElement *src, *capsfilter1, *scale, *capsfilter2, *sink;
511 GstCaps *caps;
512 GstPad *pad;
513
514 GST_DEBUG ("Running test for src templ caps '%s' and sink templ caps '%s'",
515 src_templ, sink_templ);
516
517 pipeline = gst_element_factory_make ("pipeline", "pipeline");
518 fail_unless (pipeline != NULL);
519
520 src = gst_element_factory_make ("videotestsrc", "src");
521 fail_unless (src != NULL);
522 g_object_set (G_OBJECT (src), "num-buffers", 1, "pattern", 2, NULL);
523
524 capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
525 fail_unless (capsfilter1 != NULL);
526 caps = gst_caps_from_string (src_templ);
527 fail_unless (caps != NULL);
528 g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
529 gst_caps_unref (caps);
530
531 scale = gst_element_factory_make ("videoscale", "scale");
532 fail_unless (scale != NULL);
533
534 capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
535 fail_unless (capsfilter2 != NULL);
536 caps = gst_caps_from_string (sink_templ);
537 fail_unless (caps != NULL);
538 g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
539 gst_caps_unref (caps);
540
541 sink = gst_element_factory_make ("fakesink", "sink");
542 fail_unless (sink != NULL);
543
544 gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
545 sink, NULL);
546
547 fail_unless (gst_element_link_pads_full (src, "src", capsfilter1, "sink",
548 LINK_CHECK_FLAGS));
549 fail_unless (gst_element_link_pads_full (capsfilter1, "src", scale, "sink",
550 LINK_CHECK_FLAGS));
551 fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
552 LINK_CHECK_FLAGS));
553 fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
554 LINK_CHECK_FLAGS));
555
556 fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
557 GST_STATE_CHANGE_ASYNC);
558
559 /* Wait for pipeline to preroll, at which point negotiation is finished */
560 fail_unless_equals_int (gst_element_get_state (pipeline, NULL, NULL, -1),
561 GST_STATE_CHANGE_SUCCESS);
562
563 /* Get negotiated caps */
564 pad = gst_element_get_static_pad (capsfilter2, "sink");
565 fail_unless (pad != NULL);
566 caps = gst_pad_get_current_caps (pad);
567 fail_unless (caps != NULL);
568 gst_object_unref (pad);
569
570 /* Check negotiated caps */
571 {
572 gint out_par_n = 0, out_par_d = 0;
573 gint out_width, out_height;
574 GstStructure *s;
575
576 s = gst_caps_get_structure (caps, 0);
577
578 fail_unless (gst_structure_get_int (s, "width", &out_width));
579 fail_unless (gst_structure_get_int (s, "height", &out_height));
580 fail_unless (gst_structure_get_fraction (s, "pixel-aspect-ratio",
581 &out_par_n, &out_par_d) || (par_n == 1 && par_d == 1));
582
583 fail_unless_equals_int (width, out_width);
584 fail_unless_equals_int (height, out_height);
585 if (par_n != 0 || par_d != 0) {
586 fail_unless_equals_int (par_n, out_par_n);
587 fail_unless_equals_int (par_d, out_par_d);
588 }
589 }
590 gst_caps_unref (caps);
591
592 /* clean up */
593 fail_unless (gst_element_set_state (pipeline,
594 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
595
596 gst_object_unref (pipeline);
597 }
598
GST_START_TEST(test_negotiation)599 GST_START_TEST (test_negotiation)
600 {
601 _test_negotiation
602 ("video/x-raw,format=(string)AYUV,width=720,height=576,pixel-aspect-ratio=16/15",
603 "video/x-raw,format=(string)AYUV,width=768,height=576", 768, 576, 1, 1);
604
605 _test_negotiation
606 ("video/x-raw,format=(string)AYUV,width=320,height=240",
607 "video/x-raw,format=(string)AYUV,width=640,height=320", 640, 320, 2, 3);
608
609 _test_negotiation
610 ("video/x-raw,format=(string)AYUV,width=320,height=240",
611 "video/x-raw,format=(string)AYUV,width=640,height=320,pixel-aspect-ratio=[0/1, 1/1]",
612 640, 320, 2, 3);
613
614 _test_negotiation
615 ("video/x-raw,format=(string)AYUV,width=1920,height=2560,pixel-aspect-ratio=1/1",
616 "video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048],pixel-aspect-ratio=1/1",
617 1536, 2048, 1, 1);
618
619 _test_negotiation
620 ("video/x-raw,format=(string)AYUV,width=1920,height=2560,pixel-aspect-ratio=1/1",
621 "video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048]",
622 1920, 2048, 4, 5);
623
624 _test_negotiation
625 ("video/x-raw,format=(string)AYUV,width=1920,height=2560",
626 "video/x-raw,format=(string)AYUV,width=[1, 2048],height=[1, 2048]",
627 1920, 2048, 4, 5);
628
629 _test_negotiation
630 ("video/x-raw,format=(string)AYUV,width=1920,height=2560",
631 "video/x-raw,format=(string)AYUV,width=1200,height=[1, 2048],pixel-aspect-ratio=1/1",
632 1200, 1600, 1, 1);
633
634 /* Doesn't keep DAR but must be possible! */
635 _test_negotiation
636 ("video/x-raw,format=(string)AYUV,width=320,height=240,pixel-aspect-ratio=1/1",
637 "video/x-raw,format=(string)AYUV,width=200,height=200,pixel-aspect-ratio=1/2",
638 200, 200, 1, 2);
639
640 _test_negotiation
641 ("video/x-raw,format=(string)AYUV,width=854,height=480",
642 "video/x-raw,format=(string)AYUV,width=[2, 512, 2],height=[2, 512, 2],pixel-aspect-ratio=1/1",
643 512, 288, 1, 1);
644 }
645
646 GST_END_TEST;
647
648 #define GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK \
649 (gst_test_reverse_negotiation_sink_get_type())
650 #define GST_TEST_REVERSE_NEGOTIATION_SINK(obj) \
651 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK,GstTestReverseNegotiationSink))
652 #define GST_TEST_REVERSE_NEGOTIATION_SINK_CLASS(klass) \
653 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK,GstTestReverseNegotiationSinkClass))
654 #define GST_IS_TEST_REVERSE_NEGOTIATION_SINK(obj) \
655 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK))
656 #define GST_IS_TEST_REVERSE_NEGOTIATION_SINK_CLASS(klass) \
657 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK))
658 #define GST_TEST_REVERSE_NEGOTIATION_SINK_CAST(obj) ((GstTestReverseNegotiationSink *)obj)
659
660 typedef struct _GstTestReverseNegotiationSink GstTestReverseNegotiationSink;
661 typedef struct _GstTestReverseNegotiationSinkClass
662 GstTestReverseNegotiationSinkClass;
663 struct _GstTestReverseNegotiationSink
664 {
665 GstBaseSink element;
666 gint nbuffers;
667 };
668
669 struct _GstTestReverseNegotiationSinkClass
670 {
671 GstBaseSinkClass parent_class;
672 };
673
674 GType gst_test_reverse_negotiation_sink_get_type (void);
675
676 G_DEFINE_TYPE (GstTestReverseNegotiationSink,
677 gst_test_reverse_negotiation_sink, GST_TYPE_BASE_SINK);
678
679 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
680 GST_PAD_SINK,
681 GST_PAD_ALWAYS,
682 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB")));
683
684 #if 0
685 static GstFlowReturn
686 gst_test_reverse_negotiation_sink_buffer_alloc (GstBaseSink * bsink,
687 guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf)
688 {
689 GstTestReverseNegotiationSink *sink =
690 GST_TEST_REVERSE_NEGOTIATION_SINK (bsink);
691 GstVideoFormat fmt;
692 gint width, height;
693
694 fail_unless (gst_video_format_parse_caps (caps, &fmt, &width, &height));
695
696 if (sink->nbuffers < 2) {
697 *buf =
698 gst_buffer_new_and_alloc (gst_video_format_get_size (fmt, width,
699 height));
700 gst_buffer_set_caps (*buf, caps);
701 } else {
702 gint fps_n, fps_d;
703
704 fail_unless (gst_video_parse_caps_framerate (caps, &fps_n, &fps_d));
705
706 width = 512;
707 height = 128;
708 *buf =
709 gst_buffer_new_and_alloc (gst_video_format_get_size (fmt, width,
710 height));
711 caps = gst_video_format_new_caps (fmt, width, height, fps_n, fps_d, 1, 1);
712 gst_buffer_set_caps (*buf, caps);
713 gst_caps_unref (caps);
714 }
715
716 return GST_FLOW_OK;
717 }
718 #endif
719
720 static GstFlowReturn
gst_test_reverse_negotiation_sink_render(GstBaseSink * bsink,GstBuffer * buffer)721 gst_test_reverse_negotiation_sink_render (GstBaseSink * bsink,
722 GstBuffer * buffer)
723 {
724 GstTestReverseNegotiationSink *sink =
725 GST_TEST_REVERSE_NEGOTIATION_SINK (bsink);
726 GstCaps *caps;
727 GstVideoInfo info;
728
729 caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (bsink));
730
731 fail_unless (caps != NULL);
732 fail_unless (gst_video_info_from_caps (&info, caps));
733
734 sink->nbuffers++;
735
736 /* The third buffer is still in the old size
737 * because the videoconverts can't convert
738 * the frame sizes
739 */
740 if (sink->nbuffers > 3) {
741 fail_unless_equals_int (GST_VIDEO_INFO_WIDTH (&info), 512);
742 fail_unless_equals_int (GST_VIDEO_INFO_HEIGHT (&info), 128);
743 }
744
745 gst_caps_unref (caps);
746
747 return GST_FLOW_OK;
748 }
749
750 static void
gst_test_reverse_negotiation_sink_class_init(GstTestReverseNegotiationSinkClass * klass)751 gst_test_reverse_negotiation_sink_class_init (GstTestReverseNegotiationSinkClass
752 * klass)
753 {
754 GstElementClass *gstelement_class;
755 GstBaseSinkClass *gstbase_sink_class;
756
757 gstelement_class = GST_ELEMENT_CLASS (klass);
758 gstbase_sink_class = GST_BASE_SINK_CLASS (klass);
759
760 gst_element_class_set_metadata (gstelement_class,
761 "Test Reverse Negotiation Sink",
762 "Sink",
763 "Some test sink", "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
764 gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
765
766 #if 0
767 gstbase_sink_class->buffer_alloc =
768 GST_DEBUG_FUNCPTR (gst_test_reverse_negotiation_sink_buffer_alloc);
769 #endif
770 gstbase_sink_class->render =
771 GST_DEBUG_FUNCPTR (gst_test_reverse_negotiation_sink_render);
772 }
773
774 static void
gst_test_reverse_negotiation_sink_init(GstTestReverseNegotiationSink * sink)775 gst_test_reverse_negotiation_sink_init (GstTestReverseNegotiationSink * sink)
776 {
777 sink->nbuffers = 0;
778 }
779
GST_START_TEST(test_negotiate_alternate)780 GST_START_TEST (test_negotiate_alternate)
781 {
782 GstHarness *h;
783 GstBuffer *buffer;
784 GstMapInfo map;
785
786 h = gst_harness_new ("videoscale");
787
788 buffer = gst_buffer_new_and_alloc (4);
789 gst_buffer_map (buffer, &map, GST_MAP_WRITE);
790 map.data[0] = 0x0;
791 map.data[1] = 0x0;
792 map.data[2] = 0x0;
793 map.data[3] = 0x0;
794 gst_buffer_unmap (buffer, &map);
795
796 gst_harness_set_sink_caps_str (h, "video/x-raw,width=1,height=1,format=ARGB");
797 gst_harness_set_src_caps_str (h,
798 "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=2,format=ARGB");
799 fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
800 GST_FLOW_NOT_NEGOTIATED);
801
802 gst_harness_set_sink_caps_str (h,
803 "video/x-raw(format:Interlaced),width=1,height=1,format=ARGB");
804 gst_harness_set_src_caps_str (h,
805 "video/x-raw,interlace-mode=alternate,width=1,height=2,format=ARGB");
806 fail_unless_equals_int (gst_harness_push (h, gst_buffer_ref (buffer)),
807 GST_FLOW_NOT_NEGOTIATED);
808
809 gst_harness_set_sink_caps_str (h,
810 "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=1,format=ARGB");
811 gst_harness_set_src_caps_str (h,
812 "video/x-raw(format:Interlaced),interlace-mode=alternate,width=1,height=2,format=ARGB");
813 fail_unless_equals_int (gst_harness_push (h, buffer), GST_FLOW_OK);
814
815 gst_harness_teardown (h);
816 }
817
818 GST_END_TEST;
819 #if 0
820 static void
821 _test_reverse_negotiation_message (GstBus * bus, GstMessage * message,
822 GMainLoop * loop)
823 {
824 GError *err = NULL;
825 gchar *debug;
826
827 switch (GST_MESSAGE_TYPE (message)) {
828 case GST_MESSAGE_ERROR:
829 gst_message_parse_error (message, &err, &debug);
830 gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
831 g_error_free (err);
832 g_free (debug);
833 g_assert_not_reached ();
834 break;
835 case GST_MESSAGE_WARNING:
836 gst_message_parse_warning (message, &err, &debug);
837 gst_object_default_error (GST_MESSAGE_SRC (message), err, debug);
838 g_error_free (err);
839 g_free (debug);
840 g_assert_not_reached ();
841 break;
842 case GST_MESSAGE_EOS:
843 g_main_loop_quit (loop);
844 break;
845 default:
846 break;
847 }
848 }
849 #endif
850
851 #if 0
852 GST_START_TEST (test_reverse_negotiation)
853 {
854 GstElement *pipeline;
855 GstElement *src, *csp1, *scale, *csp2, *sink;
856 GstBus *bus;
857 GMainLoop *loop;
858
859 pipeline = gst_element_factory_make ("pipeline", "pipeline");
860 fail_unless (pipeline != NULL);
861
862 src = gst_element_factory_make ("videotestsrc", "src");
863 fail_unless (src != NULL);
864 g_object_set (G_OBJECT (src), "num-buffers", 8, NULL);
865
866 csp1 = gst_element_factory_make ("videoconvert", "csp1");
867 fail_unless (csp1 != NULL);
868
869 scale = gst_element_factory_make ("videoscale", "scale");
870 fail_unless (scale != NULL);
871
872 csp2 = gst_element_factory_make ("videoconvert", "csp2");
873 fail_unless (csp2 != NULL);
874
875 sink = g_object_new (GST_TYPE_TEST_REVERSE_NEGOTIATION_SINK, NULL);
876 fail_unless (sink != NULL);
877 g_object_set (sink, "async", FALSE, NULL);
878
879 gst_bin_add_many (GST_BIN (pipeline), src, csp1, scale, csp2, sink, NULL);
880
881 fail_unless (gst_element_link_pads_full (src, "src", csp1, "sink",
882 LINK_CHECK_FLAGS));
883 fail_unless (gst_element_link_pads_full (csp1, "src", scale, "sink",
884 LINK_CHECK_FLAGS));
885 fail_unless (gst_element_link_pads_full (scale, "src", csp2, "sink",
886 LINK_CHECK_FLAGS));
887 fail_unless (gst_element_link_pads_full (csp2, "src", sink, "sink",
888 LINK_CHECK_FLAGS));
889
890 loop = g_main_loop_new (NULL, FALSE);
891
892 bus = gst_element_get_bus (pipeline);
893 fail_unless (bus != NULL);
894 gst_bus_add_signal_watch (bus);
895
896 g_signal_connect (bus, "message",
897 G_CALLBACK (_test_reverse_negotiation_message), loop);
898
899 gst_object_unref (bus);
900
901 fail_unless (gst_element_set_state (pipeline,
902 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
903
904 g_main_loop_run (loop);
905
906 fail_unless (gst_element_set_state (pipeline,
907 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
908
909 gst_object_unref (pipeline);
910 g_main_loop_unref (loop);
911 }
912
913 GST_END_TEST;
914 #endif
915
GST_START_TEST(test_basetransform_negotiation)916 GST_START_TEST (test_basetransform_negotiation)
917 {
918 GstElement *pipeline, *src, *sink, *scale, *capsfilter1, *capsfilter2;
919 GstMessage *msg;
920 GstCaps *caps;
921
922 pipeline = gst_pipeline_new (NULL);
923 src = gst_element_factory_make ("videotestsrc", NULL);
924 capsfilter1 = gst_element_factory_make ("capsfilter", NULL);
925 scale = gst_element_factory_make ("videoscale", NULL);
926 capsfilter2 = gst_element_factory_make ("capsfilter", NULL);
927 sink = gst_element_factory_make ("fakesink", NULL);
928 fail_unless (pipeline && src && capsfilter1 && scale && capsfilter2 && sink);
929
930 g_object_set (src, "num-buffers", 3, NULL);
931
932 caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
933 "UYVY", "width", G_TYPE_INT, 352,
934 "height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
935 "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
936 g_object_set (capsfilter1, "caps", caps, NULL);
937 gst_caps_unref (caps);
938
939 /* same caps, just different pixel-aspect-ratio */
940 caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
941 "UYVY", "width", G_TYPE_INT, 352,
942 "height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 30, 1,
943 "pixel-aspect-ratio", GST_TYPE_FRACTION, 12, 11, NULL);
944 g_object_set (capsfilter2, "caps", caps, NULL);
945 gst_caps_unref (caps);
946
947 gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
948 sink, NULL);
949 fail_unless (gst_element_link_many (src, capsfilter1, scale, capsfilter2,
950 sink, NULL));
951
952 fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
953 GST_STATE_CHANGE_ASYNC);
954
955 msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline), -1,
956 GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
957 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);
958 gst_message_unref (msg);
959
960 gst_element_set_state (pipeline, GST_STATE_NULL);
961 gst_object_unref (pipeline);
962 }
963
964 GST_END_TEST;
965
966 #endif /* !defined(VSCALE_TEST_GROUP) */
967
968 static Suite *
videoscale_suite(void)969 videoscale_suite (void)
970 {
971 Suite *s = suite_create ("videoscale");
972 TCase *tc_chain = tcase_create ("general");
973
974 suite_add_tcase (s, tc_chain);
975 tcase_set_timeout (tc_chain, 180);
976 #ifndef VSCALE_TEST_GROUP
977 tcase_add_test (tc_chain, test_template_formats);
978 tcase_add_test (tc_chain, test_passthrough_method_0);
979 tcase_add_test (tc_chain, test_passthrough_method_1);
980 tcase_add_test (tc_chain, test_passthrough_method_2);
981 tcase_add_test (tc_chain, test_passthrough_method_3);
982 tcase_add_test (tc_chain, test_negotiation);
983 tcase_add_test (tc_chain, test_negotiate_alternate);
984 #if 0
985 tcase_add_test (tc_chain, test_reverse_negotiation);
986 #endif
987 tcase_add_test (tc_chain, test_basetransform_negotiation);
988 #else
989 #if VSCALE_TEST_GROUP == 1
990 tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0);
991 tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1);
992 tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2);
993 tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_3);
994 tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_0);
995 tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_1);
996 tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_2);
997 tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_3);
998 #elif VSCALE_TEST_GROUP == 2
999 tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_0);
1000 tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_1);
1001 tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_2);
1002 tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x1_method_3);
1003 tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_0);
1004 tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_1);
1005 tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_2);
1006 tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_3);
1007 #elif VSCALE_TEST_GROUP == 3
1008 tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_0);
1009 tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_1);
1010 tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_2);
1011 tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_3);
1012 tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_0);
1013 tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_1);
1014 tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_2);
1015 tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_3);
1016 #elif VSCALE_TEST_GROUP == 4
1017 tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_0);
1018 tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_1);
1019 tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_2);
1020 tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_3);
1021 tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_0);
1022 tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_1);
1023 tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_2);
1024 tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_3);
1025 #elif VSCALE_TEST_GROUP == 5
1026 tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_0);
1027 tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_1);
1028 tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_2);
1029 tcase_skip_broken_test (tc_chain, test_downscale_640x480_320x1_method_3);
1030 tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_0);
1031 tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_1);
1032 tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_2);
1033 tcase_skip_broken_test (tc_chain, test_upscale_320x1_640x480_method_3);
1034 #elif VSCALE_TEST_GROUP == 6
1035 tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_0);
1036 tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_1);
1037 tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_2);
1038 tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x240_method_3);
1039 tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_0);
1040 tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_1);
1041 tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_2);
1042 tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_3);
1043 #endif
1044 #endif /* VSCALE_TEST_GROUP */
1045
1046 return s;
1047 }
1048
1049 /* NOTE:
1050 * We need to do the filename dance below in order to avoid having
1051 * multiple parallel tests (identified by VSCALE_TEST_GROUP) going
1052 * to the same output xml file (when using GST_CHECK_XML) */
1053 int
main(int argc,char ** argv)1054 main (int argc, char **argv)
1055 {
1056 Suite *s;
1057
1058 gst_check_init (&argc, &argv);
1059 s = videoscale_suite ();
1060 #ifndef VSCALE_TEST_GROUP
1061 #define FULL_RUN_NAME __FILE__
1062 #else
1063 #define STR_HELPER(x) #x
1064 #define STR(x) STR_HELPER(x)
1065 #define FULL_RUN_NAME __FILE__ STR(VSCALE_TEST_GROUP)".c"
1066 #endif
1067 return gst_check_run_suite (s, "videoscale", FULL_RUN_NAME);
1068 }
1069