diff --git a/tests/check/elements/rglimiter.c b/tests/check/elements/rglimiter.c index 4b9ea02883..104df22585 100644 --- a/tests/check/elements/rglimiter.c +++ b/tests/check/elements/rglimiter.c @@ -33,6 +33,7 @@ static GstPad *mysrcpad, *mysinkpad; #define RG_LIMITER_CAPS_TEMPLATE_STRING \ "audio/x-raw, " \ "format = (string) "GST_AUDIO_NE (F32) ", " \ + "layout = (string) interleaved, " \ "channels = (int) [ 1, MAX ], " \ "rate = (int) [ 1, MAX ]" @@ -108,7 +109,8 @@ create_test_buffer (void) caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, - "format", G_TYPE_STRING, GST_AUDIO_NE (F32), NULL); + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), + "layout", G_TYPE_STRING, "interleaved", NULL); gst_pad_set_caps (mysrcpad, caps); gst_caps_unref (caps); diff --git a/tests/check/elements/rgvolume.c b/tests/check/elements/rgvolume.c index fc9a180848..c5bb3e36a9 100644 --- a/tests/check/elements/rgvolume.c +++ b/tests/check/elements/rgvolume.c @@ -35,6 +35,7 @@ static GstPad *mysrcpad, *mysinkpad; #define RG_VOLUME_CAPS_TEMPLATE_STRING \ "audio/x-raw, " \ "format = (string) "GST_AUDIO_NE (F32) ", " \ + "layout = (string) interleaved, " \ "channels = (int) [ 1, MAX ], " \ "rate = (int) [ 1, MAX ]" @@ -56,6 +57,7 @@ static GstBuffer *test_buffer_new (gfloat value); static gboolean event_func (GstPad * pad, GstObject * parent, GstEvent * event) { + GST_DEBUG ("received event %p", event); events = g_list_append (events, event); return TRUE; @@ -65,6 +67,7 @@ static GstElement * setup_rgvolume (void) { GstElement *element; + GstCaps *caps; GST_DEBUG ("setup_rgvolume"); element = gst_check_setup_element ("rgvolume"); @@ -77,6 +80,11 @@ setup_rgvolume (void) gst_pad_set_active (mysrcpad, TRUE); gst_pad_set_active (mysinkpad, TRUE); + caps = gst_caps_from_string ("audio/x-raw, format = F32LE, " + "layout = interleaved, rate = 8000, channels = 1"); + gst_pad_set_caps (mysrcpad, caps); + gst_caps_unref (caps); + return element; } @@ -94,16 +102,21 @@ send_newsegment_and_empty_buffer (void) fail_unless (gst_pad_push_event (mysrcpad, ev), "Pushing newsegment event failed"); + /* makes caps event */ buf = test_buffer_new (0.0); gst_buffer_resize (buf, 0, 0); GST_BUFFER_DURATION (buf) = 0; GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET (buf); fail_unless (gst_pad_push (mysrcpad, buf) == GST_FLOW_OK); - fail_unless (g_list_length (events) == 1); + fail_unless (g_list_length (events) == 2); fail_unless (events->data == ev); gst_mini_object_unref ((GstMiniObject *) events->data); events = g_list_remove (events, ev); + ev = events->data; + gst_mini_object_unref ((GstMiniObject *) ev); + events = g_list_remove (events, ev); + fail_unless (g_list_length (events) == 0); fail_unless (g_list_length (buffers) == 1); fail_unless (buffers->data == buf); @@ -152,6 +165,8 @@ send_eos_event (GstElement * element) { GstEvent *event = gst_event_new_eos (); + GST_DEBUG ("events : %d", g_list_length (events)); + fail_unless (g_list_length (events) == 0); fail_unless (gst_pad_push_event (mysrcpad, event), "Pushing EOS event failed"); @@ -201,7 +216,6 @@ static GstBuffer * test_buffer_new (gfloat value) { GstBuffer *buf; - GstCaps *caps; GstMapInfo map; gfloat *data; gint i; @@ -213,10 +227,6 @@ test_buffer_new (gfloat value) data[i] = value; gst_buffer_unmap (buf, &map); - caps = gst_caps_from_string ("audio/x-raw-float, " - "rate = 8000, channels = 1, endianness = BYTE_ORDER, width = 32"); - gst_pad_set_caps (mysrcpad, caps); - gst_caps_unref (caps); ASSERT_BUFFER_REFCOUNT (buf, "buf", 1); @@ -338,8 +348,6 @@ GST_START_TEST (test_events) GST_TAG_ARTIST, "Foobar", NULL); event = gst_event_new_tag (tag_list); new_event = send_tag_event (element, event); - /* Expect the element to modify the writable event. */ - fail_unless (event == new_event, "Writable tag event not reused"); gst_event_parse_tag (new_event, &tag_list); fail_unless (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist)); fail_unless (g_str_equal (artist, "Foobar")); @@ -354,15 +362,11 @@ GST_START_TEST (test_events) GST_TAG_ALBUM_GAIN, -1.54, GST_TAG_ALBUM_PEAK, 0.693415, GST_TAG_ARTIST, "Foobar", NULL); event = gst_event_new_tag (tag_list); - /* Holding an extra ref makes the event unwritable: */ - gst_event_ref (event); new_event = send_tag_event (element, event); - fail_unless (event != new_event, "Unwritable tag event reused"); gst_event_parse_tag (new_event, &tag_list); fail_unless (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist)); fail_unless (g_str_equal (artist, "Foobar")); g_free (artist); - gst_event_unref (event); gst_event_unref (new_event); cleanup_rgvolume (element); diff --git a/tests/check/elements/spectrum.c b/tests/check/elements/spectrum.c index 4ea3741b99..ff3d030053 100644 --- a/tests/check/elements/spectrum.c +++ b/tests/check/elements/spectrum.c @@ -36,6 +36,7 @@ GstPad *mysrcpad, *mysinkpad; "audio/x-raw, " \ " rate = (int) [ 1, MAX ], " \ " channels = (int) [ 1, MAX ], " \ + " layout = (string) interleaved, " \ " format = (string) { " \ GST_AUDIO_NE(S16) ", " \ GST_AUDIO_NE(S32) ", " \ @@ -46,24 +47,28 @@ GstPad *mysrcpad, *mysinkpad; "audio/x-raw, " \ "rate = (int) 44100, " \ "channels = (int) 1, " \ + "layout = (string) interleaved, " \ "format = (string) " GST_AUDIO_NE(S16) #define SPECT_CAPS_STRING_S32 \ "audio/x-raw, " \ "rate = (int) 44100, " \ "channels = (int) 1, " \ + "layout = (string) interleaved, " \ "format = (string) " GST_AUDIO_NE(S32) #define SPECT_CAPS_STRING_F32 \ "audio/x-raw, " \ " rate = (int) 44100, " \ " channels = (int) 1, " \ + " layout = (string) interleaved, " \ " format = (string) " GST_AUDIO_NE(F32) #define SPECT_CAPS_STRING_F64 \ "audio/x-raw, " \ " rate = (int) 44100, " \ " channels = (int) 1, " \ + " layout = (string) interleaved, " \ " format = (string) " GST_AUDIO_NE(F64) #define SPECT_BANDS 256 diff --git a/tests/check/elements/videocrop.c b/tests/check/elements/videocrop.c index 7538fc8b34..101835e7d8 100644 --- a/tests/check/elements/videocrop.c +++ b/tests/check/elements/videocrop.c @@ -36,15 +36,18 @@ static GList * video_crop_get_test_caps (GstElement * videocrop) { - const GstCaps *allowed_caps; + GstCaps *templ, *allowed_caps; GstPad *srcpad; GList *list = NULL; guint i; srcpad = gst_element_get_static_pad (videocrop, "src"); fail_unless (srcpad != NULL); - allowed_caps = gst_pad_get_pad_template_caps (srcpad); - fail_unless (allowed_caps != NULL); + templ = gst_pad_get_pad_template_caps (srcpad); + fail_unless (templ != NULL); + + allowed_caps = gst_caps_normalize (templ); + gst_caps_unref (templ); for (i = 0; i < gst_caps_get_size (allowed_caps); ++i) { GstStructure *new_structure; @@ -59,12 +62,14 @@ video_crop_get_test_caps (GstElement * videocrop) gst_structure_remove_field (new_structure, "height"); gst_caps_append_structure (single_caps, new_structure); + GST_DEBUG ("have caps %" GST_PTR_FORMAT, single_caps); /* should be fixed without width/height */ fail_unless (gst_caps_is_fixed (single_caps)); list = g_list_prepend (list, single_caps); } + gst_caps_unref (allowed_caps); gst_object_unref (srcpad); return list; @@ -80,8 +85,8 @@ GST_START_TEST (test_unit_sizes) fail_unless (videocrop != NULL, "Failed to create videocrop element"); vcrop_klass = GST_BASE_TRANSFORM_GET_CLASS (videocrop); - csp = gst_element_factory_make ("ffmpegcolorspace", "csp"); - fail_unless (csp != NULL, "Failed to create ffmpegcolorspace element"); + csp = gst_element_factory_make ("videoconvert", "csp"); + fail_unless (csp != NULL, "Failed to create videoconvert element"); csp_klass = GST_BASE_TRANSFORM_GET_CLASS (csp); caps_list = video_crop_get_test_caps (videocrop); @@ -120,10 +125,10 @@ GST_START_TEST (test_unit_sizes) caps_str = gst_caps_to_string (caps); GST_INFO ("Testing unit size for %s", caps_str); - /* skip if ffmpegcolorspace doesn't support these caps + /* skip if videoconvert doesn't support these caps * (only works with gst-plugins-base 0.10.9.1 or later) */ if (!csp_klass->get_unit_size ((GstBaseTransform *) csp, caps, &csp_size)) { - GST_INFO ("ffmpegcolorspace does not support format %s", caps_str); + GST_INFO ("videoconvert does not support format %s", caps_str); g_free (caps_str); continue; } @@ -132,7 +137,7 @@ GST_START_TEST (test_unit_sizes) caps, &vc_size)); fail_unless (vc_size == csp_size, - "videocrop and ffmpegcolorspace return different unit sizes for " + "videocrop and videoconvert return different unit sizes for " "caps %s: vc_size=%d, csp_size=%d", caps_str, vc_size, csp_size); g_free (caps_str); @@ -251,10 +256,12 @@ check_1x1_buffer (GstBuffer * buf, GstCaps * caps) GstVideoInfo info; GstVideoFrame frame; /* the exact values we check for come from videotestsrc */ - static const guint yuv_values[] = { 81, 90, 240, 0 }; - static const guint rgb_values[] = { 0xff, 0, 0, 0 }; + static const guint yuv_values[] = { 81, 90, 240, 255 }; + static const guint rgb_values[] = { 0xff, 0, 0, 255 }; + static const guint gray_values[] = { 63, 63, 63, 255 }; const guint *values; guint i; + const GstVideoFormatInfo *finfo; fail_unless (buf != NULL); fail_unless (caps != NULL); @@ -262,15 +269,52 @@ check_1x1_buffer (GstBuffer * buf, GstCaps * caps) fail_unless (gst_video_info_from_caps (&info, caps)); fail_unless (gst_video_frame_map (&frame, &info, buf, GST_MAP_READ)); - if (GST_VIDEO_INFO_IS_YUV (&info)) + finfo = info.finfo; + + + if (GST_VIDEO_INFO_FORMAT (&info) == GST_VIDEO_FORMAT_Y800) + values = gray_values; + else if (GST_VIDEO_INFO_IS_YUV (&info)) values = yuv_values; + else if (GST_VIDEO_INFO_IS_GRAY (&info)) + values = gray_values; else values = rgb_values; + GST_MEMDUMP ("buffer", GST_VIDEO_FRAME_PLANE_DATA (&frame, 0), 8); + for (i = 0; i < GST_VIDEO_FRAME_N_COMPONENTS (&frame); i++) { guint8 *data = GST_VIDEO_FRAME_COMP_DATA (&frame, i); - fail_unless_equals_int (data[0], values[i]); + GST_DEBUG ("W: %d", GST_VIDEO_FORMAT_INFO_W_SUB (finfo, i)); + GST_DEBUG ("H: %d", GST_VIDEO_FORMAT_INFO_H_SUB (finfo, i)); + + if (GST_VIDEO_FORMAT_INFO_W_SUB (finfo, + i) >= GST_VIDEO_FRAME_WIDTH (&frame)) + continue; + if (GST_VIDEO_FORMAT_INFO_H_SUB (finfo, + i) >= GST_VIDEO_FRAME_HEIGHT (&frame)) + continue; + + if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 8) { + fail_unless_equals_int (data[0], values[i]); + } else if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 16) { + guint16 pixels, val; + gint depth; + + if (GST_VIDEO_FORMAT_INFO_IS_LE (finfo)) + pixels = GST_READ_UINT16_LE (data); + else + pixels = GST_READ_UINT16_BE (data); + + depth = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, i); + val = pixels >> GST_VIDEO_FORMAT_INFO_SHIFT (finfo, i); + val = val & ((1 << depth) - 1); + + GST_DEBUG ("val %08x %d : %d", pixels, i, val); + fail_unless_equals_int (val, values[i] >> (8 - depth)); + } else { + } } /* @@ -297,12 +341,6 @@ GST_START_TEST (test_crop_to_1x1) s = gst_caps_get_structure (caps, 0); fail_unless (s != NULL); - if (g_strcmp0 (gst_structure_get_name (s), "video/x-raw-gray") == 0) { - /* videotestsrc does not support this format */ - gst_caps_unref (caps); - continue; - } - GST_INFO ("testing format: %" GST_PTR_FORMAT, caps); gst_structure_set (s, "width", G_TYPE_INT, 160, @@ -489,7 +527,7 @@ GST_START_TEST (test_caps_transform) klass = GST_BASE_TRANSFORM_GET_CLASS (ctx.crop); fail_unless (klass != NULL); - caps = gst_caps_new_simple ("video/x-raw-yuv", + caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING, "I420", "framerate", GST_TYPE_FRACTION, 1, 1, "width", G_TYPE_INT, 200, "height", G_TYPE_INT, 100, NULL);