Commit 012d4c65 authored by Christian Schaller's avatar Christian Schaller

add ported videofilter to cvs head

Original commit message from CVS:
add ported videofilter to cvs head
parent 08b451f1
2005-05-06 Christian Schaller <uraeus@gnome.org>
* PORTED_09: update to add videofilter
* configure.ac: re-add videofilter
* gst/videofilter/Makefile.am: remove videobalance (not ported yet)
* gst/videofilter/gstgamma.c: (gst_gamma_class_init):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_class_init):
* gst/videofilter/gstvideofilter.c: (gst_videofilter_getcaps),
(gst_videofilter_setcaps), (gst_videofilter_init),
(gst_videofilter_chain), (gst_videofilter_set_output_size):
* gst/videofilter/gstvideoflip.c: (gst_videoflip_class_init):
2005-05-06 Christian Schaller <uraeus@gnome.org>
* ext/mad: ported plugin from threaded branch
......
List of ported plugins (update when you commit a ported plugin):
osssink (wim) - partially done in threaded
effectv (wim)
mad (wim)
videofilter (wim)
osssink is partially done in the threaded branch (wim)
- Remember that some plugins are already ported and now in the gst-plugins-base module.
......
......@@ -294,7 +294,8 @@ AC_SUBST(GST_PLUGIN_LDFLAGS)
dnl these are all the gst plug-ins, compilable without additional libs
GST_PLUGINS_ALL="\
effectv \
law"
law \
videofilter"
dnl see if we can build C++ plug-ins
if test "x$HAVE_CXX" = "xyes"; then
......@@ -426,6 +427,7 @@ gst-plugins.spec
gst/Makefile
gst/effectv/Makefile
gst/law/Makefile
gst/videofilter/Makefile
sys/Makefile
ext/Makefile
ext/mad/Makefile
......
plugin_LTLIBRARIES = libgstvideofilter.la libgstvideoflip.la \
libgstvideobalance.la libgstgamma.la
libgstgamma.la
noinst_LTLIBRARIES = libgstvideoexample.la
noinst_HEADERS = gstvideofilter.h gstvideoflip.h gstvideobalance.h
noinst_HEADERS = gstvideofilter.h gstvideoflip.h
EXTRA_DIST = gstvideotemplate.c make_filter
CLEANFILES = gstvideoexample.c
......@@ -23,10 +23,10 @@ libgstvideoflip_la_CFLAGS = $(GST_CFLAGS)
libgstvideoflip_la_LIBADD =
libgstvideoflip_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstvideobalance_la_SOURCES = gstvideobalance.c
libgstvideobalance_la_CFLAGS = $(GST_CFLAGS) $(LIBOIL_CFLAGS)
libgstvideobalance_la_LIBADD = $(top_builddir)/gst-libs/gst/libgstinterfaces-$(GST_MAJORMINOR).la
libgstvideobalance_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(LIBOIL_LIBS) -lm
# libgstvideobalance_la_SOURCES = gstvideobalance.c
# libgstvideobalance_la_CFLAGS = $(GST_CFLAGS) $(LIBOIL_CFLAGS)
# libgstvideobalance_la_LIBADD = $(top_builddir)/gst-libs/gst/libgstinterfaces-$(GST_MAJORMINOR).la
# libgstvideobalance_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(LIBOIL_LIBS) -lm
libgstgamma_la_SOURCES = gstgamma.c
libgstgamma_la_CFLAGS = $(GST_CFLAGS)
......
......@@ -164,6 +164,9 @@ gst_gamma_class_init (gpointer g_class, gpointer class_data)
gobject_class = G_OBJECT_CLASS (g_class);
videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
gobject_class->set_property = gst_gamma_set_property;
gobject_class->get_property = gst_gamma_get_property;
g_object_class_install_property (gobject_class, ARG_GAMMA,
g_param_spec_double ("gamma", "Gamma", "gamma",
0.01, 10, 1, G_PARAM_READWRITE));
......@@ -177,9 +180,6 @@ gst_gamma_class_init (gpointer g_class, gpointer class_data)
g_param_spec_double ("bluegamma", "Gamma_b",
"gamma value for the blue channel", 0.01, 10, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_gamma_set_property;
gobject_class->get_property = gst_gamma_get_property;
videofilter_class->setup = gst_gamma_setup;
}
......
......@@ -198,6 +198,9 @@ gst_videobalance_class_init (gpointer g_class, gpointer class_data)
parent_class = g_type_class_ref (GST_TYPE_VIDEOFILTER);
gobject_class->set_property = gst_videobalance_set_property;
gobject_class->get_property = gst_videobalance_get_property;
g_object_class_install_property (gobject_class, ARG_CONTRAST,
g_param_spec_double ("contrast", "Contrast", "contrast",
0, 2, 1, G_PARAM_READWRITE));
......@@ -210,8 +213,6 @@ gst_videobalance_class_init (gpointer g_class, gpointer class_data)
g_param_spec_double ("saturation", "Saturation", "saturation",
0, 2, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_videobalance_set_property;
gobject_class->get_property = gst_videobalance_get_property;
gobject_class->dispose = gst_videobalance_dispose;
videofilter_class->setup = gst_videobalance_setup;
......
......@@ -51,7 +51,7 @@ static void gst_videofilter_set_property (GObject * object, guint prop_id,
static void gst_videofilter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_videofilter_chain (GstPad * pad, GstData * _data);
static GstFlowReturn gst_videofilter_chain (GstPad * pad, GstBuffer * buffer);
GstCaps *gst_videofilter_class_get_capslist (GstVideofilterClass * klass);
static void gst_videofilter_setup (GstVideofilter * videofilter);
......@@ -172,70 +172,56 @@ gst_videofilter_getcaps (GstPad * pad)
{
GstVideofilter *videofilter;
GstVideofilterClass *klass;
//GstCaps *caps;
GstCaps *othercaps;
GstPad *otherpad;
//int i;
GstCaps *caps;
GstPad *peer;
int i;
GST_DEBUG ("gst_videofilter_getcaps");
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad));
klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad :
videofilter->srcpad;
othercaps = gst_pad_get_allowed_caps (otherpad);
return othercaps;
#if 0
/* FIXME videofilter doesn't allow passthru of video formats it
* doesn't understand. */
/* Look through our list of caps and find those that match with
* the peer's formats. Create a list of them. */
/* FIXME optimize if peercaps == NULL */
/* we can handle anything that was registered */
caps = gst_caps_new_empty ();
for (i = 0; i < klass->formats->len; i++) {
GstCaps *icaps;
GstCaps *fromcaps;
fromcaps =
gst_caps_new_full (gst_videofilter_format_get_structure
(g_ptr_array_index (klass->formats, i)), NULL);
icaps = gst_caps_intersect (fromcaps, peercaps);
if (icaps != NULL) {
gst_caps_append (caps, fromcaps);
} else {
gst_caps_free (fromcaps);
gst_caps_append (caps, fromcaps);
}
peer = gst_pad_get_peer (pad);
if (peer) {
GstCaps *peercaps;
peercaps = gst_pad_get_caps (peer);
if (peercaps) {
GstCaps *icaps;
icaps = gst_caps_intersect (peercaps, caps);
gst_caps_unref (peercaps);
gst_caps_unref (caps);
caps = icaps;
}
if (icaps)
gst_caps_free (icaps);
//gst_object_unref (peer);
}
gst_caps_free (peercaps);
return caps;
#endif
}
static GstPadLinkReturn
gst_videofilter_link (GstPad * pad, const GstCaps * caps)
static gboolean
gst_videofilter_setcaps (GstPad * pad, GstCaps * caps)
{
GstVideofilter *videofilter;
GstStructure *structure;
gboolean ret;
int width, height;
double framerate;
GstPadLinkReturn lret;
GstPad *otherpad;
GST_DEBUG ("gst_videofilter_src_link");
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
int ret;
otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad :
videofilter->srcpad;
videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
......@@ -248,11 +234,9 @@ gst_videofilter_link (GstPad * pad, const GstCaps * caps)
ret &= gst_structure_get_double (structure, "framerate", &framerate);
if (!ret)
return GST_PAD_LINK_REFUSED;
return FALSE;
lret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (lret))
return lret;
gst_pad_set_caps (videofilter->srcpad, caps);
GST_DEBUG ("width %d height %d", width, height);
......@@ -273,7 +257,7 @@ gst_videofilter_link (GstPad * pad, const GstCaps * caps)
gst_videofilter_setup (videofilter);
return GST_PAD_LINK_OK;
return TRUE;
}
static void
......@@ -290,7 +274,7 @@ gst_videofilter_init (GTypeInstance * instance, gpointer g_class)
videofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->sinkpad);
gst_pad_set_chain_function (videofilter->sinkpad, gst_videofilter_chain);
gst_pad_set_link_function (videofilter->sinkpad, gst_videofilter_link);
gst_pad_set_setcaps_function (videofilter->sinkpad, gst_videofilter_setcaps);
gst_pad_set_getcaps_function (videofilter->sinkpad, gst_videofilter_getcaps);
pad_template =
......@@ -298,16 +282,14 @@ gst_videofilter_init (GTypeInstance * instance, gpointer g_class)
g_return_if_fail (pad_template != NULL);
videofilter->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->srcpad);
gst_pad_set_link_function (videofilter->srcpad, gst_videofilter_link);
gst_pad_set_getcaps_function (videofilter->srcpad, gst_videofilter_getcaps);
videofilter->inited = FALSE;
}
static void
gst_videofilter_chain (GstPad * pad, GstData * _data)
static GstFlowReturn
gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVideofilter *videofilter;
guchar *data;
gulong size;
......@@ -315,19 +297,21 @@ gst_videofilter_chain (GstPad * pad, GstData * _data)
GST_DEBUG ("gst_videofilter_chain");
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (videofilter->inited);
videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad));
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
if (videofilter->passthru) {
gst_pad_push (videofilter->srcpad, GST_DATA (buf));
return;
return gst_pad_push (videofilter->srcpad, buf);
}
if (GST_PAD_CAPS (pad) == NULL) {
return GST_FLOW_NOT_NEGOTIATED;
}
GST_DEBUG ("gst_videofilter_chain: got buffer of %ld bytes in '%s'", size,
......@@ -339,19 +323,19 @@ gst_videofilter_chain (GstPad * pad, GstData * _data)
videofilter->to_width, videofilter->to_height, size,
videofilter->from_buf_size, videofilter->to_buf_size);
g_return_if_fail (size >= videofilter->from_buf_size);
if (size > videofilter->from_buf_size) {
GST_INFO ("buffer size %ld larger than expected (%d)",
size, videofilter->from_buf_size);
return GST_FLOW_ERROR;
}
outbuf = gst_pad_alloc_buffer (videofilter->srcpad, GST_BUFFER_OFFSET_NONE,
videofilter->to_buf_size);
videofilter->to_buf_size, GST_RPAD_CAPS (videofilter->srcpad));
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
g_return_if_fail (videofilter->format);
g_return_val_if_fail (videofilter->format, GST_FLOW_ERROR);
GST_DEBUG ("format %s", videofilter->format->fourcc);
videofilter->in_buf = buf;
......@@ -363,9 +347,11 @@ gst_videofilter_chain (GstPad * pad, GstData * _data)
GST_DEBUG ("gst_videofilter_chain: pushing buffer of %d bytes in '%s'",
GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videofilter));
gst_pad_push (videofilter->srcpad, GST_DATA (outbuf));
gst_pad_push (videofilter->srcpad, outbuf);
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
static void
......@@ -422,7 +408,6 @@ void
gst_videofilter_set_output_size (GstVideofilter * videofilter,
int width, int height)
{
int ret;
GstCaps *srccaps;
GstStructure *structure;
......@@ -434,17 +419,14 @@ gst_videofilter_set_output_size (GstVideofilter * videofilter,
videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height
* videofilter->format->bpp) / 8;
srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad));
//srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad));
srccaps = gst_caps_copy (GST_PAD_CAPS (videofilter->srcpad));
structure = gst_caps_get_structure (srccaps, 0);
gst_structure_set (structure, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
ret = gst_pad_try_set_caps (videofilter->srcpad, srccaps);
if (ret < 0) {
g_critical ("could not set output size");
}
gst_pad_set_caps (videofilter->srcpad, srccaps);
}
static void
......
......@@ -147,14 +147,14 @@ gst_videoflip_class_init (gpointer g_class, gpointer class_data)
gobject_class = G_OBJECT_CLASS (g_class);
videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
gobject_class->set_property = gst_videoflip_set_property;
gobject_class->get_property = gst_videoflip_get_property;
g_object_class_install_property (gobject_class, ARG_METHOD,
g_param_spec_enum ("method", "method", "method",
GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R,
G_PARAM_READWRITE));
gobject_class->set_property = gst_videoflip_set_property;
gobject_class->get_property = gst_videoflip_get_property;
videofilter_class->setup = gst_videoflip_setup;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment