tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
/* GStreamer unit test for video
|
2006-05-12 21:30:00 +00:00
|
|
|
*
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
* Copyright (C) <2003> David A. Schleef <ds@schleef.org>
|
2006-05-12 21:30:00 +00:00
|
|
|
* Copyright (C) <2006> Jan Schmidt <thaytan@mad.scientist.com>
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
* Copyright (C) <2008> Tim-Philipp Müller <tim centricular net>
|
2006-05-12 21:30:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
/* These are from the current/old videotestsrc; we check our new public API
|
|
|
|
* in libgstvideo against the old one to make sure the sizes and offsets
|
|
|
|
* end up the same */
|
|
|
|
|
|
|
|
typedef struct paintinfo_struct paintinfo;
|
|
|
|
struct paintinfo_struct
|
|
|
|
{
|
|
|
|
unsigned char *dest; /* pointer to first byte of video data */
|
|
|
|
unsigned char *yp, *up, *vp; /* pointers to first byte of each component
|
|
|
|
* for both packed/planar YUV and RGB */
|
|
|
|
unsigned char *ap; /* pointer to first byte of alpha component */
|
|
|
|
unsigned char *endptr; /* pointer to byte beyond last video data */
|
|
|
|
int ystride;
|
|
|
|
int ustride;
|
|
|
|
int vstride;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fourcc_list_struct
|
|
|
|
{
|
2010-03-15 21:49:53 +00:00
|
|
|
const char *fourcc;
|
|
|
|
const char *name;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
int bitspp;
|
|
|
|
void (*paint_setup) (paintinfo * p, unsigned char *dest);
|
|
|
|
};
|
|
|
|
|
|
|
|
static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_YUY2 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_UYVY (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_YVYU (paintinfo * p, unsigned char *dest);
|
|
|
|
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_AYUV (paintinfo * p, unsigned char *dest);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void paint_setup_IMC1 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_IMC2 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_IMC3 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_IMC4 (paintinfo * p, unsigned char *dest);
|
|
|
|
#endif
|
|
|
|
static void paint_setup_YUV9 (paintinfo * p, unsigned char *dest);
|
|
|
|
static void paint_setup_YVU9 (paintinfo * p, unsigned char *dest);
|
|
|
|
|
|
|
|
int fourcc_get_size (struct fourcc_list_struct *fourcc, int w, int h);
|
|
|
|
|
|
|
|
struct fourcc_list_struct fourcc_list[] = {
|
|
|
|
/* packed */
|
|
|
|
{"YUY2", "YUY2", 16, paint_setup_YUY2},
|
|
|
|
{"UYVY", "UYVY", 16, paint_setup_UYVY},
|
|
|
|
{"Y422", "Y422", 16, paint_setup_UYVY},
|
|
|
|
{"UYNV", "UYNV", 16, paint_setup_UYVY}, /* FIXME: UYNV? */
|
|
|
|
{"YVYU", "YVYU", 16, paint_setup_YVYU},
|
|
|
|
{"AYUV", "AYUV", 32, paint_setup_AYUV},
|
|
|
|
|
|
|
|
/* interlaced */
|
|
|
|
/*{ "IUYV", "IUY2", 16, paint_setup_YVYU }, */
|
|
|
|
|
|
|
|
/* inverted */
|
|
|
|
/*{ "cyuv", "cyuv", 16, paint_setup_YVYU }, */
|
|
|
|
|
|
|
|
/*{ "Y41P", "Y41P", 12, paint_setup_YVYU }, */
|
|
|
|
|
|
|
|
/* interlaced */
|
|
|
|
/*{ "IY41", "IY41", 12, paint_setup_YVYU }, */
|
|
|
|
|
|
|
|
/*{ "Y211", "Y211", 8, paint_setup_YVYU }, */
|
|
|
|
|
|
|
|
/*{ "Y41T", "Y41T", 12, paint_setup_YVYU }, */
|
|
|
|
/*{ "Y42P", "Y42P", 16, paint_setup_YVYU }, */
|
|
|
|
/*{ "CLJR", "CLJR", 8, paint_setup_YVYU }, */
|
|
|
|
/*{ "IYU1", "IYU1", 12, paint_setup_YVYU }, */
|
|
|
|
{"IYU2", "IYU2", 24, paint_setup_IYU2},
|
|
|
|
|
|
|
|
/* planar */
|
|
|
|
/* YVU9 */
|
|
|
|
{"YVU9", "YVU9", 9, paint_setup_YVU9},
|
|
|
|
/* YUV9 */
|
|
|
|
{"YUV9", "YUV9", 9, paint_setup_YUV9},
|
|
|
|
/* IF09 */
|
|
|
|
/* YV12 */
|
|
|
|
{"YV12", "YV12", 12, paint_setup_YV12},
|
|
|
|
/* I420 */
|
|
|
|
{"I420", "I420", 12, paint_setup_I420},
|
|
|
|
/* NV12 */
|
|
|
|
/* NV21 */
|
|
|
|
#if 0
|
|
|
|
/* IMC1 */
|
|
|
|
{"IMC1", "IMC1", 16, paint_setup_IMC1},
|
|
|
|
/* IMC2 */
|
|
|
|
{"IMC2", "IMC2", 12, paint_setup_IMC2},
|
|
|
|
/* IMC3 */
|
|
|
|
{"IMC3", "IMC3", 16, paint_setup_IMC3},
|
|
|
|
/* IMC4 */
|
|
|
|
{"IMC4", "IMC4", 12, paint_setup_IMC4},
|
|
|
|
#endif
|
|
|
|
/* CLPL */
|
|
|
|
/* Y41B */
|
|
|
|
{"Y41B", "Y41B", 12, paint_setup_Y41B},
|
|
|
|
/* Y42B */
|
|
|
|
{"Y42B", "Y42B", 16, paint_setup_Y42B},
|
|
|
|
/* Y800 grayscale */
|
|
|
|
{"Y800", "Y800", 8, paint_setup_Y800}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* returns the size in bytes for one video frame of the given dimensions
|
|
|
|
* given the fourcc */
|
|
|
|
int
|
|
|
|
fourcc_get_size (struct fourcc_list_struct *fourcc, int w, int h)
|
|
|
|
{
|
|
|
|
paintinfo pi = { NULL, };
|
|
|
|
paintinfo *p = π
|
|
|
|
|
|
|
|
p->width = w;
|
|
|
|
p->height = h;
|
|
|
|
|
|
|
|
fourcc->paint_setup (p, NULL);
|
|
|
|
|
|
|
|
return (unsigned long) p->endptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_I420 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
|
|
|
p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
|
|
|
|
p->ustride = GST_ROUND_UP_8 (p->width) / 2;
|
|
|
|
p->vp = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
|
|
|
|
p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
|
|
|
|
p->endptr = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_YV12 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
|
|
|
p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
|
|
|
|
p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
|
|
|
|
p->up = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
|
|
|
|
p->ustride = GST_ROUND_UP_8 (p->ystride) / 2;
|
|
|
|
p->endptr = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_AYUV (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->ap = dest;
|
|
|
|
p->yp = dest + 1;
|
|
|
|
p->up = dest + 2;
|
|
|
|
p->vp = dest + 3;
|
|
|
|
p->ystride = p->width * 4;
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->up = dest + 1;
|
|
|
|
p->vp = dest + 3;
|
|
|
|
p->ystride = GST_ROUND_UP_2 (p->width) * 2;
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_UYVY (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest + 1;
|
|
|
|
p->up = dest;
|
|
|
|
p->vp = dest + 2;
|
|
|
|
p->ystride = GST_ROUND_UP_2 (p->width) * 2;
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_YVYU (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->up = dest + 3;
|
|
|
|
p->vp = dest + 1;
|
|
|
|
p->ystride = GST_ROUND_UP_2 (p->width) * 2;
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_IYU2 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
/* untested */
|
|
|
|
p->yp = dest + 1;
|
|
|
|
p->up = dest + 0;
|
|
|
|
p->vp = dest + 2;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width * 3);
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_Y41B (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
|
|
|
p->up = p->yp + p->ystride * p->height;
|
2009-10-07 09:48:37 +00:00
|
|
|
p->ustride = GST_ROUND_UP_16 (p->width) / 4;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->vp = p->up + p->ustride * p->height;
|
2009-10-07 09:48:37 +00:00
|
|
|
p->vstride = GST_ROUND_UP_16 (p->width) / 4;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->endptr = p->vp + p->vstride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_Y42B (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
|
|
|
p->up = p->yp + p->ystride * p->height;
|
|
|
|
p->ustride = GST_ROUND_UP_8 (p->width) / 2;
|
|
|
|
p->vp = p->up + p->ustride * p->height;
|
|
|
|
p->vstride = GST_ROUND_UP_8 (p->width) / 2;
|
|
|
|
p->endptr = p->vp + p->vstride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_Y800 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
/* untested */
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
|
|
|
p->endptr = dest + p->ystride * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void
|
|
|
|
paint_setup_IMC1 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->up = dest + p->width * p->height;
|
|
|
|
p->vp = dest + p->width * p->height + p->width * p->height / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_IMC2 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->vp = dest + p->width * p->height;
|
|
|
|
p->up = dest + p->width * p->height + p->width / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_IMC3 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->up = dest + p->width * p->height + p->width * p->height / 2;
|
|
|
|
p->vp = dest + p->width * p->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_IMC4 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->vp = dest + p->width * p->height + p->width / 2;
|
|
|
|
p->up = dest + p->width * p->height;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_YVU9 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->vp = p->yp + p->ystride * p->height;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->up = p->vp + p->vstride * (GST_ROUND_UP_4 (p->height) / 4);
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->endptr = p->up + p->ustride * (GST_ROUND_UP_4 (p->height) / 4);
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_setup_YUV9 (paintinfo * p, unsigned char *dest)
|
|
|
|
{
|
|
|
|
p->yp = dest;
|
|
|
|
p->ystride = GST_ROUND_UP_4 (p->width);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->up = p->yp + p->ystride * p->height;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->vp = p->up + p->ustride * (GST_ROUND_UP_4 (p->height) / 4);
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
|
2011-04-04 23:00:30 +00:00
|
|
|
p->endptr = p->vp + p->vstride * (GST_ROUND_UP_4 (p->height) / 4);
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define gst_video_format_is_packed video_format_is_packed
|
|
|
|
static gboolean
|
|
|
|
video_format_is_packed (GstVideoFormat fmt)
|
|
|
|
{
|
|
|
|
switch (fmt) {
|
|
|
|
case GST_VIDEO_FORMAT_I420:
|
|
|
|
case GST_VIDEO_FORMAT_YV12:
|
|
|
|
case GST_VIDEO_FORMAT_Y41B:
|
|
|
|
case GST_VIDEO_FORMAT_Y42B:
|
2010-06-08 09:02:08 +00:00
|
|
|
case GST_VIDEO_FORMAT_Y800:
|
2010-12-03 00:01:06 +00:00
|
|
|
case GST_VIDEO_FORMAT_YUV9:
|
|
|
|
case GST_VIDEO_FORMAT_YVU9:
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
return FALSE;
|
2010-12-03 00:01:06 +00:00
|
|
|
case GST_VIDEO_FORMAT_IYU1:
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
case GST_VIDEO_FORMAT_YUY2:
|
2009-04-15 23:31:55 +00:00
|
|
|
case GST_VIDEO_FORMAT_YVYU:
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
case GST_VIDEO_FORMAT_UYVY:
|
|
|
|
case GST_VIDEO_FORMAT_AYUV:
|
|
|
|
case GST_VIDEO_FORMAT_RGBx:
|
|
|
|
case GST_VIDEO_FORMAT_BGRx:
|
|
|
|
case GST_VIDEO_FORMAT_xRGB:
|
|
|
|
case GST_VIDEO_FORMAT_xBGR:
|
|
|
|
case GST_VIDEO_FORMAT_RGBA:
|
|
|
|
case GST_VIDEO_FORMAT_BGRA:
|
|
|
|
case GST_VIDEO_FORMAT_ARGB:
|
|
|
|
case GST_VIDEO_FORMAT_ABGR:
|
|
|
|
case GST_VIDEO_FORMAT_RGB:
|
|
|
|
case GST_VIDEO_FORMAT_BGR:
|
2010-12-03 00:01:06 +00:00
|
|
|
case GST_VIDEO_FORMAT_RGB8_PALETTED:
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-28 12:39:14 +00:00
|
|
|
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;
|
|
|
|
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
GST_START_TEST (test_video_formats)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (fourcc_list); ++i) {
|
2011-07-07 22:57:33 +00:00
|
|
|
const GstVideoFormatInfo *vf_info;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
GstVideoFormat fmt;
|
|
|
|
const gchar *s;
|
|
|
|
guint32 fourcc;
|
|
|
|
guint w, h;
|
|
|
|
|
|
|
|
s = fourcc_list[i].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)
|
|
|
|
continue;
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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=%", fourcc_list[i].fourcc,
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
gst_video_format_is_packed (fmt));
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_unless (GST_VIDEO_FORMAT_INFO_IS_YUV (vf_info));
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
|
|
|
|
/* 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) {
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_unless (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
} else {
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vf_info));
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (w = 1; w <= 65; ++w) {
|
|
|
|
for (h = 1; h <= 65; ++h) {
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
paintinfo paintinfo = { 0, };
|
2008-05-26 10:26:00 +00:00
|
|
|
guint off0, off1, off2, off3;
|
|
|
|
guint size;
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
|
|
|
|
GST_LOG ("%s, %dx%d", fourcc_list[i].fourcc, w, h);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
gst_video_info_init (&vinfo);
|
|
|
|
gst_video_info_set_format (&vinfo, fmt, w, h);
|
|
|
|
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
paintinfo.width = w;
|
|
|
|
paintinfo.height = h;
|
|
|
|
fourcc_list[i].paint_setup (&paintinfo, NULL);
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 0),
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
paintinfo.ystride);
|
2010-06-08 09:02:08 +00:00
|
|
|
if (!gst_video_format_is_packed (fmt)
|
2011-07-07 22:57:33 +00:00
|
|
|
&& !GST_VIDEO_FORMAT_INFO_IS_GRAY (vf_info)) {
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
/* planar */
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 1),
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
paintinfo.ustride);
|
2011-07-07 22:57:33 +00:00
|
|
|
fail_unless_equals_int (GST_VIDEO_INFO_COMP_STRIDE (&vinfo, 2),
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
paintinfo.vstride);
|
|
|
|
/* check component_width * height against offsets/size somehow? */
|
|
|
|
}
|
2008-05-26 10:26:00 +00:00
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2010-12-03 00:01:06 +00:00
|
|
|
|
|
|
|
fail_unless_equals_int (size, (unsigned long) paintinfo.endptr);
|
|
|
|
fail_unless_equals_int (off0, (unsigned long) paintinfo.yp);
|
|
|
|
fail_unless_equals_int (off1, (unsigned long) paintinfo.up);
|
2008-05-26 10:26:00 +00:00
|
|
|
fail_unless_equals_int (off2, (unsigned long) paintinfo.vp);
|
|
|
|
|
|
|
|
/* should be 0 if there's no alpha component */
|
2011-07-07 22:57:33 +00:00
|
|
|
off3 = GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 3);
|
2008-05-26 10:26:00 +00:00
|
|
|
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) */
|
2010-06-08 09:02:08 +00:00
|
|
|
if (fmt != GST_VIDEO_FORMAT_Y41B && fmt != GST_VIDEO_FORMAT_Y42B
|
|
|
|
&& fmt != GST_VIDEO_FORMAT_Y800) {
|
2008-05-26 10:26:00 +00:00
|
|
|
guint cs0, cs1, cs2, cs3;
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2008-05-26 10:26:00 +00:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
if (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vinfo.finfo)) {
|
|
|
|
cs3 = GST_VIDEO_INFO_COMP_WIDTH (&vinfo, 3) *
|
|
|
|
GST_VIDEO_INFO_COMP_HEIGHT (&vinfo, 2);
|
2008-05-26 10:26:00 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-03-23 14:13:57 +00:00
|
|
|
GST_START_TEST (test_video_formats_rgb)
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
2011-03-23 14:13:57 +00:00
|
|
|
gint width, height, framerate_n, framerate_d, par_n, par_d;
|
2011-07-07 22:57:33 +00:00
|
|
|
GstCaps *caps;
|
2011-03-23 14:13:57 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2011-03-23 14:13:57 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
fail_unless (gst_structure_get_int (structure, "width", &width));
|
|
|
|
fail_unless (gst_structure_get_int (structure, "height", &height));
|
|
|
|
fail_unless (gst_structure_get_fraction (structure, "framerate", &framerate_n,
|
|
|
|
&framerate_d));
|
|
|
|
fail_unless (gst_structure_get_fraction (structure, "pixel-aspect-ratio",
|
|
|
|
&par_n, &par_d));
|
|
|
|
|
|
|
|
fail_unless (width == 800);
|
|
|
|
fail_unless (height == 600);
|
|
|
|
fail_unless (framerate_n == 0);
|
|
|
|
fail_unless (framerate_d == 1);
|
|
|
|
fail_unless (par_n == 1);
|
|
|
|
fail_unless (par_d == 1);
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-05-12 21:30:00 +00:00
|
|
|
GST_START_TEST (test_dar_calc)
|
|
|
|
{
|
|
|
|
guint display_ratio_n, display_ratio_d;
|
|
|
|
|
|
|
|
/* Ensure that various Display Ratio calculations are correctly done */
|
|
|
|
/* video 768x576, par 16/15, display par 16/15 = 4/3 */
|
|
|
|
fail_unless (gst_video_calculate_display_ratio (&display_ratio_n,
|
|
|
|
&display_ratio_d, 768, 576, 16, 15, 16, 15));
|
|
|
|
fail_unless (display_ratio_n == 4 && display_ratio_d == 3);
|
|
|
|
|
|
|
|
/* video 720x480, par 32/27, display par 1/1 = 16/9 */
|
|
|
|
fail_unless (gst_video_calculate_display_ratio (&display_ratio_n,
|
|
|
|
&display_ratio_d, 720, 480, 32, 27, 1, 1));
|
|
|
|
fail_unless (display_ratio_n == 16 && display_ratio_d == 9);
|
|
|
|
|
|
|
|
/* video 360x288, par 533333/500000, display par 16/15 =
|
|
|
|
* dar 1599999/1600000 */
|
|
|
|
fail_unless (gst_video_calculate_display_ratio (&display_ratio_n,
|
|
|
|
&display_ratio_d, 360, 288, 533333, 500000, 16, 15));
|
|
|
|
fail_unless (display_ratio_n == 1599999 && display_ratio_d == 1280000);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-03-17 10:32:28 +00:00
|
|
|
GST_START_TEST (test_parse_caps_rgb)
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const gchar *tmpl_caps_string;
|
|
|
|
GstVideoFormat fmt;
|
|
|
|
} formats[] = {
|
|
|
|
/* 24 bit */
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
GST_VIDEO_CAPS_MAKE ("RGB"), GST_VIDEO_FORMAT_RGB}, {
|
|
|
|
GST_VIDEO_CAPS_MAKE ("BGR"), GST_VIDEO_FORMAT_BGR},
|
2008-03-17 10:32:28 +00:00
|
|
|
/* 32 bit (no alpha) */
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
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},
|
2008-03-17 10:32:28 +00:00
|
|
|
/* 32 bit (with alpha) */
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
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}
|
2008-03-17 10:32:28 +00:00
|
|
|
};
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
2008-03-17 10:32:28 +00:00
|
|
|
GstCaps *caps, *caps2;
|
|
|
|
|
|
|
|
caps = gst_caps_from_string (formats[i].tmpl_caps_string);
|
2008-04-11 17:13:52 +00:00
|
|
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, 2 * (i + 1), "height",
|
|
|
|
G_TYPE_INT, i + 1, "framerate", GST_TYPE_FRACTION, 15, 1,
|
2008-03-17 10:32:28 +00:00
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
|
|
|
|
g_assert (gst_caps_is_fixed (caps));
|
|
|
|
|
|
|
|
GST_DEBUG ("testing caps: %" GST_PTR_FORMAT, caps);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2008-03-17 10:32:28 +00:00
|
|
|
|
|
|
|
/* make sure they're serialised back correctly */
|
2011-07-07 22:57:33 +00:00
|
|
|
caps2 = gst_video_info_to_caps (&vinfo);
|
2008-03-17 10:32:28 +00:00
|
|
|
fail_unless (caps != NULL);
|
|
|
|
fail_unless (gst_caps_is_equal (caps, caps2));
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_caps_unref (caps2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-11-15 17:34:37 +00:00
|
|
|
GST_START_TEST (test_events)
|
|
|
|
{
|
|
|
|
GstEvent *e;
|
|
|
|
gboolean in_still;
|
|
|
|
|
|
|
|
e = gst_video_event_new_still_frame (TRUE);
|
|
|
|
fail_if (e == NULL, "Failed to create still frame event");
|
|
|
|
fail_unless (gst_video_event_parse_still_frame (e, &in_still),
|
|
|
|
"Failed to parse still frame event");
|
|
|
|
fail_unless (gst_video_event_parse_still_frame (e, NULL),
|
|
|
|
"Failed to parse still frame event w/ in_still == NULL");
|
|
|
|
fail_unless (in_still == TRUE);
|
|
|
|
gst_event_unref (e);
|
|
|
|
|
|
|
|
e = gst_video_event_new_still_frame (FALSE);
|
|
|
|
fail_if (e == NULL, "Failed to create still frame event");
|
|
|
|
fail_unless (gst_video_event_parse_still_frame (e, &in_still),
|
|
|
|
"Failed to parse still frame event");
|
|
|
|
fail_unless (gst_video_event_parse_still_frame (e, NULL),
|
|
|
|
"Failed to parse still frame event w/ in_still == NULL");
|
|
|
|
fail_unless (in_still == FALSE);
|
|
|
|
gst_event_unref (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-09-12 14:53:59 +00:00
|
|
|
GST_START_TEST (test_convert_frame)
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
2010-09-12 14:53:59 +00:00
|
|
|
GstCaps *from_caps, *to_caps;
|
|
|
|
GstBuffer *from_buffer, *to_buffer;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint i;
|
|
|
|
guint8 *data;
|
|
|
|
|
2011-09-05 13:51:25 +00:00
|
|
|
gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
|
|
|
|
|
2010-09-12 14:53:59 +00:00
|
|
|
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
|
|
|
|
|
2011-03-28 13:51:46 +00:00
|
|
|
data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
|
2010-09-12 14:53:59 +00:00
|
|
|
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 */
|
|
|
|
}
|
2011-03-28 13:51:46 +00:00
|
|
|
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2010-09-12 14:53:59 +00:00
|
|
|
|
|
|
|
to_caps =
|
|
|
|
gst_caps_from_string
|
|
|
|
("something/that, does=(string)not, exist=(boolean)FALSE");
|
|
|
|
|
|
|
|
to_buffer =
|
2011-07-07 22:57:33 +00:00
|
|
|
gst_video_convert_frame (from_buffer, from_caps, to_caps,
|
|
|
|
GST_CLOCK_TIME_NONE, &error);
|
2010-09-12 14:53:59 +00:00
|
|
|
fail_if (to_buffer != NULL);
|
|
|
|
fail_unless (error != NULL);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
|
|
|
|
gst_caps_unref (to_caps);
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
|
|
|
|
2010-09-12 14:53:59 +00:00
|
|
|
to_buffer =
|
2011-07-07 22:57:33 +00:00
|
|
|
gst_video_convert_frame (from_buffer, from_caps, to_caps,
|
|
|
|
GST_CLOCK_TIME_NONE, &error);
|
2010-09-12 14:53:59 +00:00
|
|
|
fail_unless (to_buffer != NULL);
|
|
|
|
fail_unless (error == NULL);
|
|
|
|
|
|
|
|
gst_buffer_unref (from_buffer);
|
|
|
|
gst_caps_unref (from_caps);
|
|
|
|
gst_buffer_unref (to_buffer);
|
|
|
|
gst_caps_unref (to_caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-09-14 06:40:07 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GMainLoop *loop;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GError *error;
|
|
|
|
} ConvertFrameContext;
|
|
|
|
|
|
|
|
static void
|
|
|
|
convert_frame_async_callback (GstBuffer * buf, GError * err,
|
|
|
|
ConvertFrameContext * cf_data)
|
|
|
|
{
|
|
|
|
cf_data->buffer = buf;
|
|
|
|
cf_data->error = err;
|
|
|
|
|
|
|
|
g_main_loop_quit (cf_data->loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_convert_frame_async)
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
2010-09-14 06:40:07 +00:00
|
|
|
GstCaps *from_caps, *to_caps;
|
|
|
|
GstBuffer *from_buffer;
|
|
|
|
gint i;
|
|
|
|
guint8 *data;
|
|
|
|
GMainLoop *loop;
|
|
|
|
ConvertFrameContext cf_data = { NULL, NULL, NULL };
|
|
|
|
|
2011-09-05 13:51:25 +00:00
|
|
|
gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
|
|
|
|
|
2010-09-14 06:40:07 +00:00
|
|
|
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
|
|
|
|
|
2011-03-28 13:51:46 +00:00
|
|
|
data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
|
2010-09-14 06:40:07 +00:00
|
|
|
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 */
|
|
|
|
}
|
2011-03-28 13:51:46 +00:00
|
|
|
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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);
|
2010-09-14 06:40:07 +00:00
|
|
|
|
|
|
|
to_caps =
|
|
|
|
gst_caps_from_string
|
|
|
|
("something/that, does=(string)not, exist=(boolean)FALSE");
|
|
|
|
|
|
|
|
loop = cf_data.loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
gst_video_convert_frame_async (from_buffer, from_caps, to_caps,
|
|
|
|
GST_CLOCK_TIME_NONE,
|
2010-09-15 09:26:48 +00:00
|
|
|
(GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
|
|
|
|
NULL);
|
2010-09-14 06:40:07 +00:00
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
fail_if (cf_data.buffer != NULL);
|
|
|
|
fail_unless (cf_data.error != NULL);
|
|
|
|
g_error_free (cf_data.error);
|
|
|
|
cf_data.error = NULL;
|
|
|
|
|
|
|
|
gst_caps_unref (to_caps);
|
2011-07-07 22:57:33 +00:00
|
|
|
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_frame_async (from_buffer, from_caps, to_caps,
|
|
|
|
GST_CLOCK_TIME_NONE,
|
2010-09-15 09:26:48 +00:00
|
|
|
(GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
|
|
|
|
NULL);
|
2010-09-14 06:40:07 +00:00
|
|
|
g_main_loop_run (loop);
|
|
|
|
fail_unless (cf_data.buffer != NULL);
|
|
|
|
fail_unless (cf_data.error == NULL);
|
|
|
|
|
|
|
|
gst_buffer_unref (from_buffer);
|
|
|
|
gst_caps_unref (from_caps);
|
|
|
|
gst_buffer_unref (cf_data.buffer);
|
|
|
|
gst_caps_unref (to_caps);
|
|
|
|
|
|
|
|
g_main_loop_unref (loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-18 11:18:15 +00:00
|
|
|
GST_START_TEST (test_video_size_from_caps)
|
|
|
|
{
|
2011-07-07 22:57:33 +00:00
|
|
|
GstVideoInfo vinfo;
|
|
|
|
GstCaps *caps;
|
2011-06-16 11:41:25 +00:00
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw",
|
2011-06-16 11:41:25 +00:00
|
|
|
"format", G_TYPE_STRING, "YV12",
|
2011-05-18 11:18:15 +00:00
|
|
|
"width", G_TYPE_INT, 640,
|
2011-07-07 22:57:33 +00:00
|
|
|
"height", G_TYPE_INT, 480, "framerate", GST_TYPE_FRACTION, 25, 1, NULL);
|
2011-05-18 11:18:15 +00:00
|
|
|
|
2011-07-07 22:57:33 +00:00
|
|
|
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));
|
2011-05-18 11:18:15 +00:00
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
static Suite *
|
2006-05-12 21:30:00 +00:00
|
|
|
video_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("video support library");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
tcase_add_test (tc_chain, test_video_formats);
|
2011-03-23 14:13:57 +00:00
|
|
|
tcase_add_test (tc_chain, test_video_formats_rgb);
|
2011-07-28 12:39:14 +00:00
|
|
|
tcase_add_test (tc_chain, test_video_formats_all);
|
2006-05-12 21:30:00 +00:00
|
|
|
tcase_add_test (tc_chain, test_dar_calc);
|
2008-03-17 10:32:28 +00:00
|
|
|
tcase_add_test (tc_chain, test_parse_caps_rgb);
|
2009-11-15 17:34:37 +00:00
|
|
|
tcase_add_test (tc_chain, test_events);
|
2010-09-12 14:53:59 +00:00
|
|
|
tcase_add_test (tc_chain, test_convert_frame);
|
2010-09-14 06:40:07 +00:00
|
|
|
tcase_add_test (tc_chain, test_convert_frame_async);
|
2011-05-18 11:18:15 +00:00
|
|
|
tcase_add_test (tc_chain, test_video_size_from_caps);
|
2006-05-12 21:30:00 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
tests/check/libs/video.c: Add unit test that makes sure that the strides, offsets and sizes returned for the various ...
Original commit message from CVS:
* tests/check/libs/video.c: (paintinfo), (paintinfo_struct),
(fourcc_list_struct), (fourcc_list), (fourcc_get_size),
(paint_setup_I420), (paint_setup_YV12), (paint_setup_AYUV),
(paint_setup_YUY2), (paint_setup_UYVY), (paint_setup_YVYU),
(paint_setup_IYU2), (paint_setup_Y41B), (paint_setup_Y42B),
(paint_setup_Y800), (paint_setup_YVU9), (paint_setup_YUV9),
(gst_video_format_is_packed), (video_format_is_packed):
Add unit test that makes sure that the strides, offsets and
sizes returned for the various YUV formats by the new video API
match the old reference implementation in videotestsrc.
2008-03-02 18:24:37 +00:00
|
|
|
GST_CHECK_MAIN (video);
|