diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 1b5de08d88..7efc5d20b6 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -149,6 +149,8 @@ gst_video_test_src_pattern_get_type (void) {GST_VIDEO_TEST_SRC_BALL, "Moving ball", "ball"}, {GST_VIDEO_TEST_SRC_SMPTE100, "SMPTE 100% color bars", "smpte100"}, {GST_VIDEO_TEST_SRC_BAR, "Bar", "bar"}, + {GST_VIDEO_TEST_SRC_PINWHEEL, "Pinwheel", "pinwheel"}, + {GST_VIDEO_TEST_SRC_SPOKES, "Spokes", "spokes"}, {0, NULL, NULL} }; @@ -341,7 +343,7 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc, { videotestsrc->pattern_type = pattern_type; - GST_DEBUG_OBJECT (videotestsrc, "setting pattern to %d", pattern_type); + GST_ERROR_OBJECT (videotestsrc, "setting pattern to %d", pattern_type); switch (pattern_type) { case GST_VIDEO_TEST_SRC_SMPTE: @@ -407,6 +409,12 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc, case GST_VIDEO_TEST_SRC_BAR: videotestsrc->make_image = gst_video_test_src_bar; break; + case GST_VIDEO_TEST_SRC_PINWHEEL: + videotestsrc->make_image = gst_video_test_src_pinwheel; + break; + case GST_VIDEO_TEST_SRC_SPOKES: + videotestsrc->make_image = gst_video_test_src_spokes; + break; default: g_assert_not_reached (); } diff --git a/gst/videotestsrc/gstvideotestsrc.h b/gst/videotestsrc/gstvideotestsrc.h index a836104a36..39ec442127 100644 --- a/gst/videotestsrc/gstvideotestsrc.h +++ b/gst/videotestsrc/gstvideotestsrc.h @@ -62,6 +62,8 @@ G_BEGIN_DECLS * @GST_VIDEO_TEST_SRC_BALL: Moving ball * @GST_VIDEO_TEST_SRC_SMPTE100: SMPTE test pattern (100% color bars) * @GST_VIDEO_TEST_SRC_BAR: Bar with foreground color + * @GST_VIDEO_TEST_SRC_PINWHEEL: Pinwheel + * @GST_VIDEO_TEST_SRC_SPOKES: Spokes * * The test pattern to produce. * @@ -103,7 +105,9 @@ typedef enum { GST_VIDEO_TEST_SRC_SOLID, GST_VIDEO_TEST_SRC_BALL, GST_VIDEO_TEST_SRC_SMPTE100, - GST_VIDEO_TEST_SRC_BAR + GST_VIDEO_TEST_SRC_BAR, + GST_VIDEO_TEST_SRC_PINWHEEL, + GST_VIDEO_TEST_SRC_SPOKES } GstVideoTestSrcPattern; typedef struct _GstVideoTestSrc GstVideoTestSrc; diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index 8aabf2ac03..2fec7e43f6 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -1222,3 +1222,104 @@ convert_hline_bayer (paintinfo * p, GstVideoFrame * frame, int y) } } } + +void +gst_video_test_src_pinwheel (GstVideoTestSrc * v, GstVideoFrame * frame) +{ + int i; + int j; + int k; + int t = v->n_frames; + paintinfo pi = PAINT_INFO_INIT; + paintinfo *p = π + struct vts_color_struct color; + int w = frame->info.width, h = frame->info.height; + double c[20]; + double s[20]; + + videotestsrc_setup_paintinfo (v, p, w, h); + + color = p->colors[COLOR_BLACK]; + p->color = &color; + + for (k = 0; k < 19; k++) { + double theta = M_PI / 19 * k + 0.001 * v->kt * t; + c[k] = cos (theta); + s[k] = sin (theta); + } + + for (j = 0; j < h; j++) { + for (i = 0; i < w; i++) { + double v; + v = 0; + for (k = 0; k < 19; k++) { + double x, y; + + x = c[k] * (i - 0.5 * w) + s[k] * (j - 0.5 * h); + x *= 1.0; + + y = CLAMP (x, -1, 1); + if (k & 1) + y = -y; + + v += y; + } + + p->tmpline_u8[i] = CLAMP (rint (v * 128 + 128), 0, 255); + } + videotestsrc_blend_line (v, p->tmpline, p->tmpline_u8, + &p->foreground_color, &p->background_color, w); + videotestsrc_convert_tmpline (p, frame, j); + } +} + +void +gst_video_test_src_spokes (GstVideoTestSrc * v, GstVideoFrame * frame) +{ + int i; + int j; + int k; + int t = v->n_frames; + paintinfo pi = PAINT_INFO_INIT; + paintinfo *p = π + struct vts_color_struct color; + int w = frame->info.width, h = frame->info.height; + double c[20]; + double s[20]; + + videotestsrc_setup_paintinfo (v, p, w, h); + + color = p->colors[COLOR_BLACK]; + p->color = &color; + + for (k = 0; k < 19; k++) { + double theta = M_PI / 19 * k + 0.001 * v->kt * t; + c[k] = cos (theta); + s[k] = sin (theta); + } + + for (j = 0; j < h; j++) { + for (i = 0; i < w; i++) { + double v; + v = 0; + for (k = 0; k < 19; k++) { + double x, y; + double sharpness = 1.0; + double linewidth = 2.0; + + x = c[k] * (i - 0.5 * w) + s[k] * (j - 0.5 * h); + x = linewidth * 0.5 - fabs (x); + x *= sharpness; + + y = CLAMP (x + 0.5, 0.0, 1.0); + + v += y; + } + + p->tmpline_u8[i] = CLAMP (rint (v * 255), 0, 255); + } + videotestsrc_blend_line (v, p->tmpline, p->tmpline_u8, + &p->foreground_color, &p->background_color, w); + videotestsrc_convert_tmpline (p, frame, j); + } +} diff --git a/gst/videotestsrc/videotestsrc.h b/gst/videotestsrc/videotestsrc.h index 6a69c8c23e..c1e5e1fb5c 100644 --- a/gst/videotestsrc/videotestsrc.h +++ b/gst/videotestsrc/videotestsrc.h @@ -80,5 +80,7 @@ void gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, GstVideoFrame * 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); #endif