#include <gst/check/gstcheck.h>
#include <gst/video/video.h>
+#if 0
#include <gst/video/video-overlay-composition.h>
+#endif
#include <string.h>
/* These are from the current/old videotestsrc; we check our new public API
static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
static void paint_setup_Y41B (paintinfo * p, unsigned char *dest);
static void paint_setup_Y42B (paintinfo * p, unsigned char *dest);
-static void paint_setup_Y800 (paintinfo * p, unsigned char *dest);
+static void paint_setup_GRAY8 (paintinfo * p, unsigned char *dest);
static void paint_setup_AYUV (paintinfo * p, unsigned char *dest);
#if 0
{"Y41B", "Y41B", 12, paint_setup_Y41B},
/* Y42B */
{"Y42B", "Y42B", 16, paint_setup_Y42B},
- /* Y800 grayscale */
- {"Y800", "Y800", 8, paint_setup_Y800}
+ /* GRAY8 grayscale */
+ {"GRAY8", "GRAY8", 8, paint_setup_GRAY8}
};
/* returns the size in bytes for one video frame of the given dimensions
}
static void
-paint_setup_Y800 (paintinfo * p, unsigned char *dest)
+paint_setup_GRAY8 (paintinfo * p, unsigned char *dest)
{
/* untested */
p->yp = dest;
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_Y41B:
case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y800:
+ case GST_VIDEO_FORMAT_GRAY8:
case GST_VIDEO_FORMAT_YUV9:
case GST_VIDEO_FORMAT_YVU9:
return FALSE;
return FALSE;
}
+GST_START_TEST (test_video_formats_all)
+{
+ GstStructure *s;
+ const GValue *val, *list_val;
+ GstCaps *caps;
+ guint num, n, num_formats;
+
+ num_formats = 100;
+ fail_unless (gst_video_format_to_string (num_formats) == NULL);
+ while (gst_video_format_to_string (num_formats) == NULL)
+ --num_formats;
+ GST_INFO ("number of known video formats: %d", num_formats);
+
+ caps = gst_caps_from_string ("video/x-raw, format=" GST_VIDEO_FORMATS_ALL);
+ s = gst_caps_get_structure (caps, 0);
+ val = gst_structure_get_value (s, "format");
+ fail_unless (val != NULL);
+ fail_unless (GST_VALUE_HOLDS_LIST (val));
+ num = gst_value_list_get_size (val);
+ fail_unless (num > 0);
+ for (n = 0; n < num; ++n) {
+ const gchar *fmt_str;
+
+ list_val = gst_value_list_get_value (val, n);
+ fail_unless (G_VALUE_HOLDS_STRING (list_val));
+ fmt_str = g_value_get_string (list_val);
+ GST_INFO ("format: %s", fmt_str);
+ fail_if (gst_video_format_from_string (fmt_str) ==
+ GST_VIDEO_FORMAT_UNKNOWN);
+ }
+ fail_unless_equals_int (num, num_formats);
+
+ gst_caps_unref (caps);
+}
+
+GST_END_TEST;
+
GST_START_TEST (test_video_formats)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (fourcc_list); ++i) {
+ const GstVideoFormatInfo *vf_info;
GstVideoFormat fmt;
const gchar *s;
guint32 fourcc;
fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
fmt = gst_video_format_from_fourcc (fourcc);
- if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
+ if (fmt == GST_VIDEO_FORMAT_UNKNOWN) {
+ GST_DEBUG ("Unknown format %s, skipping tests", fourcc_list[i].fourcc);
continue;
+ }
+
+ vf_info = gst_video_format_get_info (fmt);
+ fail_unless (vf_info != NULL);
+
+ fail_unless_equals_int (GST_VIDEO_FORMAT_INFO_FORMAT (vf_info), fmt);
GST_INFO ("Fourcc %s, packed=%d", fourcc_list[i].fourcc,
gst_video_format_is_packed (fmt));
- fail_unless (gst_video_format_is_yuv (fmt));
+ fail_unless (GST_VIDEO_FORMAT_INFO_IS_YUV (vf_info));
/* use any non-NULL pointer so we can compare against NULL */
{
paintinfo paintinfo = { 0, };
fourcc_list[i].paint_setup (&paintinfo, (unsigned char *) s);
if (paintinfo.ap != NULL) {
- fail_unless (gst_video_format_has_alpha (fmt));
+ fail_unless (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
} else {
- fail_if (gst_video_format_has_alpha (fmt));
+ fail_if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
}
}
for (w = 1; w <= 65; ++w) {
for (h = 1; h <= 65; ++h) {
+ GstVideoInfo vinfo;
paintinfo paintinfo = { 0, };
guint off0, off1, off2, off3;
+ guint cs0, cs1, cs2, cs3;
guint size;
GST_LOG ("%s, %dx%d", fourcc_list[i].fourcc, w, h);
+ gst_video_info_init (&vinfo);
+ gst_video_info_set_format (&vinfo, fmt, w, h);
+
paintinfo.width = w;
paintinfo.height = h;
fourcc_list[i].paint_setup (&paintinfo, NULL);
- fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 0, w),
+ fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 0),
paintinfo.ystride);
if (!gst_video_format_is_packed (fmt)
- && !gst_video_format_is_gray (fmt)) {
+ && !GST_VIDEO_INFO_N_PLANES (&vinfo) > 2) {
/* planar */
- fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 1, w),
+ fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 1),
paintinfo.ustride);
- fail_unless_equals_int (gst_video_format_get_row_stride (fmt, 2, w),
+ fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 2),
paintinfo.vstride);
/* check component_width * height against offsets/size somehow? */
}
- size = gst_video_format_get_size (fmt, w, h);
- off0 = gst_video_format_get_component_offset (fmt, 0, w, h);
- off1 = gst_video_format_get_component_offset (fmt, 1, w, h);
- off2 = gst_video_format_get_component_offset (fmt, 2, w, h);
+ size = GST_VIDEO_INFO_SIZE (&vinfo);
+ off0 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 0);
+ off1 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 1);
+ off2 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 2);
+
+ GST_INFO ("size %d <> %d", size, paintinfo.endptr);
+ GST_INFO ("off0 %d <> %d", off0, paintinfo.yp);
+ GST_INFO ("off1 %d <> %d", off1, paintinfo.up);
+ GST_INFO ("off2 %d <> %d", off2, paintinfo.vp);
fail_unless_equals_int (size, (unsigned long) paintinfo.endptr);
fail_unless_equals_int (off0, (unsigned long) paintinfo.yp);
fail_unless_equals_int (off2, (unsigned long) paintinfo.vp);
/* should be 0 if there's no alpha component */
- off3 = gst_video_format_get_component_offset (fmt, 3, w, h);
+ off3 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 3);
fail_unless_equals_int (off3, (unsigned long) paintinfo.ap);
- /* some gstvideo checks ... (FIXME: fails for Y41B and Y42B; not sure
- * if the check or the _get_component_size implementation is wrong) */
- if (fmt != GST_VIDEO_FORMAT_Y41B && fmt != GST_VIDEO_FORMAT_Y42B
- && fmt != GST_VIDEO_FORMAT_Y800) {
- guint cs0, cs1, cs2, cs3;
-
- cs0 = gst_video_format_get_component_width (fmt, 0, w) *
- gst_video_format_get_component_height (fmt, 0, h);
- cs1 = gst_video_format_get_component_width (fmt, 1, w) *
- gst_video_format_get_component_height (fmt, 1, h);
- cs2 = gst_video_format_get_component_width (fmt, 2, w) *
- gst_video_format_get_component_height (fmt, 2, h);
-
- /* GST_LOG ("cs0=%d,cs1=%d,cs2=%d,off0=%d,off1=%d,off2=%d,size=%d",
- cs0, cs1, cs2, off0, off1, off2, size); */
-
- if (!gst_video_format_is_packed (fmt))
- fail_unless (cs0 <= off1);
-
- if (gst_video_format_has_alpha (fmt)) {
- cs3 = gst_video_format_get_component_width (fmt, 3, w) *
- gst_video_format_get_component_height (fmt, 3, h);
- fail_unless (cs3 < size);
- /* U/V/alpha shouldn't take up more space than the Y component */
- fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0);
- fail_if (cs2 > cs0, "cs2 (%d) should be <= cs0 (%d)", cs2, cs0);
- fail_if (cs3 > cs0, "cs3 (%d) should be <= cs0 (%d)", cs3, cs0);
-
- /* all components together shouldn't take up more space than size */
- fail_unless (cs0 + cs1 + cs2 + cs3 <= size);
- } else {
- /* U/V shouldn't take up more space than the Y component */
- fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0);
- fail_if (cs2 > cs0, "cs2 (%d) should be <= cs0 (%d)", cs2, cs0);
-
- /* all components together shouldn't take up more space than size */
- fail_unless (cs0 + cs1 + cs2 <= size,
- "cs0 (%d) + cs1 (%d) + cs2 (%d) should be <= size (%d)",
- cs0, cs1, cs2, size);
- }
+ cs0 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 0) *
+ GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 0);
+ cs1 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 1) *
+ GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 1);
+ cs2 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 2) *
+ GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 2);
+
+ /* GST_LOG ("cs0=%d,cs1=%d,cs2=%d,off0=%d,off1=%d,off2=%d,size=%d",
+ cs0, cs1, cs2, off0, off1, off2, size); */
+
+ if (!gst_video_format_is_packed (fmt))
+ fail_unless (cs0 <= off1);
+
+ if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vinfo.finfo)) {
+ cs3 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 3) *
+ GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 2);
+ fail_unless (cs3 < size);
+ /* U/V/alpha shouldn't take up more space than the Y component */
+ fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0);
+ fail_if (cs2 > cs0, "cs2 (%d) should be <= cs0 (%d)", cs2, cs0);
+ fail_if (cs3 > cs0, "cs3 (%d) should be <= cs0 (%d)", cs3, cs0);
+
+ /* all components together shouldn't take up more space than size */
+ fail_unless (cs0 + cs1 + cs2 + cs3 <= size);
+ } else {
+ /* U/V shouldn't take up more space than the Y component */
+ fail_if (cs1 > cs0, "cs1 (%d) should be <= cs0 (%d)", cs1, cs0);
+ fail_if (cs2 > cs0, "cs2 (%d) should be <= cs0 (%d)", cs2, cs0);
+
+ /* all components together shouldn't take up more space than size */
+ fail_unless (cs0 + cs1 + cs2 <= size,
+ "cs0 (%d) + cs1 (%d) + cs2 (%d) should be <= size (%d)",
+ cs0, cs1, cs2, size);
}
}
}
GST_START_TEST (test_video_formats_rgb)
{
+ GstVideoInfo vinfo;
gint width, height, framerate_n, framerate_d, par_n, par_d;
- GstCaps *caps =
- gst_video_format_new_caps (GST_VIDEO_FORMAT_RGB, 800, 600, 0, 1, 1, 1);
+ GstCaps *caps;
GstStructure *structure;
+ gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_RGB, 800, 600);
+ vinfo.par_n = 1;
+ vinfo.par_d = 1;
+ vinfo.fps_n = 0;
+ vinfo.fps_d = 1;
+ caps = gst_video_info_to_caps (&vinfo);
structure = gst_caps_get_structure (caps, 0);
fail_unless (gst_structure_get_int (structure, "width", &width));
GST_END_TEST;
-GST_START_TEST (test_video_template_caps)
-{
- GstCaps *caps = gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB);
- gst_caps_unref (caps);
-}
-
-GST_END_TEST;
-
-
GST_START_TEST (test_dar_calc)
{
guint display_ratio_n, display_ratio_d;
} formats[] = {
/* 24 bit */
{
- GST_VIDEO_CAPS_RGB, GST_VIDEO_FORMAT_RGB}, {
- GST_VIDEO_CAPS_BGR, GST_VIDEO_FORMAT_BGR},
+ GST_VIDEO_CAPS_MAKE ("RGB"), GST_VIDEO_FORMAT_RGB}, {
+ GST_VIDEO_CAPS_MAKE ("BGR"), GST_VIDEO_FORMAT_BGR},
/* 32 bit (no alpha) */
{
- GST_VIDEO_CAPS_RGBx, GST_VIDEO_FORMAT_RGBx}, {
- GST_VIDEO_CAPS_xRGB, GST_VIDEO_FORMAT_xRGB}, {
- GST_VIDEO_CAPS_BGRx, GST_VIDEO_FORMAT_BGRx}, {
- GST_VIDEO_CAPS_xBGR, GST_VIDEO_FORMAT_xBGR},
+ GST_VIDEO_CAPS_MAKE ("RGBx"), GST_VIDEO_FORMAT_RGBx}, {
+ GST_VIDEO_CAPS_MAKE ("xRGB"), GST_VIDEO_FORMAT_xRGB}, {
+ GST_VIDEO_CAPS_MAKE ("BGRx"), GST_VIDEO_FORMAT_BGRx}, {
+ GST_VIDEO_CAPS_MAKE ("xBGR"), GST_VIDEO_FORMAT_xBGR},
/* 32 bit (with alpha) */
{
- GST_VIDEO_CAPS_RGBA, GST_VIDEO_FORMAT_RGBA}, {
- GST_VIDEO_CAPS_ARGB, GST_VIDEO_FORMAT_ARGB}, {
- GST_VIDEO_CAPS_BGRA, GST_VIDEO_FORMAT_BGRA}, {
- GST_VIDEO_CAPS_ABGR, GST_VIDEO_FORMAT_ABGR},
+ GST_VIDEO_CAPS_MAKE ("RGBA"), GST_VIDEO_FORMAT_RGBA}, {
+ GST_VIDEO_CAPS_MAKE ("ARGB"), GST_VIDEO_FORMAT_ARGB}, {
+ GST_VIDEO_CAPS_MAKE ("BGRA"), GST_VIDEO_FORMAT_BGRA}, {
+ GST_VIDEO_CAPS_MAKE ("ABGR"), GST_VIDEO_FORMAT_ABGR},
/* 16 bit */
{
- GST_VIDEO_CAPS_RGB_16, GST_VIDEO_FORMAT_RGB16}, {
- GST_VIDEO_CAPS_BGR_16, GST_VIDEO_FORMAT_BGR16}, {
- GST_VIDEO_CAPS_RGB_15, GST_VIDEO_FORMAT_RGB15}, {
- GST_VIDEO_CAPS_BGR_15, GST_VIDEO_FORMAT_BGR15}
+ GST_VIDEO_CAPS_MAKE ("RGB16"), GST_VIDEO_FORMAT_RGB16}, {
+ GST_VIDEO_CAPS_MAKE ("BGR16"), GST_VIDEO_FORMAT_BGR16}, {
+ GST_VIDEO_CAPS_MAKE ("RGB15"), GST_VIDEO_FORMAT_RGB15}, {
+ GST_VIDEO_CAPS_MAKE ("BGR15"), GST_VIDEO_FORMAT_BGR15}
};
gint i;
for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
- GstVideoFormat fmt = GST_VIDEO_FORMAT_UNKNOWN;
+ GstVideoInfo vinfo;
GstCaps *caps, *caps2;
- int w = -1, h = -1;
caps = gst_caps_from_string (formats[i].tmpl_caps_string);
gst_caps_set_simple (caps, "width", G_TYPE_INT, 2 * (i + 1), "height",
G_TYPE_INT, i + 1, "framerate", GST_TYPE_FRACTION, 15, 1,
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
+ "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
+ "interlace-mode", G_TYPE_STRING, "progressive", NULL);
g_assert (gst_caps_is_fixed (caps));
GST_DEBUG ("testing caps: %" GST_PTR_FORMAT, caps);
- fail_unless (gst_video_format_parse_caps (caps, &fmt, &w, &h));
- fail_unless_equals_int (fmt, formats[i].fmt);
- fail_unless_equals_int (w, 2 * (i + 1));
- fail_unless_equals_int (h, i + 1);
+ gst_video_info_init (&vinfo);
+ fail_unless (gst_video_info_from_caps (&vinfo, caps));
+ fail_unless_equals_int (GST_VIDEO_INFO_FORMAT (&vinfo), formats[i].fmt);
+ fail_unless_equals_int (GST_VIDEO_INFO_WIDTH (&vinfo), 2 * (i + 1));
+ fail_unless_equals_int (GST_VIDEO_INFO_HEIGHT (&vinfo), i + 1);
/* make sure they're serialised back correctly */
- caps2 = gst_video_format_new_caps (fmt, w, h, 15, 1, 1, 1);
+ caps2 = gst_video_info_to_caps (&vinfo);
fail_unless (caps != NULL);
- fail_unless (gst_caps_is_equal (caps, caps2));
+ fail_unless (gst_caps_is_equal (caps, caps2),
+ "caps [%" GST_PTR_FORMAT "] not equal to caps2 [%" GST_PTR_FORMAT "]",
+ caps, caps2);
gst_caps_unref (caps);
gst_caps_unref (caps2);
GST_START_TEST (test_convert_frame)
{
+ GstVideoInfo vinfo;
GstCaps *from_caps, *to_caps;
- GstBuffer *from_buffer, *to_buffer;
+ GstBuffer *from_buffer;
+ GstSample *from_sample, *to_sample;
GError *error = NULL;
gint i;
- guint8 *data;
+ GstMapInfo map;
gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
- data = GST_BUFFER_DATA (from_buffer);
+ gst_buffer_map (from_buffer, &map, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
- data[4 * i + 0] = 0; /* x */
- data[4 * i + 1] = 255; /* R */
- data[4 * i + 2] = 0; /* G */
- data[4 * i + 3] = 0; /* B */
+ map.data[4 * i + 0] = 0; /* x */
+ map.data[4 * i + 1] = 255; /* R */
+ map.data[4 * i + 2] = 0; /* G */
+ map.data[4 * i + 3] = 0; /* B */
}
- from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
- 640, 480, 25, 1, 1, 1);
- gst_buffer_set_caps (from_buffer, from_caps);
+ gst_buffer_unmap (from_buffer, &map);
+
+ gst_video_info_init (&vinfo);
+ gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 480);
+ vinfo.fps_n = 25;
+ vinfo.fps_d = 1;
+ vinfo.par_n = 1;
+ vinfo.par_d = 1;
+ from_caps = gst_video_info_to_caps (&vinfo);
+
+ from_sample = gst_sample_new (from_buffer, from_caps, NULL, NULL);
to_caps =
gst_caps_from_string
("something/that, does=(string)not, exist=(boolean)FALSE");
- to_buffer =
- gst_video_convert_frame (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- &error);
- fail_if (to_buffer != NULL);
+ to_sample =
+ gst_video_convert_sample (from_sample, to_caps,
+ GST_CLOCK_TIME_NONE, &error);
+ fail_if (to_sample != NULL);
fail_unless (error != NULL);
g_error_free (error);
error = NULL;
gst_caps_unref (to_caps);
- to_caps =
- gst_video_format_new_caps (GST_VIDEO_FORMAT_I420, 240, 320, 25, 1, 1, 2);
- to_buffer =
- gst_video_convert_frame (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- &error);
- fail_unless (to_buffer != NULL);
- fail_unless (gst_caps_can_intersect (to_caps, GST_BUFFER_CAPS (to_buffer)));
+ gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_I420, 240, 320);
+ vinfo.fps_n = 25;
+ vinfo.fps_d = 1;
+ vinfo.par_n = 1;
+ vinfo.par_d = 2;
+ to_caps = gst_video_info_to_caps (&vinfo);
+
+ to_sample =
+ gst_video_convert_sample (from_sample, to_caps,
+ GST_CLOCK_TIME_NONE, &error);
+ fail_unless (to_sample != NULL);
fail_unless (error == NULL);
gst_buffer_unref (from_buffer);
gst_caps_unref (from_caps);
- gst_buffer_unref (to_buffer);
+ gst_sample_unref (from_sample);
+ gst_sample_unref (to_sample);
gst_caps_unref (to_caps);
}
typedef struct
{
GMainLoop *loop;
- GstBuffer *buffer;
+ GstSample *sample;
GError *error;
} ConvertFrameContext;
static void
-convert_frame_async_callback (GstBuffer * buf, GError * err,
+convert_sample_async_callback (GstSample * sample, GError * err,
ConvertFrameContext * cf_data)
{
- cf_data->buffer = buf;
+ cf_data->sample = sample;
cf_data->error = err;
g_main_loop_quit (cf_data->loop);
GST_START_TEST (test_convert_frame_async)
{
+ GstVideoInfo vinfo;
GstCaps *from_caps, *to_caps;
GstBuffer *from_buffer;
+ GstSample *from_sample;
gint i;
- guint8 *data;
+ GstMapInfo map;
GMainLoop *loop;
ConvertFrameContext cf_data = { NULL, NULL, NULL };
gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
- data = GST_BUFFER_DATA (from_buffer);
+ gst_buffer_map (from_buffer, &map, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
- data[4 * i + 0] = 0; /* x */
- data[4 * i + 1] = 255; /* R */
- data[4 * i + 2] = 0; /* G */
- data[4 * i + 3] = 0; /* B */
+ map.data[4 * i + 0] = 0; /* x */
+ map.data[4 * i + 1] = 255; /* R */
+ map.data[4 * i + 2] = 0; /* G */
+ map.data[4 * i + 3] = 0; /* B */
}
- from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
- 640, 480, 25, 1, 1, 1);
- gst_buffer_set_caps (from_buffer, from_caps);
+ gst_buffer_unmap (from_buffer, &map);
+
+ gst_video_info_init (&vinfo);
+ gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 470);
+ vinfo.par_n = 1;
+ vinfo.par_d = 1;
+ vinfo.fps_n = 25;
+ vinfo.fps_d = 1;
+ from_caps = gst_video_info_to_caps (&vinfo);
to_caps =
gst_caps_from_string
loop = cf_data.loop = g_main_loop_new (NULL, FALSE);
- gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
+ from_sample = gst_sample_new (from_buffer, from_caps, NULL, NULL);
+ gst_buffer_unref (from_buffer);
+ gst_caps_unref (from_caps);
+
+ gst_video_convert_sample_async (from_sample, to_caps,
+ GST_CLOCK_TIME_NONE,
+ (GstVideoConvertSampleCallback) convert_sample_async_callback, &cf_data,
NULL);
g_main_loop_run (loop);
- fail_if (cf_data.buffer != NULL);
+ fail_if (cf_data.sample != NULL);
fail_unless (cf_data.error != NULL);
g_error_free (cf_data.error);
cf_data.error = NULL;
gst_caps_unref (to_caps);
- to_caps =
- gst_video_format_new_caps (GST_VIDEO_FORMAT_I420, 240, 320, 25, 1, 1, 2);
- gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
+ gst_video_info_init (&vinfo);
+ gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_I420, 240, 320);
+ vinfo.par_n = 1;
+ vinfo.par_d = 2;
+ vinfo.fps_n = 25;
+ vinfo.fps_d = 1;
+ to_caps = gst_video_info_to_caps (&vinfo);
+ gst_video_convert_sample_async (from_sample, to_caps,
+ GST_CLOCK_TIME_NONE,
+ (GstVideoConvertSampleCallback) convert_sample_async_callback, &cf_data,
NULL);
g_main_loop_run (loop);
- fail_unless (cf_data.buffer != NULL);
- fail_unless (gst_caps_can_intersect (to_caps,
- GST_BUFFER_CAPS (cf_data.buffer)));
+ fail_unless (cf_data.sample != NULL);
fail_unless (cf_data.error == NULL);
- gst_buffer_unref (from_buffer);
- gst_caps_unref (from_caps);
- gst_buffer_unref (cf_data.buffer);
+ gst_sample_unref (cf_data.sample);
gst_caps_unref (to_caps);
g_main_loop_unref (loop);
GST_START_TEST (test_video_size_from_caps)
{
- gint size;
- guint32 fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
- GstCaps *caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fourcc,
+ GstVideoInfo vinfo;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("video/x-raw",
+ "format", G_TYPE_STRING, "YV12",
"width", G_TYPE_INT, 640,
- "height", G_TYPE_INT, 480,
- "framerate", GST_TYPE_FRACTION, 25, 1,
- NULL);
+ "height", G_TYPE_INT, 480, "framerate", GST_TYPE_FRACTION, 25, 1, NULL);
- fail_unless (gst_video_get_size_from_caps (caps, &size));
- fail_unless (size ==
- gst_video_format_get_size (gst_video_format_from_fourcc (fourcc), 640,
- 480));
- fail_unless (size == (640 * 480 * 12 / 8));
+ gst_video_info_init (&vinfo);
+ fail_unless (gst_video_info_from_caps (&vinfo, caps));
+ fail_unless (GST_VIDEO_INFO_SIZE (&vinfo) == (640 * 480 * 12 / 8));
gst_caps_unref (caps);
}
GST_END_TEST;
+#if 0
+/* FIXME 0.11: port overlay composition to buffer meta */
GST_START_TEST (test_overlay_composition)
{
GstVideoOverlayComposition *comp1, *comp2;
}
GST_END_TEST;
+#endif
static Suite *
video_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_video_formats);
tcase_add_test (tc_chain, test_video_formats_rgb);
- tcase_add_test (tc_chain, test_video_template_caps);
+ tcase_add_test (tc_chain, test_video_formats_all);
tcase_add_test (tc_chain, test_dar_calc);
tcase_add_test (tc_chain, test_parse_caps_rgb);
tcase_add_test (tc_chain, test_events);
tcase_add_test (tc_chain, test_convert_frame);
tcase_add_test (tc_chain, test_convert_frame_async);
tcase_add_test (tc_chain, test_video_size_from_caps);
+#if 0
+ /* FIXME 0.11: port overlay compositions */
tcase_add_test (tc_chain, test_overlay_composition);
tcase_add_test (tc_chain, test_overlay_composition_premultiplied_alpha);
+#endif
return s;
}