summaryrefslogtreecommitdiffstats
path: root/gst/effectv/gstvertigo.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/effectv/gstvertigo.c')
-rw-r--r--gst/effectv/gstvertigo.c304
1 files changed, 152 insertions, 152 deletions
diff --git a/gst/effectv/gstvertigo.c b/gst/effectv/gstvertigo.c
index d44a5a0b..abe92a52 100644
--- a/gst/effectv/gstvertigo.c
+++ b/gst/effectv/gstvertigo.c
@@ -25,10 +25,13 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+
+#include <gstvideofilter.h>
+
#include <math.h>
#include <string.h>
-#include <gst/gst.h>
-#include <gstvideofilter.h>
+
+#include <gst/video/video.h>
#define GST_TYPE_VERTIGOTV \
(gst_vertigotv_get_type())
@@ -61,18 +64,11 @@ struct _GstVertigoTV
struct _GstVertigoTVClass
{
GstVideofilterClass parent_class;
-
- void (*reset) (GstElement * element);
};
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- RESET_SIGNAL,
- LAST_SIGNAL
-};
+GType gst_vertigotv_get_type (void);
+/* Filter signals and args */
enum
{
ARG_0,
@@ -80,152 +76,77 @@ enum
ARG_ZOOM_SPEED
};
-static void gst_vertigotv_base_init (gpointer g_class);
-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);
-
-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 guint gst_vertigotv_signals[LAST_SIGNAL] = { 0 };
-
-GType
-gst_vertigotv_get_type (void)
+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>");
+
+static GstStaticPadTemplate gst_vertigotv_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
+ );
+
+static GstStaticPadTemplate gst_vertigotv_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
+ );
+
+static GstVideofilterClass *parent_class = NULL;
+
+static gboolean
+gst_vertigotv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
+ GstCaps * outcaps)
{
- static GType vertigotv_type = 0;
+ GstVertigoTV *filter = GST_VERTIGOTV (btrans);
+ GstStructure *structure;
+ gboolean ret = FALSE;
- if (!vertigotv_type) {
- static const GTypeInfo vertigotv_info = {
- sizeof (GstVertigoTVClass),
- gst_vertigotv_base_init,
- NULL,
- (GClassInitFunc) gst_vertigotv_class_init,
- NULL,
- NULL,
- sizeof (GstVertigoTV),
- 0,
- (GInstanceInitFunc) gst_vertigotv_init,
- };
+ structure = gst_caps_get_structure (incaps, 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}
-};
+ if (gst_structure_get_int (structure, "width", &filter->width) &&
+ gst_structure_get_int (structure, "height", &filter->height)) {
+ gint area = filter->width * filter->height;
-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;
+ g_free (filter->buffer);
+ filter->buffer = (guint32 *) g_malloc (area * 2 * sizeof (guint32));
- gst_element_class_set_details (element_class, &vertigotv_details);
+ memset (filter->buffer, 0, area * 2 * sizeof (guint32));
+ filter->current_buffer = filter->buffer;
+ filter->alt_buffer = filter->buffer + area;
+ filter->phase = 0;
- for (i = 0; i < G_N_ELEMENTS (gst_vertigotv_formats); i++) {
- gst_videofilter_class_add_format (videofilter_class,
- gst_vertigotv_formats + i);
+ ret = TRUE;
}
- gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
+ return ret;
}
-static void
-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;
- videofilter_class = GST_VIDEOFILTER_CLASS (klass);
-
- gst_vertigotv_signals[RESET_SIGNAL] =
- g_signal_new ("reset-parms",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GstVertigoTVClass, reset),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
- klass->reset = gst_vertigotv_reset_handler;
-
- gobject_class->set_property = gst_vertigotv_set_property;
- gobject_class->get_property = gst_vertigotv_get_property;
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SPEED,
- g_param_spec_float ("speed", "Speed", "Control the speed of movement",
- 0.01, 100.0, 0.02, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ZOOM_SPEED,
- g_param_spec_float ("zoom_speed", "Zoom Speed",
- "Control the rate of zooming", 1.01, 1.1, 1.01, G_PARAM_READWRITE));
-
- videofilter_class->setup = gst_vertigotv_setup;
-}
-
-static void
-gst_vertigotv_reset_handler (GstElement * element)
-{
- GstVertigoTV *filter = GST_VERTIGOTV (element);
-
- filter->phase = 0.0;
- filter->phase_increment = 0.02;
- filter->zoomrate = 1.01;
-}
-
-static void
-gst_vertigotv_setup (GstVideofilter * videofilter)
+static gboolean
+gst_vertigotv_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
+ guint * size)
{
GstVertigoTV *filter;
- gint area;
- int width = gst_videofilter_get_input_width (videofilter);
- int height = gst_videofilter_get_input_height (videofilter);
-
- g_return_if_fail (GST_IS_VERTIGOTV (videofilter));
- filter = GST_VERTIGOTV (videofilter);
-
- filter->width = width;
- filter->height = height;
+ GstStructure *structure;
+ gboolean ret = FALSE;
+ gint width, height;
- area = width * height;
+ filter = GST_VERTIGOTV (btrans);
- g_free (filter->buffer);
- filter->buffer = (guint32 *) g_malloc (area * 2 * sizeof (guint32));
+ structure = gst_caps_get_structure (caps, 0);
- memset (filter->buffer, 0, area * 2 * sizeof (guint32));
- filter->current_buffer = filter->buffer;
- filter->alt_buffer = filter->buffer + area;
- filter->phase = 0;
-}
-
-static void
-gst_vertigotv_init (GTypeInstance * instance, gpointer g_class)
-{
- GstVertigoTV *filter = GST_VERTIGOTV (instance);
+ if (gst_structure_get_int (structure, "width", &width) &&
+ gst_structure_get_int (structure, "height", &height)) {
+ *size = width * height * 32 / 8;
+ ret = TRUE;
+ GST_DEBUG_OBJECT (filter, "our frame size is %d bytes (%dx%d)", *size,
+ width, height);
+ }
- filter->buffer = NULL;
- filter->phase = 0.0;
- filter->phase_increment = 0.02;
- filter->zoomrate = 1.01;
+ return ret;
}
static void
@@ -276,22 +197,22 @@ gst_vertigotv_set_parms (GstVertigoTV * filter)
filter->phase = 0;
}
-static void
-gst_vertigotv_rgb32 (GstVideofilter * videofilter, void *d, void *s)
+static GstFlowReturn
+gst_vertigotv_transform (GstBaseTransform * trans, GstBuffer * in,
+ GstBuffer * out)
{
GstVertigoTV *filter;
- guint32 *src, *dest;
- guint32 *p;
+ guint32 *src, *dest, *p;
guint32 v;
- gint x, y;
- gint ox, oy;
- gint i;
- gint width, height, area;
+ gint x, y, ox, oy, i, width, height, area;
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ filter = GST_VERTIGOTV (trans);
- filter = GST_VERTIGOTV (videofilter);
+ gst_buffer_stamp (out, in);
- src = (guint32 *) s;
- dest = (guint32 *) d;
+ src = (guint32 *) GST_BUFFER_DATA (in);
+ dest = (guint32 *) GST_BUFFER_DATA (out);
width = filter->width;
height = filter->height;
@@ -327,6 +248,8 @@ gst_vertigotv_rgb32 (GstVideofilter * videofilter, void *d, void *s)
p = filter->current_buffer;
filter->current_buffer = filter->alt_buffer;
filter->alt_buffer = p;
+
+ return ret;
}
static void
@@ -373,3 +296,80 @@ gst_vertigotv_get_property (GObject * object, guint prop_id, GValue * value,
break;
}
}
+
+static void
+gst_vertigotv_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_set_details (element_class, &vertigotv_details);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vertigotv_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vertigotv_src_template));
+}
+
+static void
+gst_vertigotv_class_init (gpointer klass, gpointer class_data)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *element_class;
+ GstBaseTransformClass *trans_class;
+
+ gobject_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+ trans_class = (GstBaseTransformClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->set_property = gst_vertigotv_set_property;
+ gobject_class->get_property = gst_vertigotv_get_property;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SPEED,
+ g_param_spec_float ("speed", "Speed", "Control the speed of movement",
+ 0.01, 100.0, 0.02, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ZOOM_SPEED,
+ g_param_spec_float ("zoom_speed", "Zoom Speed",
+ "Control the rate of zooming", 1.01, 1.1, 1.01, G_PARAM_READWRITE));
+
+ trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_vertigotv_set_caps);
+ trans_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_vertigotv_get_unit_size);
+ trans_class->transform = GST_DEBUG_FUNCPTR (gst_vertigotv_transform);
+}
+
+static void
+gst_vertigotv_init (GTypeInstance * instance, gpointer g_class)
+{
+ GstVertigoTV *filter = GST_VERTIGOTV (instance);
+
+ filter->buffer = NULL;
+ filter->phase = 0.0;
+ filter->phase_increment = 0.02;
+ filter->zoomrate = 1.01;
+}
+
+GType
+gst_vertigotv_get_type (void)
+{
+ static GType vertigotv_type = 0;
+
+ if (!vertigotv_type) {
+ static const GTypeInfo vertigotv_info = {
+ sizeof (GstVertigoTVClass),
+ gst_vertigotv_base_init,
+ NULL,
+ (GClassInitFunc) gst_vertigotv_class_init,
+ NULL,
+ NULL,
+ sizeof (GstVertigoTV),
+ 0,
+ (GInstanceInitFunc) gst_vertigotv_init,
+ };
+
+ vertigotv_type =
+ g_type_register_static (GST_TYPE_VIDEOFILTER, "GstVertigoTV",
+ &vertigotv_info, 0);
+ }
+ return vertigotv_type;
+}