diff --git a/gst/sensorfx/gstsensorfxblur.c b/gst/sensorfx/gstsensorfxblur.c new file mode 100644 index 0000000..e6d34fd --- /dev/null +++ b/gst/sensorfx/gstsensorfxblur.c @@ -0,0 +1,362 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef + * Copyright (C) 2003 Arwed v. Merkatz + * Copyright (C) 2006 Mark Nauwelaerts + * Copyright (C) 2010 United States Government, Joshua M. Doe + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * 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. + */ + +/** +* SECTION:element-sfxblur +* +* Convert grayscale video from one bpp/depth combination to another. +* +* +* Example launch line +* |[ +* gst-launch videotestsrc ! sfxblur ! ffmpegcolorspace ! autovideosink +* ]| +* +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include + +#include "gstopencvutils.h" +#include "gstsensorfxblur.h" + +/* GstSensorFxBlur signals and args */ +enum +{ + /* FILL ME */ + LAST_SIGNAL +}; + +enum +{ + PROP_0, + PROP_LOWIN, +}; + +#define DEFAULT_PROP_LOWIN 0.0 + +static const GstElementDetails sfxblur_details = +GST_ELEMENT_DETAILS ("Blurs video", + "Filter/Effect/Video", + "Applies a blur kernel to video", + "Joshua Doe finalize (object); +} + +/** + * gst_sfxblur_class_init: + * @object: #GstSensorFxBlurClass. + * + */ +static void +gst_sfxblur_class_init (GstSensorFxBlurClass * object) +{ + GObjectClass *obj_class = G_OBJECT_CLASS (object); + GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (object); + + GST_DEBUG ("class init"); + + + /* Register GObject vmethods */ + obj_class->finalize = GST_DEBUG_FUNCPTR (gst_sfxblur_finalize); + obj_class->set_property = GST_DEBUG_FUNCPTR (gst_sfxblur_set_property); + obj_class->get_property = GST_DEBUG_FUNCPTR (gst_sfxblur_get_property); + + /* Install GObject properties */ + g_object_class_install_property (obj_class, PROP_LOWIN, + g_param_spec_double ("lower-input-level", "Lower Input Level", "Lower Input Level", + 0.0, 1.0, DEFAULT_PROP_LOWIN, G_PARAM_READWRITE)); + + /* Register GstBaseTransform vmethods */ + trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_sfxblur_set_caps); + trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_sfxblur_transform_ip); +} + +/** +* gst_sfxblur_init: +* @sfxblur: GstSensorFxBlur +* @g_class: GstSensorFxBlurClass +* +* Initialize the new element +*/ +static void +gst_sfxblur_init (GstSensorFxBlur * sfxblur, + GstSensorFxBlurClass * g_class) +{ + GST_DEBUG_OBJECT (sfxblur, "init class instance"); + + gst_sfxblur_reset (sfxblur); + +} + +/** + * gst_sfxblur_set_property: + * @object: #GObject + * @prop_id: guint + * @value: #GValue + * @pspec: #GParamSpec + * + */ +static void +gst_sfxblur_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstSensorFxBlur *sfxblur = GST_SENSORFXBLUR (object); + + GST_DEBUG ("setting property %s", pspec->name); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/** + * gst_sfxblur_get_property: + * @object: #GObject + * @prop_id: guint + * @value: #GValue + * @pspec: #GParamSpec + * + */ +static void +gst_sfxblur_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ + GstSensorFxBlur *sfxblur = GST_SENSORFXBLUR (object); + + GST_DEBUG ("getting property %s", pspec->name); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/************************************************************************/ +/* GstBaseTransform vmethod implementations */ +/************************************************************************/ + +/** + * gst_sfxblur_set_caps: + * base: #GstBaseTransform + * incaps: #GstCaps + * outcaps: #GstCaps + * + * Notification of the actual caps set. + * + * Returns: TRUE on acceptance of caps + */ +static gboolean +gst_sfxblur_set_caps (GstBaseTransform * base, GstCaps * incaps, + GstCaps * outcaps) +{ + GstSensorFxBlur *levels; + GstStructure *structure; + gboolean res; + + levels = GST_SENSORFXBLUR (base); + + GST_DEBUG_OBJECT (levels, + "set_caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps); + + GST_DEBUG_OBJECT (incaps, "incaps"); + GST_DEBUG_OBJECT (outcaps, "outcaps"); + + /* retrieve input caps info */ + structure = gst_caps_get_structure (incaps, 0); + + //mime = gst_structure_get_name (structure); + //if (g_strcmp0 ("video/x-raw-gray", mime) == 0) + // levels-> + + res = gst_structure_get (structure, + "width", G_TYPE_INT, &levels->width, + "height", G_TYPE_INT, &levels->height, + "bpp", G_TYPE_INT, &levels->bpp, + "depth", G_TYPE_INT, &levels->depth, + "endianness", G_TYPE_INT, &levels->endianness, + NULL); + if (!res) + return FALSE; + + levels->stride = GST_ROUND_UP_4 (levels->width * levels->depth/8); + + return res; +} + +GstFlowReturn gst_sfxblur_transform_ip( GstBaseTransform * base, GstBuffer * buf ) +{ + + return GST_FLOW_OK; +} + +/************************************************************************/ +/* GstSensorFxBlur method implementations */ +/************************************************************************/ + +/** + * gst_sfxblur_reset: + * @sfxblur: #GstSensorFxBlur + * + * Reset instance variables and free memory + */ +static void +gst_sfxblur_reset(GstSensorFxBlur* sfxblur) +{ + sfxblur->width = 0; + sfxblur->height = 0; + sfxblur->stride = 0; + sfxblur->bpp = 0; + sfxblur->depth = 0; + sfxblur->endianness = 0; +} + +gboolean +gst_sfxblur_plugin_init (GstPlugin * plugin) +{ + return gst_element_register (plugin, "sfxblur", GST_RANK_NONE, + GST_TYPE_SENSORFXBLUR); +} diff --git a/gst/sensorfx/gstsensorfxblur.h b/gst/sensorfx/gstsensorfxblur.h new file mode 100644 index 0000000..7d7fd37 --- /dev/null +++ b/gst/sensorfx/gstsensorfxblur.h @@ -0,0 +1,80 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David Schleef + * Copyright (C) 2003 Arwed v. Merkatz + * Copyright (C) 2006 Mark Nauwelaerts + * Copyright (C) 2010 United States Government, Joshua M. Doe + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * 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. + */ + + +#ifndef __GST_SENSORFXBLUR_H__ +#define __GST_SENSORFXBLUR_H__ + +#include + +G_BEGIN_DECLS + +#define GST_TYPE_SENSORFXBLUR \ + (gst_sfxblur_get_type()) +#define GST_SENSORFXBLUR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SENSORFXBLUR,GstSensorFxBlur)) +#define GST_SENSORFXBLUR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SENSORFXBLUR,GstSensorFxBlurClass)) +#define GST_IS_SENSORFXBLUR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SENSORFXBLUR)) +#define GST_IS_SENSORFXBLUR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SENSORFXBLUR)) + +typedef struct _GstSensorFxBlur GstSensorFxBlur; +typedef struct _GstSensorFxBlurClass GstSensorFxBlurClass; + +/** +* GstSensorFxBlur: +* @element: the parent element. +* +* +* The opaque GstSensorFxBlur data structure. +*/ +struct _GstSensorFxBlur +{ + GstVideoFilter element; + + /* format */ + gint width; + gint height; + guint stride; + gint bpp; + gint depth; + gint endianness; + + /* properties */ + +}; + +struct _GstSensorFxBlurClass +{ + GstVideoFilterClass parent_class; +}; + +GType gst_sfxblur_get_type(void); + +gboolean gst_sfxblur_plugin_init (GstPlugin * plugin); + +G_END_DECLS + +#endif /* __GST_SENSORFXBLUR_H__ */