Port all elements that can be ported to videofilter, and fix up the caps.
authorJan Schmidt <thaytan@mad.scientist.com>
Fri, 12 Mar 2004 13:56:51 +0000 (13:56 +0000)
committerJan Schmidt <thaytan@mad.scientist.com>
Fri, 12 Mar 2004 13:56:51 +0000 (13:56 +0000)
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?

ChangeLog
gst/effectv/gstaging.c
gst/effectv/gstdice.c
gst/effectv/gstedge.c
gst/effectv/gsteffectv.c
gst/effectv/gstquark.c
gst/effectv/gstrev.c
gst/effectv/gstshagadelic.c
gst/effectv/gstvertigo.c
gst/effectv/gstwarp.c

index 4958cb5..65b34d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2004-03-13  Jan Schmidt  <thaytan@mad.scientist.com>
+       * gst/effectv/gstaging.c: (gst_agingtv_base_init),
+       (gst_agingtv_setup):
+       * gst/effectv/gstdice.c: (gst_dicetv_get_type),
+       (gst_dicetv_base_init), (gst_dicetv_class_init),
+       (gst_dicetv_setup), (gst_dicetv_init), (gst_dicetv_draw):
+       * gst/effectv/gstedge.c: (gst_edgetv_get_type),
+       (gst_edgetv_base_init), (gst_edgetv_class_init), (gst_edgetv_init),
+       (gst_edgetv_setup), (gst_edgetv_rgb32):
+       * gst/effectv/gsteffectv.c:
+       * gst/effectv/gstquark.c: (gst_quarktv_link), (gst_quarktv_init),
+       (gst_quarktv_set_property):
+       * gst/effectv/gstrev.c: (gst_revtv_get_type),
+       (gst_revtv_base_init), (gst_revtv_class_init), (gst_revtv_init),
+       (gst_revtv_setup), (gst_revtv_rgb32):
+       * gst/effectv/gstshagadelic.c: (gst_shagadelictv_get_type),
+       (gst_shagadelictv_base_init), (gst_shagadelictv_class_init),
+       (gst_shagadelictv_init), (gst_shagadelictv_setup),
+       (gst_shagadelictv_rgb32):
+       * gst/effectv/gstvertigo.c: (gst_vertigotv_get_type),
+       (gst_vertigotv_base_init), (gst_vertigotv_class_init),
+       (gst_vertigotv_setup), (gst_vertigotv_init), (gst_vertigotv_rgb32):
+       * gst/effectv/gstwarp.c:
+       Port everything that can be ported to videofilter and fix up the caps.
+       Can someone with a big-endian machine please check these?
+
 2004-03-10  Ronald Bultje  <rbultje@ronald.bitfreak.net>
 
        * sys/oss/gstosssink.c: (gst_osssink_init), (gst_osssink_get_time),
index 49acae5..b6739f4 100644 (file)
@@ -41,9 +41,6 @@
 #include <gstvideofilter.h>
 #include <string.h>
 #include <math.h>
-#include "gsteffectv.h"
-
-
 
 #define GST_TYPE_AGINGTV \
   (gst_agingtv_get_type())
@@ -89,7 +86,6 @@ struct _GstAgingTVClass {
   GstVideofilterClass parent_class;
 };
 
-
 /* GstAgingTV signals and args */
 enum {
   /* FILL ME */
@@ -103,12 +99,12 @@ enum {
 
 static void    gst_agingtv_base_init   (gpointer g_class);
 static void    gst_agingtv_class_init  (gpointer g_class, gpointer class_data);
-static void    gst_agingtv_init                (GTypeInstance *instance, gpointer g_class);
-static void     gst_agingtv_setup(GstVideofilter *videofilter);
+static void    gst_agingtv_init        (GTypeInstance *instance, gpointer g_class);
+static void     gst_agingtv_setup      (GstVideofilter *videofilter);
 
 static void    gst_agingtv_set_property                (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 static void    gst_agingtv_get_property                (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void     gst_agingtv_rgb32 (GstVideofilter *videofilter, void *d, void *s);
+static void     gst_agingtv_rgb32      (GstVideofilter *videofilter, void *d, void *s);
 
 GType
 gst_agingtv_get_type (void)
@@ -134,12 +130,8 @@ gst_agingtv_get_type (void)
 }
 
 static GstVideofilterFormat gst_agingtv_formats[] = {
-  { "RGB ", 32, gst_agingtv_rgb32, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00, 0x000000ff },
-  { "RGB ", 32, gst_agingtv_rgb32, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000, 0x0000ff00 },
-  { "RGB ", 32, gst_agingtv_rgb32, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00, 0x00ff0000 },
-  { "RGB ", 32, gst_agingtv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 },
+  { "RGB ", 32, gst_agingtv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }
 };
-
   
 static void
 gst_agingtv_base_init (gpointer g_class)
@@ -147,7 +139,7 @@ gst_agingtv_base_init (gpointer g_class)
   static GstElementDetails agingtv_details = GST_ELEMENT_DETAILS (
     "AgingTV",
     "Filter/Effect/Video",
-    "AgingTV does realtime goo'ing of the video input",
+    "AgingTV adds age to video input using scratches and dust",
     "Sam Lantinga <slouken@devolution.com>"
   );
   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
@@ -212,7 +204,6 @@ static void gst_agingtv_setup(GstVideofilter *videofilter)
 
   agingtv->width = width;
   agingtv->height = height;
-
 }
 
 static unsigned int 
index c2c2de7..ba2d1d6 100644 (file)
 #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;
index 137eb35..26bf269 100644 (file)
 #endif
 #include <string.h>
 #include <gst/gst.h>
-#include "gsteffectv.h"
+#include <gstvideofilter.h>
 
 #define GST_TYPE_EDGETV \
   (gst_edgetv_get_type())
 #define GST_EDGETV(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EDGETV,GstEdgeTV))
 #define GST_EDGETV_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstEdgeTV))
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EDGETV,GstEdgeTVClass))
 #define GST_IS_EDGETV(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EDGETV))
 #define GST_IS_EDGETV_CLASS(obj) \
