enum
{
ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_FOURCC,
- ARG_RATE,
ARG_TYPE,
ARG_SYNC,
/* FILL ME */
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
- g_param_spec_int ("width", "width", "Default width",
- 1, G_MAXINT, 320, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
- g_param_spec_int ("height", "height", "Default height",
- 1, G_MAXINT, 240, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FOURCC,
- g_param_spec_string ("fourcc", "fourcc", "fourcc",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RATE,
- g_param_spec_double ("fps", "FPS", "Default frame rate",
- 0., G_MAXDOUBLE, 30., G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
g_param_spec_enum ("pattern", "Pattern", "Type of test pattern to generate",
GST_TYPE_VIDEOTESTSRC_PATTERN, 1, G_PARAM_READWRITE));
gst_videotestsrc_set_pattern(videotestsrc, GST_VIDEOTESTSRC_SMPTE);
videotestsrc->sync = TRUE;
- videotestsrc->default_width = 320;
- videotestsrc->default_height = 240;
- videotestsrc->default_rate = 30.;
}
return NULL;
}
- newsize = (videotestsrc->width * videotestsrc->height * videotestsrc->bpp) >> 3;
+ newsize = gst_videotestsrc_get_size (videotestsrc, videotestsrc->width,
+ videotestsrc->height);
g_return_val_if_fail (newsize > 0, NULL);
GST_DEBUG ("size=%ld %dx%d", newsize, videotestsrc->width, videotestsrc->height);
GParamSpec * pspec)
{
GstVideotestsrc *src;
- const char *format;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_VIDEOTESTSRC (object));
GST_DEBUG ("gst_videotestsrc_set_property");
switch (prop_id) {
- case ARG_WIDTH:
- src->default_width = g_value_get_int (value);
- break;
- case ARG_HEIGHT:
- src->default_height = g_value_get_int (value);
- break;
- case ARG_FOURCC:
- format = g_value_get_string (value);
- if(paintrect_find_name (format) != NULL){
- src->forced_format = g_strdup(format);
- GST_DEBUG ("forcing format to \"%s\"\n", format);
- }else{
- GST_DEBUG ("unknown format \"%s\"\n", format);
- }
- break;
- case ARG_RATE:
- src->default_rate = g_value_get_double (value);
- break;
case ARG_TYPE:
gst_videotestsrc_set_pattern (src, g_value_get_enum (value));
break;
src = GST_VIDEOTESTSRC (object);
switch (prop_id) {
- case ARG_WIDTH:
- g_value_set_int (value, src->default_width);
- break;
- case ARG_HEIGHT:
- g_value_set_int (value, src->default_height);
- break;
- case ARG_FOURCC:
- g_value_set_string (value, src->forced_format);
- break;
- case ARG_RATE:
- g_value_set_double (value, src->default_rate);
- break;
case ARG_TYPE:
g_value_set_enum (value, src->type);
break;
static void paint_setup_YVYU (paintinfo * p, char *dest);
static void paint_setup_IYU2 (paintinfo * p, char *dest);
static void paint_setup_Y800 (paintinfo * p, char *dest);
+#if 0
static void paint_setup_IMC1 (paintinfo * p, char *dest);
static void paint_setup_IMC2 (paintinfo * p, char *dest);
static void paint_setup_IMC3 (paintinfo * p, char *dest);
static void paint_setup_IMC4 (paintinfo * p, char *dest);
+#endif
static void paint_setup_YUV9 (paintinfo * p, char *dest);
static void paint_setup_YVU9 (paintinfo * p, char *dest);
static void paint_setup_xRGB8888 (paintinfo * p, char *dest);
static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
+#if 0
static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
+#endif
static void paint_hline_YUV9 (paintinfo * p, int x, int y, int w);
static void paint_hline_str4 (paintinfo * p, int x, int y, int w);
static void paint_hline_str3 (paintinfo * p, int x, int y, int w);
{"I420", "I420", 12, paint_setup_I420, paint_hline_I420},
/* NV12 */
/* NV21 */
+#if 0
/* IMC1 */
{"IMC1", "IMC1", 16, paint_setup_IMC1, paint_hline_IMC1},
/* IMC2 */
{"IMC3", "IMC3", 16, paint_setup_IMC3, paint_hline_IMC1},
/* IMC4 */
{"IMC4", "IMC4", 12, paint_setup_IMC4, paint_hline_IMC1},
+#endif
/* CLPL */
/* Y41B */
/* Y42B */
}
}
+int
+gst_videotestsrc_get_size (GstVideotestsrc * v, int w, int h)
+{
+ paintinfo pi = { 0 };
+ paintinfo *p = π
+ struct fourcc_list_struct *fourcc;
+
+ p->width = w;
+ p->height = h;
+ fourcc = v->fourcc;
+ if (fourcc == NULL)
+ return 0;
+
+ fourcc->paint_setup (p, NULL);
+
+ return (unsigned long)p->endptr;
+}
+
void
gst_videotestsrc_smpte (GstVideotestsrc * v, unsigned char *dest, int w, int h)
{
}
}
+#define ROUND_UP_2(x) (((x)+1)&~1)
+#define ROUND_UP_4(x) (((x)+3)&~3)
+#define ROUND_UP_8(x) (((x)+7)&~7)
+
static void
paint_setup_I420 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->up = dest + p->width * p->height;
- p->vp = dest + p->width * p->height + p->width * p->height / 4;
+ p->ystride = ROUND_UP_4(p->width);
+ p->up = p->yp + p->ystride * ROUND_UP_2(p->height);
+ p->ustride = ROUND_UP_8(p->width)/2;
+ p->vp = p->up + p->ustride * ROUND_UP_2 (p->height) / 2;
+ p->vstride = ROUND_UP_8(p->ystride)/2;
+ p->endptr = p->vp + p->vstride * ROUND_UP_2 (p->height) / 2;
}
static void
{
int x1 = x / 2;
int x2 = (x + w) / 2;
- int offset = y * p->width;
- int offset1 = (y / 2) * (p->width / 2);
+ int offset = y * p->ystride;
+ int offset1 = (y / 2) * p->ustride;
memset (p->yp + offset + x, p->color->Y, w);
memset (p->up + offset1 + x1, p->color->U, x2 - x1);
paint_setup_YV12 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->up = dest + p->width * p->height + p->width * p->height / 4;
- p->vp = dest + p->width * p->height;
+ p->ystride = ROUND_UP_4(p->width);
+ p->vp = p->yp + p->ystride * ROUND_UP_2(p->height);
+ p->vstride = ROUND_UP_8(p->ystride)/2;
+ p->up = p->vp + p->vstride * ROUND_UP_2(p->height) / 2;
+ p->ustride = ROUND_UP_8(p->ystride)/2;
+ p->endptr = p->up + p->ustride * ROUND_UP_2(p->height) / 2;
}
static void
p->yp = dest;
p->up = dest + 1;
p->vp = dest + 3;
+ p->ystride = ROUND_UP_2(p->width) * 2;
+ p->endptr = dest + p->ystride * p->height;
}
static void
p->yp = dest + 1;
p->up = dest;
p->vp = dest + 2;
+ p->ystride = ROUND_UP_2(p->width) * 2;
+ p->endptr = dest + p->ystride * p->height;
}
static void
p->yp = dest;
p->up = dest + 3;
p->vp = dest + 1;
+ p->ystride = ROUND_UP_2(p->width * 2);
+ p->endptr = dest + p->ystride * p->height;
}
static void
int x2 = (x + w) / 2;
int offset;
- offset = y * p->width * 2;
+ offset = y * p->ystride;
memset_str2 (p->yp + offset + x * 2, p->color->Y, w);
memset_str4 (p->up + offset + x1 * 4, p->color->U, x2 - x1);
memset_str4 (p->vp + offset + x1 * 4, p->color->V, x2 - x1);
static void
paint_setup_IYU2 (paintinfo * p, char *dest)
{
+ /* untested */
p->yp = dest + 1;
p->up = dest + 0;
p->vp = dest + 2;
+ p->ystride = ROUND_UP_4(p->width * 3);
+ p->endptr = dest + p->ystride * p->height;
}
static void
{
int offset;
- offset = y * p->width * 3;
+ offset = y * p->ystride;
memset_str3 (p->yp + offset + x * 3, p->color->Y, w);
memset_str3 (p->up + offset + x * 3, p->color->U, w);
memset_str3 (p->vp + offset + x * 3, p->color->V, w);
static void
paint_setup_Y800 (paintinfo * p, char *dest)
{
+ /* untested */
p->yp = dest;
+ p->ystride = ROUND_UP_4 (p->width);
+ p->endptr = dest + p->ystride * p->height;
}
static void
paint_hline_Y800 (paintinfo * p, int x, int y, int w)
{
- int offset = y * p->width;
+ int offset = y * p->ystride;
memset (p->yp + offset + x, p->color->Y, w);
}
+#if 0
static void
paint_setup_IMC1 (paintinfo * p, char *dest)
{
memset (p->up + offset1 + x1, p->color->U, x2 - x1);
memset (p->vp + offset1 + x1, p->color->V, x2 - x1);
}
+#endif
static void
paint_setup_YVU9 (paintinfo * p, char *dest)
{
+ int h = ROUND_UP_4(p->height);
p->yp = dest;
- p->vp = dest + p->width * p->height;
- p->up = dest + p->width * p->height + (p->width/4) * (p->height/4);
+ p->ystride = ROUND_UP_4(p->width);
+ p->vp = p->yp + p->ystride * ROUND_UP_4(p->height);
+ p->vstride = ROUND_UP_4(p->ystride/4);
+ p->up = p->vp + p->vstride * ROUND_UP_4(h/4);
+ p->ustride = ROUND_UP_4(p->ystride/4);
+ p->endptr = p->up + p->ustride * ROUND_UP_4(h/4);
}
static void
paint_setup_YUV9 (paintinfo * p, char *dest)
{
+ /* untested */
+ int h = ROUND_UP_4(p->height);
p->yp = dest;
- p->up = dest + p->width * p->height;
- p->vp = dest + p->width * p->height + (p->width/4) * (p->height/4);
+ p->ystride = ROUND_UP_4(p->width);
+ p->up = p->yp + p->ystride * h;
+ p->ustride = ROUND_UP_4(p->ystride/4);
+ p->vp = p->up + p->ustride * ROUND_UP_4(h/4);
+ p->vstride = ROUND_UP_4(p->ystride/4);
+ p->endptr = p->vp + p->vstride * ROUND_UP_4(h/4);
}
static void
{
int x1 = x / 4;
int x2 = (x + w) / 4;
- int offset = y * p->width;
- int offset1 = (y / 4) * (p->width / 4);
+ int offset = y * p->ystride;
+ int offset1 = (y / 4) * p->ustride;
memset (p->yp + offset + x, p->color->Y, w);
memset (p->up + offset1 + x1, p->color->U, x2 - x1);
p->yp = dest + 1;
p->up = dest + 2;
p->vp = dest + 3;
+ p->ystride = p->width*4;
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
p->yp = dest + 3;
p->up = dest + 2;
p->vp = dest + 1;
+ p->ystride = p->width*4;
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
p->yp = dest + 0;
p->up = dest + 1;
p->vp = dest + 2;
+ p->ystride = p->width*4;
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
p->yp = dest + 2;
p->up = dest + 1;
p->vp = dest + 0;
+ p->ystride = p->width*4;
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
p->yp = dest + 0;
p->up = dest + 1;
p->vp = dest + 2;
- p->stride = (p->width*3 + 1)&(~0x3);
+ p->ystride = ROUND_UP_4(p->width*3);
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
p->yp = dest + 2;
p->up = dest + 1;
p->vp = dest + 0;
- p->stride = (p->width*3 + 1)&(~0x3);
+ p->ystride = ROUND_UP_4(p->width*3);
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
paint_hline_str4 (paintinfo * p, int x, int y, int w)
{
- int offset = y * p->width * 4;
+ int offset = y * p->ystride;
memset_str4 (p->yp + offset + x * 4, p->color->R, w);
memset_str4 (p->up + offset + x * 4, p->color->G, w);
static void
paint_hline_str3 (paintinfo * p, int x, int y, int w)
{
- int offset = y * p->stride;
+ int offset = y * p->ystride;
memset_str3 (p->yp + offset + x * 3, p->color->R, w);
memset_str3 (p->up + offset + x * 3, p->color->G, w);
paint_setup_RGB565 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->stride = (p->width*2 + 1)&(~0x3);
+ p->ystride = ROUND_UP_4(p->width*2);
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
paint_hline_RGB565 (paintinfo * p, int x, int y, int w)
{
- int offset = y * p->stride;
+ int offset = y * p->ystride;
unsigned int a,b;
a = (p->color->R&0xf8) | (p->color->G>>5);
paint_setup_xRGB1555 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->stride = (p->width*2 + 1)&(~0x3);
+ p->ystride = ROUND_UP_4(p->width*2);
+ p->endptr = p->dest + p->ystride * p->height;
}
static void
paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w)
{
- int offset = y * p->stride;
+ int offset = y * p->ystride;
unsigned int a,b;
a = ((p->color->R>>1)&0x7c) | (p->color->G>>6);
#endif
}
-#if 0
-#ifdef unused
-static void
-gst_videotestsrc_smpte_RGB (GstVideotestsrc * v, unsigned char *dest, int w, int h)
-{
- int i;
- int y1, y2;
-
- y1 = h * 2 / 3;
- y2 = h * 0.75;
-
- /* color bars */
- for (i = 0; i < 7; i++) {
- int x1 = i * w / 7;
- int x2 = (i + 1) * w / 7;
- unsigned char col[2];
-
- col[0] = (g_colors[i] & 0xe0) | (b_colors[i] >> 3);
- col[1] = (r_colors[i] & 0xf8) | (g_colors[i] >> 5);
- paint_rect2 (dest, w * 2, x1, 0, x2 - x1, y1, col);
- }
-
- /* inverse blue bars */
- for (i = 0; i < 7; i++) {
- int x1 = i * w / 7;
- int x2 = (i + 1) * w / 7;
- unsigned char col[2];
- int k;
-
- if (i & 1) {
- k = 7;
- } else {
- k = 6 - i;
- }
- col[0] = (g_colors[k] & 0xe0) | (b_colors[k] >> 3);
- col[1] = (r_colors[k] & 0xf8) | (g_colors[k] >> 5);
- paint_rect2 (dest, w * 2, x1, y1, x2 - x1, y2 - y1, col);
- }
-
- /* -I, white, Q regions */
- for (i = 0; i < 3; i++) {
- int x1 = i * w / 6;
- int x2 = (i + 1) * w / 6;
- unsigned char col[2];
- int k;
-
- if (i == 0) {
- k = 8;
- } else if (i == 1) {
- k = 0;
- } else {
- k = 9;
- }
-
- col[0] = (g_colors[k] & 0xe0) | (b_colors[k] >> 3);
- col[1] = (r_colors[k] & 0xf8) | (g_colors[k] >> 5);
- paint_rect2 (dest, w * 2, x1, y2, x2 - x1, h - y2, col);
- }
-
- {
- int x1 = w / 2;
- int x2 = w - 1;
-
- paint_rect_random (dest, w * 2, x1 * 2, y2, (x2 - x1) * 2, h - y2);
- }
-}
-#endif
-
-static void
-gst_videotestsrc_smpte_RGB (GstVideotestsrc * v, unsigned char *dest, int w, int h)
-{
- int i;
- int y1, y2;
-
- y1 = h * 2 / 3;
- y2 = h * 0.75;
-
- /* color bars */
- for (i = 0; i < 7; i++) {
- int x1 = i * w / 7;
- int x2 = (i + 1) * w / 7;
- unsigned char col[2];
-
- col[0] = 0;
- col[1] = r_colors[i];
- col[2] = g_colors[i];
- col[3] = b_colors[i];
- paint_rect4 (dest, w * 4, x1, 0, x2 - x1, y1, col);
- }
-
- /* inverse blue bars */
- for (i = 0; i < 7; i++) {
- int x1 = i * w / 7;
- int x2 = (i + 1) * w / 7;
- unsigned char col[2];
- int k;
-
- if (i & 1) {
- k = 7;
- } else {
- k = 6 - i;
- }
- col[0] = 0;
- col[1] = r_colors[k];
- col[2] = g_colors[k];
- col[3] = b_colors[k];
- paint_rect4 (dest, w * 4, x1, y1, x2 - x1, y2 - y1, col);
- }
-
- /* -I, white, Q regions */
- for (i = 0; i < 3; i++) {
- int x1 = i * w / 6;
- int x2 = (i + 1) * w / 6;
- unsigned char col[2];
- int k;
-
- if (i == 0) {
- k = 8;
- } else if (i == 1) {
- k = 0;
- } else {
- k = 9;
- }
-
- col[0] = 0;
- col[1] = r_colors[k];
- col[2] = g_colors[k];
- col[3] = b_colors[k];
- paint_rect4 (dest, w * 4, x1, y2, x2 - x1, h - y2, col);
- }
-
- {
- int x1 = w / 2;
- int x2 = w - 1;
-
- paint_rect_random (dest, w * 4, x1 * 4, y2, (x2 - x1) * 4, h - y2);
- }
-}
-#endif
-