#define GST_CAT_DEFAULT video_test_src_debug
#define DEFAULT_PATTERN GST_VIDEO_TEST_SRC_SMPTE
+#define DEFAULT_ANIMATION_MODE GST_VIDEO_TEST_SRC_FRAMES
+#define DEFAULT_MOTION_TYPE GST_VIDEO_TEST_SRC_WAVY
+#define DEFAULT_FLIP FALSE
#define DEFAULT_TIMESTAMP_OFFSET 0
#define DEFAULT_IS_LIVE FALSE
#define DEFAULT_COLOR_SPEC GST_VIDEO_TEST_SRC_BT601
PROP_YOFFSET,
PROP_FOREGROUND_COLOR,
PROP_BACKGROUND_COLOR,
- PROP_HORIZONTAL_SPEED
+ PROP_HORIZONTAL_SPEED,
+ PROP_ANIMATION_MODE,
+ PROP_MOTION_TYPE,
+ PROP_FLIP,
+ PROP_LAST
};
return video_test_src_pattern_type;
}
+
+/*"animation-mode", which can
+ * take the following values: frames (current behaviour that should stay the
+ * default), running time, wall clock time.
+ */
+
+#define GST_TYPE_VIDEO_TEST_SRC_ANIMATION_MODE (gst_video_test_src_animation_mode_get_type ())
+static GType
+gst_video_test_src_animation_mode_get_type (void)
+{
+ static GType video_test_src_animation_mode = 0;
+ static const GEnumValue animation_modes[] = {
+
+ {GST_VIDEO_TEST_SRC_FRAMES, "frame count", "frames"},
+ {GST_VIDEO_TEST_SRC_WALL_TIME, "wall clock time", "wall-time"},
+ {GST_VIDEO_TEST_SRC_RUNNING_TIME, "running time", "running-time"},
+ {0, NULL, NULL}
+ };
+
+ if (!video_test_src_animation_mode) {
+ video_test_src_animation_mode =
+ g_enum_register_static ("GstVideoTestSrcAnimationMode",
+ animation_modes);
+ }
+ return video_test_src_animation_mode;
+}
+
+
+#define GST_TYPE_VIDEO_TEST_SRC_MOTION_TYPE (gst_video_test_src_motion_type_get_type ())
+static GType
+gst_video_test_src_motion_type_get_type (void)
+{
+ static GType video_test_src_motion_type = 0;
+ static const GEnumValue motion_types[] = {
+ {GST_VIDEO_TEST_SRC_WAVY, "Ball waves back and forth, up and down",
+ "wavy"},
+ {GST_VIDEO_TEST_SRC_SWEEP, "1 revolution per second", "sweep"},
+ {GST_VIDEO_TEST_SRC_HSWEEP, "1/2 revolution per second, then reset to top",
+ "hsweep"},
+ {0, NULL, NULL}
+ };
+
+ if (!video_test_src_motion_type) {
+ video_test_src_motion_type =
+ g_enum_register_static ("GstVideoTestSrcMotionType", motion_types);
+ }
+ return video_test_src_motion_type;
+}
+
+
static void
gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
{
g_param_spec_enum ("pattern", "Pattern",
"Type of test pattern to generate", GST_TYPE_VIDEO_TEST_SRC_PATTERN,
DEFAULT_PATTERN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_ANIMATION_MODE,
+ g_param_spec_enum ("animation-mode", "Animation mode",
+ "For pattern=ball, which counter defines the position of the ball.",
+ GST_TYPE_VIDEO_TEST_SRC_ANIMATION_MODE, DEFAULT_ANIMATION_MODE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_MOTION_TYPE,
+ g_param_spec_enum ("motion", "Motion",
+ "For pattern=ball, what motion the ball does",
+ GST_TYPE_VIDEO_TEST_SRC_MOTION_TYPE, DEFAULT_MOTION_TYPE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_FLIP,
+ g_param_spec_boolean ("flip", "Flip",
+ "For pattern=ball, invert colors every second.",
+ DEFAULT_FLIP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (gobject_class, PROP_TIMESTAMP_OFFSET,
g_param_spec_int64 ("timestamp-offset", "Timestamp offset",
"An offset added to timestamps set on buffers (in ns)", 0,
/* we operate in time */
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (src), DEFAULT_IS_LIVE);
+
+ src->animation_mode = DEFAULT_ANIMATION_MODE;
+ src->motion_type = DEFAULT_MOTION_TYPE;
+ src->flip = DEFAULT_FLIP;
+
}
static GstCaps *
case PROP_HORIZONTAL_SPEED:
src->horizontal_speed = g_value_get_int (value);
break;
+ case PROP_ANIMATION_MODE:
+ src->animation_mode = g_value_get_enum (value);
+ break;
+ case PROP_MOTION_TYPE:
+ src->motion_type = g_value_get_enum (value);
+ break;
+ case PROP_FLIP:
+ src->flip = g_value_get_boolean (value);
+ break;
default:
break;
}
case PROP_HORIZONTAL_SPEED:
g_value_set_int (value, src->horizontal_speed);
break;
+ case PROP_ANIMATION_MODE:
+ g_value_set_enum (value, src->animation_mode);
+ break;
+ case PROP_MOTION_TYPE:
+ g_value_set_enum (value, src->motion_type);
+ break;
+ case PROP_FLIP:
+ g_value_set_boolean (value, src->flip);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
gst_object_sync_values (GST_OBJECT (psrc), GST_BUFFER_PTS (buffer));
- src->make_image (src, &frame);
+ src->make_image (src, GST_BUFFER_PTS (buffer), &frame);
if ((pal = gst_video_format_get_palette (GST_VIDEO_FRAME_FORMAT (&frame),
&palsize))) {
GST_VIDEO_TEST_SRC_COLORS
} GstVideoTestSrcPattern;
+typedef enum {
+ GST_VIDEO_TEST_SRC_FRAMES,
+ GST_VIDEO_TEST_SRC_WALL_TIME,
+ GST_VIDEO_TEST_SRC_RUNNING_TIME
+} GstVideoTestSrcAnimationMode;
+
+
+typedef enum {
+ GST_VIDEO_TEST_SRC_WAVY,
+ GST_VIDEO_TEST_SRC_SWEEP,
+ GST_VIDEO_TEST_SRC_HSWEEP
+} GstVideoTestSrcMotionType;
+
typedef struct _GstVideoTestSrc GstVideoTestSrc;
typedef struct _GstVideoTestSrcClass GstVideoTestSrcClass;
/* smpte & snow */
guint random_state;
- void (*make_image) (GstVideoTestSrc *v, GstVideoFrame *frame);
+ /* Ball motion */
+ GstVideoTestSrcAnimationMode animation_mode;
+ GstVideoTestSrcMotionType motion_type;
+ gboolean flip;
+
+ void (*make_image) (GstVideoTestSrc *v, GstClockTime pts, GstVideoFrame *frame);
/* temporary AYUV/ARGB scanline */
guint8 *tmpline_u8;
}
void
-gst_video_test_src_smpte (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_smpte (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int y1, y2;
}
void
-gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_bar (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_bar (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int j;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_snow (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_snow (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_black (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_black (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
gst_video_test_src_unicolor (v, frame, COLOR_BLACK);
}
void
-gst_video_test_src_white (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_white (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
gst_video_test_src_unicolor (v, frame, COLOR_WHITE);
}
void
-gst_video_test_src_red (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_red (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
gst_video_test_src_unicolor (v, frame, COLOR_RED);
}
void
-gst_video_test_src_green (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_green (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
gst_video_test_src_unicolor (v, frame, COLOR_GREEN);
}
void
-gst_video_test_src_blue (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_blue (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
gst_video_test_src_unicolor (v, frame, COLOR_BLUE);
}
void
-gst_video_test_src_blink (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_blink (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_solid (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_solid (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_checkers1 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_checkers1 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int x, y;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_checkers2 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_checkers2 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int x, y;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_checkers4 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_checkers4 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int x, y;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_checkers8 (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_checkers8 (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int x, y;
paintinfo pi = PAINT_INFO_INIT;
void
-gst_video_test_src_zoneplate (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_zoneplate (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
#undef SCALE_AMPLITUDE
void
-gst_video_test_src_circular (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_circular (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_gamut (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_gamut (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int x, y;
paintinfo pi = PAINT_INFO_INIT;
}
void
-gst_video_test_src_ball (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_ball (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
- paintinfo pi = PAINT_INFO_INIT;
- paintinfo *p = π
- int t = v->n_frames;
- double x, y;
int radius = 20;
int w = frame->info.width, h = frame->info.height;
+ GTimeVal rand_tv;
+ gdouble rad = 0;
+ double x, y;
+ int flipit = 0;
- videotestsrc_setup_paintinfo (v, p, w, h);
+ paintinfo pi = PAINT_INFO_INIT;
+ paintinfo *p = π
- x = radius + (0.5 + 0.5 * sin (2 * G_PI * t / 200)) * (w - 2 * radius);
- y = radius + (0.5 + 0.5 * sin (2 * G_PI * sqrt (2) * t / 200)) * (h -
- 2 * radius);
+ struct vts_color_struct
+ *foreground_color = &p->foreground_color,
+ *background_color = &p->background_color;
+
+ switch (v->animation_mode) {
+ case GST_VIDEO_TEST_SRC_FRAMES:
+ rad = (gdouble) (v->n_frames) / 200;
+ flipit = (v->n_frames / 50) % 2;
+ break;
+ case GST_VIDEO_TEST_SRC_WALL_TIME:
+ g_get_current_time (&rand_tv);
+
+ rad = (gdouble) (rand_tv.tv_usec) / 1000000.0 + rand_tv.tv_sec;
+ flipit = rand_tv.tv_sec % 2;
+ break;
+ case GST_VIDEO_TEST_SRC_RUNNING_TIME:
+ rad = (gdouble) (pts) / GST_SECOND;
+ flipit = (pts / GST_SECOND) % 2;
+ break;
+ }
+ if (v->motion_type == GST_VIDEO_TEST_SRC_HSWEEP) {
+ /* Periodic reset for half sweep */
+ rad /= 2;
+ rad -= floor (2 * rad) / 2;
+ }
+ /* Scale for the animation calcs */
+ rad = 2 * G_PI * rad;
+
+ if (v->motion_type == GST_VIDEO_TEST_SRC_WAVY) {
+ x = radius + (0.5 + 0.5 * sin (rad)) * (w - 2 * radius);
+ y = radius + (0.5 + 0.5 * sin (rad * sqrt (2))) * (h - 2 * radius);
+ } else {
+ /* sweep and hsweep */
+ /* x,y is center of circle,
+ * radius is radius
+ * rad = angle .. of sweep.
+ */
+
+ radius = MIN (h, w) / 4 - 0;
+
+ /* 0 is the margin between edge of screen and top of ball */
+ x = w / 2 + sin (rad) * radius;
+ y = h / 2 - cos (rad) * radius;
+ }
+
+ if (v->flip && flipit) {
+ foreground_color = &p->background_color;
+ background_color = &p->foreground_color;
+ }
+
+ /* draw ball on frame */
+ videotestsrc_setup_paintinfo (v, p, w, h);
for (i = 0; i < h; i++) {
if (i < y - radius || i > y + radius) {
memset (p->tmpline_u8, 0, w);
} else {
- int r = rint (sqrt (radius * radius - (i - y) * (i - y)));
+ double o = MAX (0, (radius * radius - (i - y) * (i - y)));
+ int r = rint (sqrt (o));
int x1, x2;
int j;
p->tmpline_u8[j] = 0;
}
}
+
+ if ((v->motion_type == GST_VIDEO_TEST_SRC_SWEEP) ||
+ (v->motion_type == GST_VIDEO_TEST_SRC_HSWEEP)) {
+ /* dot in the middle (to draw a line down the center) */
+ p->tmpline_u8[w / 2] = 255;
+ p->tmpline_u8[(int) x] = 255;
+ }
+
videotestsrc_blend_line (v, p->tmpline, p->tmpline_u8,
- &p->foreground_color, &p->background_color, w);
+ foreground_color, background_color, w);
videotestsrc_convert_tmpline (p, frame, i);
}
+
+ if ((v->motion_type == GST_VIDEO_TEST_SRC_SWEEP) ||
+ (v->motion_type == GST_VIDEO_TEST_SRC_HSWEEP)) {
+ /* draw a line across the middle of frame and ball. */
+ for (i = 0; i < w; i++) {
+ p->tmpline_u8[i] = 255;
+ }
+ videotestsrc_blend_line (v, p->tmpline, p->tmpline_u8,
+ foreground_color, background_color, w);
+ videotestsrc_convert_tmpline (p, frame, h / 2);
+ videotestsrc_convert_tmpline (p, frame, y);
+ }
}
static void
}
void
-gst_video_test_src_pinwheel (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_pinwheel (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_spokes (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_spokes (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_gradient (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
}
void
-gst_video_test_src_colors (GstVideoTestSrc * v, GstVideoFrame * frame)
+gst_video_test_src_colors (GstVideoTestSrc * v, GstClockTime pts,
+ GstVideoFrame * frame)
{
int i;
int j;
};
#define PAINT_INFO_INIT {0, }
-void gst_video_test_src_smpte (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_snow (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_black (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_white (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_red (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_green (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_blue (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_solid (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_blink (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_checkers1 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_checkers2 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_checkers4 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_checkers8 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_circular (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_zoneplate (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_gamut (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_ball (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_bar (GstVideoTestSrc * v, GstVideoFrame *frame);
-void gst_video_test_src_pinwheel (GstVideoTestSrc * v, GstVideoFrame * frame);
-void gst_video_test_src_spokes (GstVideoTestSrc * v, GstVideoFrame * frame);
-void gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame);
-void gst_video_test_src_colors (GstVideoTestSrc * v, GstVideoFrame * frame);
+void gst_video_test_src_smpte (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_snow (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_black (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_white (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_red (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_green (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_blue (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_solid (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_blink (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_checkers1 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_checkers2 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_checkers4 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_checkers8 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_circular (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_zoneplate (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_gamut (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_ball (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_bar (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame *frame);
+void gst_video_test_src_pinwheel (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame * frame);
+void gst_video_test_src_spokes (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame * frame);
+void gst_video_test_src_gradient (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame * frame);
+void gst_video_test_src_colors (GstVideoTestSrc * v, GstClockTime pts, GstVideoFrame * frame);
#endif