summaryrefslogtreecommitdiffstats
path: root/gst/effectv/gstwarp.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/gstwarp.c
parent1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff)
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'gst/effectv/gstwarp.c')
-rw-r--r--gst/effectv/gstwarp.c199
1 files changed, 107 insertions, 92 deletions
diff --git a/gst/effectv/gstwarp.c b/gst/effectv/gstwarp.c
index 82c24ddd..4eb81a65 100644
--- a/gst/effectv/gstwarp.c
+++ b/gst/effectv/gstwarp.c
@@ -62,45 +62,51 @@
typedef struct _GstWarpTV GstWarpTV;
typedef struct _GstWarpTVClass GstWarpTVClass;
-struct _GstWarpTV {
+struct _GstWarpTV
+{
GstVideofilter videofilter;
gint width, height;
gint *offstable;
gint32 *disttable;
gint32 ctable[1024];
- gint32 sintable[1024+256];
+ gint32 sintable[1024 + 256];
gint tval;
};
-struct _GstWarpTVClass {
+struct _GstWarpTVClass
+{
GstVideofilterClass parent_class;
};
/* GstWarpTV signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_warptv_base_init (gpointer g_class);
-static void gst_warptv_class_init (gpointer g_class, gpointer class_data);
-static void gst_warptv_init (GTypeInstance *instance, gpointer g_class);
+static void gst_warptv_base_init (gpointer g_class);
+static void gst_warptv_class_init (gpointer g_class, gpointer class_data);
+static void gst_warptv_init (GTypeInstance * instance, gpointer g_class);
-static void gst_warptv_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_warptv_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_warptv_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_warptv_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_warptv_setup(GstVideofilter *videofilter);
-static void initSinTable (GstWarpTV *filter);
-static void initOffsTable (GstWarpTV *filter);
-static void initDistTable (GstWarpTV *filter);
-static void gst_warptv_rgb32 (GstVideofilter *videofilter, void *d, void *s);
+static void gst_warptv_setup (GstVideofilter * videofilter);
+static void initSinTable (GstWarpTV * filter);
+static void initOffsTable (GstWarpTV * filter);
+static void initDistTable (GstWarpTV * filter);
+static void gst_warptv_rgb32 (GstVideofilter * videofilter, void *d, void *s);
GType
gst_warptv_get_type (void)
@@ -109,46 +115,48 @@ gst_warptv_get_type (void)
if (!warptv_type) {
static const GTypeInfo warptv_info = {
- sizeof(GstWarpTVClass),
+ sizeof (GstWarpTVClass),
gst_warptv_base_init,
NULL,
gst_warptv_class_init,
NULL,
NULL,
- sizeof(GstWarpTV),
+ sizeof (GstWarpTV),
0,
gst_warptv_init,
};
- warptv_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
- "GstWarpTV", &warptv_info, 0);
+ warptv_type = g_type_register_static (GST_TYPE_VIDEOFILTER,
+ "GstWarpTV", &warptv_info, 0);
}
return warptv_type;
}
static GstVideofilterFormat gst_warptv_formats[] = {
- { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00, 0x000000ff },
- { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000, 0x0000ff00 },
- { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00, 0x00ff0000 },
- { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 },
+ {"RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00,
+ 0x000000ff},
+ {"RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000,
+ 0x0000ff00},
+ {"RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00,
+ 0x00ff0000},
+ {"RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000,
+ 0xff000000},
};
static void
gst_warptv_base_init (gpointer g_class)
{
- static GstElementDetails warptv_details = GST_ELEMENT_DETAILS (
- "WarpTV",
- "Filter/Effect/Video",
- "WarpTV does realtime goo'ing of the video input",
- "Sam Lantinga <slouken@devolution.com>"
- );
+ static GstElementDetails warptv_details = GST_ELEMENT_DETAILS ("WarpTV",
+ "Filter/Effect/Video",
+ "WarpTV does realtime goo'ing of the video input",
+ "Sam Lantinga <slouken@devolution.com>");
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, &warptv_details);
- for(i=0;i<G_N_ELEMENTS(gst_warptv_formats);i++){
- gst_videofilter_class_add_format(videofilter_class,
+ for (i = 0; i < G_N_ELEMENTS (gst_warptv_formats); i++) {
+ gst_videofilter_class_add_format (videofilter_class,
gst_warptv_formats + i);
}
@@ -165,10 +173,9 @@ gst_warptv_class_init (gpointer g_class, gpointer class_data)
videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
#if 0
- g_object_class_install_property(gobject_class, ARG_METHOD,
- g_param_spec_enum("method","method","method",
- GST_TYPE_WARPTV_METHOD, GST_WARPTV_METHOD_1,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_METHOD,
+ g_param_spec_enum ("method", "method", "method",
+ GST_TYPE_WARPTV_METHOD, GST_WARPTV_METHOD_1, G_PARAM_READWRITE));
#endif
gobject_class->set_property = gst_warptv_set_property;
@@ -178,28 +185,29 @@ gst_warptv_class_init (gpointer g_class, gpointer class_data)
}
static void
-gst_warptv_init (GTypeInstance *instance, gpointer g_class)
+gst_warptv_init (GTypeInstance * instance, gpointer g_class)
{
GstWarpTV *warptv = GST_WARPTV (instance);
GstVideofilter *videofilter;
- GST_DEBUG("gst_warptv_init");
+ GST_DEBUG ("gst_warptv_init");
- videofilter = GST_VIDEOFILTER(warptv);
+ videofilter = GST_VIDEOFILTER (warptv);
/* do stuff */
}
static void
-gst_warptv_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_warptv_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstWarpTV *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_WARPTV(object));
- src = GST_WARPTV(object);
+ g_return_if_fail (GST_IS_WARPTV (object));
+ src = GST_WARPTV (object);
- GST_DEBUG("gst_warptv_set_property");
+ GST_DEBUG ("gst_warptv_set_property");
switch (prop_id) {
#if 0
case ARG_METHOD:
@@ -212,13 +220,14 @@ gst_warptv_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
static void
-gst_warptv_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_warptv_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstWarpTV *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_WARPTV(object));
- src = GST_WARPTV(object);
+ g_return_if_fail (GST_IS_WARPTV (object));
+ src = GST_WARPTV (object);
switch (prop_id) {
#if 0
@@ -233,14 +242,15 @@ gst_warptv_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
-static void gst_warptv_setup(GstVideofilter *videofilter)
+static void
+gst_warptv_setup (GstVideofilter * videofilter)
{
GstWarpTV *warptv;
- int width = gst_videofilter_get_input_width(videofilter);
- int height = gst_videofilter_get_input_height(videofilter);
+ int width = gst_videofilter_get_input_width (videofilter);
+ int height = gst_videofilter_get_input_height (videofilter);
- g_return_if_fail(GST_IS_WARPTV(videofilter));
- warptv = GST_WARPTV(videofilter);
+ g_return_if_fail (GST_IS_WARPTV (videofilter));
+ warptv = GST_WARPTV (videofilter);
/* if any setup needs to be done, do it here */
@@ -254,7 +264,7 @@ static void gst_warptv_setup(GstVideofilter *videofilter)
g_free (warptv->disttable);
g_free (warptv->offstable);
- warptv->offstable = (guint32 *) g_malloc (height * sizeof (guint32));
+ warptv->offstable = (guint32 *) g_malloc (height * sizeof (guint32));
warptv->disttable = g_malloc (width * height * sizeof (guint32));
initSinTable (warptv);
@@ -262,11 +272,11 @@ static void gst_warptv_setup(GstVideofilter *videofilter)
initDistTable (warptv);
}
-static void
-initSinTable (GstWarpTV *filter)
+static void
+initSinTable (GstWarpTV * filter)
{
- gint32 *tptr, *tsinptr;
- double i;
+ gint32 *tptr, *tsinptr;
+ double i;
tsinptr = tptr = filter->sintable;
@@ -277,35 +287,36 @@ initSinTable (GstWarpTV *filter)
*tptr++ = *tsinptr++;
}
-static void
-initOffsTable (GstWarpTV *filter)
+static void
+initOffsTable (GstWarpTV * filter)
{
int y;
-
+
for (y = 0; y < filter->height; y++) {
filter->offstable[y] = y * filter->width;
}
}
-
-static void
-initDistTable (GstWarpTV *filter)
+
+static void
+initDistTable (GstWarpTV * filter)
{
gint32 halfw, halfh, *distptr;
+
#ifdef PS2
- float x,y,m;
+ float x, y, m;
#else
- double x,y,m;
+ double x, y, m;
#endif
- halfw = filter->width>> 1;
+ halfw = filter->width >> 1;
halfh = filter->height >> 1;
distptr = filter->disttable;
- m = sqrt ((double)(halfw * halfw + halfh * halfh));
+ m = sqrt ((double) (halfw * halfw + halfh * halfh));
for (y = -halfh; y < halfh; y++)
- for (x= -halfw; x < halfw; x++)
+ for (x = -halfw; x < halfw; x++)
#ifdef PS2
*distptr++ = ((int) ((sqrtf (x * x + y * y) * 511.9999) / m)) << 1;
#else
@@ -313,34 +324,34 @@ initDistTable (GstWarpTV *filter)
#endif
}
-static void gst_warptv_rgb32 (GstVideofilter *videofilter,
- void *d, void *s)
+static void
+gst_warptv_rgb32 (GstVideofilter * videofilter, void *d, void *s)
{
GstWarpTV *warptv;
- int width = gst_videofilter_get_input_width(videofilter);
- int height = gst_videofilter_get_input_height(videofilter);
+ int width = gst_videofilter_get_input_width (videofilter);
+ int height = gst_videofilter_get_input_height (videofilter);
guint32 *src = s;
guint32 *dest = d;
- gint xw,yw,cw;
- gint32 c,i, x,y, dx,dy, maxx, maxy;
+ gint xw, yw, cw;
+ gint32 c, i, x, y, dx, dy, maxx, maxy;
gint32 skip, *ctptr, *distptr;
gint32 *sintable, *ctable;
- g_return_if_fail(GST_IS_WARPTV(videofilter));
- warptv = GST_WARPTV(videofilter);
+ g_return_if_fail (GST_IS_WARPTV (videofilter));
+ warptv = GST_WARPTV (videofilter);
- xw = (gint) (sin ((warptv->tval + 100) * M_PI / 128) * 30);
- yw = (gint) (sin ((warptv->tval) * M_PI / 256) * -35);
- cw = (gint) (sin ((warptv->tval - 70) * M_PI / 64) * 50);
+ xw = (gint) (sin ((warptv->tval + 100) * M_PI / 128) * 30);
+ yw = (gint) (sin ((warptv->tval) * M_PI / 256) * -35);
+ cw = (gint) (sin ((warptv->tval - 70) * M_PI / 64) * 50);
xw += (gint) (sin ((warptv->tval - 10) * M_PI / 512) * 40);
- yw += (gint) (sin ((warptv->tval + 30) * M_PI / 512) * 40);
+ yw += (gint) (sin ((warptv->tval + 30) * M_PI / 512) * 40);
ctptr = warptv->ctable;
distptr = warptv->disttable;
sintable = warptv->sintable;
ctable = warptv->ctable;
- skip = 0 ; /* video_width*sizeof(RGB32)/4 - video_width;; */
+ skip = 0; /* video_width*sizeof(RGB32)/4 - video_width;; */
c = 0;
for (x = 0; x < 512; x++) {
@@ -349,24 +360,28 @@ static void gst_warptv_rgb32 (GstVideofilter *videofilter,
*ctptr++ = ((sintable[i + 256] * xw) >> 15);
c += cw;
}
- maxx = width - 2; maxy = height - 2;
+ maxx = width - 2;
+ maxy = height - 2;
for (y = 0; y < height - 1; y++) {
for (x = 0; x < width; x++) {
- i = *distptr++;
- dx = ctable [i + 1] + x;
- dy = ctable [i] + y;
-
- if (dx < 0) dx = 0;
- else if (dx > maxx) dx = maxx;
-
- if (dy < 0) dy = 0;
- else if (dy > maxy) dy = maxy;
- *dest++ = src[warptv->offstable[dy] + dx];
+ i = *distptr++;
+ dx = ctable[i + 1] + x;
+ dy = ctable[i] + y;
+
+ if (dx < 0)
+ dx = 0;
+ else if (dx > maxx)
+ dx = maxx;
+
+ if (dy < 0)
+ dy = 0;
+ else if (dy > maxy)
+ dy = maxy;
+ *dest++ = src[warptv->offstable[dy] + dx];
}
dest += skip;
}
warptv->tval = (warptv->tval + 1) & 511;
}
-