tests: improve some tests

This commit is contained in:
Wim Taymans 2012-02-06 09:49:38 +01:00
parent f75fa8e3c3
commit 16cc9b3807
2 changed files with 36 additions and 20 deletions

View file

@ -28,7 +28,7 @@
#define ASPECT_RATIO_CROP_CAPS \ #define ASPECT_RATIO_CROP_CAPS \
GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \ GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \
"RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, " \ "RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, " \
"YUY2, YVYU, UYVY, Y800, I420, YV12, RGB16 " \ "YUY2, YVYU, UYVY, Y800, I420, YV12, RGB16, " \
"RGB15 }") "RGB15 }")
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@ -67,12 +67,16 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
/* create the src pad */ /* create the src pad */
src_pad = gst_pad_new (NULL, GST_PAD_SRC); src_pad = gst_pad_new (NULL, GST_PAD_SRC);
gst_pad_set_active (src_pad, TRUE);
GST_DEBUG ("setting caps %s %" GST_PTR_FORMAT, in_string, incaps);
fail_unless (gst_pad_set_caps (src_pad, incaps),
"Couldn't set input caps %" GST_PTR_FORMAT, incaps);
pad_peer = gst_element_get_static_pad (element, "sink"); pad_peer = gst_element_get_static_pad (element, "sink");
fail_if (pad_peer == NULL); fail_if (pad_peer == NULL);
fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK, fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK,
"Could not link source and %s sink pads", GST_ELEMENT_NAME (element)); "Could not link source and %s sink pads", GST_ELEMENT_NAME (element));
gst_object_unref (pad_peer); gst_object_unref (pad_peer);
gst_pad_set_active (src_pad, TRUE);
/* create the sink pad */ /* create the sink pad */
pad_peer = gst_element_get_static_pad (element, "src"); pad_peer = gst_element_get_static_pad (element, "src");
@ -88,9 +92,6 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing"); "could not set to playing");
fail_unless (gst_pad_set_caps (src_pad, incaps),
"Couldn't set input caps %" GST_PTR_FORMAT, incaps);
fail_unless (gst_pad_push (src_pad, buffer) == GST_FLOW_OK, fail_unless (gst_pad_push (src_pad, buffer) == GST_FLOW_OK,
"Failed to push buffer"); "Failed to push buffer");
fail_unless (gst_element_set_state (element, fail_unless (gst_element_set_state (element,
@ -127,12 +128,12 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
GST_START_TEST (test_no_cropping) GST_START_TEST (test_no_cropping)
{ {
check_aspectratiocrop check_aspectratiocrop
("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1", ("video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1", "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1",
153600, 153600, 4, 3); 153600, 153600, 4, 3);
check_aspectratiocrop check_aspectratiocrop
("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)320, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3", ("video/x-raw, format=(string)YUY2, width=(int)320, height=(int)320, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)320, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3", "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)320, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3",
204800, 204800, 4, 3); 204800, 204800, 4, 3);
} }
@ -141,18 +142,18 @@ GST_END_TEST;
GST_START_TEST (test_autocropping) GST_START_TEST (test_autocropping)
{ {
check_aspectratiocrop check_aspectratiocrop
("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3", ("video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)240, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3", "video/x-raw, format=(string)YUY2, width=(int)240, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)4/3",
153600, 115200, 4, 3); 153600, 115200, 4, 3);
check_aspectratiocrop check_aspectratiocrop
("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/9", ("video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/9",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)180, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/9", "video/x-raw, format=(string)YUY2, width=(int)180, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/9",
153600, 86400, 4, 3); 153600, 86400, 4, 3);
check_aspectratiocrop check_aspectratiocrop
("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/15", ("video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/15",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)192, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/15", "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)192, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)16/15",
153600, 122880, 16, 9); 153600, 122880, 16, 9);
} }

View file

@ -127,10 +127,12 @@ get_expected_gain (guint sample_rate)
#define RG_ANALYSIS_CAPS_TEMPLATE_STRING \ #define RG_ANALYSIS_CAPS_TEMPLATE_STRING \
"audio/x-raw, " \ "audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (F32) ", " \ "format = (string) "GST_AUDIO_NE (F32) ", " \
"layout = (string) interleaved, " \
REPLAY_GAIN_CAPS \ REPLAY_GAIN_CAPS \
"; " \ "; " \
"audio/x-raw, " \ "audio/x-raw, " \
"format = (string) "GST_AUDIO_NE (S16) ", " \ "format = (string) "GST_AUDIO_NE (S16) ", " \
"layout = (string) interleaved, " \
REPLAY_GAIN_CAPS REPLAY_GAIN_CAPS
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@ -362,7 +364,8 @@ test_buffer_const_float_mono (gint sample_rate, gsize n_frames, gfloat value)
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL); "rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1,
"layout", G_TYPE_STRING, "interleaved", NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -391,7 +394,10 @@ test_buffer_const_float_stereo (gint sample_rate, gsize n_frames,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2, NULL); "layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate,
"channels", G_TYPE_INT, 2,
"channel-mask", GST_TYPE_BITMASK, (gint64) 0x3, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -418,6 +424,7 @@ test_buffer_const_int16_mono (gint sample_rate, gint depth, gsize n_frames,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (S16), "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
"layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL); "rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -447,7 +454,9 @@ test_buffer_const_int16_stereo (gint sample_rate, gint depth, gsize n_frames,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (S16), "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2, NULL); "layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2,
"channel-mask", GST_TYPE_BITMASK, (gint64) 0x3, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -484,6 +493,7 @@ test_buffer_square_float_mono (gint * accumulator, gint sample_rate,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL); "rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -521,7 +531,9 @@ test_buffer_square_float_stereo (gint * accumulator, gint sample_rate,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2, NULL); "layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2,
"channel-mask", GST_TYPE_BITMASK, (gint64) 0x3, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -555,6 +567,7 @@ test_buffer_square_int16_mono (gint * accumulator, gint sample_rate,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (S16), "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
"layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL); "rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 1, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -592,7 +605,9 @@ test_buffer_square_int16_stereo (gint * accumulator, gint sample_rate,
caps = gst_caps_new_simple ("audio/x-raw", caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (S16), "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2, NULL); "layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, sample_rate, "channels", G_TYPE_INT, 2,
"channel-mask", GST_TYPE_BITMASK, (gint64) 0x3, NULL);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);