summaryrefslogtreecommitdiffstats
path: root/gst/effectv/gstdice.c
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2004-03-12 13:56:51 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2004-03-12 13:56:51 +0000
commitefe98f103049b9612c4bcfeae4572dcd8a6ea37b (patch)
tree128ebc12142b38e9f550e84551c53a941c02ae61 /gst/effectv/gstdice.c
parent2cb6e77679267eff31d33743e83b3686e665df91 (diff)
Port all elements that can be ported to videofilter, and fix up the caps.
Original commit message from CVS: Port all elements that can be ported to videofilter, and fix up the caps. Can someone with a big-endian machine please check them?
Diffstat (limited to 'gst/effectv/gstdice.c')
-rw-r--r--gst/effectv/gstdice.c157
1 files changed, 70 insertions, 87 deletions
diff --git a/gst/effectv/gstdice.c b/gst/effectv/gstdice.c
index c2c2de73..ba2d1d6c 100644
--- a/gst/effectv/gstdice.c
+++ b/gst/effectv/gstdice.c
@@ -15,14 +15,14 @@
#endif
#include <string.h>
#include <gst/gst.h>
-#include "gsteffectv.h"
+#include <gstvideofilter.h>
#define GST_TYPE_DICETV \
(gst_dicetv_get_type())
#define GST_DICETV(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DICETV,GstDiceTV))
#define GST_DICETV_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstDiceTV))
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DICETV,GstDiceTVClass))
#define GST_IS_DICETV(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DICETV))
#define GST_IS_DICETV_CLASS(obj) \
@@ -45,9 +45,7 @@ typedef enum _dice_dir
struct _GstDiceTV
{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
+ GstVideofilter videofilter;
gint width, height;
gchar* dicemap;
@@ -60,20 +58,11 @@ struct _GstDiceTV
struct _GstDiceTVClass
{
- GstElementClass parent_class;
+ GstVideofilterClass parent_class;
void (*reset) (GstElement *element);
};
-/* 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>"
-);
-
-
/* Filter signals and args */
enum
{
@@ -88,9 +77,9 @@ enum
ARG_CUBE_BITS,
};
-static void gst_dicetv_base_init (gpointer g_class);
-static void gst_dicetv_class_init (GstDiceTVClass * klass);
-static void gst_dicetv_init (GstDiceTV * filter);
+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);
@@ -99,10 +88,9 @@ 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_chain (GstPad * pad, GstData *_data);
-
-static GstElementClass *parent_class = NULL;
static guint gst_dicetv_signals[LAST_SIGNAL] = { 0 };
GType gst_dicetv_get_type (void)
@@ -122,86 +110,95 @@ GType gst_dicetv_get_type (void)
(GInstanceInitFunc) gst_dicetv_init,
};
- dicetv_type = g_type_register_static (GST_TYPE_ELEMENT, "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 },
+};
+
static void
gst_dicetv_base_init (gpointer g_class)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (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>"
+ );
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_effectv_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_effectv_sink_template));
-
+ 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,
+ gst_dicetv_formats + i);
+ }
+
+ gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
}
static void
-gst_dicetv_class_init (GstDiceTVClass * klass)
+gst_dicetv_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
+ GstVideofilterClass *videofilter_class;
+ GstDiceTVClass *dicetv_class;
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+ gobject_class = G_OBJECT_CLASS (g_class);
+ videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
+ dicetv_class = GST_DICETV_CLASS (g_class);
gst_dicetv_signals[RESET_SIGNAL] =
g_signal_new ("reset",
- G_TYPE_FROM_CLASS (klass),
+ 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);
- klass->reset = gst_dicetv_reset_handler;
+ dicetv_class->reset = gst_dicetv_reset_handler;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CUBE_BITS,
+ 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));
gobject_class->set_property = gst_dicetv_set_property;
gobject_class->get_property = gst_dicetv_get_property;
+
+ videofilter_class->setup = gst_dicetv_setup;
}
-static GstPadLinkReturn
-gst_dicetv_sinkconnect (GstPad * pad, const GstCaps * caps)
+static void
+gst_dicetv_setup (GstVideofilter *videofilter)
{
- GstDiceTV *filter;
- GstStructure *structure;
+ GstDiceTV *dicetv;
- filter = GST_DICETV (gst_pad_get_parent (pad));
+ g_return_if_fail (GST_IS_DICETV (videofilter));
+ dicetv = GST_DICETV (videofilter);
- structure = gst_caps_get_structure (caps, 0);
+ dicetv->width = gst_videofilter_get_input_width (videofilter);
+ dicetv->height = gst_videofilter_get_input_height (videofilter);
- gst_structure_get_int (structure, "width", &filter->width);
- gst_structure_get_int (structure, "height", &filter->height);
-
- g_free (filter->dicemap);
- filter->dicemap = (gchar *) g_malloc (filter->height * filter->width * sizeof(char));
- gst_dicetv_create_map (filter);
-
- return gst_pad_try_set_caps (filter->srcpad, caps);
+ g_free (dicetv->dicemap);
+ dicetv->dicemap = (gchar *) g_malloc (dicetv->height * dicetv->width * sizeof(char));
+ gst_dicetv_create_map (dicetv);
}
static void
-gst_dicetv_init (GstDiceTV * filter)
+gst_dicetv_init (GTypeInstance *instance, gpointer g_class)
{
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_effectv_sink_template), "sink");
- gst_pad_set_chain_function (filter->sinkpad, gst_dicetv_chain);
- gst_pad_set_link_function (filter->sinkpad, gst_dicetv_sinkconnect);
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
-
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_effectv_src_template), "src");
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ GstDiceTV *filter = GST_DICETV (instance);
filter->dicemap = NULL;
filter->g_cube_bits = DEFAULT_CUBE_BITS;
@@ -218,7 +215,6 @@ gst_dicetv_reset_handler (GstElement *element)
gst_dicetv_create_map (filter);
}
-
static unsigned int
fastrand (void)
{
@@ -228,8 +224,11 @@ fastrand (void)
}
static void
-gst_dicetv_draw (GstDiceTV *filter, guint32 *src, guint32 *dest)
+gst_dicetv_draw (GstVideofilter *videofilter, void *d, void *s)
{
+ GstDiceTV *filter;
+ guint32 *src;
+ guint32 *dest;
gint i;
gint map_x, map_y, map_i;
gint base;
@@ -238,6 +237,14 @@ gst_dicetv_draw (GstDiceTV *filter, guint32 *src, guint32 *dest)
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;
+
+ video_width = filter->width;
+ g_cube_bits = filter->g_cube_bits;
+ g_cube_size = filter->g_cube_size;
+
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++) {
@@ -315,30 +322,6 @@ gst_dicetv_create_map (GstDiceTV *filter)
}
static void
-gst_dicetv_chain (GstPad * pad, GstData *_data)
-{
- GstBuffer *buf = GST_BUFFER (_data);
- GstDiceTV *filter;
- guint32 *src, *dest;
- GstBuffer *outbuf;
-
- filter = GST_DICETV (gst_pad_get_parent (pad));
-
- src = (guint32 *) GST_BUFFER_DATA (buf);
-
- outbuf = gst_buffer_new ();
- GST_BUFFER_SIZE (outbuf) = (filter->width * filter->height * sizeof(guint32));
- dest = (guint32 *) GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
-
- gst_dicetv_draw (filter, src, dest);
-
- gst_buffer_unref (buf);
-
- gst_pad_push (filter->srcpad, GST_DATA (outbuf));
-}
-
-static void
gst_dicetv_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstDiceTV *filter;