diff options
Diffstat (limited to 'tests/check/elements/videocrop.c')
-rw-r--r-- | tests/check/elements/videocrop.c | 92 |
1 files changed, 61 insertions, 31 deletions
diff --git a/tests/check/elements/videocrop.c b/tests/check/elements/videocrop.c index fc7c5dc14..9f68e9575 100644 --- a/tests/check/elements/videocrop.c +++ b/tests/check/elements/videocrop.c @@ -155,6 +155,7 @@ typedef struct GstElement *src; GstElement *filter; GstElement *crop; + GstElement *filter2; GstElement *sink; GstBuffer *last_buf; } GstVideoCropTestContext; @@ -179,12 +180,16 @@ videocrop_test_cropping_init_context (GstVideoCropTestContext * ctx) fail_unless (ctx->filter != NULL, "Failed to create capsfilter element"); ctx->crop = gst_element_factory_make ("videocrop", "crop"); fail_unless (ctx->crop != NULL, "Failed to create videocrop element"); + ctx->filter2 = gst_element_factory_make ("capsfilter", "filter2"); + fail_unless (ctx->filter2 != NULL, + "Failed to create second capsfilter element"); ctx->sink = gst_element_factory_make ("fakesink", "sink"); fail_unless (ctx->sink != NULL, "Failed to create fakesink element"); gst_bin_add_many (GST_BIN (ctx->pipeline), ctx->src, ctx->filter, - ctx->crop, ctx->sink, NULL); - gst_element_link_many (ctx->src, ctx->filter, ctx->crop, ctx->sink, NULL); + ctx->crop, ctx->filter2, ctx->sink, NULL); + gst_element_link_many (ctx->src, ctx->filter, ctx->crop, ctx->filter2, + ctx->sink, NULL); /* set pattern to 'red' - for our purposes it doesn't matter anyway */ g_object_set (ctx->src, "pattern", 4, NULL); @@ -213,13 +218,15 @@ typedef void (*GstVideoCropTestBufferFunc) (GstBuffer * buffer); static void videocrop_test_cropping (GstVideoCropTestContext * ctx, GstCaps * in_caps, - gint left, gint right, gint top, gint bottom, + GstCaps * out_caps, gint left, gint right, gint top, gint bottom, GstVideoCropTestBufferFunc func) { - GST_LOG ("lrtb = %03u %03u %03u %03u, caps = %" GST_PTR_FORMAT, left, right, - top, bottom, in_caps); + GST_LOG ("lrtb = %03u %03u %03u %03u, in_caps = %" GST_PTR_FORMAT + ", out_caps = %" GST_PTR_FORMAT, left, right, top, bottom, in_caps, + out_caps); g_object_set (ctx->filter, "caps", in_caps, NULL); + g_object_set (ctx->filter2, "caps", out_caps, NULL); g_object_set (ctx->crop, "left", left, "right", right, "top", top, "bottom", bottom, NULL); @@ -359,11 +366,12 @@ GST_START_TEST (test_crop_to_1x1) gst_structure_set (s, "width", G_TYPE_INT, 160, "height", G_TYPE_INT, 160, NULL); - videocrop_test_cropping (&ctx, caps, 159, 0, 159, 0, check_1x1_buffer); + videocrop_test_cropping (&ctx, caps, NULL, 159, 0, 159, 0, + check_1x1_buffer); /* commented out because they don't really add anything useful check-wise: - videocrop_test_cropping (&ctx, caps, 0, 159, 0, 159, check_1x1_buffer); - videocrop_test_cropping (&ctx, caps, 159, 0, 0, 159, check_1x1_buffer); - videocrop_test_cropping (&ctx, caps, 0, 159, 159, 0, check_1x1_buffer); + videocrop_test_cropping (&ctx, caps, NULL, 0, 159, 0, 159, check_1x1_buffer); + videocrop_test_cropping (&ctx, caps, NULL, 159, 0, 0, 159, check_1x1_buffer); + videocrop_test_cropping (&ctx, caps, NULL, 0, 159, 159, 0, check_1x1_buffer); */ gst_caps_unref (caps); } @@ -413,7 +421,7 @@ GST_START_TEST (test_cropping) GST_INFO ("testing format: %" GST_PTR_FORMAT, caps); for (i = 0; i < G_N_ELEMENTS (sizes_to_try); ++i) { - GstCaps *in_caps; + GstCaps *in_caps, *out_caps; GST_INFO (" - %d x %d", sizes_to_try[i].width, sizes_to_try[i].height); @@ -421,29 +429,51 @@ GST_START_TEST (test_cropping) "height", G_TYPE_INT, sizes_to_try[i].height, NULL); in_caps = gst_caps_copy (caps); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 1, 0, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 1, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 1, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 0, 1, NULL); - videocrop_test_cropping (&ctx, in_caps, 63, 0, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 63, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 63, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 0, 63, NULL); - videocrop_test_cropping (&ctx, in_caps, 63, 0, 0, 1, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 63, 1, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 1, 63, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 1, 0, 0, 63, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 0, 0, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 32, 0, 0, 128, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 32, 128, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 0, 128, 32, 0, NULL); - videocrop_test_cropping (&ctx, in_caps, 128, 0, 0, 32, NULL); - videocrop_test_cropping (&ctx, in_caps, 1, 1, 1, 1, NULL); - videocrop_test_cropping (&ctx, in_caps, 63, 63, 63, 63, NULL); - videocrop_test_cropping (&ctx, in_caps, 64, 64, 64, 64, NULL); + gst_structure_set (s, "width", G_TYPE_INT, 1, "height", G_TYPE_INT, 1, + NULL); + out_caps = gst_caps_copy (caps); + + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 1, 0, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 1, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 1, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 0, 1, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 63, 0, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 63, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 63, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 0, 63, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 63, 0, 0, 1, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 63, 1, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 1, 63, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 1, 0, 0, 63, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 0, 0, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 32, 0, 0, 128, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 32, 128, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 0, 128, 32, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 128, 0, 0, 32, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 1, 1, 1, 1, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 63, 63, 63, 63, NULL); + videocrop_test_cropping (&ctx, in_caps, NULL, 64, 64, 64, 64, NULL); + + /* Dynamic cropping */ + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, -1, -1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, 0, -1, -1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, 0, -1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, -1, 0, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, -1, -1, 0, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, 10, -1, 10, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, 10, -1, 10, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, + sizes_to_try[i].width - 1, -1, -1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, + sizes_to_try[i].width - 1, -1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, -1, + sizes_to_try[i].height - 1, -1, NULL); + videocrop_test_cropping (&ctx, in_caps, out_caps, -1, -1, -1, + sizes_to_try[i].height - 1, NULL); gst_caps_unref (in_caps); + gst_caps_unref (out_caps); } } |