@@ -44,9 +44,7 @@ typedef struct _GstEdgeTVClass GstEdgeTVClass;
 
 struct _GstEdgeTV
 {
-  GstElement element;
-
-  GstPad *sinkpad, *srcpad;
+  GstVideofilter videofilter;
 
   gint width, height;
   gint map_width, map_height;
@@ -56,18 +54,9 @@ struct _GstEdgeTV
 
 struct _GstEdgeTVClass
 {
-  GstElementClass parent_class;
+  GstVideofilterClass parent_class;
 };
 
-/* elementfactory information */
-static GstElementDetails gst_edgetv_details = GST_ELEMENT_DETAILS (
-  "EdgeTV",
-  "Filter/Effect/Video",
-  "Apply edge detect on video",
-  "Wim Taymans <wim.taymans@chello.be>"
-);
-
-
 /* Filter signals and args */
 enum
 {
@@ -81,17 +70,17 @@ enum
 };
 
 static void    gst_edgetv_base_init            (gpointer g_class);
-static void    gst_edgetv_class_init           (GstEdgeTVClass * klass);
-static void    gst_edgetv_init                 (GstEdgeTV * filter);
+static void    gst_edgetv_class_init           (gpointer g_class, gpointer class_data);
+static void    gst_edgetv_init                 (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_edgetv_set_property         (GObject * object, guint prop_id,
                                                 const GValue * value, GParamSpec * pspec);
 static void    gst_edgetv_get_property         (GObject * object, guint prop_id,
                                                 GValue * value, GParamSpec * pspec);
 
-static void    gst_edgetv_chain                (GstPad * pad, GstData *_data);
+static void     gst_edgetv_setup               (GstVideofilter *videofilter);
+static void     gst_edgetv_rgb32               (GstVideofilter *videofilter, void *d, void *s);
 
-static GstElementClass *parent_class = NULL;
 /*static guint gst_edgetv_signals[LAST_SIGNAL] = { 0 }; */
 
 GType gst_edgetv_get_type (void)
@@ -111,99 +100,97 @@ GType gst_edgetv_get_type (void)
       (GInstanceInitFunc) gst_edgetv_init,
     };
 
-    edgetv_type = g_type_register_static (GST_TYPE_ELEMENT, "GstEdgeTV", &edgetv_info, 0);
+    edgetv_type = g_type_register_static (GST_TYPE_VIDEOFILTER, "GstEdgeTV", &edgetv_info, 0);
   }
   return edgetv_type;
 }
 
+static GstVideofilterFormat gst_edgetv_formats[] = {
+  { "RGB ", 32, gst_edgetv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }
+};
+
 static void
 gst_edgetv_base_init (gpointer g_class)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  /* elementfactory information */
+  static GstElementDetails gst_edgetv_details = GST_ELEMENT_DETAILS (
+    "EdgeTV",
+    "Filter/Effect/Video",
+    "Apply edge detect on video",
+    "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_edgetv_details);
+
+  for(i=0; i < G_N_ELEMENTS(gst_edgetv_formats); i++) {
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_edgetv_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_edgetv_class_init (GstEdgeTVClass * klass)
+gst_edgetv_class_init (gpointer g_class, gpointer class_data)
 {
   GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
-
-  gobject_class = (GObjectClass *) klass;
-  gstelement_class = (GstElementClass *) klass;
+  GstVideofilterClass *videofilter_class;
 
-  parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+  gobject_class = G_OBJECT_CLASS (g_class);
+  videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
 
   gobject_class->set_property = gst_edgetv_set_property;
   gobject_class->get_property = gst_edgetv_get_property;
-}
 
-static GstPadLinkReturn
-gst_edgetv_sinkconnect (GstPad * pad, const GstCaps * caps)
-{
-  GstEdgeTV *filter;
-  GstStructure *structure;
-
-  filter = GST_EDGETV (gst_pad_get_parent (pad));
-
-  structure = gst_caps_get_structure (caps, 0);
-
-  gst_structure_get_int (structure, "width", &filter->width);
-  gst_structure_get_int (structure, "height", &filter->height);
-
-  filter->map_width = filter->width / 4;
-  filter->map_height = filter->height / 4;
-  filter->video_width_margin = filter->width - filter->map_width * 4;
-
-  g_free (filter->map);
-  filter->map = (guint32 *)g_malloc (filter->map_width * filter->map_height * sizeof(guint32) * 2);
-  memset(filter->map, 0, filter->map_width * filter->map_height * sizeof(guint32) * 2);
-
-  return gst_pad_try_set_caps (filter->srcpad, caps);
+  videofilter_class->setup = gst_edgetv_setup;
 }
 
 static void
-gst_edgetv_init (GstEdgeTV * filter)
+gst_edgetv_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_edgetv_chain);
-  gst_pad_set_link_function (filter->sinkpad, gst_edgetv_sinkconnect);
-  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+  GstEdgeTV *edgetv = GST_EDGETV (instance);
 
-  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);
+  edgetv->map = NULL;
+}
 
-  filter->map = NULL;
+static void gst_edgetv_setup(GstVideofilter *videofilter)
+{
+  GstEdgeTV *edgetv;
+  int width = gst_videofilter_get_input_width (videofilter);
+  int height = gst_videofilter_get_input_height (videofilter);
+
+  g_return_if_fail (GST_IS_EDGETV (videofilter));
+  edgetv = GST_EDGETV (videofilter);
+
+  edgetv->width = width;
+  edgetv->height = height;
+  edgetv->map_width = width / 4;
+  edgetv->map_height = height / 4;
+  edgetv->video_width_margin = width % 4;
+
+  g_free (edgetv->map);
+  edgetv->map = (guint32 *)g_malloc (edgetv->map_width * edgetv->map_height * sizeof (guint32) * 2);
+  memset(edgetv->map, 0, edgetv->map_width * edgetv->map_height * sizeof (guint32) * 2);
 }
 
-static void
-gst_edgetv_chain (GstPad * pad, GstData *_data)
+static void     
+gst_edgetv_rgb32 (GstVideofilter *videofilter, void *d, void *s)
 {
-  GstBuffer *buf = GST_BUFFER (_data);
   GstEdgeTV *filter;
   int x, y;
   int r, g, b;
   guint32 *src, *dest;
   guint32 p, q;
   guint32 v0, v1, v2, v3;
-  GstBuffer *outbuf;
-
-  filter = GST_EDGETV (gst_pad_get_parent (pad));
 
-  src = (guint32 *) GST_BUFFER_DATA (buf);
+  filter = GST_EDGETV (videofilter);
 
-  outbuf = gst_buffer_new ();
-  GST_BUFFER_SIZE (outbuf) = (filter->width * filter->height * 4);
-  dest = (guint32 *) GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
-  GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+  src = (guint32 *) s;
+  dest = (guint32 *) d;
   
   src += filter->width * 4 + 4;
   dest += filter->width * 4 + 4;
@@ -282,9 +269,6 @@ gst_edgetv_chain (GstPad * pad, GstData *_data)
     src += filter->width * 3 + 8 + filter->video_width_margin;
     dest += filter->width * 3 + 8 + filter->video_width_margin;
   }
-  gst_buffer_unref (buf);
-
-  gst_pad_push (filter->srcpad, GST_DATA (outbuf));
 }
 
 static void
index 6bd3643..2fa1583 100644 (file)
@@ -54,7 +54,10 @@ GST_STATIC_PAD_TEMPLATE (
     "src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ( GST_VIDEO_CAPS_xRGB_HOST_ENDIAN )
+    GST_STATIC_CAPS ( 
+                       GST_VIDEO_CAPS_BGRx "; "
+                       GST_VIDEO_CAPS_RGBx
+                   )
 );
 
 GstStaticPadTemplate gst_effectv_sink_template =
@@ -62,7 +65,10 @@ GST_STATIC_PAD_TEMPLATE (
     "sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ( GST_VIDEO_CAPS_xRGB_HOST_ENDIAN )
+    GST_STATIC_CAPS ( 
+                       GST_VIDEO_CAPS_BGRx "; "
+                       GST_VIDEO_CAPS_RGBx
+                   )
 );
 
 static gboolean
index 6d51bc5..1b4a227 100644 (file)
@@ -34,7 +34,7 @@
 #define GST_QUARKTV(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QUARKTV,GstQuarkTV))
 #define GST_QUARKTV_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstQuarkTV))
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QUARKTV,GstQuarkTVClass))
 #define GST_IS_QUARKTV(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUARKTV))
 #define GST_IS_QUARKTV_CLASS(obj) \
@@ -168,29 +168,37 @@ gst_quarktv_class_init (GstQuarkTVClass * klass)
 }
 
 static GstPadLinkReturn
-gst_quarktv_sinkconnect (GstPad * pad, const GstCaps * caps)
+gst_quarktv_link (GstPad * pad, const GstCaps * caps)
 {
   GstQuarkTV *filter;
+  GstPad *otherpad;
   gint i;
   GstStructure *structure;
+  GstPadLinkReturn res;
 
   filter = GST_QUARKTV (gst_pad_get_parent (pad));
+  g_return_val_if_fail (GST_IS_QUARKTV (filter), GST_PAD_LINK_REFUSED);
 
-  structure = gst_caps_get_structure (caps, 0);
+  otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
 
-  gst_structure_get_int  (structure, "width", &filter->width);
-  gst_structure_get_int  (structure, "height", &filter->height);
+  res = gst_pad_try_set_caps (otherpad, caps);
+  if (GST_PAD_LINK_FAILED (res))
+    return res;
 
-  filter->area = filter->width * filter->height;
+  structure = gst_caps_get_structure (caps, 0);
+  if (!gst_structure_get_int (structure, "width", &filter->width) ||
+      !gst_structure_get_int (structure, "height", &filter->height))
+    return GST_PAD_LINK_REFUSED;
 
-  g_free (filter->planetable);
-  filter->planetable = (GstBuffer **) g_malloc(filter->planes * sizeof(GstBuffer *));
+  filter->area = filter->width * filter->height;
 
   for(i = 0; i < filter->planes; i++) {
+    if (filter->planetable[i]) 
+      gst_buffer_unref (filter->planetable[i]);
     filter->planetable[i] = NULL;
   }
 
-  return gst_pad_try_set_caps (filter->srcpad, caps);
+  return GST_PAD_LINK_OK;
 }
 
 static void
@@ -198,17 +206,21 @@ gst_quarktv_init (GstQuarkTV * filter)
 {
   filter->sinkpad = gst_pad_new_from_template (
       gst_static_pad_template_get(&gst_effectv_sink_template), "sink");
+  gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
   gst_pad_set_chain_function (filter->sinkpad, gst_quarktv_chain);
-  gst_pad_set_link_function (filter->sinkpad, gst_quarktv_sinkconnect);
+  gst_pad_set_link_function (filter->sinkpad, gst_quarktv_link);
   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_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
+  gst_pad_set_link_function (filter->srcpad, gst_quarktv_link);
   gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
 
   filter->planes = PLANES;
   filter->current_plane = filter->planes - 1;
-  filter->planetable = NULL;
+  filter->planetable = (GstBuffer **) g_malloc(filter->planes * sizeof(GstBuffer *));
+  memset (filter->planetable, 0, filter->planes * sizeof(GstBuffer *));
 }
 
 static void
@@ -292,8 +304,29 @@ gst_quarktv_set_property (GObject * object, guint prop_id, const GValue * value,
 
   switch (prop_id) {
     case ARG_PLANES:
-      filter->planes = g_value_get_int (value);
-      filter->current_plane = filter->planes - 1;
+      {
+        gint new_n_planes = g_value_get_int (value);
+       GstBuffer **new_planetable;
+       gint i;
+
+        /* If the number of planes changed, copy across any existing planes */
+       if (new_n_planes != filter->planes)
+        {
+          new_planetable = (GstBuffer **) g_malloc(new_n_planes * sizeof(GstBuffer *));
+
+          for(i = 0; (i < new_n_planes) && (i < filter->planes); i++) {
+            new_planetable[i] = filter->planetable[i];
+          }
+          for(; i < filter->planes; i++) {
+            if (filter->planetable[i]) 
+              gst_buffer_unref (filter->planetable[i]);
+          }
+          g_free (filter->planetable);
+          filter->planetable = new_planetable;
+          filter->current_plane = filter->planes - 1;
+          filter->planes = new_n_planes;
+        }
+      }
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index bca245d..33e6bf8 100644 (file)
 #include <math.h>
 #include <string.h>
 #include <gst/gst.h>
-#include "gsteffectv.h"
+#include <gstvideofilter.h>
 
 #define GST_TYPE_REVTV \
   (gst_revtv_get_type())
 #define GST_REVTV(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_REVTV,GstRevTV))
 #define GST_REVTV_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstRevTV))
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_REVTV,GstRevTVClass))
 #define GST_IS_REVTV(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_REVTV))
 #define GST_IS_REVTV_CLASS(obj) \
@@ -66,9 +66,7 @@ typedef struct _GstRevTVClass GstRevTVClass;
 
 struct _GstRevTV
 {
-  GstElement element;
-
-  GstPad *sinkpad, *srcpad;
+  GstVideofilter videofilter;
 
   gint width, height;
   gint vgrabtime;
@@ -79,20 +77,11 @@ struct _GstRevTV
 
 struct _GstRevTVClass
 {
-  GstElementClass parent_class;
+  GstVideofilterClass parent_class;
 
   void (*reset) (GstElement *element);
 };
 
-/* elementfactory information */
-static GstElementDetails gst_revtv_details = GST_ELEMENT_DETAILS (
-  "RevTV",
-  "Filter/Effect/Video",
-  "A video waveform monitor for each line of video processed",
-  "Wim Taymans <wim.taymans@chello.be>"
-);
-
-
 /* Filter signals and args */
 enum
 {
@@ -109,17 +98,16 @@ enum
 };
 
 static void    gst_revtv_base_init             (gpointer g_class);
-static void    gst_revtv_class_init            (GstRevTVClass * klass);
-static void    gst_revtv_init                  (GstRevTV * filter);
+static void    gst_revtv_class_init            (gpointer g_class, gpointer class_data);
+static void    gst_revtv_init                  (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_revtv_set_property          (GObject * object, guint prop_id,
                                                 const GValue * value, GParamSpec * pspec);
 static void    gst_revtv_get_property          (GObject * object, guint prop_id,
                                                 GValue * value, GParamSpec * pspec);
+static void     gst_revtv_setup                        (GstVideofilter *videofilter);
+static void     gst_revtv_rgb32                (GstVideofilter *videofilter, void *d, void *s);
 
-static void    gst_revtv_chain                 (GstPad * pad, GstData *_data);
-
-static GstElementClass *parent_class = NULL;
 /* static guint gst_revtv_signals[LAST_SIGNAL] = { 0 }; */
 
 GType gst_revtv_get_type (void)
@@ -139,34 +127,48 @@ GType gst_revtv_get_type (void)
       (GInstanceInitFunc) gst_revtv_init,
     };
 
-    revtv_type = g_type_register_static (GST_TYPE_ELEMENT, "GstRevTV", &revtv_info, 0);
+    revtv_type = g_type_register_static (GST_TYPE_VIDEOFILTER, "GstRevTV", &revtv_info, 0);
   }
   return revtv_type;
 }
 
+static GstVideofilterFormat gst_revtv_formats[] = {
+  { "RGB ", 32, gst_revtv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }
+};
+
 static void
 gst_revtv_base_init (gpointer g_class)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  /* elementfactory information */
+  static GstElementDetails gst_revtv_details = GST_ELEMENT_DETAILS (
+    "RevTV",
+    "Filter/Effect/Video",
+    "A video waveform monitor for each line of video processed",
+    "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_revtv_details);
+
+  for(i=0; i < G_N_ELEMENTS(gst_revtv_formats); i++) {
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_revtv_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_revtv_class_init (GstRevTVClass * klass)
+gst_revtv_class_init (gpointer klass, gpointer class_data)
 {
   GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
+  GstVideofilterClass *videofilter_class;
 
-  gobject_class = (GObjectClass *) klass;
-  gstelement_class = (GstElementClass *) klass;
-
-  parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+  gobject_class = G_OBJECT_CLASS (klass);
+  videofilter_class = GST_VIDEOFILTER_CLASS (klass);
 
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DELAY,
     g_param_spec_int ("delay","Delay","Delay in frames between updates",
@@ -180,67 +182,52 @@ gst_revtv_class_init (GstRevTVClass * klass)
 
   gobject_class->set_property = gst_revtv_set_property;
   gobject_class->get_property = gst_revtv_get_property;
+
+  videofilter_class->setup = gst_revtv_setup;
 }
 
-static GstPadLinkReturn
-gst_revtv_sinkconnect (GstPad * pad, const GstCaps * caps)
+static void
+gst_revtv_init (GTypeInstance *instance, gpointer g_class)
 {
-  GstRevTV *filter;
-  GstStructure *structure;
-
-  filter = GST_REVTV (gst_pad_get_parent (pad));
-
-  structure = gst_caps_get_structure (caps, 0);
-
-  gst_structure_get_int  (structure, "width", &filter->width);
-  gst_structure_get_int  (structure, "height", &filter->height);
+  GstRevTV *restv = GST_REVTV (instance);
 
-  return gst_pad_try_set_caps (filter->srcpad, caps);
+  restv->vgrabtime = 1;
+  restv->vgrab = 0;
+  restv->linespace = 6;
+  restv->vscale = 50;
 }
 
 static void
-gst_revtv_init (GstRevTV * filter)
+gst_revtv_setup (GstVideofilter *videofilter)
 {
-  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_revtv_chain);
-  gst_pad_set_link_function (filter->sinkpad, gst_revtv_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);
-
-  filter->vgrabtime = 1;
-  filter->vgrab = 0;
-  filter->linespace = 6;
-  filter->vscale = 50;
-}
+  GstRevTV *revtv;
+
+  g_return_if_fail (GST_IS_REVTV (videofilter));
+  revtv = GST_REVTV (videofilter);
 
+  revtv->width = gst_videofilter_get_input_width (videofilter);
+  revtv->height = gst_videofilter_get_input_height (videofilter);
+}
 
 static void
-gst_revtv_chain (GstPad * pad, GstData *_data)
+gst_revtv_rgb32 (GstVideofilter *videofilter, void *d, void *s)
 {
-  GstBuffer *buf = GST_BUFFER (_data);
   GstRevTV *filter;
   guint32 *src, *dest;
-  GstBuffer *outbuf;
-  gint width, height, area;
+  gint width, height;
   guint32 *nsrc;
   gint y, x, R, G, B, yval;
 
-  filter = GST_REVTV (gst_pad_get_parent (pad));
+  filter = GST_REVTV (videofilter);
 
-  src = (guint32 *) GST_BUFFER_DATA (buf);
+  src = (guint32 *) s;
+  dest = (guint32 *) d;
 
   width = filter->width;
   height = filter->height;
-  area = width * height;
 
-  outbuf = gst_buffer_new ();
-  GST_BUFFER_SIZE (outbuf) = area * sizeof(guint32);
-  dest = (guint32 *) GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
-  GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+  /* Clear everything to black */
+  memset (dest, 0, width*height*sizeof(guint32));
 
   // draw the offset lines
   for (y = 0; y < height ; y += filter->linespace){
@@ -259,10 +246,6 @@ gst_revtv_chain (GstPad * pad, GstData *_data)
       }
     }
   }
-  
-  gst_buffer_unref (buf);
-
-  gst_pad_push (filter->srcpad, GST_DATA (outbuf));
 }
 
 static void
index 22948b5..790649d 100644 (file)
 #include <math.h>
 #include <string.h>
 #include <gst/gst.h>
-#include "gsteffectv.h"
+#include <gstvideofilter.h>
 
 #define GST_TYPE_SHAGADELICTV \
   (gst_shagadelictv_get_type())
 #define GST_SHAGADELICTV(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SHAGADELICTV,GstShagadelicTV))
 #define GST_SHAGADELICTV_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstShagadelicTV))
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SHAGADELICTV,GstShagadelicTVClass))
 #define GST_IS_SHAGADELICTV(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHAGADELICTV))
 #define GST_IS_SHAGADELICTV_CLASS(obj) \
