summaryrefslogtreecommitdiffstats
path: root/gst/effectv/gstedge.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/effectv/gstedge.c')
-rw-r--r--gst/effectv/gstedge.c142
1 files changed, 63 insertions, 79 deletions
diff --git a/gst/effectv/gstedge.c b/gst/effectv/gstedge.c
index 137eb358..26bf2696 100644
--- a/gst/effectv/gstedge.c
+++ b/gst/effectv/gstedge.c
@@ -26,14 +26,14 @@
#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