videotestsrc: Add foreground/background-color properties

Replace solid-color property with foreground-color and add
background-color.  Pull some common code out of each of the
pattern generating functions.  Fix many of the patterns to
use foreground-color/background-color instead of white/black.
Generated images are indentical to previously if foreground-color
and background-color are left as default.

API: GstVideoTestSrc::foreground-color
API: GstVideoTestSrc::background-color
This commit is contained in:
David Schleef 2010-09-05 20:35:13 -07:00
parent cdb5981bca
commit 131d619737
4 changed files with 210 additions and 245 deletions

View file

@ -50,7 +50,8 @@ GST_DEBUG_CATEGORY_STATIC (video_test_src_debug);
#define DEFAULT_IS_LIVE FALSE #define DEFAULT_IS_LIVE FALSE
#define DEFAULT_PEER_ALLOC TRUE #define DEFAULT_PEER_ALLOC TRUE
#define DEFAULT_COLOR_SPEC GST_VIDEO_TEST_SRC_BT601 #define DEFAULT_COLOR_SPEC GST_VIDEO_TEST_SRC_BT601
#define DEFAULT_SOLID_COLOR 0xff000000 #define DEFAULT_FOREGROUND_COLOR 0xffffffff
#define DEFAULT_BACKGROUND_COLOR 0xff000000
enum enum
{ {
@ -72,7 +73,8 @@ enum
PROP_KT2, PROP_KT2,
PROP_XOFFSET, PROP_XOFFSET,
PROP_YOFFSET, PROP_YOFFSET,
PROP_SOLID_COLOR, PROP_FOREGROUND_COLOR,
PROP_BACKGROUND_COLOR,
PROP_LAST PROP_LAST
}; };
@ -264,16 +266,31 @@ gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
"Zoneplate 2nd order products y offset", G_MININT32, G_MAXINT32, 0, "Zoneplate 2nd order products y offset", G_MININT32, G_MAXINT32, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstTextOverlay:solid-color * GstVideoTestSrc:foreground-color
* *
* Color to use for solid-color pattern. * Color to use for solid-color pattern and foreground color of other
* patterns. Default is white (0xffffffff).
* *
* Since: 0.10.31 * Since: 0.10.31
**/ **/
g_object_class_install_property (gobject_class, PROP_SOLID_COLOR, g_object_class_install_property (gobject_class, PROP_FOREGROUND_COLOR,
g_param_spec_uint ("solid-color", "Solid Color", g_param_spec_uint ("foreground-color", "Foreground Color",
"Solid color to use (big-endian ARGB)", 0, G_MAXUINT32, "Foreground color to use (big-endian ARGB)", 0, G_MAXUINT32,
DEFAULT_SOLID_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); DEFAULT_FOREGROUND_COLOR,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstVideoTestSrc:background-color
*
* Color to use for background color of some patterns. Default is
* black (0xff000000).
*
* Since: 0.10.31
**/
g_object_class_install_property (gobject_class, PROP_BACKGROUND_COLOR,
g_param_spec_uint ("background-color", "Background Color",
"Background color to use (big-endian ARGB)", 0, G_MAXUINT32,
DEFAULT_BACKGROUND_COLOR,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstbasesrc_class->get_caps = gst_video_test_src_getcaps; gstbasesrc_class->get_caps = gst_video_test_src_getcaps;
gstbasesrc_class->set_caps = gst_video_test_src_setcaps; gstbasesrc_class->set_caps = gst_video_test_src_setcaps;
@ -296,7 +313,8 @@ gst_video_test_src_init (GstVideoTestSrc * src, GstVideoTestSrcClass * g_class)
gst_video_test_src_set_pattern (src, DEFAULT_PATTERN); gst_video_test_src_set_pattern (src, DEFAULT_PATTERN);
src->timestamp_offset = DEFAULT_TIMESTAMP_OFFSET; src->timestamp_offset = DEFAULT_TIMESTAMP_OFFSET;
src->solid_color = DEFAULT_SOLID_COLOR; src->foreground_color = DEFAULT_FOREGROUND_COLOR;
src->background_color = DEFAULT_BACKGROUND_COLOR;
/* we operate in time */ /* we operate in time */
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
@ -454,8 +472,11 @@ gst_video_test_src_set_property (GObject * object, guint prop_id,
case PROP_YOFFSET: case PROP_YOFFSET:
src->yoffset = g_value_get_int (value); src->yoffset = g_value_get_int (value);
break; break;
case PROP_SOLID_COLOR: case PROP_FOREGROUND_COLOR:
src->solid_color = g_value_get_uint (value); src->foreground_color = g_value_get_uint (value);
break;
case PROP_BACKGROUND_COLOR:
src->background_color = g_value_get_uint (value);
break; break;
default: default:
break; break;
@ -519,8 +540,11 @@ gst_video_test_src_get_property (GObject * object, guint prop_id,
case PROP_YOFFSET: case PROP_YOFFSET:
g_value_set_int (value, src->yoffset); g_value_set_int (value, src->yoffset);
break; break;
case PROP_SOLID_COLOR: case PROP_FOREGROUND_COLOR:
g_value_set_uint (value, src->solid_color); g_value_set_uint (value, src->foreground_color);
break;
case PROP_BACKGROUND_COLOR:
g_value_set_uint (value, src->background_color);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -160,7 +160,10 @@ struct _GstVideoTestSrc {
gint yoffset; gint yoffset;
/* solid color */ /* solid color */
guint solid_color; guint foreground_color;
guint background_color;
gint zoneplate_t;
void (*make_image) (GstVideoTestSrc *v, unsigned char *dest, int w, int h); void (*make_image) (GstVideoTestSrc *v, unsigned char *dest, int w, int h);
}; };

View file

@ -690,6 +690,119 @@ gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h)
return (unsigned long) p->endptr; return (unsigned long) p->endptr;
} }
#define SCALEBITS 10
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
#define RGB_TO_Y(r, g, b) \
((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
#define RGB_TO_U(r1, g1, b1, shift)\
(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V(r1, g1, b1, shift)\
(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_Y_CCIR(r, g, b) \
((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_Y_CCIR_709(r, g, b) \
((FIX(0.212600*219.0/255.0) * (r) + FIX(0.715200*219.0/255.0) * (g) + \
FIX(0.072200*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
#define RGB_TO_U_CCIR_709(r1, g1, b1, shift)\
(((- FIX(0.114572*224.0/255.0) * r1 - FIX(0.385427*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V_CCIR_709(r1, g1, b1, shift)\
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.454153*224.0/255.0) * g1 - \
FIX(0.045847*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
static void
videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
{
int a, r, g, b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
p->paint_hline = v->fourcc->paint_hline;
a = (v->foreground_color >> 24) & 0xff;
r = (v->foreground_color >> 16) & 0xff;
g = (v->foreground_color >> 8) & 0xff;
b = (v->foreground_color >> 0) & 0xff;
p->foreground_color.A = a;
p->foreground_color.R = r;
p->foreground_color.G = g;
p->foreground_color.B = b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
p->foreground_color.Y = RGB_TO_Y_CCIR (r, g, b);
p->foreground_color.U = RGB_TO_U_CCIR (r, g, b, 0);
p->foreground_color.V = RGB_TO_V_CCIR (r, g, b, 0);
} else {
p->foreground_color.Y = RGB_TO_Y_CCIR_709 (r, g, b);
p->foreground_color.U = RGB_TO_U_CCIR_709 (r, g, b, 0);
p->foreground_color.V = RGB_TO_V_CCIR_709 (r, g, b, 0);
}
p->foreground_color.gray = RGB_TO_Y (r, g, b);
a = (v->background_color >> 24) & 0xff;
r = (v->background_color >> 16) & 0xff;
g = (v->background_color >> 8) & 0xff;
b = (v->background_color >> 0) & 0xff;
p->background_color.A = a;
p->background_color.R = r;
p->background_color.G = g;
p->background_color.B = b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
p->background_color.Y = RGB_TO_Y_CCIR (r, g, b);
p->background_color.U = RGB_TO_U_CCIR (r, g, b, 0);
p->background_color.V = RGB_TO_V_CCIR (r, g, b, 0);
} else {
p->background_color.Y = RGB_TO_Y_CCIR_709 (r, g, b);
p->background_color.U = RGB_TO_U_CCIR_709 (r, g, b, 0);
p->background_color.V = RGB_TO_V_CCIR_709 (r, g, b, 0);
}
p->background_color.gray = RGB_TO_Y (r, g, b);
}
static void
videotestsrc_blend_color (struct vts_color_struct *dest,
struct vts_color_struct *a, struct vts_color_struct *b, int x)
{
#define BLEND1(a,b,x) ((a)*(x) + (b)*(255-(x)))
#define DIV255(x) (((x) + (((x)+128)>>8) + 128)>>8)
#define BLEND(a,b,x) DIV255(BLEND1(a,b,x))
dest->Y = BLEND (a->Y, b->Y, x);
dest->U = BLEND (a->U, b->U, x);
dest->V = BLEND (a->V, b->V, x);
dest->R = BLEND (a->R, b->R, x);
dest->G = BLEND (a->G, b->G, x);
dest->B = BLEND (a->B, b->B, x);
dest->gray = BLEND (a->gray, b->gray, x);
#undef BLEND
}
void void
gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w, gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
int h) int h)
@ -701,19 +814,12 @@ gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
y1 = 2 * h / 3; y1 = 2 * h / 3;
y2 = h * 0.75; y2 = h * 0.75;
@ -793,13 +899,9 @@ gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
for (i = x1; i < w; i++) { for (i = x1; i < w; i++) {
for (j = y2; j < h; j++) { for (j = y2; j < h; j++) {
/* FIXME not strictly correct */
int y = random_char (); int y = random_char ();
color.Y = y; videotestsrc_blend_color (&color, &p->foreground_color,
color.R = y; &p->background_color, y);
color.G = y;
color.B = y;
color.gray = (y << 8) | random_char ();
p->paint_hline (p, i, j, 1); p->paint_hline (p, i, j, 1);
} }
} }
@ -817,19 +919,12 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_75;
} else {
p->colors = vts_colors_bt709_ycbcr_75;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
/* color bars */ /* color bars */
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
@ -853,32 +948,21 @@ gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
struct vts_color_struct color; struct vts_color_struct color;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
for (i = 0; i < w; i++) { for (i = 0; i < w; i++) {
for (j = 0; j < h; j++) { for (j = 0; j < h; j++) {
/* FIXME not strictly correct */
int y = random_char (); int y = random_char ();
color.Y = y; videotestsrc_blend_color (&color, &p->foreground_color,
color.R = y; &p->background_color, y);
color.G = y;
color.B = y;
color.gray = (y << 8) | random_char ();
p->paint_hline (p, i, j, 1); p->paint_hline (p, i, j, 1);
} }
} }
@ -893,21 +977,20 @@ gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
p->color = p->colors + color_index; p->color = p->colors + color_index;
if (color_index == COLOR_BLACK) {
p->color = &p->background_color;
}
if (color_index == COLOR_WHITE) {
p->color = &p->foreground_color;
}
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
p->paint_hline (p, 0, i, w); p->paint_hline (p, 0, i, w);
@ -944,46 +1027,6 @@ gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE); gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE);
} }
#define SCALEBITS 10
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
#define RGB_TO_Y(r, g, b) \
((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
#define RGB_TO_U(r1, g1, b1, shift)\
(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V(r1, g1, b1, shift)\
(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_Y_CCIR(r, g, b) \
((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_Y_CCIR_709(r, g, b) \
((FIX(0.212600*219.0/255.0) * (r) + FIX(0.715200*219.0/255.0) * (g) + \
FIX(0.072200*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
#define RGB_TO_U_CCIR_709(r1, g1, b1, shift)\
(((- FIX(0.114572*224.0/255.0) * r1 - FIX(0.385427*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V_CCIR_709(r1, g1, b1, shift)\
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.454153*224.0/255.0) * g1 - \
FIX(0.045847*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
void void
gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w, gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
int h) int h)
@ -992,44 +1035,16 @@ gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
struct vts_color_struct yuv;
guint8 a, r, g, b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
a = (v->solid_color >> 24) & 0xff; p->color = &p->foreground_color;
r = (v->solid_color >> 16) & 0xff;
g = (v->solid_color >> 8) & 0xff;
b = (v->solid_color >> 0) & 0xff;
yuv.A = a;
yuv.R = r;
yuv.G = g;
yuv.B = b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
yuv.Y = RGB_TO_Y_CCIR (r, g, b);
yuv.U = RGB_TO_U_CCIR (r, g, b, 0);
yuv.V = RGB_TO_V_CCIR (r, g, b, 0);
} else {
yuv.Y = RGB_TO_Y_CCIR_709 (r, g, b);
yuv.U = RGB_TO_U_CCIR_709 (r, g, b, 0);
yuv.V = RGB_TO_V_CCIR_709 (r, g, b, 0);
}
yuv.gray = RGB_TO_Y (r, g, b);
p->color = &yuv;
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
p->paint_hline (p, 0, i, w); p->paint_hline (p, 0, i, w);
@ -1044,19 +1059,13 @@ gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
p->color = p->colors + COLOR_GREEN; p->color = p->colors + COLOR_GREEN;
@ -1076,19 +1085,12 @@ gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
p->color = p->colors + COLOR_GREEN; p->color = p->colors + COLOR_GREEN;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
@ -1116,19 +1118,12 @@ gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
p->color = p->colors + COLOR_GREEN; p->color = p->colors + COLOR_GREEN;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
@ -1162,19 +1157,12 @@ gst_video_test_src_checkers8 (GstVideoTestSrc * v, guchar * dest, int w, int h)
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
p->color = p->colors + COLOR_GREEN; p->color = p->colors + COLOR_GREEN;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
@ -1203,10 +1191,7 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
struct vts_color_struct color; struct vts_color_struct color;
static guint8 sine_array[256]; static guint8 sine_array[256];
static int sine_array_inited = FALSE; static int sine_array_inited = FALSE;
int t = v->zoneplate_t;
static int t = 0; /* time - increment phase vs time by 1 for each generated frame */
/* this may not fit with the correct gstreamer notion of time, so maybe FIXME? */
int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */ int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */
int yreset = -(h / 2) - v->yoffset; int yreset = -(h / 2) - v->yoffset;
@ -1235,19 +1220,12 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
sine_array_inited = TRUE; sine_array_inited = TRUE;
} }
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -1327,18 +1305,14 @@ gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
/*phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1); */ /*phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1); */
phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1); phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1);
color.Y = sine_array[phase & 0xff]; videotestsrc_blend_color (&color, &p->foreground_color,
&p->background_color, sine_array[phase & 0xff]);
color.R = color.Y;
color.G = color.Y;
color.B = color.Y;
color.gray = color.Y << 8;
p->paint_hline (p, i, j, 1); p->paint_hline (p, i, j, 1);
} }
} }
t++; v->zoneplate_t++;
} }
void void
@ -1353,9 +1327,7 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
struct vts_color_struct color; struct vts_color_struct color;
static guint8 sine_array[256]; static guint8 sine_array[256];
static int sine_array_inited = FALSE; static int sine_array_inited = FALSE;
int t = v->zoneplate_t;
static int t = 0; /* time - increment phase vs time by 1 for each generated frame */
/* this may not fit with the correct gstreamer notion of time, so maybe FIXME? */
int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */ int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */
int yreset = -(h / 2) - v->yoffset; int yreset = -(h / 2) - v->yoffset;
@ -1385,19 +1357,12 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
sine_array_inited = TRUE; sine_array_inited = TRUE;
} }
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -1460,10 +1425,9 @@ gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
} }
} }
t++; v->zoneplate_t++;
} }
#undef SCALE_AMPLITUDE
#undef SCALE_AMPLITUDE #undef SCALE_AMPLITUDE
void void
gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest, gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
@ -1492,19 +1456,12 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
sine_array_inited = TRUE; sine_array_inited = TRUE;
} }
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
color = p->colors[COLOR_BLACK]; color = p->colors[COLOR_BLACK];
p->color = &color; p->color = &color;
@ -1531,8 +1488,7 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
h)) / (2 * w); h)) / (2 * w);
seg = floor (dist * 16); seg = floor (dist * 16);
if (seg == 0 || seg >= 8) { if (seg == 0 || seg >= 8) {
color.Y = 255; color = p->foreground_color;
color.gray = 65535;
} else { } else {
#ifdef SCALE_AMPLITUDE #ifdef SCALE_AMPLITUDE
double a; double a;
@ -1542,16 +1498,13 @@ gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
a = ampl[seg]; a = ampl[seg];
if (a < 0) if (a < 0)
a = 0; a = 0;
color.Y = 128 + a * (sine_array[d & 0xff] - 128); videotestsrc_blend_color (&color, &p->foreground_color,
color.gray = 128 + a * (sine_array[d & 0xff] - 128); &p->background_color, 128 + a * (sine_array[d & 0xff] - 128));
#else #else
color.Y = sine_array[d & 0xff]; videotestsrc_blend_color (&color, &p->foreground_color,
color.gray = sine_array[d & 0xff]; &p->background_color, sine_array[d & 0xff]);
#endif #endif
} }
color.R = color.Y;
color.G = color.Y;
color.B = color.Y;
p->paint_hline (p, i, j, 1); p->paint_hline (p, i, j, 1);
} }
} }
@ -1567,19 +1520,12 @@ gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h)
struct vts_color_struct yuv_primary; struct vts_color_struct yuv_primary;
struct vts_color_struct yuv_secondary; struct vts_color_struct yuv_secondary;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
int region = (y * 4) / h; int region = (y * 4) / h;
@ -1627,28 +1573,16 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
paintinfo pi = { NULL, }; paintinfo pi = { NULL, };
paintinfo *p = &pi; paintinfo *p = &pi;
struct fourcc_list_struct *fourcc; struct fourcc_list_struct *fourcc;
struct vts_color_struct yuv_primary; int t = v->zoneplate_t;
struct vts_color_struct yuv_secondary;
static int t = 0;
double x, y; double x, y;
int radius = 20; int radius = 20;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { videotestsrc_setup_paintinfo (v, p, w, h);
p->colors = vts_colors_bt601_ycbcr_100;
} else {
p->colors = vts_colors_bt709_ycbcr_100;
}
p->width = w;
p->height = h;
fourcc = v->fourcc; fourcc = v->fourcc;
if (fourcc == NULL) if (fourcc == NULL)
return; return;
yuv_primary = p->colors[COLOR_WHITE];
yuv_secondary = p->colors[COLOR_BLACK];
fourcc->paint_setup (p, dest); fourcc->paint_setup (p, dest);
p->paint_hline = fourcc->paint_hline;
x = radius + (0.5 + 0.5 * sin (2 * M_PI * t / 200)) * (w - 2 * radius); x = radius + (0.5 + 0.5 * sin (2 * M_PI * t / 200)) * (w - 2 * radius);
y = radius + (0.5 + 0.5 * sin (2 * M_PI * sqrt (2) * t / 200)) * (h - y = radius + (0.5 + 0.5 * sin (2 * M_PI * sqrt (2) * t / 200)) * (h -
@ -1656,14 +1590,14 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
if (i < y - radius || i > y + radius) { if (i < y - radius || i > y + radius) {
p->color = &yuv_primary; p->color = &p->foreground_color;
p->paint_hline (p, 0, i, w); p->paint_hline (p, 0, i, w);
} else { } else {
int r = rint (sqrt (radius * radius - (i - y) * (i - y))); int r = rint (sqrt (radius * radius - (i - y) * (i - y)));
int x1, x2; int x1, x2;
int j; int j;
p->color = &yuv_primary; p->color = &p->foreground_color;
x1 = 0; x1 = 0;
x2 = MAX (0, x - r); x2 = MAX (0, x - r);
p->paint_hline (p, x1, i, x2 - x1); p->paint_hline (p, x1, i, x2 - x1);
@ -1676,31 +1610,32 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
rr *= 0.5; rr *= 0.5;
if (rr < 0) { if (rr < 0) {
p->color = &yuv_primary; p->color = &p->foreground_color;
} else if (rr > 1) { } else if (rr > 1) {
p->color = &yuv_secondary; p->color = &p->background_color;
} else { } else {
#define BLEND(a,b,x) (rint((a)*(1-x) + (b)*(x))) #define BLEND(a,b,x) (rint((a)*(1-x) + (b)*(x)))
yuv.Y = BLEND (yuv_primary.Y, yuv_secondary.Y, rr); yuv.Y = BLEND (p->foreground_color.Y, p->background_color.Y, rr);
yuv.U = BLEND (yuv_primary.U, yuv_secondary.U, rr); yuv.U = BLEND (p->foreground_color.U, p->background_color.U, rr);
yuv.V = BLEND (yuv_primary.V, yuv_secondary.V, rr); yuv.V = BLEND (p->foreground_color.V, p->background_color.V, rr);
yuv.R = BLEND (yuv_primary.R, yuv_secondary.R, rr); yuv.R = BLEND (p->foreground_color.R, p->background_color.R, rr);
yuv.G = BLEND (yuv_primary.G, yuv_secondary.G, rr); yuv.G = BLEND (p->foreground_color.G, p->background_color.G, rr);
yuv.B = BLEND (yuv_primary.B, yuv_secondary.B, rr); yuv.B = BLEND (p->foreground_color.B, p->background_color.B, rr);
yuv.gray = BLEND (yuv_primary.gray, yuv_secondary.gray, rr); yuv.gray =
BLEND (p->foreground_color.gray, p->background_color.gray, rr);
p->color = &yuv; p->color = &yuv;
} }
p->paint_hline (p, j, i, 1); p->paint_hline (p, j, i, 1);
} }
p->color = &yuv_primary; p->color = &p->foreground_color;
x1 = MIN (w, x + r + 1); x1 = MIN (w, x + r + 1);
x2 = w; x2 = w;
p->paint_hline (p, x1, i, x2 - x1); p->paint_hline (p, x1, i, x2 - x1);
} }
} }
t++; v->zoneplate_t++;
} }

View file

@ -53,6 +53,9 @@ struct paintinfo_struct
const struct vts_color_struct *color; const struct vts_color_struct *color;
/* const struct vts_color_struct *color; */ /* const struct vts_color_struct *color; */
void (*paint_hline) (paintinfo * p, int x, int y, int w); void (*paint_hline) (paintinfo * p, int x, int y, int w);
struct vts_color_struct foreground_color;
struct vts_color_struct background_color;
}; };
struct fourcc_list_struct struct fourcc_list_struct