diff options
author | Jan Schmidt <thaytan@mad.scientist.com> | 2004-03-12 13:56:51 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@mad.scientist.com> | 2004-03-12 13:56:51 +0000 |
commit | efe98f103049b9612c4bcfeae4572dcd8a6ea37b (patch) | |
tree | 128ebc12142b38e9f550e84551c53a941c02ae61 /gst/effectv/gstvertigo.c | |
parent | 2cb6e77679267eff31d33743e83b3686e665df91 (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/gstvertigo.c')
-rw-r--r-- | gst/effectv/gstvertigo.c | 119 |
1 files changed, 51 insertions, 68 deletions
diff --git a/gst/effectv/gstvertigo.c b/gst/effectv/gstvertigo.c index 9bcbf393..06e795ea 100644 --- a/gst/effectv/gstvertigo.c +++ b/gst/effectv/gstvertigo.c @@ -28,14 +28,14 @@ #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; |