diff --git a/ChangeLog b/ChangeLog index e18358b6d3..7112d10a50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-04-03 David Schleef + + * gst/videotestsrc/gstvideotestsrc.c: + * gst/videotestsrc/gstvideotestsrc.h: + * gst/videotestsrc/videotestsrc.c: + * gst/videotestsrc/videotestsrc.h: + Add a test pattern called "circular", which has concentric + rings with varying radial frequency. The main purpose of this + pattern is to test fidelity loss in a filter or scaler element. + Notably, this pattern is scale invariant, and is optimally viewed + with a width (and height) of 400. + 2007-04-03 Wim Taymans Patch by: Tommi Myöhänen diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 08f8f92d59..5d76b313c7 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -113,6 +113,7 @@ gst_video_test_src_pattern_get_type (void) {GST_VIDEO_TEST_SRC_CHECKERS2, "Checkers 2px", "checkers-2"}, {GST_VIDEO_TEST_SRC_CHECKERS4, "Checkers 4px", "checkers-4"}, {GST_VIDEO_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"}, + {GST_VIDEO_TEST_SRC_CIRCULAR, "Circular", "circular"}, {0, NULL, NULL} }; @@ -243,6 +244,9 @@ gst_video_test_src_set_pattern (GstVideoTestSrc * videotestsrc, case GST_VIDEO_TEST_SRC_CHECKERS8: videotestsrc->make_image = gst_video_test_src_checkers8; break; + case GST_VIDEO_TEST_SRC_CIRCULAR: + videotestsrc->make_image = gst_video_test_src_circular; + break; default: g_assert_not_reached (); } diff --git a/gst/videotestsrc/gstvideotestsrc.h b/gst/videotestsrc/gstvideotestsrc.h index 8e05d657a6..0027ffb42a 100644 --- a/gst/videotestsrc/gstvideotestsrc.h +++ b/gst/videotestsrc/gstvideotestsrc.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS * @GST_VIDEO_TEST_SRC_CHECKERS2: Checkers pattern (2px) * @GST_VIDEO_TEST_SRC_CHECKERS4: Checkers pattern (4px) * @GST_VIDEO_TEST_SRC_CHECKERS8: Checkers pattern (8px) + * @GST_VIDEO_TEST_SRC_CIRCULAR: Circular pattern * * The test pattern to produce. */ @@ -64,7 +65,8 @@ typedef enum { GST_VIDEO_TEST_SRC_CHECKERS1, GST_VIDEO_TEST_SRC_CHECKERS2, GST_VIDEO_TEST_SRC_CHECKERS4, - GST_VIDEO_TEST_SRC_CHECKERS8 + GST_VIDEO_TEST_SRC_CHECKERS8, + GST_VIDEO_TEST_SRC_CIRCULAR } GstVideoTestSrcPattern; typedef struct _GstVideoTestSrc GstVideoTestSrc; diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index abaa2121d0..1a9d56d872 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -30,6 +30,7 @@ #include #include +#include static unsigned char random_char (void) @@ -901,6 +902,91 @@ gst_video_test_src_checkers8 (GstVideoTestSrc * v, guchar * dest, int w, int h) } } +#undef SCALE_AMPLITUDE +void +gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest, + int w, int h) +{ + int i; + int j; + paintinfo pi = { NULL, }; + paintinfo *p = π + struct fourcc_list_struct *fourcc; + struct vts_color_struct color; + static uint8_t sine_array[256]; + static int sine_array_inited = FALSE; + double freq[8]; + +#ifdef SCALE_AMPLITUDE + double ampl[8]; +#endif + int d; + + if (!sine_array_inited) { + for (i = 0; i < 256; i++) { + sine_array[i] = + floor (255 * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5); + } + sine_array_inited = TRUE; + } + + p->width = w; + p->height = h; + fourcc = v->fourcc; + if (fourcc == NULL) + return; + + fourcc->paint_setup (p, dest); + p->paint_hline = fourcc->paint_hline; + + color = vts_colors[COLOR_BLACK]; + p->color = &color; + + for (i = 1; i < 8; i++) { + freq[i] = 200 * pow (2.0, -(i - 1) / 4.0); +#ifdef SCALE_AMPLITUDE + { + double x; + + x = 2 * M_PI * freq[i] / w; + ampl[i] = sin (x) / x; + } +#endif + } + + for (i = 0; i < w; i++) { + for (j = 0; j < h; j++) { + double dist; + int seg; + + dist = + sqrt ((2 * i - w) * (2 * i - w) + (2 * j - h) * (2 * j - + h)) / (2 * w); + seg = floor (dist * 16); + if (seg == 0 || seg >= 8) { + color.Y = 255; + } else { +#ifdef SCALE_AMPLITUDE + double a; +#endif + d = floor (256 * dist * freq[seg] + 0.5); +#ifdef SCALE_AMPLITUDE + a = ampl[seg]; + if (a < 0) + a = 0; + color.Y = 128 + a * (sine_array[d & 0xff] - 128); +#else + color.Y = sine_array[d & 0xff]; +#endif + } + color.R = color.Y; + color.G = color.Y; + color.B = color.Y; + p->paint_hline (p, i, j, 1); + } + } +} + static void paint_setup_I420 (paintinfo * p, unsigned char *dest) { diff --git a/gst/videotestsrc/videotestsrc.h b/gst/videotestsrc/videotestsrc.h index c9d522436e..5ad6b0e7de 100644 --- a/gst/videotestsrc/videotestsrc.h +++ b/gst/videotestsrc/videotestsrc.h @@ -91,6 +91,8 @@ void gst_video_test_src_checkers4 (GstVideoTestSrc * v, unsigned char *dest, int w, int h); void gst_video_test_src_checkers8 (GstVideoTestSrc * v, unsigned char *dest, int w, int h); +void gst_video_test_src_circular (GstVideoTestSrc * v, + unsigned char *dest, int w, int h); extern struct fourcc_list_struct fourcc_list[]; extern int n_fourccs;