videotestsrc: add moving color bars pattern

This pattern is moving the color bars with a given
speed. Negative speed is inverting the moving direction.

https://bugzilla.gnome.org/show_bug.cgi?id=628500
This commit is contained in:
Thijs Vermeir 2010-09-01 15:18:31 +02:00 committed by David Schleef
parent 0cceeb2035
commit 809460c651
4 changed files with 82 additions and 1 deletions

View file

@ -53,6 +53,7 @@ GST_DEBUG_CATEGORY_STATIC (video_test_src_debug);
#define DEFAULT_COLOR_SPEC GST_VIDEO_TEST_SRC_BT601
#define DEFAULT_FOREGROUND_COLOR 0xffffffff
#define DEFAULT_BACKGROUND_COLOR 0xff000000
#define DEFAULT_MOVING_SPEED 1
enum
{
@ -76,6 +77,7 @@ enum
PROP_YOFFSET,
PROP_FOREGROUND_COLOR,
PROP_BACKGROUND_COLOR,
PROP_MOVING_SPEED,
PROP_LAST
};
@ -132,6 +134,8 @@ gst_video_test_src_pattern_get_type (void)
"chroma-zone-plate"},
{GST_VIDEO_TEST_SRC_SOLID, "Solid color", "solid-color"},
{GST_VIDEO_TEST_SRC_BALL, "Moving ball", "ball"},
{GST_VIDEO_TEST_SRC_MOVING_COLOR_BARS, "Moving color bars",
"moving-color-bars"},
{0, NULL, NULL}
};
@ -293,6 +297,12 @@ gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
DEFAULT_BACKGROUND_COLOR,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MOVING_SPEED,
g_param_spec_int ("moving-speed", "Move color bars with this speed",
"Move bars every frame with this amount of pixels (negative is inverse direction)",
G_MININT32, G_MAXINT32, DEFAULT_MOVING_SPEED,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstbasesrc_class->get_caps = gst_video_test_src_getcaps;
gstbasesrc_class->set_caps = gst_video_test_src_setcaps;
gstbasesrc_class->is_seekable = gst_video_test_src_is_seekable;
@ -316,6 +326,7 @@ gst_video_test_src_init (GstVideoTestSrc * src, GstVideoTestSrcClass * g_class)
src->timestamp_offset = DEFAULT_TIMESTAMP_OFFSET;
src->foreground_color = DEFAULT_FOREGROUND_COLOR;
src->background_color = DEFAULT_BACKGROUND_COLOR;
src->moving_speed = DEFAULT_MOVING_SPEED;
/* we operate in time */
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
@ -411,6 +422,9 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc,
case GST_VIDEO_TEST_SRC_BALL:
videotestsrc->make_image = gst_video_test_src_ball;
break;
case GST_VIDEO_TEST_SRC_MOVING_COLOR_BARS:
videotestsrc->make_image = gst_video_test_src_moving_color_bars;
break;
default:
g_assert_not_reached ();
}
@ -479,6 +493,8 @@ gst_video_test_src_set_property (GObject * object, guint prop_id,
case PROP_BACKGROUND_COLOR:
src->background_color = g_value_get_uint (value);
break;
case PROP_MOVING_SPEED:
src->moving_speed = g_value_get_int (value);
default:
break;
}
@ -547,6 +563,9 @@ gst_video_test_src_get_property (GObject * object, guint prop_id,
case PROP_BACKGROUND_COLOR:
g_value_set_uint (value, src->background_color);
break;
case PROP_MOVING_SPEED:
g_value_set_int (value, src->moving_speed);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -57,6 +57,7 @@ G_BEGIN_DECLS
* @GST_VIDEO_TEST_SRC_GAMUT: Gamut checking pattern
* @GST_VIDEO_TEST_SRC_CHROMA_ZONE_PLATE: Chroma zone plate
* @GST_VIDEO_TEST_SRC_BALL: Moving ball
* @GST_VIDEO_TEST_SRC_MOVING_COLOR_BARS: Moving color bars
*
* The test pattern to produce.
*
@ -96,7 +97,8 @@ typedef enum {
GST_VIDEO_TEST_SRC_GAMUT,
GST_VIDEO_TEST_SRC_CHROMA_ZONE_PLATE,
GST_VIDEO_TEST_SRC_SOLID,
GST_VIDEO_TEST_SRC_BALL
GST_VIDEO_TEST_SRC_BALL,
GST_VIDEO_TEST_SRC_MOVING_COLOR_BARS
} GstVideoTestSrcPattern;
/**
@ -165,6 +167,10 @@ struct _GstVideoTestSrc {
gint zoneplate_t;
/* moving color bars */
gint moving_offset;
gint moving_speed;
void (*make_image) (GstVideoTestSrc *v, unsigned char *dest, int w, int h);
};

View file

@ -1638,6 +1638,60 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
v->zoneplate_t++;
}
void
gst_video_test_src_moving_color_bars (GstVideoTestSrc * v, unsigned char *dest,
int w, int h)
{
int i, j;
paintinfo pi = { NULL, };
paintinfo *p = π
struct fourcc_list_struct *fourcc;
int offset;
videotestsrc_setup_paintinfo (v, p, w, h);
fourcc = v->fourcc;
if (fourcc == NULL)
return;
fourcc->paint_setup (p, dest);
offset = v->moving_offset;
v->moving_offset += v->moving_speed;
if (v->moving_offset >= w) {
v->moving_offset -= w;
} else if (v->moving_offset < 0) {
v->moving_offset += w;
}
/* color bars */
for (i = 0; i < 7; i++) {
int w1, w2 = 0;
int x1 = i * w / 7 + offset;
int x2 = (i + 1) * w / 7 + offset;
if (x1 > w) {
x1 -= w;
x2 -= w;
}
if (x2 > w) {
w1 = w - x1;
w2 = (x2 - x1) - w1;
} else {
w1 = x2 - x1;
}
p->color = p->colors + i;
for (j = 0; j < h; j++) {
if (x2 > w) {
p->paint_hline (p, 0, j, w2);
}
p->paint_hline (p, x1, j, w1);
}
}
}
static void
paint_setup_I420 (paintinfo * p, unsigned char *dest)

View file

@ -118,6 +118,8 @@ void gst_video_test_src_chromazoneplate (GstVideoTestSrc * v,
unsigned char *dest, int w, int h);
void gst_video_test_src_ball (GstVideoTestSrc * v,
unsigned char *dest, int w, int h);
void gst_video_test_src_moving_color_bars (GstVideoTestSrc * v,
unsigned char *dest, int w, int h);
extern struct fourcc_list_struct fourcc_list[];
extern int n_fourccs;