summaryrefslogtreecommitdiffstats
path: root/gst/effectv/gstdice.c
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
commit5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch)
tree74a5b1eaf3a324b520e64e87404fd0b3018a7829 /gst/effectv/gstdice.c
parent1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff)
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'gst/effectv/gstdice.c')
-rw-r--r--gst/effectv/gstdice.c222
1 files changed, 114 insertions, 108 deletions
diff --git a/gst/effectv/gstdice.c b/gst/effectv/gstdice.c
index ba2d1d6c..a7cbbc36 100644
--- a/gst/effectv/gstdice.c
+++ b/gst/effectv/gstdice.c
@@ -35,12 +35,12 @@ typedef struct _GstDiceTVClass GstDiceTVClass;
#define MAX_CUBE_BITS 5
#define MIN_CUBE_BITS 0
-typedef enum _dice_dir
+typedef enum _dice_dir
{
- DICE_UP = 0,
- DICE_RIGHT = 1,
- DICE_DOWN = 2,
- DICE_LEFT = 3
+ DICE_UP = 0,
+ DICE_RIGHT = 1,
+ DICE_DOWN = 2,
+ DICE_LEFT = 3
} DiceDir;
struct _GstDiceTV
@@ -48,7 +48,7 @@ struct _GstDiceTV
GstVideofilter videofilter;
gint width, height;
- gchar* dicemap;
+ gchar *dicemap;
gint g_cube_bits;
gint g_cube_size;
@@ -60,7 +60,7 @@ struct _GstDiceTVClass
{
GstVideofilterClass parent_class;
- void (*reset) (GstElement *element);
+ void (*reset) (GstElement * element);
};
/* Filter signals and args */
@@ -77,29 +77,30 @@ enum
ARG_CUBE_BITS,
};
-static void gst_dicetv_base_init (gpointer g_class);
-static void gst_dicetv_class_init (gpointer g_class, gpointer class_data);
-static void gst_dicetv_init (GTypeInstance *instance, gpointer g_class);
+static void gst_dicetv_base_init (gpointer g_class);
+static void gst_dicetv_class_init (gpointer g_class, gpointer class_data);
+static void gst_dicetv_init (GTypeInstance * instance, gpointer g_class);
-static void gst_dicetv_reset_handler (GstElement *elem);
-static void gst_dicetv_create_map (GstDiceTV *filter);
+static void gst_dicetv_reset_handler (GstElement * elem);
+static void gst_dicetv_create_map (GstDiceTV * filter);
-static void gst_dicetv_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_dicetv_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static void gst_dicetv_setup (GstVideofilter *videofilter);
-static void gst_dicetv_draw (GstVideofilter *videofilter, void *d, void *s);
+static void gst_dicetv_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_dicetv_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_dicetv_setup (GstVideofilter * videofilter);
+static void gst_dicetv_draw (GstVideofilter * videofilter, void *d, void *s);
static guint gst_dicetv_signals[LAST_SIGNAL] = { 0 };
-GType gst_dicetv_get_type (void)
+GType
+gst_dicetv_get_type (void)
{
static GType dicetv_type = 0;
if (!dicetv_type) {
static const GTypeInfo dicetv_info = {
- sizeof (GstDiceTVClass),
+ sizeof (GstDiceTVClass),
gst_dicetv_base_init,
NULL,
(GClassInitFunc) gst_dicetv_class_init,
@@ -110,37 +111,41 @@ GType gst_dicetv_get_type (void)
(GInstanceInitFunc) gst_dicetv_init,
};
- dicetv_type = g_type_register_static (GST_TYPE_VIDEOFILTER, "GstDiceTV", &dicetv_info, 0);
+ dicetv_type =
+ g_type_register_static (GST_TYPE_VIDEOFILTER, "GstDiceTV", &dicetv_info,
+ 0);
}
return dicetv_type;
}
static GstVideofilterFormat gst_dicetv_formats[] = {
- { "RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00, 0x000000ff },
- { "RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000, 0x0000ff00 },
- { "RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00, 0x00ff0000 },
- { "RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 },
+ {"RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00,
+ 0x000000ff},
+ {"RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000,
+ 0x0000ff00},
+ {"RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00,
+ 0x00ff0000},
+ {"RGB ", 32, gst_dicetv_draw, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000,
+ 0xff000000},
};
static void
gst_dicetv_base_init (gpointer g_class)
{
/* elementfactory information */
- static GstElementDetails gst_dicetv_details = GST_ELEMENT_DETAILS (
- "DiceTV",
- "Filter/Effect/Video",
- "'Dices' the screen up into many small squares",
- "Wim Taymans <wim.taymans@chello.be>"
- );
+ static GstElementDetails gst_dicetv_details = GST_ELEMENT_DETAILS ("DiceTV",
+ "Filter/Effect/Video",
+ "'Dices' the screen up into many small squares",
+ "Wim Taymans <wim.taymans@chello.be>");
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
int i;
-
+
gst_element_class_set_details (element_class, &gst_dicetv_details);
- for(i=0; i < G_N_ELEMENTS(gst_dicetv_formats); i++) {
- gst_videofilter_class_add_format(videofilter_class,
+ for (i = 0; i < G_N_ELEMENTS (gst_dicetv_formats); i++) {
+ gst_videofilter_class_add_format (videofilter_class,
gst_dicetv_formats + i);
}
@@ -159,19 +164,17 @@ gst_dicetv_class_init (gpointer g_class, gpointer class_data)
dicetv_class = GST_DICETV_CLASS (g_class);
gst_dicetv_signals[RESET_SIGNAL] =
- g_signal_new ("reset",
- G_TYPE_FROM_CLASS (g_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstDiceTVClass, reset),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("reset",
+ G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstDiceTVClass, reset),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
dicetv_class->reset = gst_dicetv_reset_handler;
-
+
g_object_class_install_property (gobject_class, ARG_CUBE_BITS,
- g_param_spec_int ("square_bits","Square Bits","The size of the Squares",
- MIN_CUBE_BITS, MAX_CUBE_BITS, DEFAULT_CUBE_BITS, G_PARAM_READWRITE));
+ g_param_spec_int ("square_bits", "Square Bits", "The size of the Squares",
+ MIN_CUBE_BITS, MAX_CUBE_BITS, DEFAULT_CUBE_BITS, G_PARAM_READWRITE));
gobject_class->set_property = gst_dicetv_set_property;
gobject_class->get_property = gst_dicetv_get_property;
@@ -180,7 +183,7 @@ gst_dicetv_class_init (gpointer g_class, gpointer class_data)
}
static void
-gst_dicetv_setup (GstVideofilter *videofilter)
+gst_dicetv_setup (GstVideofilter * videofilter)
{
GstDiceTV *dicetv;
@@ -191,12 +194,13 @@ gst_dicetv_setup (GstVideofilter *videofilter)
dicetv->height = gst_videofilter_get_input_height (videofilter);
g_free (dicetv->dicemap);
- dicetv->dicemap = (gchar *) g_malloc (dicetv->height * dicetv->width * sizeof(char));
+ dicetv->dicemap =
+ (gchar *) g_malloc (dicetv->height * dicetv->width * sizeof (char));
gst_dicetv_create_map (dicetv);
}
static void
-gst_dicetv_init (GTypeInstance *instance, gpointer g_class)
+gst_dicetv_init (GTypeInstance * instance, gpointer g_class)
{
GstDiceTV *filter = GST_DICETV (instance);
@@ -208,7 +212,7 @@ gst_dicetv_init (GTypeInstance *instance, gpointer g_class)
}
static void
-gst_dicetv_reset_handler (GstElement *element)
+gst_dicetv_reset_handler (GstElement * element)
{
GstDiceTV *filter = GST_DICETV (element);
@@ -217,14 +221,14 @@ gst_dicetv_reset_handler (GstElement *element)
static unsigned int
fastrand (void)
-{
+{
static unsigned int fastrand_val;
return (fastrand_val = fastrand_val * 1103515245 + 12345);
}
-static void
-gst_dicetv_draw (GstVideofilter *videofilter, void *d, void *s)
+static void
+gst_dicetv_draw (GstVideofilter * videofilter, void *d, void *s)
{
GstDiceTV *filter;
guint32 *src;
@@ -236,10 +240,10 @@ gst_dicetv_draw (GstVideofilter *videofilter, void *d, void *s)
gint video_width = filter->width;
gint g_cube_bits = filter->g_cube_bits;
gint g_cube_size = filter->g_cube_size;
-
+
filter = GST_DICETV (videofilter);
- src = (guint32 *)s;
- dest = (guint32 *)d;
+ src = (guint32 *) s;
+ dest = (guint32 *) d;
video_width = filter->width;
g_cube_bits = filter->g_cube_bits;
@@ -248,64 +252,64 @@ gst_dicetv_draw (GstVideofilter *videofilter, void *d, void *s)
map_i = 0;
for (map_y = 0; map_y < filter->g_map_height; map_y++) {
for (map_x = 0; map_x < filter->g_map_width; map_x++) {
- base = (map_y << g_cube_bits) * video_width + (map_x << g_cube_bits);
-
- switch (filter->dicemap[map_i]) {
- case DICE_UP:
- for (dy = 0; dy < g_cube_size; dy++) {
- i = base + dy * video_width;
- for (dx = 0; dx < g_cube_size; dx++) {
- dest[i] = src[i];
- i++;
- }
- }
- break;
- case DICE_LEFT:
- for (dy = 0; dy < g_cube_size; dy++) {
- i = base + dy * video_width;
-
- for (dx = 0; dx < g_cube_size; dx++) {
- di = base + (dx * video_width) + (g_cube_size - dy - 1);
- dest[di] = src[i];
- i++;
- }
- }
- break;
- case DICE_DOWN:
- for (dy = 0; dy < g_cube_size; dy++) {
- di = base + dy * video_width;
- i = base + (g_cube_size - dy - 1) * video_width + g_cube_size;
- for (dx = 0; dx < g_cube_size; dx++) {
- i--;
- dest[di] = src[i];
- di++;
- }
- }
- break;
- case DICE_RIGHT:
- for (dy = 0; dy < g_cube_size; dy++) {
- i = base + (dy * video_width);
- for (dx = 0; dx < g_cube_size; dx++) {
- di = base + dy + (g_cube_size - dx - 1) * video_width;
- dest[di] = src[i];
- i++;
- }
- }
- break;
- default:
- g_assert_not_reached ();
- break;
+ base = (map_y << g_cube_bits) * video_width + (map_x << g_cube_bits);
+
+ switch (filter->dicemap[map_i]) {
+ case DICE_UP:
+ for (dy = 0; dy < g_cube_size; dy++) {
+ i = base + dy * video_width;
+ for (dx = 0; dx < g_cube_size; dx++) {
+ dest[i] = src[i];
+ i++;
+ }
+ }
+ break;
+ case DICE_LEFT:
+ for (dy = 0; dy < g_cube_size; dy++) {
+ i = base + dy * video_width;
+
+ for (dx = 0; dx < g_cube_size; dx++) {
+ di = base + (dx * video_width) + (g_cube_size - dy - 1);
+ dest[di] = src[i];
+ i++;
+ }
+ }
+ break;
+ case DICE_DOWN:
+ for (dy = 0; dy < g_cube_size; dy++) {
+ di = base + dy * video_width;
+ i = base + (g_cube_size - dy - 1) * video_width + g_cube_size;
+ for (dx = 0; dx < g_cube_size; dx++) {
+ i--;
+ dest[di] = src[i];
+ di++;
+ }
+ }
+ break;
+ case DICE_RIGHT:
+ for (dy = 0; dy < g_cube_size; dy++) {
+ i = base + (dy * video_width);
+ for (dx = 0; dx < g_cube_size; dx++) {
+ di = base + dy + (g_cube_size - dx - 1) * video_width;
+ dest[di] = src[i];
+ i++;
+ }
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
}
map_i++;
}
}
}
-static void
-gst_dicetv_create_map (GstDiceTV *filter)
+static void
+gst_dicetv_create_map (GstDiceTV * filter)
{
gint x, y, i;
-
+
filter->g_map_height = filter->height >> filter->g_cube_bits;
filter->g_map_width = filter->width >> filter->g_cube_bits;
filter->g_cube_size = 1 << filter->g_cube_bits;
@@ -313,16 +317,17 @@ gst_dicetv_create_map (GstDiceTV *filter)
i = 0;
for (y = 0; y < filter->g_map_height; y++) {
- for(x = 0; x < filter->g_map_width; x++) {
+ for (x = 0; x < filter->g_map_width; x++) {
// dicemap[i] = ((i + y) & 0x3); /* Up, Down, Left or Right */
- filter->dicemap[i] = (fastrand() >> 24) & 0x03;
+ filter->dicemap[i] = (fastrand () >> 24) & 0x03;
i++;
}
}
}
static void
-gst_dicetv_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_dicetv_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstDiceTV *filter;
@@ -341,7 +346,8 @@ gst_dicetv_set_property (GObject * object, guint prop_id, const GValue * value,
}
static void
-gst_dicetv_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_dicetv_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstDiceTV *filter;