gstreamer/gst/videotestsrc/generate_sine_table.c

44 lines
667 B
C
Raw Normal View History

2010-09-06 03:57:48 +00:00
#include <stdio.h>
#include <math.h>
2011-06-01 05:14:09 +00:00
#include <glib.h>
2010-09-06 03:57:48 +00:00
static int
get_value (int i)
{
int x;
2011-06-01 05:14:09 +00:00
x = floor (256 * (0.5 + 0.5 * sin (i * 2 * G_PI / 256)));
2010-09-06 03:57:48 +00:00
if (x > 255)
x = 255;
return x;
}
int
main (int argc, char *argv[])
{
int i;
int j;
printf ("static const guint8\n");
printf ("sine_table[256] = {\n");
for (i = 0; i < 256; i += 8) {
printf (" ");
for (j = 0; j < 8; j++) {
printf ("%3d", get_value (i + j));
if (j != 7) {
printf (", ");
} else {
if (i + j != 255) {
printf (",\n");
} else {
printf ("\n");
}
}
}
}
printf ("};\n");
return 0;
2010-09-06 03:57:48 +00:00
}