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.
44 * SECTION:element-quarktv
46 * RevTV acts like a video waveform monitor for each line of video
47 * processed. This creates a pseudo 3D effect based on the brightness
48 * of the video along each line.
51 * <title>Example launch line</title>
53 * gst-launch -v videotestsrc ! revtv ! ffmpegcolorspace ! autovideosink
54 * ]| This pipeline shows the effect of revtv on a test stream.
67 #include <gst/video/video.h>
68 #include <gst/controller/gstcontroller.h>
70 #define THE_COLOR 0xffffffff
80 GST_BOILERPLATE (GstRevTV, gst_revtv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
82 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
83 #define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx
85 #define CAPS_STR GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_xRGB
88 static GstStaticPadTemplate gst_revtv_src_template =
89 GST_STATIC_PAD_TEMPLATE ("src",
92 GST_STATIC_CAPS (CAPS_STR)
95 static GstStaticPadTemplate gst_revtv_sink_template =
96 GST_STATIC_PAD_TEMPLATE ("sink",
99 GST_STATIC_CAPS (CAPS_STR)
103 gst_revtv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
106 GstRevTV *filter = GST_REVTV (btrans);
107 GstStructure *structure;
108 gboolean ret = FALSE;
110 structure = gst_caps_get_structure (incaps, 0);
112 GST_OBJECT_LOCK (filter);
113 if (gst_structure_get_int (structure, "width", &filter->width) &&
114 gst_structure_get_int (structure, "height", &filter->height)) {
117 GST_OBJECT_UNLOCK (filter);
123 gst_revtv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
125 GstRevTV *filter = GST_REVTV (trans);
129 gint y, x, R, G, B, yval;
130 GstFlowReturn ret = GST_FLOW_OK;
131 gint linespace, vscale;
132 GstClockTime timestamp, stream_time;
134 timestamp = GST_BUFFER_TIMESTAMP (in);
136 gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME, timestamp);
138 GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
139 GST_TIME_ARGS (timestamp));
141 if (GST_CLOCK_TIME_IS_VALID (stream_time))
142 gst_object_sync_values (G_OBJECT (filter), stream_time);
144 src = (guint32 *) GST_BUFFER_DATA (in);
145 dest = (guint32 *) GST_BUFFER_DATA (out);
147 GST_OBJECT_LOCK (filter);
148 width = filter->width;
149 height = filter->height;
151 /* Clear everything to black */
152 memset (dest, 0, width * height * sizeof (guint32));
154 linespace = filter->linespace;
155 vscale = filter->vscale;
157 /* draw the offset lines */
158 for (y = 0; y < height; y += linespace) {
159 for (x = 0; x <= width; x++) {
160 nsrc = src + (y * width) + x;
162 /* Calc Y Value for curpix */
163 R = ((*nsrc) & 0xff0000) >> (16 - 1);
164 G = ((*nsrc) & 0xff00) >> (8 - 2);
167 yval = y - ((short) (R + G + B) / vscale);
170 dest[x + (yval * width)] = THE_COLOR;
174 GST_OBJECT_UNLOCK (filter);
180 gst_revtv_set_property (GObject * object, guint prop_id, const GValue * value,
183 GstRevTV *filter = GST_REVTV (object);
185 GST_OBJECT_LOCK (filter);
188 filter->vgrabtime = g_value_get_int (value);
191 filter->linespace = g_value_get_int (value);
194 filter->vscale = g_value_get_int (value);
197 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
200 GST_OBJECT_UNLOCK (filter);
204 gst_revtv_get_property (GObject * object, guint prop_id, GValue * value,
207 GstRevTV *filter = GST_REVTV (object);
211 g_value_set_int (value, filter->vgrabtime);
214 g_value_set_int (value, filter->linespace);
217 g_value_set_int (value, filter->vscale);
220 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
226 gst_revtv_base_init (gpointer g_class)
228 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
230 gst_element_class_set_details_simple (element_class, "RevTV effect",
231 "Filter/Effect/Video",
232 "A video waveform monitor for each line of video processed",
233 "Wim Taymans <wim.taymans@chello.be>");
235 gst_element_class_add_static_pad_template (element_class,
236 &gst_revtv_sink_template);
237 gst_element_class_add_static_pad_template (element_class,
238 &gst_revtv_src_template);
242 gst_revtv_class_init (GstRevTVClass * klass)
244 GObjectClass *gobject_class = (GObjectClass *) klass;
245 GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
247 gobject_class->set_property = gst_revtv_set_property;
248 gobject_class->get_property = gst_revtv_get_property;
250 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DELAY,
251 g_param_spec_int ("delay", "Delay", "Delay in frames between updates",
253 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
254 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LINESPACE,
255 g_param_spec_int ("linespace", "Linespace", "Control line spacing", 1,
257 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
258 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GAIN,
259 g_param_spec_int ("gain", "Gain", "Control gain", 1, 200, 50,
260 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
262 trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_revtv_set_caps);
263 trans_class->transform = GST_DEBUG_FUNCPTR (gst_revtv_transform);
267 gst_revtv_init (GstRevTV * restv, GstRevTVClass * klass)
269 restv->vgrabtime = 1;
271 restv->linespace = 6;