@@ -46,9 +46,7 @@ typedef struct _GstShagadelicTVClass GstShagadelicTVClass;
 
 struct _GstShagadelicTV
 {
-  GstElement element;
-
-  GstPad *sinkpad, *srcpad;
+  GstVideofilter videofilter;
 
   gint width, height;
   gint stat;
@@ -63,18 +61,9 @@ struct _GstShagadelicTV
 
 struct _GstShagadelicTVClass
 {
-  GstElementClass parent_class;
+  GstVideofilterClass parent_class;
 };
 
-/* elementfactory information */
-static GstElementDetails gst_shagadelictv_details = GST_ELEMENT_DETAILS (
-  "ShagadelicTV",
-  "Filter/Effect/Video",
-  "Oh behave, ShagedelicTV makes images shagadelic!",
-  "Wim Taymans <wim.taymans@chello.be>"
-);
-
-
 /* Filter signals and args */
 enum
 {
@@ -88,8 +77,8 @@ enum
 };
 
 static void    gst_shagadelictv_base_init      (gpointer g_class);
-static void    gst_shagadelictv_class_init     (GstShagadelicTVClass * klass);
-static void    gst_shagadelictv_init           (GstShagadelicTV * filter);
+static void    gst_shagadelictv_class_init     (gpointer g_class, gpointer class_data);
+static void    gst_shagadelictv_init           (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_shagadelic_initialize       (GstShagadelicTV *filter);
 
@@ -97,10 +86,9 @@ static void  gst_shagadelictv_set_property   (GObject * object, guint prop_id,
                                                 const GValue * value, GParamSpec * pspec);
 static void    gst_shagadelictv_get_property   (GObject * object, guint prop_id,
                                                 GValue * value, GParamSpec * pspec);
+static void    gst_shagadelictv_setup          (GstVideofilter *videofilter);
+static void     gst_shagadelictv_rgb32                 (GstVideofilter *videofilter, void *d, void *s);
 
-static void    gst_shagadelictv_chain          (GstPad * pad, GstData *_data);
-
-static GstElementClass *parent_class = NULL;
 /*static guint gst_shagadelictv_signals[LAST_SIGNAL] = { 0 }; */
 
 GType gst_shagadelictv_get_type (void)
@@ -120,52 +108,77 @@ GType gst_shagadelictv_get_type (void)
       (GInstanceInitFunc) gst_shagadelictv_init,
     };
 
-    shagadelictv_type = g_type_register_static (GST_TYPE_ELEMENT, "GstShagadelicTV", &shagadelictv_info, 0);
+    shagadelictv_type = g_type_register_static (GST_TYPE_VIDEOFILTER, "GstShagadelicTV", &shagadelictv_info, 0);
   }
   return shagadelictv_type;
 }
 
+static GstVideofilterFormat gst_shagadelictv_formats[] = {
+  { "RGB ", 32, gst_shagadelictv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }
+};
+  
 static void
 gst_shagadelictv_base_init (gpointer g_class)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  /* elementfactory information */
+  static GstElementDetails gst_shagadelictv_details = GST_ELEMENT_DETAILS (
+    "ShagadelicTV",
+    "Filter/Effect/Video",
+    "Oh behave, ShagedelicTV makes images shagadelic!",
+    "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_shagadelictv_details);
+
+  for(i=0;i<G_N_ELEMENTS(gst_shagadelictv_formats);i++){
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_shagadelictv_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_shagadelictv_class_init (GstShagadelicTVClass * klass)
+gst_shagadelictv_class_init (gpointer g_class, gpointer class_data)
 {
   GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
-
-  gobject_class = (GObjectClass *) klass;
-  gstelement_class = (GstElementClass *) klass;
+  GstVideofilterClass *videofilter_class;
 
-  parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+  gobject_class = G_OBJECT_CLASS (g_class);
+  videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
 
   gobject_class->set_property = gst_shagadelictv_set_property;
   gobject_class->get_property = gst_shagadelictv_get_property;
+
+  videofilter_class->setup = gst_shagadelictv_setup;
 }
 
-static GstPadLinkReturn
-gst_shagadelictv_sinkconnect (GstPad * pad, const GstCaps * caps)
+static void
+gst_shagadelictv_init (GTypeInstance *instance, gpointer g_class)
 {
-  GstShagadelicTV *filter;
-  gint area;
-  GstStructure *structure;
+  GstShagadelicTV *filter = GST_SHAGADELICTV (instance);
+
+  filter->ripple = NULL;
+  filter->spiral = NULL;
+}
 
-  filter = GST_SHAGADELICTV (gst_pad_get_parent (pad));
+static void 
+gst_shagadelictv_setup(GstVideofilter *videofilter)
+{
+  GstShagadelicTV *filter;
+  int width = gst_videofilter_get_input_width(videofilter);
+  int height = gst_videofilter_get_input_height(videofilter);
+  int area;
 
-  structure = gst_caps_get_structure (caps, 0);
+  g_return_if_fail (GST_IS_SHAGADELICTV (videofilter));
+  filter = GST_SHAGADELICTV (videofilter);
 
-  gst_structure_get_int  (structure, "width", &filter->width);
-  gst_structure_get_int  (structure, "height", &filter->height);
+  filter->width = width;
+  filter->height = height;
 
   area = filter->width * filter->height;
 
@@ -176,25 +189,6 @@ gst_shagadelictv_sinkconnect (GstPad * pad, const GstCaps * caps)
   filter->spiral = (gchar *) g_malloc (area);
 
   gst_shagadelic_initialize (filter);
-
-  return gst_pad_try_set_caps (filter->srcpad, caps);
-}
-
-static void
-gst_shagadelictv_init (GstShagadelicTV * filter)
-{
-  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_shagadelictv_chain);
-  gst_pad_set_link_function (filter->sinkpad, gst_shagadelictv_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);
-
-  filter->ripple = NULL;
-  filter->spiral = NULL;
 }
 
 static unsigned int
@@ -259,30 +253,20 @@ gst_shagadelic_initialize (GstShagadelicTV *filter)
   filter->phase = 0;
 }
 
