From 042b25542c6de5a9e9a6d226c9b303aa023eca70 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 Oct 2014 11:26:24 +0200 Subject: [PATCH] videotestsrc: add gradient pattern Makes a gradient between background and foreground color. --- gst/videotestsrc/gstvideotestsrc.c | 4 ++++ gst/videotestsrc/gstvideotestsrc.h | 3 ++- gst/videotestsrc/videotestsrc.c | 26 ++++++++++++++++++++++++++ gst/videotestsrc/videotestsrc.h | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 6951b3d..94013f9 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -151,6 +151,7 @@ gst_video_test_src_pattern_get_type (void) {GST_VIDEO_TEST_SRC_BAR, "Bar", "bar"}, {GST_VIDEO_TEST_SRC_PINWHEEL, "Pinwheel", "pinwheel"}, {GST_VIDEO_TEST_SRC_SPOKES, "Spokes", "spokes"}, + {GST_VIDEO_TEST_SRC_GRADIENT, "Gradient", "gradient"}, {0, NULL, NULL} }; @@ -423,6 +424,9 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc, case GST_VIDEO_TEST_SRC_SPOKES: videotestsrc->make_image = gst_video_test_src_spokes; break; + case GST_VIDEO_TEST_SRC_GRADIENT: + videotestsrc->make_image = gst_video_test_src_gradient; + break; default: g_assert_not_reached (); } diff --git a/gst/videotestsrc/gstvideotestsrc.h b/gst/videotestsrc/gstvideotestsrc.h index 468aad7..1c77a8e 100644 --- a/gst/videotestsrc/gstvideotestsrc.h +++ b/gst/videotestsrc/gstvideotestsrc.h @@ -107,7 +107,8 @@ typedef enum { GST_VIDEO_TEST_SRC_SMPTE100, GST_VIDEO_TEST_SRC_BAR, GST_VIDEO_TEST_SRC_PINWHEEL, - GST_VIDEO_TEST_SRC_SPOKES + GST_VIDEO_TEST_SRC_SPOKES, + GST_VIDEO_TEST_SRC_GRADIENT } GstVideoTestSrcPattern; typedef struct _GstVideoTestSrc GstVideoTestSrc; diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index b4adf90..debbca0 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -1336,3 +1336,29 @@ gst_video_test_src_spokes (GstVideoTestSrc * v, GstVideoFrame * frame) videotestsrc_convert_tmpline (p, frame, j); } } + +void +gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame) +{ + int i; + int j; + paintinfo pi = PAINT_INFO_INIT; + paintinfo *p = π + struct vts_color_struct color; + int w = frame->info.width, h = frame->info.height; + + videotestsrc_setup_paintinfo (v, p, w, h); + + color = p->colors[COLOR_BLACK]; + p->color = &color; + + for (j = 0; j < h; j++) { + int y = j * 255.0 / h; + for (i = 0; i < w; i++) { + p->tmpline_u8[i] = y; + } + 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 c1e5e1f..9a23b9a 100644 --- a/gst/videotestsrc/videotestsrc.h +++ b/gst/videotestsrc/videotestsrc.h @@ -82,5 +82,6 @@ void gst_video_test_src_smpte100 (GstVideoTestSrc * v, GstVideoFrame *fra 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); #endif -- 2.7.4