*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch -v videotestsrc ! optv ! videoconvert ! autovideosink
+ * gst-launch-1.0 -v videotestsrc ! optv ! videoconvert ! autovideosink
* ]| This pipeline shows the effect of optv on a test stream.
* </refsect2>
*/
#include "gsteffectv.h"
#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
enum
{
}
static GstFlowReturn
-gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
+gst_optv_transform_frame (GstVideoFilter * vfilter, GstVideoFrame * in_frame,
+ GstVideoFrame * out_frame)
{
- GstOpTV *filter = GST_OPTV (trans);
+ GstOpTV *filter = GST_OPTV (vfilter);
guint32 *src, *dest;
- GstVideoFrame in_frame, out_frame;
gint8 *p;
guint8 *diff;
gint x, y, width, height;
GstClockTime timestamp, stream_time;
guint8 phase;
- timestamp = GST_BUFFER_TIMESTAMP (in);
+ timestamp = GST_BUFFER_TIMESTAMP (in_frame->buffer);
stream_time =
- gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME, timestamp);
+ gst_segment_to_stream_time (&GST_BASE_TRANSFORM (vfilter)->segment,
+ GST_FORMAT_TIME, timestamp);
GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
if (G_UNLIKELY (filter->opmap[0] == NULL))
return GST_FLOW_NOT_NEGOTIATED;
- if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
- goto invalid_in;
-
- if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
- goto invalid_out;
+ src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+ dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
- src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
- dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
-
- width = GST_VIDEO_FRAME_WIDTH (&in_frame);
- height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
+ width = GST_VIDEO_FRAME_WIDTH (in_frame);
+ height = GST_VIDEO_FRAME_HEIGHT (in_frame);
GST_OBJECT_LOCK (filter);
switch (filter->mode) {
}
GST_OBJECT_UNLOCK (filter);
- gst_video_frame_unmap (&in_frame);
- gst_video_frame_unmap (&out_frame);
-
return GST_FLOW_OK;
-
- /* ERRORS */
-invalid_in:
- {
- GST_DEBUG_OBJECT (filter, "invalid input frame");
- return GST_FLOW_ERROR;
- }
-invalid_out:
- {
- GST_DEBUG_OBJECT (filter, "invalid output frame");
- gst_video_frame_unmap (&in_frame);
- return GST_FLOW_ERROR;
- }
}
static gboolean
-gst_optv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
- GstCaps * outcaps)
+gst_optv_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
{
- GstOpTV *filter = GST_OPTV (btrans);
- GstVideoInfo info;
+ GstOpTV *filter = GST_OPTV (vfilter);
gint i, width, height;
- if (!gst_video_info_from_caps (&info, incaps))
- goto invalid_caps;
-
- filter->info = info;
-
- width = GST_VIDEO_INFO_WIDTH (&info);
- height = GST_VIDEO_INFO_HEIGHT (&info);
+ width = GST_VIDEO_INFO_WIDTH (in_info);
+ height = GST_VIDEO_INFO_HEIGHT (in_info);
for (i = 0; i < 4; i++) {
- if (filter->opmap[i])
- g_free (filter->opmap[i]);
+ g_free (filter->opmap[i]);
filter->opmap[i] = g_new (gint8, width * height);
}
setOpmap (filter->opmap, width, height);
- if (filter->diff)
- g_free (filter->diff);
+ g_free (filter->diff);
filter->diff = g_new (guint8, width * height);
return TRUE;
-
- /* ERRORS */
-invalid_caps:
- {
- GST_DEBUG_OBJECT (filter, "invalid caps received");
- return FALSE;
- }
}
static gboolean
gint i;
for (i = 0; i < 4; i++) {
- if (filter->opmap[i])
- g_free (filter->opmap[i]);
+ g_free (filter->opmap[i]);
filter->opmap[i] = NULL;
}
}
- if (filter->diff)
- g_free (filter->diff);
+ g_free (filter->diff);
filter->diff = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+ GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
gobject_class->set_property = gst_optv_set_property;
gobject_class->get_property = gst_optv_get_property;
"Luma threshold", 0, G_MAXINT, DEFAULT_THRESHOLD,
GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gst_element_class_set_details_simple (gstelement_class, "OpTV effect",
+ gst_element_class_set_static_metadata (gstelement_class, "OpTV effect",
"Filter/Effect/Video",
"Optical art meets real-time video effect",
"FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_optv_sink_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_optv_src_template));
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_optv_sink_template);
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_optv_src_template);
- trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_optv_set_caps);
- trans_class->transform = GST_DEBUG_FUNCPTR (gst_optv_transform);
trans_class->start = GST_DEBUG_FUNCPTR (gst_optv_start);
+ vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_optv_set_info);
+ vfilter_class->transform_frame = GST_DEBUG_FUNCPTR (gst_optv_transform_frame);
+
initPalette ();
}