-int shagadelicDraw()
-{
-       return 0;
-}
 static void
-gst_shagadelictv_chain (GstPad * pad, GstData *_data)
+gst_shagadelictv_rgb32 (GstVideofilter *videofilter, void *d, void *s)
 {
-  GstBuffer *buf = GST_BUFFER (_data);
   GstShagadelicTV *filter;
   guint32 *src, *dest;
-  GstBuffer *outbuf;
   gint x, y;
   guint32 v;
   guchar r, g, b;
   gint width, height;
 
-  filter = GST_SHAGADELICTV (gst_pad_get_parent (pad));
-
-  src = (guint32 *) GST_BUFFER_DATA (buf);
+  filter = GST_SHAGADELICTV (videofilter);
 
-  outbuf = gst_buffer_new ();
-  GST_BUFFER_SIZE (outbuf) = (filter->width * filter->height * 4);
-  dest = (guint32 *) GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
-  GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+  src = (guint32 *) s;
+  dest = (guint32 *) d;
 
   width = filter->width;
   height = filter->height;
@@ -312,10 +296,6 @@ gst_shagadelictv_chain (GstPad * pad, GstData *_data)
   filter->ry += filter->rvy;
   filter->bx += filter->bvx;
   filter->by += filter->bvy;
-
-  gst_buffer_unref (buf);
-
-  gst_pad_push (filter->srcpad, GST_DATA (outbuf));
 }
 
 static void
index 9bcbf39..06e795e 100644 (file)
 #include <math.h>
 #include <string.h>
 #include <gst/gst.h>
-#include "gsteffectv.h"
+#include <gstvideofilter.h>
 
 #define GST_TYPE_VERTIGOTV \
   (gst_vertigotv_get_type())
 #define GST_VERTIGOTV(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VERTIGOTV,GstVertigoTV))
 #define GST_VERTIGOTV_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstVertigoTV))
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VERTIGOTV,GstVertigoTVClass))
 #define GST_IS_VERTIGOTV(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VERTIGOTV))
 #define GST_IS_VERTIGOTV_CLASS(obj) \
@@ -46,9 +46,7 @@ typedef struct _GstVertigoTVClass GstVertigoTVClass;
 
 struct _GstVertigoTV
 {
-  GstElement element;
-
-  GstPad *sinkpad, *srcpad;
+  GstVideofilter videofilter;
 
   gint width, height;
   guint32 *buffer;
@@ -58,25 +56,15 @@ struct _GstVertigoTV
   gdouble phase;
   gdouble phase_increment;
   gdouble zoomrate;
-
 };
 
 struct _GstVertigoTVClass
 {
-  GstElementClass parent_class;
+  GstVideofilterClass parent_class;
 
   void (*reset) (GstElement *element);
 };
 
-/* elementfactory information */
-static GstElementDetails gst_vertigotv_details = GST_ELEMENT_DETAILS (
-  "VertigoTV",
-  "Filter/Effect/Video",
-  "A loopback alpha blending effector with rotating and scaling",
-  "Wim Taymans <wim.taymans@chello.be>"
-);
-
-
 /* Filter signals and args */
 enum
 {
@@ -93,8 +81,9 @@ enum
 };
 
 static void    gst_vertigotv_base_init         (gpointer g_class);
-static void    gst_vertigotv_class_init        (GstVertigoTVClass * klass);
-static void    gst_vertigotv_init              (GstVertigoTV * filter);
+static void    gst_vertigotv_class_init        (GstVertigoTVClass * klass, gpointer class_data);
+static void    gst_vertigotv_init              (GTypeInstance *instance, gpointer g_class);
+static void     gst_vertigotv_setup            (GstVideofilter *videofilter);
 
 static void    gst_vertigotv_reset_handler     (GstElement *element);
 
@@ -102,10 +91,8 @@ static void         gst_vertigotv_set_property      (GObject * object, guint prop_id,
                                                 const GValue * value, GParamSpec * pspec);
 static void    gst_vertigotv_get_property      (GObject * object, guint prop_id,
                                                 GValue * value, GParamSpec * pspec);
+static void     gst_vertigotv_rgb32            (GstVideofilter *videofilter, void *d, void *s);
 
-static void    gst_vertigotv_chain             (GstPad * pad, GstData *_data);
-
-static GstElementClass *parent_class = NULL;
 static guint gst_vertigotv_signals[LAST_SIGNAL] = { 0 };
 
 GType gst_vertigotv_get_type (void)
@@ -125,34 +112,49 @@ GType gst_vertigotv_get_type (void)
       (GInstanceInitFunc) gst_vertigotv_init,
     };
 
-    vertigotv_type = g_type_register_static (GST_TYPE_ELEMENT, "GstVertigoTV", &vertigotv_info, 0);
+    vertigotv_type = g_type_register_static (GST_TYPE_VIDEOFILTER, "GstVertigoTV", &vertigotv_info, 0);
   }
   return vertigotv_type;
 }
 
