Commit e859791a authored by David Schleef's avatar David Schleef
Browse files

gst/videotestsrc/: Add a test pattern called "circular", which has concentric...

gst/videotestsrc/: Add a test pattern called "circular", which has concentric rings with varying radial frequency.  T...

Original commit message from CVS:
* 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.
parent 8676f3dc
2007-04-03 David Schleef <ds@schleef.org>
* 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 <wim@fluendo.com>
 
Patch by: Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
......@@ -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 ();
}
......
......@@ -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;
......
......@@ -30,6 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
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 = &pi;
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)
{
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment