From 1756816071157e3f837eaabba8453e1b453a91d4 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 7 Jan 2004 10:16:09 +0000 Subject: [PATCH] Make warpTV a subclass of videofilter Original commit message from CVS: Make warpTV a subclass of videofilter --- ChangeLog | 11 ++ gst/effectv/Makefile.am | 2 +- gst/effectv/gsteffectv.c | 3 + gst/effectv/gstwarp.c | 330 ++++++++++++++++++++++++----------------------- 4 files changed, 184 insertions(+), 162 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fecd16..264d72e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-01-07 David Schleef + + * gst/videofilter/gstvideotemplate.c: + * gst/videofilter/gstvideotemplate.h: + * gst/videofilter/make_filter: + Merge videotemplate header into source file. + * gst/effectv/Makefile.am: + * gst/effectv/gsteffectv.c: (plugin_init): + * gst/effectv/gstwarp.c: + Make warpTV a subclass of videofilter. + 2004-01-07 Benjamin Otte * ext/mad/gstid3tag.c: (gst_mad_id3_to_tag_list): diff --git a/gst/effectv/Makefile.am b/gst/effectv/Makefile.am index e4668ae..2c3af0d 100644 --- a/gst/effectv/Makefile.am +++ b/gst/effectv/Makefile.am @@ -2,7 +2,7 @@ plugin_LTLIBRARIES = libgsteffectv.la libgsteffectv_la_SOURCES = gsteffectv.c gstedge.c gstaging.c gstdice.c gstwarp.c gstshagadelic.c gstvertigo.c gstrev.c gstquark.c -libgsteffectv_la_CFLAGS = $(GST_CFLAGS) +libgsteffectv_la_CFLAGS = $(GST_CFLAGS) -I$(top_srcdir)/gst/videofilter libgsteffectv_la_LIBADD = libgsteffectv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/gst/effectv/gsteffectv.c b/gst/effectv/gsteffectv.c index 2c90e22..e0dec63 100644 --- a/gst/effectv/gsteffectv.c +++ b/gst/effectv/gsteffectv.c @@ -70,6 +70,9 @@ plugin_init (GstPlugin * plugin) { gint i = 0; + if (!gst_library_load ("gstvideofilter")) + return FALSE; + while (_elements[i].name) { if (!gst_element_register (plugin, _elements[i].name, GST_RANK_NONE, (_elements[i].type) ())) diff --git a/gst/effectv/gstwarp.c b/gst/effectv/gstwarp.c index 0364853..95c72c1 100644 --- a/gst/effectv/gstwarp.c +++ b/gst/effectv/gstwarp.c @@ -1,11 +1,11 @@ /* GStreamer * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef * * EffecTV - Realtime Digital Video Effector * Copyright (C) 2001 FUKUCHI Kentarou - * - * EffecTV is free software. This library is free software; - * you can redistribute it and/or + * + * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. @@ -19,8 +19,14 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. - - * From main.c of warp-1.1: + */ + +/* + * This file was (probably) generated from gstvideotemplate.c, + * gstvideotemplate.c,v 1.11 2004/01/07 08:56:45 ds Exp + */ + +/* From main.c of warp-1.1: * * Simple DirectMedia Layer demo * Realtime picture 'gooing' @@ -30,21 +36,24 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#include +#include #include #include -#include #include "gsteffectv.h" #ifndef M_PI #define M_PI 3.14159265358979323846 #endif + #define GST_TYPE_WARPTV \ (gst_warptv_get_type()) #define GST_WARPTV(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WARPTV,GstWarpTV)) #define GST_WARPTV_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstWarpTV)) + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WARPTV,GstWarpTVClass)) #define GST_IS_WARPTV(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WARPTV)) #define GST_IS_WARPTV_CLASS(obj) \ @@ -53,11 +62,8 @@ typedef struct _GstWarpTV GstWarpTV; typedef struct _GstWarpTVClass GstWarpTVClass; -struct _GstWarpTV -{ - GstElement element; - - GstPad *sinkpad, *srcpad; +struct _GstWarpTV { + GstVideofilter videofilter; gint width, height; gint *offstable; @@ -67,134 +73,193 @@ struct _GstWarpTV gint tval; }; -struct _GstWarpTVClass -{ - GstElementClass parent_class; +struct _GstWarpTVClass { + GstVideofilterClass parent_class; }; -/* elementfactory information */ -static GstElementDetails gst_warptv_details = GST_ELEMENT_DETAILS ( - "WarpTV", - "Filter/Effect/Video", - "WarpTV does realtime goo'ing of the video input", - "Sam Lantinga " -); - -/* Filter signals and args */ -enum -{ +/* GstWarpTV signals and args */ +enum { /* FILL ME */ LAST_SIGNAL }; -enum -{ +enum { ARG_0, + /* FILL ME */ }; -static void gst_warptv_base_init (gpointer g_class); -static void gst_warptv_class_init (GstWarpTVClass * klass); -static void gst_warptv_init (GstWarpTV * filter); - -static void gst_warptv_initialize (GstWarpTV *filter); - -static void gst_warptv_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec); -static void gst_warptv_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec); +static void gst_warptv_base_init (gpointer g_class); +static void gst_warptv_class_init (gpointer g_class, gpointer class_data); +static void gst_warptv_init (GTypeInstance *instance, gpointer g_class); -static void gst_warptv_chain (GstPad * pad, GstData *_data); +static void gst_warptv_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void gst_warptv_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static GstElementClass *parent_class = NULL; -/*static guint gst_warptv_signals[LAST_SIGNAL] = { 0 }; */ +static void gst_warptv_setup(GstVideofilter *videofilter); +static void initSinTable (GstWarpTV *filter); +static void initOffsTable (GstWarpTV *filter); +static void initDistTable (GstWarpTV *filter); +static void gst_warptv_rgb32 (GstVideofilter *videofilter, void *d, void *s); -GType gst_warptv_get_type (void) +GType +gst_warptv_get_type (void) { static GType warptv_type = 0; if (!warptv_type) { static const GTypeInfo warptv_info = { - sizeof (GstWarpTVClass), + sizeof(GstWarpTVClass), gst_warptv_base_init, NULL, - (GClassInitFunc) gst_warptv_class_init, + gst_warptv_class_init, NULL, NULL, - sizeof (GstWarpTV), + sizeof(GstWarpTV), 0, - (GInstanceInitFunc) gst_warptv_init, + gst_warptv_init, }; - - warptv_type = g_type_register_static (GST_TYPE_ELEMENT, "GstWarpTV", &warptv_info, 0); + warptv_type = g_type_register_static(GST_TYPE_VIDEOFILTER, + "GstWarpTV", &warptv_info, 0); } return warptv_type; } +static GstVideofilterFormat gst_warptv_formats[] = { + { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00, 0x000000ff }, + { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000, 0x0000ff00 }, + { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00, 0x00ff0000 }, + { "RGB ", 32, gst_warptv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 }, +}; + + static void gst_warptv_base_init (gpointer g_class) { + static GstElementDetails warptv_details = GST_ELEMENT_DETAILS ( + "WarpTV", + "Filter/Effect/Video", + "WarpTV does realtime goo'ing of the video input", + "Sam Lantinga " + ); 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, &warptv_details); + + for(i=0;iset_property = gst_warptv_set_property; gobject_class->get_property = gst_warptv_get_property; + + videofilter_class->setup = gst_warptv_setup; } -static GstPadLinkReturn -gst_warptv_sinkconnect (GstPad * pad, const GstCaps * caps) +static void +gst_warptv_init (GTypeInstance *instance, gpointer g_class) { - GstWarpTV *filter; - GstStructure *structure; + GstWarpTV *warptv = GST_WARPTV (instance); + GstVideofilter *videofilter; + + GST_DEBUG("gst_warptv_init"); + + videofilter = GST_VIDEOFILTER(warptv); - filter = GST_WARPTV (gst_pad_get_parent (pad)); - structure = gst_caps_get_structure (caps, 0); + /* do stuff */ +} - gst_structure_get_int (structure, "width", &filter->width); - gst_structure_get_int (structure, "height", &filter->height); +static void +gst_warptv_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + GstWarpTV *src; - gst_warptv_initialize (filter); + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_WARPTV(object)); + src = GST_WARPTV(object); - return gst_pad_try_set_caps (filter->srcpad, caps); + GST_DEBUG("gst_warptv_set_property"); + switch (prop_id) { +#if 0 + case ARG_METHOD: + src->method = g_value_get_enum (value); + break; +#endif + default: + break; + } } static void -gst_warptv_init (GstWarpTV * filter) +gst_warptv_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - 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_warptv_chain); - gst_pad_set_link_function (filter->sinkpad, gst_warptv_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->tval = 0; - filter->disttable = NULL; - filter->offstable = NULL; + GstWarpTV *src; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_WARPTV(object)); + src = GST_WARPTV(object); + + switch (prop_id) { +#if 0 + case ARG_METHOD: + g_value_set_enum (value, src->method); + break; +#endif + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +static void gst_warptv_setup(GstVideofilter *videofilter) +{ + GstWarpTV *warptv; + int width = gst_videofilter_get_input_width(videofilter); + int height = gst_videofilter_get_input_height(videofilter); + + g_return_if_fail(GST_IS_WARPTV(videofilter)); + warptv = GST_WARPTV(videofilter); + + /* if any setup needs to be done, do it here */ + + warptv->width = width; + warptv->height = height; + warptv->tval = 0; + + g_free (warptv->disttable); + g_free (warptv->offstable); + + warptv->offstable = (guint32 *) g_malloc (height * sizeof (guint32)); + warptv->disttable = g_malloc (width * height * sizeof (guint32)); + + initSinTable (warptv); + initOffsTable (warptv); + initDistTable (warptv); +} + static void initSinTable (GstWarpTV *filter) { @@ -246,53 +311,32 @@ initDistTable (GstWarpTV *filter) #endif } -static void -gst_warptv_initialize (GstWarpTV *filter) -{ - g_free (filter->disttable); - g_free (filter->offstable); - - filter->offstable = (guint32 *) g_malloc (filter->height * sizeof (guint32)); - filter->disttable = g_malloc (filter->width * filter->height * sizeof (guint32)); - - initSinTable (filter); - initOffsTable (filter); - initDistTable (filter); -} - -static void -gst_warptv_chain (GstPad * pad, GstData *_data) +static void gst_warptv_rgb32 (GstVideofilter *videofilter, + void *d, void *s) { - GstBuffer *buf = GST_BUFFER (_data); - GstWarpTV *filter; - guint32 *src, *dest; + GstWarpTV *warptv; + int width = gst_videofilter_get_input_width(videofilter); + int height = gst_videofilter_get_input_height(videofilter); + guint32 *src = s; + guint32 *dest = d; gint xw,yw,cw; - GstBuffer *outbuf; gint32 c,i, x,y, dx,dy, maxx, maxy; - gint32 width, height, skip, *ctptr, *distptr; + gint32 skip, *ctptr, *distptr; gint32 *sintable, *ctable; - filter = GST_WARPTV (gst_pad_get_parent (pad)); + g_return_if_fail(GST_IS_WARPTV(videofilter)); + warptv = GST_WARPTV(videofilter); - src = (guint32 *) GST_BUFFER_DATA (buf); + xw = (gint) (sin ((warptv->tval + 100) * M_PI / 128) * 30); + yw = (gint) (sin ((warptv->tval) * M_PI / 256) * -35); + cw = (gint) (sin ((warptv->tval - 70) * M_PI / 64) * 50); + xw += (gint) (sin ((warptv->tval - 10) * M_PI / 512) * 40); + yw += (gint) (sin ((warptv->tval + 30) * M_PI / 512) * 40); - 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); - - xw = (gint) (sin ((filter->tval + 100) * M_PI / 128) * 30); - yw = (gint) (sin ((filter->tval) * M_PI / 256) * -35); - cw = (gint) (sin ((filter->tval - 70) * M_PI / 64) * 50); - xw += (gint) (sin ((filter->tval - 10) * M_PI / 512) * 40); - yw += (gint) (sin ((filter->tval + 30) * M_PI / 512) * 40); - - ctptr = filter->ctable; - distptr = filter->disttable; - width = filter->width; - height = filter->height; - sintable = filter->sintable; - ctable = filter->ctable; + ctptr = warptv->ctable; + distptr = warptv->disttable; + sintable = warptv->sintable; + ctable = warptv->ctable; skip = 0 ; /* video_width*sizeof(RGB32)/4 - video_width;; */ c = 0; @@ -316,47 +360,11 @@ gst_warptv_chain (GstPad * pad, GstData *_data) if (dy < 0) dy = 0; else if (dy > maxy) dy = maxy; - *dest++ = src[filter->offstable[dy] + dx]; + *dest++ = src[warptv->offstable[dy] + dx]; } dest += skip; } - filter->tval = (filter->tval + 1) & 511; - - gst_buffer_unref (buf); - - gst_pad_push (filter->srcpad, GST_DATA (outbuf)); + warptv->tval = (warptv->tval + 1) & 511; } -static void -gst_warptv_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) -{ - GstWarpTV *filter; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail (GST_IS_WARPTV (object)); - - filter = GST_WARPTV (object); - - switch (prop_id) { - default: - break; - } -} - -static void -gst_warptv_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) -{ - GstWarpTV *filter; - - /* it's not null if we got it, but it might not be ours */ - g_return_if_fail (GST_IS_WARPTV (object)); - - filter = GST_WARPTV (object); - - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} -- 2.7.4