+static GstVideofilterFormat gst_vertigotv_formats[] = {
+  { "RGB ", 32, gst_vertigotv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }
+};
+
 static void
 gst_vertigotv_base_init (gpointer g_class)
 {
+  /* elementfactory information */
+  static GstElementDetails vertigotv_details = GST_ELEMENT_DETAILS (
+    "VertigoTV",
+    "Filter/Effect/Video",
+    "A loopback alpha blending effector with rotating and scaling",
+    "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, &vertigotv_details);
 
-  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));
-  gst_element_class_set_details (element_class, &gst_vertigotv_details);
+  for(i=0;i<G_N_ELEMENTS(gst_vertigotv_formats);i++){
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_vertigotv_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_vertigotv_class_init (GstVertigoTVClass * klass)
+gst_vertigotv_class_init (GstVertigoTVClass * klass, gpointer class_data)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
+  GstVideofilterClass *videofilter_class;
 
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
-
-  parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+  videofilter_class = GST_VIDEOFILTER_CLASS (klass);
 
   gst_vertigotv_signals[RESET_SIGNAL] =
     g_signal_new ("reset-parms",
@@ -174,6 +176,8 @@ gst_vertigotv_class_init (GstVertigoTVClass * klass)
 
   gobject_class->set_property = gst_vertigotv_set_property;
   gobject_class->get_property = gst_vertigotv_get_property;
+
+  videofilter_class->setup = gst_vertigotv_setup;
 }
 
 static void
@@ -186,22 +190,21 @@ gst_vertigotv_reset_handler (GstElement *element)
   filter->zoomrate = 1.01;
 }
 
-
-static GstPadLinkReturn
-gst_vertigotv_sinkconnect (GstPad * pad, const GstCaps * caps)
+static void 
+gst_vertigotv_setup(GstVideofilter *videofilter)
 {
   GstVertigoTV *filter;
   gint area;
-  GstStructure *structure;
+  int width = gst_videofilter_get_input_width(videofilter);
+  int height = gst_videofilter_get_input_height(videofilter);
 
-  filter = GST_VERTIGOTV (gst_pad_get_parent (pad));
+  g_return_if_fail(GST_IS_VERTIGOTV(videofilter));
+  filter = GST_VERTIGOTV(videofilter);
 
-  structure = gst_caps_get_structure (caps, 0);
+  filter->width = width;
+  filter->height = height;
 
-  gst_structure_get_int  (structure, "width", &filter->width);
-  gst_structure_get_int  (structure, "height", &filter->height);
-
-  area = filter->width * filter->height;
+  area = width * height;
 
   g_free (filter->buffer);
   filter->buffer = (guint32 *) g_malloc (area * 2 * sizeof(guint32));
@@ -210,22 +213,12 @@ gst_vertigotv_sinkconnect (GstPad * pad, const GstCaps * caps)
   filter->current_buffer = filter->buffer;
   filter->alt_buffer = filter->buffer + area;
   filter->phase = 0;
-
-  return gst_pad_try_set_caps (filter->srcpad, caps);
 }
 
 static void
-gst_vertigotv_init (GstVertigoTV * filter)
+gst_vertigotv_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_vertigotv_chain);
-  gst_pad_set_link_function (filter->sinkpad, gst_vertigotv_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);
+  GstVertigoTV *filter = GST_VERTIGOTV (instance);
 
   filter->buffer = NULL;
   filter->phase = 0.0;
@@ -276,13 +269,11 @@ gst_vertigotv_set_parms (GstVertigoTV *filter)
   if (filter->phase > 5700000) filter->phase = 0;
 }
        
-static void
-gst_vertigotv_chain (GstPad * pad, GstData *_data)
+static void     
+gst_vertigotv_rgb32 (GstVideofilter *videofilter, void *d, void *s)
 {
-  GstBuffer *buf = GST_BUFFER (_data);
   GstVertigoTV *filter;
   guint32 *src, *dest;
-  GstBuffer *outbuf;
   guint32 *p;
   guint32 v;
   gint x, y;
@@ -290,19 +281,15 @@ gst_vertigotv_chain (GstPad * pad, GstData *_data)
   gint i;
   gint width, height, area;
 
-  filter = GST_VERTIGOTV (gst_pad_get_parent (pad));
+  filter = GST_VERTIGOTV (videofilter);
 
-  src = (guint32 *) GST_BUFFER_DATA (buf);
+  src = (guint32 *) s;
+  dest = (guint32 *) d;
 
   width = filter->width;
   height = filter->height;
   area = width * height;
 
-  outbuf = gst_buffer_new ();
-  GST_BUFFER_SIZE (outbuf) = area * sizeof(guint32);
-  dest = (guint32 *) GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
-  GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
-  
   gst_vertigotv_set_parms (filter);
   p = filter->alt_buffer;
 
@@ -328,10 +315,6 @@ gst_vertigotv_chain (GstPad * pad, GstData *_data)
 
   memcpy(dest, filter->alt_buffer, area * sizeof(guint32));
 
-  gst_buffer_unref (buf);
-
-  gst_pad_push (filter->srcpad, GST_DATA (outbuf));
-
   p = filter->current_buffer;
   filter->current_buffer = filter->alt_buffer;
   filter->alt_buffer = p;
index 6331993..82c24dd 100644 (file)
@@ -132,7 +132,6 @@ static GstVideofilterFormat gst_warptv_formats[] = {
   { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 },
 };
 
-  
 static void
 gst_warptv_base_init (gpointer g_class)
 {