mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
videotestsrc: Add pinwheel and spokes patterns
This commit is contained in:
parent
965546192d
commit
0c4beda8f0
4 changed files with 117 additions and 2 deletions
|
@ -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 ();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue