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 ! videoconvert ! autovideosink
54 * ]| This pipeline shows the effect of revtv on a test stream.
67 #define THE_COLOR 0xffffffff
77 #define gst_revtv_parent_class parent_class
78 G_DEFINE_TYPE (GstRevTV, gst_revtv, GST_TYPE_VIDEO_FILTER);
80 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
81 #define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx }")
83 #define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
86 static GstStaticPadTemplate gst_revtv_src_template =
87 GST_STATIC_PAD_TEMPLATE ("src",
90 GST_STATIC_CAPS (CAPS_STR)
93 static GstStaticPadTemplate gst_revtv_sink_template =
94 GST_STATIC_PAD_TEMPLATE ("sink",
97 GST_STATIC_CAPS (CAPS_STR)
101 gst_revtv_transform_frame (GstVideoFilter * vfilter, GstVideoFrame * in_frame,
102 GstVideoFrame * out_frame)
104 GstRevTV *filter = GST_REVTV (vfilter);
106 gint width, height, sstride, dstride;
108 gint y, x, R, G, B, yval;
109 gint linespace, vscale;
110 GstClockTime timestamp, stream_time;
112 timestamp = GST_BUFFER_TIMESTAMP (in_frame->buffer);
114 gst_segment_to_stream_time (&GST_BASE_TRANSFORM (vfilter)->segment,
115 GST_FORMAT_TIME, timestamp);
117 GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
118 GST_TIME_ARGS (timestamp));
120 if (GST_CLOCK_TIME_IS_VALID (stream_time))
121 gst_object_sync_values (GST_OBJECT (filter), stream_time);
123 src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
124 sstride = GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 0);
125 dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
126 dstride = GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 0);
128 width = GST_VIDEO_FRAME_WIDTH (in_frame);
129 height = GST_VIDEO_FRAME_HEIGHT (in_frame);
131 /* Clear everything to black */
132 memset (dest, 0, dstride * height * sizeof (guint32));
134 GST_OBJECT_LOCK (filter);
135 linespace = filter->linespace;
136 vscale = filter->vscale;
138 /* draw the offset lines */
139 for (y = 0; y < height; y += linespace) {
140 for (x = 0; x <= width; x++) {
141 nsrc = src + (y * sstride) + x;
143 /* Calc Y Value for curpix */
144 R = ((*nsrc) & 0xff0000) >> (16 - 1);
145 G = ((*nsrc) & 0xff00) >> (8 - 2);
148 yval = y - ((short) (R + G + B) / vscale);
151 dest[x + (yval * dstride)] = THE_COLOR;
155 GST_OBJECT_UNLOCK (filter);
161 gst_revtv_set_property (GObject * object, guint prop_id, const GValue * value,
164 GstRevTV *filter = GST_REVTV (object);
166 GST_OBJECT_LOCK (filter);
169 filter->vgrabtime = g_value_get_int (value);
172 filter->linespace = g_value_get_int (value);
175 filter->vscale = g_value_get_int (value);
178 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
181 GST_OBJECT_UNLOCK (filter);
185 gst_revtv_get_property (GObject * object, guint prop_id, GValue * value,
188 GstRevTV *filter = GST_REVTV (object);
192 g_value_set_int (value, filter->vgrabtime);
195 g_value_set_int (value, filter->linespace);
198 g_value_set_int (value, filter->vscale);
201 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
207 gst_revtv_class_init (GstRevTVClass * klass)
209 GObjectClass *gobject_class = (GObjectClass *) klass;
210 GstElementClass *gstelement_class = (GstElementClass *) klass;
211 GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
213 gobject_class->set_property = gst_revtv_set_property;
214 gobject_class->get_property = gst_revtv_get_property;
216 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DELAY,
217 g_param_spec_int ("delay", "Delay", "Delay in frames between updates",
219 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
220 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LINESPACE,
221 g_param_spec_int ("linespace", "Linespace", "Control line spacing", 1,
223 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
224 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GAIN,
225 g_param_spec_int ("gain", "Gain", "Control gain", 1, 200, 50,
226 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
228 gst_element_class_set_details_simple (gstelement_class, "RevTV effect",
229 "Filter/Effect/Video",
230 "A video waveform monitor for each line of video processed",
231 "Wim Taymans <wim.taymans@gmail.be>");
233 gst_element_class_add_pad_template (gstelement_class,
234 gst_static_pad_template_get (&gst_revtv_sink_template));
235 gst_element_class_add_pad_template (gstelement_class,
236 gst_static_pad_template_get (&gst_revtv_src_template));
238 vfilter_class->transform_frame =
239 GST_DEBUG_FUNCPTR (gst_revtv_transform_frame);
243 gst_revtv_init (GstRevTV * restv)
245 restv->vgrabtime = 1;
247 restv->linespace = 6;