videotestsrc: add all colors mode

This commit is contained in:
Wim Taymans 2015-03-10 11:55:11 +01:00
parent 06fd6f2f63
commit 9bbfc3c848
4 changed files with 35 additions and 1 deletions

View file

@ -152,6 +152,7 @@ gst_video_test_src_pattern_get_type (void)
{GST_VIDEO_TEST_SRC_PINWHEEL, "Pinwheel", "pinwheel"}, {GST_VIDEO_TEST_SRC_PINWHEEL, "Pinwheel", "pinwheel"},
{GST_VIDEO_TEST_SRC_SPOKES, "Spokes", "spokes"}, {GST_VIDEO_TEST_SRC_SPOKES, "Spokes", "spokes"},
{GST_VIDEO_TEST_SRC_GRADIENT, "Gradient", "gradient"}, {GST_VIDEO_TEST_SRC_GRADIENT, "Gradient", "gradient"},
{GST_VIDEO_TEST_SRC_COLORS, "Colors", "colors"},
{0, NULL, NULL} {0, NULL, NULL}
}; };
@ -428,6 +429,9 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc,
case GST_VIDEO_TEST_SRC_GRADIENT: case GST_VIDEO_TEST_SRC_GRADIENT:
videotestsrc->make_image = gst_video_test_src_gradient; videotestsrc->make_image = gst_video_test_src_gradient;
break; break;
case GST_VIDEO_TEST_SRC_COLORS:
videotestsrc->make_image = gst_video_test_src_colors;
break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }

View file

@ -64,6 +64,8 @@ G_BEGIN_DECLS
* @GST_VIDEO_TEST_SRC_BAR: Bar with foreground color * @GST_VIDEO_TEST_SRC_BAR: Bar with foreground color
* @GST_VIDEO_TEST_SRC_PINWHEEL: Pinwheel * @GST_VIDEO_TEST_SRC_PINWHEEL: Pinwheel
* @GST_VIDEO_TEST_SRC_SPOKES: Spokes * @GST_VIDEO_TEST_SRC_SPOKES: Spokes
* @GST_VIDEO_TEST_SRC_GRADIENT: Gradient
* @GST_VIDEO_TEST_SRC_COLORS: All colors
* *
* The test pattern to produce. * The test pattern to produce.
* *
@ -108,7 +110,8 @@ typedef enum {
GST_VIDEO_TEST_SRC_BAR, GST_VIDEO_TEST_SRC_BAR,
GST_VIDEO_TEST_SRC_PINWHEEL, GST_VIDEO_TEST_SRC_PINWHEEL,
GST_VIDEO_TEST_SRC_SPOKES, GST_VIDEO_TEST_SRC_SPOKES,
GST_VIDEO_TEST_SRC_GRADIENT GST_VIDEO_TEST_SRC_GRADIENT,
GST_VIDEO_TEST_SRC_COLORS
} GstVideoTestSrcPattern; } GstVideoTestSrcPattern;
typedef struct _GstVideoTestSrc GstVideoTestSrc; typedef struct _GstVideoTestSrc GstVideoTestSrc;

View file

@ -1362,3 +1362,29 @@ gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame)
videotestsrc_convert_tmpline (p, frame, j); videotestsrc_convert_tmpline (p, frame, j);
} }
} }
void
gst_video_test_src_colors (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++) {
for (i = 0; i < w; i++) {
p->tmpline[i * 4 + 0] = 0xff;
p->tmpline[i * 4 + 1] = ((i * 4096) / w) % 256;
p->tmpline[i * 4 + 2] = (((j * 16) / h) << 4) | ((i * 16) / w);
p->tmpline[i * 4 + 3] = ((j * 4096) / h) % 256;
}
videotestsrc_convert_tmpline (p, frame, j);
}
}

View file

@ -83,5 +83,6 @@ void gst_video_test_src_bar (GstVideoTestSrc * v, GstVideoFrame *fra
void gst_video_test_src_pinwheel (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_spokes (GstVideoTestSrc * v, GstVideoFrame * frame);
void gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame); void gst_video_test_src_gradient (GstVideoTestSrc * v, GstVideoFrame * frame);
void gst_video_test_src_colors (GstVideoTestSrc * v, GstVideoFrame * frame);
#endif #endif