tests: alphacolor: Port to 0.11

This commit is contained in:
Thiago Santos 2011-10-12 08:24:28 -03:00
parent 1a10116bbe
commit 12534340fd

View file

@ -29,12 +29,12 @@ GstPad *mysrcpad, *mysinkpad;
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV"))
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("AYUV"))
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB)
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBA, RGB }"))
);
static GstElement *
@ -106,6 +106,13 @@ create_caps_rgba32 (void)
return caps;
}
static void
push_caps (GstCaps * caps)
{
fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
}
static GstBuffer *
create_buffer_rgb24_3x4 (void)
{
@ -118,15 +125,15 @@ create_buffer_rgb24_3x4 (void)
};
guint rowstride = GST_ROUND_UP_4 (WIDTH * 3);
GstBuffer *buf;
GstCaps *caps;
gpointer buf_data;
gsize size;
buf = gst_buffer_new_and_alloc (HEIGHT * rowstride);
fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (rgb24_3x4_img));
memcpy (GST_BUFFER_DATA (buf), rgb24_3x4_img, sizeof (rgb24_3x4_img));
buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
fail_unless_equals_int (size, sizeof (rgb24_3x4_img));
memcpy (buf_data, rgb24_3x4_img, sizeof (rgb24_3x4_img));
caps = create_caps_rgb24 ();
gst_buffer_set_caps (buf, caps);
gst_caps_unref (caps);
gst_buffer_unmap (buf, buf_data, size);
return buf;
}
@ -148,15 +155,15 @@ create_buffer_rgba32_3x4 (void)
};
guint rowstride = WIDTH * 4;
GstBuffer *buf;
GstCaps *caps;
gpointer buf_data;
gsize size;
buf = gst_buffer_new_and_alloc (HEIGHT * rowstride);
fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (rgba32_3x4_img));
memcpy (GST_BUFFER_DATA (buf), rgba32_3x4_img, sizeof (rgba32_3x4_img));
buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
fail_unless_equals_int (size, sizeof (rgba32_3x4_img));
memcpy (buf_data, rgba32_3x4_img, sizeof (rgba32_3x4_img));
caps = create_caps_rgba32 ();
gst_buffer_set_caps (buf, caps);
gst_caps_unref (caps);
gst_buffer_unmap (buf, buf_data, size);
return buf;
}
@ -173,6 +180,8 @@ GST_START_TEST (test_rgb24)
fail_unless_equals_int (gst_element_set_state (alphacolor, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
push_caps (create_caps_rgb24 ());
inbuffer = create_buffer_rgb24_3x4 ();
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@ -214,6 +223,8 @@ GST_START_TEST (test_rgba32)
GstCaps *incaps;
guint8 *ayuv;
guint outlength;
gpointer buf_data;
gsize size;
incaps = create_caps_rgba32 ();
alphacolor = setup_alphacolor ();
@ -221,8 +232,10 @@ GST_START_TEST (test_rgba32)
fail_unless_equals_int (gst_element_set_state (alphacolor, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
push_caps (create_caps_rgba32 ());
inbuffer = create_buffer_rgba32_3x4 ();
GST_DEBUG ("Created buffer of %d bytes", GST_BUFFER_SIZE (inbuffer));
GST_DEBUG ("Created buffer of %d bytes", gst_buffer_get_size (inbuffer));
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away reference */
@ -238,9 +251,10 @@ GST_START_TEST (test_rgba32)
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
outlength = WIDTH * HEIGHT * 4; /* output is AYUV */
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
buf_data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
fail_unless_equals_int (size, outlength);
ayuv = GST_BUFFER_DATA (outbuffer);
ayuv = buf_data;
/* check alpha values (0x00 = totally transparent, 0xff = totally opaque) */
fail_unless_ayuv_pixel_has_alpha (ayuv, 0, 0, 0xff);
@ -259,6 +273,8 @@ GST_START_TEST (test_rgba32)
/* we don't check the YUV data, because apparently results differ slightly
* depending on whether we run in valgrind or not */
gst_buffer_unmap (outbuffer, buf_data, size);
buffers = g_list_remove (buffers, outbuffer);
gst_buffer_unref (outbuffer);