2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
5 * Copyright (C) 2001 FUKUCHI Kentarou
7 * EffecTV - Realtime Digital Video Effector
8 * Copyright (C) 2001 FUKUCHI Kentarou
10 * revTV based on Rutt-Etra Video Synthesizer 1974?
12 * (c)2002 Ed Tannenbaum
14 * This effect acts like a waveform monitor on each line.
15 * It was originally done by deflecting the electron beam on a monitor using
16 * additional electromagnets on the yoke of a b/w CRT.
17 * Here it is emulated digitally.
19 * Experimaental tapes were made with this system by Bill and
20 * Louise Etra and Woody and Steina Vasulka
22 * The line spacing can be controlled using the 1 and 2 Keys.
23 * The gain is controlled using the 3 and 4 keys.
24 * The update rate is controlled using the 0 and - keys.
26 * EffecTV is free software. This library is free software;
27 * you can redistribute it and/or
28 * modify it under the terms of the GNU Library General Public
29 * License as published by the Free Software Foundation; either
30 * version 2 of the License, or (at your option) any later version.
32 * This library is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 * Library General Public License for more details.
37 * You should have received a copy of the GNU Library General Public
38 * License along with this library; if not, write to the
39 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
40 * Boston, MA 02111-1307, USA.
49 #include <gstvideofilter.h>
51 #define GST_TYPE_REVTV \
52 (gst_revtv_get_type())
53 #define GST_REVTV(obj) \
54 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_REVTV,GstRevTV))
55 #define GST_REVTV_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_REVTV,GstRevTVClass))
57 #define GST_IS_REVTV(obj) \
58 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_REVTV))
59 #define GST_IS_REVTV_CLASS(obj) \
60 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_REVTV))
62 #define THE_COLOR 0xffffffff
64 typedef struct _GstRevTV GstRevTV;
65 typedef struct _GstRevTVClass GstRevTVClass;
69 GstVideofilter videofilter;
80 GstVideofilterClass parent_class;
82 void (*reset) (GstElement * element);
85 /* Filter signals and args */
100 static void gst_revtv_base_init (gpointer g_class);
101 static void gst_revtv_class_init (gpointer g_class, gpointer class_data);
102 static void gst_revtv_init (GTypeInstance * instance, gpointer g_class);
104 static void gst_revtv_set_property (GObject * object, guint prop_id,
105 const GValue * value, GParamSpec * pspec);
106 static void gst_revtv_get_property (GObject * object, guint prop_id,
107 GValue * value, GParamSpec * pspec);
108 static void gst_revtv_setup (GstVideofilter * videofilter);
109 static void gst_revtv_rgb32 (GstVideofilter * videofilter, void *d, void *s);
111 /* static guint gst_revtv_signals[LAST_SIGNAL] = { 0 }; */
114 gst_revtv_get_type (void)
116 static GType revtv_type = 0;
119 static const GTypeInfo revtv_info = {
120 sizeof (GstRevTVClass),
123 (GClassInitFunc) gst_revtv_class_init,
128 (GInstanceInitFunc) gst_revtv_init,
132 g_type_register_static (GST_TYPE_VIDEOFILTER, "GstRevTV", &revtv_info,
138 static GstVideofilterFormat gst_revtv_formats[] = {
139 {"RGB ", 32, gst_revtv_rgb32, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000,
144 gst_revtv_base_init (gpointer g_class)
146 /* elementfactory information */
147 static GstElementDetails gst_revtv_details = GST_ELEMENT_DETAILS ("RevTV",
148 "Filter/Effect/Video",
149 "A video waveform monitor for each line of video processed",
150 "Wim Taymans <wim.taymans@chello.be>");
152 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
153 GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
156 gst_element_class_set_details (element_class, &gst_revtv_details);
158 for (i = 0; i < G_N_ELEMENTS (gst_revtv_formats); i++) {
159 gst_videofilter_class_add_format (videofilter_class, gst_revtv_formats + i);
162 gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
166 gst_revtv_class_init (gpointer klass, gpointer class_data)
168 GObjectClass *gobject_class;
169 GstVideofilterClass *videofilter_class;
171 gobject_class = G_OBJECT_CLASS (klass);
172 videofilter_class = GST_VIDEOFILTER_CLASS (klass);
174 gobject_class->set_property = gst_revtv_set_property;
175 gobject_class->get_property = gst_revtv_get_property;
177 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DELAY,
178 g_param_spec_int ("delay", "Delay", "Delay in frames between updates",
179 1, 100, 1, G_PARAM_READWRITE));
180 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LINESPACE,
181 g_param_spec_int ("linespace", "Linespace", "Control line spacing",
182 1, 100, 6, G_PARAM_READWRITE));
183 g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GAIN,
184 g_param_spec_int ("gain", "Gain", "Control gain",
185 1, 200, 50, G_PARAM_READWRITE));
187 videofilter_class->setup = gst_revtv_setup;
191 gst_revtv_init (GTypeInstance * instance, gpointer g_class)
193 GstRevTV *restv = GST_REVTV (instance);
195 restv->vgrabtime = 1;
197 restv->linespace = 6;
202 gst_revtv_setup (GstVideofilter * videofilter)
206 g_return_if_fail (GST_IS_REVTV (videofilter));
207 revtv = GST_REVTV (videofilter);
209 revtv->width = gst_videofilter_get_input_width (videofilter);
210 revtv->height = gst_videofilter_get_input_height (videofilter);
214 gst_revtv_rgb32 (GstVideofilter * videofilter, void *d, void *s)
220 gint y, x, R, G, B, yval;
222 filter = GST_REVTV (videofilter);
225 dest = (guint32 *) d;
227 width = filter->width;
228 height = filter->height;
230 /* Clear everything to black */
231 memset (dest, 0, width * height * sizeof (guint32));
233 // draw the offset lines
234 for (y = 0; y < height; y += filter->linespace) {
235 for (x = 0; x <= width; x++) {
236 nsrc = src + (y * width) + x;
238 // Calc Y Value for curpix
239 R = ((*nsrc) & 0xff0000) >> (16 - 1);
240 G = ((*nsrc) & 0xff00) >> (8 - 2);
243 yval = y - ((short) (R + G + B) / filter->vscale);
246 dest[x + (yval * width)] = THE_COLOR;
253 gst_revtv_set_property (GObject * object, guint prop_id, const GValue * value,
258 g_return_if_fail (GST_IS_REVTV (object));
260 filter = GST_REVTV (object);
264 filter->vgrabtime = g_value_get_int (value);
267 filter->linespace = g_value_get_int (value);
270 filter->vscale = g_value_get_int (value);
278 gst_revtv_get_property (GObject * object, guint prop_id, GValue * value,
283 g_return_if_fail (GST_IS_REVTV (object));
285 filter = GST_REVTV (object);
289 g_value_set_int (value, filter->vgrabtime);
292 g_value_set_int (value, filter->linespace);
295 g_value_set_int (value, filter->vscale);
298 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);