much cleanup hacking made possible by plugin changes

Original commit message from CVS:
much cleanup hacking made possible by plugin changes
This commit is contained in:
David Schleef 2003-11-08 02:52:41 +00:00
parent bd2c86e953
commit aee9dba783
5 changed files with 202 additions and 343 deletions

View file

@ -18,6 +18,11 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/*
* This file was (probably) generated from gstvideobalance.c,
* $Id$
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
@ -27,15 +32,6 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
/* elementfactory information */
static GstElementDetails videobalance_details = {
"Video Balance control",
"Filter/Video",
"Adjusts brightness, contrast, hue, saturation on a video stream",
"David Schleef <ds@schleef.org>"
};
/* GstVideobalance signals and args */ /* GstVideobalance signals and args */
enum { enum {
/* FILL ME */ /* FILL ME */
@ -51,9 +47,9 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static void gst_videobalance_class_init (GstVideobalanceClass *klass); static void gst_videobalance_base_init (gpointer g_class);
static void gst_videobalance_base_init (GstVideobalanceClass *klass); static void gst_videobalance_class_init (gpointer g_class, gpointer class_data);
static void gst_videobalance_init (GstVideobalance *videobalance); static void gst_videobalance_init (GTypeInstance *instance, gpointer g_class);
static void gst_videobalance_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_videobalance_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_videobalance_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gst_videobalance_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@ -61,10 +57,6 @@ static void gst_videobalance_get_property (GObject *object, guint prop_id, GVal
static void gst_videobalance_planar411(GstVideofilter *videofilter, void *dest, void *src); static void gst_videobalance_planar411(GstVideofilter *videofilter, void *dest, void *src);
static void gst_videobalance_setup(GstVideofilter *videofilter); static void gst_videobalance_setup(GstVideofilter *videofilter);
static GstVideobalanceClass *this_class = NULL;
static GstVideofilterClass *parent_class = NULL;
static GstElementClass *element_class = NULL;
GType GType
gst_videobalance_get_type (void) gst_videobalance_get_type (void)
{ {
@ -73,16 +65,17 @@ gst_videobalance_get_type (void)
if (!videobalance_type) { if (!videobalance_type) {
static const GTypeInfo videobalance_info = { static const GTypeInfo videobalance_info = {
sizeof(GstVideobalanceClass), sizeof(GstVideobalanceClass),
(GBaseInitFunc)gst_videobalance_base_init, gst_videobalance_base_init,
NULL, NULL,
(GClassInitFunc)gst_videobalance_class_init, gst_videobalance_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstVideobalance), sizeof(GstVideobalance),
0, 0,
(GInstanceInitFunc)gst_videobalance_init, gst_videobalance_init,
}; };
videobalance_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideobalance", &videobalance_info, 0); videobalance_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
"GstVideobalance", &videobalance_info, 0);
} }
return videobalance_type; return videobalance_type;
} }
@ -91,129 +84,74 @@ static GstVideofilterFormat gst_videobalance_formats[] = {
{ "I420", 12, gst_videobalance_planar411, }, { "I420", 12, gst_videobalance_planar411, },
}; };
static GstPadTemplate *gst_videobalance_sink_template_factory (void);
static GstPadTemplate *gst_videobalance_src_template_factory (void);
static void static void
gst_videobalance_base_init (GstVideobalanceClass *klass) gst_videobalance_base_init (gpointer g_class)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); static GstElementDetails videobalance_details = GST_ELEMENT_DETAILS (
"Video Balance Control",
gst_element_class_add_pad_template (element_class, "Filter/Video",
GST_PAD_TEMPLATE_GET (gst_videobalance_sink_template_factory)); "Adjusts brightness, contrast, hue, saturation on a video stream",
gst_element_class_add_pad_template (element_class, "David Schleef <ds@schleef.org>"
GST_PAD_TEMPLATE_GET (gst_videobalance_src_template_factory)); );
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
int i;
gst_element_class_set_details (element_class, &videobalance_details); gst_element_class_set_details (element_class, &videobalance_details);
for(i=0;i<G_N_ELEMENTS(gst_videobalance_formats);i++){
gst_videofilter_class_add_format(videofilter_class,
gst_videobalance_formats + i);
}
gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
} }
static void static void
gst_videobalance_class_init (GstVideobalanceClass *klass) gst_videobalance_class_init (gpointer g_class, gpointer class_data)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstVideofilterClass *videofilter_class;
GstVideofilterClass *gstvideofilter_class;
int i;
gobject_class = (GObjectClass*)klass; gobject_class = G_OBJECT_CLASS (g_class);
gstelement_class = (GstElementClass*)klass; videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
gstvideofilter_class = (GstVideofilterClass *)klass;
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CONTRAST, g_object_class_install_property(gobject_class, ARG_CONTRAST,
g_param_spec_double("contrast","Contrast","contrast", g_param_spec_double("contrast","Contrast","contrast",
0, 2, 1, G_PARAM_READWRITE)); 0, 2, 1, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BRIGHTNESS, g_object_class_install_property(gobject_class, ARG_BRIGHTNESS,
g_param_spec_double("brightness","Brightness","brightness", g_param_spec_double("brightness","Brightness","brightness",
-1, 1, 0, G_PARAM_READWRITE)); -1, 1, 0, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HUE, g_object_class_install_property(gobject_class, ARG_HUE,
g_param_spec_double("hue","Hue","hue", g_param_spec_double("hue","Hue","hue",
-1, 1, 0, G_PARAM_READWRITE)); -1, 1, 0, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SATURATION, g_object_class_install_property(gobject_class, ARG_SATURATION,
g_param_spec_double("saturation","Saturation","saturation", g_param_spec_double("saturation","Saturation","saturation",
0, 2, 1, G_PARAM_READWRITE)); 0, 2, 1, G_PARAM_READWRITE));
this_class = klass;
parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
element_class = g_type_class_ref(GST_TYPE_ELEMENT);
gobject_class->set_property = gst_videobalance_set_property; gobject_class->set_property = gst_videobalance_set_property;
gobject_class->get_property = gst_videobalance_get_property; gobject_class->get_property = gst_videobalance_get_property;
gstvideofilter_class->setup = gst_videobalance_setup; videofilter_class->setup = gst_videobalance_setup;
for(i=0;i<G_N_ELEMENTS(gst_videobalance_formats);i++){
gst_videofilter_class_add_format(gstvideofilter_class,
gst_videobalance_formats + i);
}
}
static GstCaps *gst_videobalance_get_capslist(void)
{
GstVideofilterClass *klass;
klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
return gst_videofilter_class_get_capslist(klass);
}
static GstPadTemplate *
gst_videobalance_src_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
}
return templ;
}
static GstPadTemplate *
gst_videobalance_sink_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
}
return templ;
} }
static void static void
gst_videobalance_init (GstVideobalance *videobalance) gst_videobalance_init (GTypeInstance *instance, gpointer g_class)
{ {
GstVideobalance *videobalance = GST_VIDEOBALANCE (instance);
GstVideofilter *videofilter; GstVideofilter *videofilter;
GST_DEBUG("gst_videobalance_init"); GST_DEBUG("gst_videobalance_init");
videofilter = GST_VIDEOFILTER(videobalance); videofilter = GST_VIDEOFILTER(videobalance);
videofilter->sinkpad = gst_pad_new_from_template ( /* do stuff */
GST_PAD_TEMPLATE_GET (gst_videobalance_sink_template_factory),
"sink");
videofilter->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (gst_videobalance_src_template_factory),
"src");
videobalance->contrast = 1; videobalance->contrast = 1;
videobalance->brightness = 0; videobalance->brightness = 0;
videobalance->saturation = 1; videobalance->saturation = 1;
videobalance->hue = 0; videobalance->hue = 0;
gst_videofilter_postinit(GST_VIDEOFILTER(videobalance));
} }
static void static void
@ -277,8 +215,8 @@ static gboolean plugin_init (GstPlugin *plugin)
if(!gst_library_load("gstvideofilter")) if(!gst_library_load("gstvideofilter"))
return FALSE; return FALSE;
return gst_element_register(plugin, "videobalance", return gst_element_register (plugin, "videobalance", GST_RANK_NONE,
GST_RANK_NONE, GST_TYPE_VIDEOBALANCE); GST_TYPE_VIDEOBALANCE);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (
@ -288,7 +226,7 @@ GST_PLUGIN_DEFINE (
"Changes hue, saturation, brightness etc. on video images", "Changes hue, saturation, brightness etc. on video images",
plugin_init, plugin_init,
VERSION, VERSION,
"LGPL", GST_LICENSE,
GST_COPYRIGHT, GST_COPYRIGHT,
GST_PACKAGE, GST_PACKAGE,
GST_ORIGIN GST_ORIGIN
@ -301,6 +239,8 @@ static void gst_videobalance_setup(GstVideofilter *videofilter)
g_return_if_fail(GST_IS_VIDEOBALANCE(videofilter)); g_return_if_fail(GST_IS_VIDEOBALANCE(videofilter));
videobalance = GST_VIDEOBALANCE(videofilter); videobalance = GST_VIDEOBALANCE(videofilter);
/* if any setup needs to be done, do it here */
} }
static void gst_videobalance_planar411(GstVideofilter *videofilter, static void gst_videobalance_planar411(GstVideofilter *videofilter,
@ -373,5 +313,6 @@ static void gst_videobalance_planar411(GstVideofilter *videofilter,
} }
} }
} }
} }

View file

@ -27,16 +27,6 @@
#if 0
/* elementfactory information */
static GstElementDetails videofilter_details = {
"Video scaler",
"Filter/Video",
"Resizes video",
"David Schleef <ds@schleef.org>"
};
#endif
/* GstVideofilter signals and args */ /* GstVideofilter signals and args */
enum { enum {
/* FILL ME */ /* FILL ME */
@ -49,9 +39,9 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static void gst_videofilter_base_init (GstVideofilterClass *klass); static void gst_videofilter_base_init (gpointer g_class);
static void gst_videofilter_class_init (GstVideofilterClass *klass); static void gst_videofilter_class_init (gpointer g_class, gpointer class_data);
static void gst_videofilter_init (GstVideofilter *videofilter); static void gst_videofilter_init (GTypeInstance *instance, gpointer g_class);
static void gst_videofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_videofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_videofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gst_videofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@ -70,14 +60,14 @@ gst_videofilter_get_type (void)
if (!videofilter_type) { if (!videofilter_type) {
static const GTypeInfo videofilter_info = { static const GTypeInfo videofilter_info = {
sizeof(GstVideofilterClass), sizeof(GstVideofilterClass),
(GBaseInitFunc)gst_videofilter_base_init, gst_videofilter_base_init,
NULL, NULL,
(GClassInitFunc)gst_videofilter_class_init, gst_videofilter_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstVideofilter), sizeof(GstVideofilter),
0, 0,
(GInstanceInitFunc)gst_videofilter_init, gst_videofilter_init,
}; };
videofilter_type = g_type_register_static(GST_TYPE_ELEMENT, videofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
"GstVideofilter", &videofilter_info, G_TYPE_FLAG_ABSTRACT); "GstVideofilter", &videofilter_info, G_TYPE_FLAG_ABSTRACT);
@ -85,26 +75,29 @@ gst_videofilter_get_type (void)
return videofilter_type; return videofilter_type;
} }
static void gst_videofilter_base_init (GstVideofilterClass *klass) static void gst_videofilter_base_init (gpointer g_class)
{ {
klass->formats = g_ptr_array_new(); static GstElementDetails videofilter_details = {
"Video scaler",
#if 0 "Filter/Video",
"Resizes video",
"David Schleef <ds@schleef.org>"
};
GstVideofilterClass *klass = (GstVideofilterClass *) g_class;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, klass->formats = g_ptr_array_new();
GST_PAD_TEMPLATE_GET (gst_videofilter_sink_template_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (gst_videofilter_src_template_factory));
gst_element_class_set_details (element_class, &videofilter_details); gst_element_class_set_details (element_class, &videofilter_details);
#endif
} }
static void gst_videofilter_class_init (GstVideofilterClass *klass) static void gst_videofilter_class_init (gpointer g_class, gpointer class_data)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GstVideofilterClass *klass;
klass = (GstVideofilterClass *)g_class;
gobject_class = (GObjectClass*)klass; gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass; gstelement_class = (GstElementClass*)klass;
@ -114,44 +107,6 @@ static void gst_videofilter_class_init (GstVideofilterClass *klass)
gobject_class->get_property = gst_videofilter_get_property; gobject_class->get_property = gst_videofilter_get_property;
} }
#if 0
static GstPadTemplate *
gst_videofilter_src_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
}
return templ;
}
static GstPadTemplate *
gst_videofilter_sink_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
}
return templ;
}
#endif
static GstCaps *gst_videofilter_format_get_caps(GstVideofilterFormat *format) static GstCaps *gst_videofilter_format_get_caps(GstVideofilterFormat *format)
{ {
unsigned int fourcc; unsigned int fourcc;
@ -347,34 +302,49 @@ gst_videofilter_sink_link (GstPad *pad, GstCaps *caps)
} }
static void static void
gst_videofilter_init (GstVideofilter *videofilter) gst_videofilter_init (GTypeInstance *instance, gpointer g_class)
{ {
GstVideofilter *videofilter = GST_VIDEOFILTER (instance);
GstPadTemplate *pad_template;
GST_DEBUG("gst_videofilter_init"); GST_DEBUG("gst_videofilter_init");
} {
GList *list;
void list = gst_element_class_get_pad_template_list (GST_ELEMENT_CLASS(g_class));
gst_videofilter_postinit (GstVideofilter *videofilter) g_print("getting pad templates from %s\n",
{ g_type_name(G_TYPE_FROM_CLASS(g_class)));
/* sinkpad and srcpad should be inited by subclass */ g_print("pad template list:");
while(list){
GstPadTemplate *padtempl = (GstPadTemplate*) list->data;
g_print(" %p \"%s\",", padtempl, padtempl->name_template);
list = g_list_next(list);
}
g_print("\n");
}
/* FIXME */
//videofilter->sinkpad = NULL; pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"sink");
g_return_if_fail(pad_template != NULL);
videofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->sinkpad); gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->sinkpad);
gst_pad_set_chain_function(videofilter->sinkpad,gst_videofilter_chain); gst_pad_set_chain_function(videofilter->sinkpad,gst_videofilter_chain);
gst_pad_set_link_function(videofilter->sinkpad,gst_videofilter_sink_link); gst_pad_set_link_function(videofilter->sinkpad,gst_videofilter_sink_link);
gst_pad_set_getcaps_function(videofilter->sinkpad,gst_videofilter_sink_getcaps); gst_pad_set_getcaps_function(videofilter->sinkpad,gst_videofilter_sink_getcaps);
/* FIXME */ pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
//videofilter->srcpad = NULL; "src");
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_element_add_pad(GST_ELEMENT(videofilter),videofilter->srcpad);
gst_pad_set_link_function(videofilter->srcpad,gst_videofilter_src_link); gst_pad_set_link_function(videofilter->srcpad,gst_videofilter_src_link);
//gst_pad_set_getcaps_function(videofilter->srcpad,gst_videofilter_getcaps); //gst_pad_set_getcaps_function(videofilter->srcpad,gst_videofilter_src_getcaps);
videofilter->inited = FALSE; videofilter->inited = FALSE;
} }
static void static void
gst_videofilter_chain (GstPad *pad, GstData *_data) gst_videofilter_chain (GstPad *pad, GstData *_data)
{ {
@ -574,14 +544,32 @@ void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
g_ptr_array_add(videofilterclass->formats, format); g_ptr_array_add(videofilterclass->formats, format);
} }
void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilter_class)
{
GstCaps *caps;
GstElementClass *element_class = GST_ELEMENT_CLASS (videofilter_class);
g_print("adding pad templates to %s\n",g_type_name(G_TYPE_FROM_CLASS(videofilter_class)));
caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_intersect(caps,
gst_videofilter_class_get_capslist (videofilter_class))));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_NEW("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_intersect(caps,
gst_videofilter_class_get_capslist (videofilter_class))));
}
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin *plugin)
{ {
#if 0
return gst_element_register(plugin, "videofilter",
GST_RANK_NONE, GST_TYPE_VIDEOFILTER);
#endif
return TRUE; return TRUE;
} }

View file

@ -98,10 +98,9 @@ GstVideofilterFormat *gst_videofilter_find_format_by_caps(GstVideofilter *filter
GstCaps *caps); GstCaps *caps);
GstCaps *gst_videofilter_class_get_capslist(GstVideofilterClass *videofilterclass); GstCaps *gst_videofilter_class_get_capslist(GstVideofilterClass *videofilterclass);
void gst_videofilter_postinit(GstVideofilter *videofilter);
void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass, void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
GstVideofilterFormat *format); GstVideofilterFormat *format);
void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilterclass);
G_END_DECLS G_END_DECLS

View file

@ -18,27 +18,19 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/*
* This file was (probably) generated from gstvideoflip.c,
* $Id$
*/
/*#define DEBUG_ENABLED */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
/*#define DEBUG_ENABLED */
#include <gstvideoflip.h> #include <gstvideoflip.h>
#include <stdlib.h>
#include <math.h>
#include <string.h> #include <string.h>
/* elementfactory information */
static GstElementDetails videoflip_details = {
"Video flipper",
"Filter/Video",
"Flips and rotates video",
"David Schleef <ds@schleef.org>"
};
/* GstVideoflip signals and args */ /* GstVideoflip signals and args */
enum { enum {
/* FILL ME */ /* FILL ME */
@ -51,9 +43,9 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
static void gst_videoflip_class_init (GstVideoflipClass *klass); static void gst_videoflip_base_init (gpointer g_class);
static void gst_videoflip_base_init (GstVideoflipClass *klass); static void gst_videoflip_class_init (gpointer g_class, gpointer class_data);
static void gst_videoflip_init (GstVideoflip *videoflip); static void gst_videoflip_init (GTypeInstance *instance, gpointer g_class);
static void gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_videoflip_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gst_videoflip_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@ -61,10 +53,6 @@ static void gst_videoflip_get_property (GObject *object, guint prop_id, GValue
static void gst_videoflip_planar411(GstVideofilter *videofilter, void *dest, void *src); static void gst_videoflip_planar411(GstVideofilter *videofilter, void *dest, void *src);
static void gst_videoflip_setup(GstVideofilter *videofilter); static void gst_videoflip_setup(GstVideofilter *videofilter);
static GstVideoflipClass *this_class = NULL;
static GstVideofilterClass *parent_class = NULL;
static GstElementClass *element_class = NULL;
#define GST_TYPE_VIDEOFLIP_METHOD (gst_videoflip_method_get_type()) #define GST_TYPE_VIDEOFLIP_METHOD (gst_videoflip_method_get_type())
static GType static GType
@ -72,19 +60,19 @@ gst_videoflip_method_get_type(void)
{ {
static GType videoflip_method_type = 0; static GType videoflip_method_type = 0;
static GEnumValue videoflip_methods[] = { static GEnumValue videoflip_methods[] = {
{ GST_VIDEOFLIP_METHOD_IDENTITY, "0", "Identity (no rotation)" }, { GST_VIDEOFLIP_METHOD_IDENTITY, "0", "Identity (no rotation)" },
{ GST_VIDEOFLIP_METHOD_90R, "1", "Rotate clockwise 90 degrees" }, { GST_VIDEOFLIP_METHOD_90R, "1", "Rotate clockwise 90 degrees" },
{ GST_VIDEOFLIP_METHOD_180, "2", "Rotate 180 degrees" }, { GST_VIDEOFLIP_METHOD_180, "2", "Rotate 180 degrees" },
{ GST_VIDEOFLIP_METHOD_90L, "3", "Rotate counter-clockwise 90 degrees" }, { GST_VIDEOFLIP_METHOD_90L, "3", "Rotate counter-clockwise 90 degrees" },
{ GST_VIDEOFLIP_METHOD_HORIZ, "4", "Flip horizontally" }, { GST_VIDEOFLIP_METHOD_HORIZ, "4", "Flip horizontally" },
{ GST_VIDEOFLIP_METHOD_VERT, "5", "Flip vertically" }, { GST_VIDEOFLIP_METHOD_VERT, "5", "Flip vertically" },
{ GST_VIDEOFLIP_METHOD_TRANS, "6", "Flip across upper left/lower right diagonal" }, { GST_VIDEOFLIP_METHOD_TRANS, "6", "Flip across upper left/lower right diagonal" },
{ GST_VIDEOFLIP_METHOD_OTHER, "7", "Flip across upper right/lower left diagonal" }, { GST_VIDEOFLIP_METHOD_OTHER, "7", "Flip across upper right/lower left diagonal" },
{ 0, NULL, NULL }, { 0, NULL, NULL },
}; };
if(!videoflip_method_type){ if(!videoflip_method_type){
videoflip_method_type = g_enum_register_static("GstVideoflipMethod", videoflip_method_type = g_enum_register_static("GstVideoflipMethod",
videoflip_methods); videoflip_methods);
} }
return videoflip_method_type; return videoflip_method_type;
} }
@ -97,16 +85,17 @@ gst_videoflip_get_type (void)
if (!videoflip_type) { if (!videoflip_type) {
static const GTypeInfo videoflip_info = { static const GTypeInfo videoflip_info = {
sizeof(GstVideoflipClass), sizeof(GstVideoflipClass),
(GBaseInitFunc)gst_videoflip_base_init, gst_videoflip_base_init,
NULL, NULL,
(GClassInitFunc)gst_videoflip_class_init, gst_videoflip_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstVideoflip), sizeof(GstVideoflip),
0, 0,
(GInstanceInitFunc)gst_videoflip_init, gst_videoflip_init,
}; };
videoflip_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideoflip", &videoflip_info, 0); videoflip_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
"GstVideoflip", &videoflip_info, 0);
} }
return videoflip_type; return videoflip_type;
} }
@ -118,133 +107,77 @@ static GstVideofilterFormat gst_videoflip_formats[] = {
{ "IYUV", 12, gst_videoflip_planar411, }, { "IYUV", 12, gst_videoflip_planar411, },
}; };
static GstPadTemplate *gst_videoflip_sink_template_factory (void);
static GstPadTemplate *gst_videoflip_src_template_factory (void);
static void static void
gst_videoflip_base_init (GstVideoflipClass *klass) gst_videoflip_base_init (gpointer g_class)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); static GstElementDetails videoflip_details = GST_ELEMENT_DETAILS (
"Video Flipper",
gst_element_class_add_pad_template (element_class, "Filter/Video",
GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory)); "Flips and rotates video",
gst_element_class_add_pad_template (element_class, "David Schleef <ds@schleef.org>"
GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory)); );
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
int i;
gst_element_class_set_details (element_class, &videoflip_details); gst_element_class_set_details (element_class, &videoflip_details);
for(i=0;i<G_N_ELEMENTS(gst_videoflip_formats);i++){
gst_videofilter_class_add_format(videofilter_class,
gst_videoflip_formats + i);
}
gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
} }
static void static void
gst_videoflip_class_init (GstVideoflipClass *klass) gst_videoflip_class_init (gpointer g_class, gpointer class_data)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstVideofilterClass *videofilter_class;
GstVideofilterClass *gstvideofilter_class;
int i;
gobject_class = (GObjectClass*)klass; gobject_class = G_OBJECT_CLASS (g_class);
gstelement_class = (GstElementClass*)klass; videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
gstvideofilter_class = (GstVideofilterClass *)klass;
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD, g_object_class_install_property(gobject_class, ARG_METHOD,
g_param_spec_enum("method","method","method", g_param_spec_enum("method","method","method",
GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R, GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
this_class = klass;
parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
element_class = g_type_class_ref(GST_TYPE_ELEMENT);
gobject_class->set_property = gst_videoflip_set_property; gobject_class->set_property = gst_videoflip_set_property;
gobject_class->get_property = gst_videoflip_get_property; gobject_class->get_property = gst_videoflip_get_property;
gstvideofilter_class->setup = gst_videoflip_setup; videofilter_class->setup = gst_videoflip_setup;
for(i=0;i<G_N_ELEMENTS(gst_videoflip_formats);i++){
gst_videofilter_class_add_format(gstvideofilter_class,
gst_videoflip_formats + i);
}
}
static GstCaps *gst_videoflip_get_capslist(void)
{
GstVideofilterClass *klass;
klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
return gst_videofilter_class_get_capslist(klass);
}
static GstPadTemplate *
gst_videoflip_src_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
}
return templ;
}
static GstPadTemplate *
gst_videoflip_sink_template_factory(void)
{
static GstPadTemplate *templ = NULL;
if(!templ){
GstCaps *caps = GST_CAPS_NEW("sink","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ());
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
}
return templ;
} }
static void static void
gst_videoflip_init (GstVideoflip *videoflip) gst_videoflip_init (GTypeInstance *instance, gpointer g_class)
{ {
GstVideoflip *videoflip = GST_VIDEOFLIP (instance);
GstVideofilter *videofilter; GstVideofilter *videofilter;
GST_DEBUG ("gst_videoflip_init"); GST_DEBUG("gst_videoflip_init");
videofilter = GST_VIDEOFILTER(videoflip); videofilter = GST_VIDEOFILTER(videoflip);
videofilter->sinkpad = gst_pad_new_from_template ( /* do stuff */
GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory),
"sink");
videofilter->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory),
"src");
gst_videofilter_postinit(GST_VIDEOFILTER(videoflip));
} }
static void static void
gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstVideoflip *videoflip; GstVideoflip *src;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_VIDEOFLIP(object)); g_return_if_fail(GST_IS_VIDEOFLIP(object));
videoflip = GST_VIDEOFLIP(object); src = GST_VIDEOFLIP(object);
GST_DEBUG ("gst_videoflip_set_property"); GST_DEBUG("gst_videoflip_set_property");
switch (prop_id) { switch (prop_id) {
case ARG_METHOD: case ARG_METHOD:
videoflip->method = g_value_get_enum (value); src->method = g_value_get_enum (value);
/* FIXME is this ok? (threading issues) */ /* FIXME is this ok? (threading issues) */
gst_videoflip_setup(GST_VIDEOFILTER(videoflip)); gst_videoflip_setup(GST_VIDEOFILTER(src));
break; break;
default: default:
break; break;
@ -254,15 +187,15 @@ gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value,
static void static void
gst_videoflip_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) gst_videoflip_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{ {
GstVideoflip *videoflip; GstVideoflip *src;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_VIDEOFLIP(object)); g_return_if_fail(GST_IS_VIDEOFLIP(object));
videoflip = GST_VIDEOFLIP(object); src = GST_VIDEOFLIP(object);
switch (prop_id) { switch (prop_id) {
case ARG_METHOD: case ARG_METHOD:
g_value_set_enum (value, videoflip->method); g_value_set_enum (value, src->method);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -275,24 +208,23 @@ static gboolean plugin_init (GstPlugin *plugin)
if(!gst_library_load("gstvideofilter")) if(!gst_library_load("gstvideofilter"))
return FALSE; return FALSE;
return gst_element_register(plugin, "videoflip", return gst_element_register (plugin, "videoflip", GST_RANK_NONE,
GST_RANK_NONE, GST_TYPE_VIDEOFLIP); GST_TYPE_VIDEOFLIP);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR, GST_VERSION_MAJOR,
GST_VERSION_MINOR, GST_VERSION_MINOR,
"videoflip", "videoflip",
"Flips video", "Flips and rotates video",
plugin_init, plugin_init,
VERSION, VERSION,
"LGPL", GST_LICENSE,
GST_COPYRIGHT, GST_COPYRIGHT,
GST_PACKAGE, GST_PACKAGE,
GST_ORIGIN GST_ORIGIN
) )
static void gst_videoflip_flip(GstVideoflip *videoflip, unsigned char *dest, static void gst_videoflip_flip(GstVideoflip *videoflip, unsigned char *dest,
unsigned char *src, int sw, int sh, int dw, int dh); unsigned char *src, int sw, int sh, int dw, int dh);
@ -332,9 +264,9 @@ static void gst_videoflip_setup (GstVideofilter *videofilter)
} }
GST_DEBUG ("format=%p \"%s\" from %dx%d to %dx%d", GST_DEBUG ("format=%p \"%s\" from %dx%d to %dx%d",
videofilter->format, videofilter->format->fourcc, videofilter->format, videofilter->format->fourcc,
from_width, from_height, from_width, from_height,
videofilter->to_width, videofilter->to_height); videofilter->to_width, videofilter->to_height);
if(videoflip->method == GST_VIDEOFLIP_METHOD_IDENTITY){ if(videoflip->method == GST_VIDEOFLIP_METHOD_IDENTITY){
GST_DEBUG ("videoflip: using passthru"); GST_DEBUG ("videoflip: using passthru");
@ -344,9 +276,9 @@ static void gst_videoflip_setup (GstVideofilter *videofilter)
} }
videofilter->from_buf_size = (videofilter->from_width * videofilter->from_height videofilter->from_buf_size = (videofilter->from_width * videofilter->from_height
* videofilter->format->depth) / 8; * videofilter->format->depth) / 8;
videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height
* videofilter->format->depth) / 8; * videofilter->format->depth) / 8;
videofilter->inited = TRUE; videofilter->inited = TRUE;
} }
@ -398,50 +330,50 @@ gst_videoflip_flip(GstVideoflip *videoflip, unsigned char *dest,
case GST_VIDEOFLIP_METHOD_90R: case GST_VIDEOFLIP_METHOD_90R:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[(sh - 1 - x)*sw + y]; dest[y*dw + x] = src[(sh - 1 - x)*sw + y];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_90L: case GST_VIDEOFLIP_METHOD_90L:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[x*sw + (sw - 1 - y)]; dest[y*dw + x] = src[x*sw + (sw - 1 - y)];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_180: case GST_VIDEOFLIP_METHOD_180:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[(sh - 1 - y)*sw + (sw - 1 - x)]; dest[y*dw + x] = src[(sh - 1 - y)*sw + (sw - 1 - x)];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_HORIZ: case GST_VIDEOFLIP_METHOD_HORIZ:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[y*sw + (sw - 1 - x)]; dest[y*dw + x] = src[y*sw + (sw - 1 - x)];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_VERT: case GST_VIDEOFLIP_METHOD_VERT:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[(sh - 1 - y)*sw + x]; dest[y*dw + x] = src[(sh - 1 - y)*sw + x];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_TRANS: case GST_VIDEOFLIP_METHOD_TRANS:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[x*sw + y]; dest[y*dw + x] = src[x*sw + y];
} }
} }
break; break;
case GST_VIDEOFLIP_METHOD_OTHER: case GST_VIDEOFLIP_METHOD_OTHER:
for(y=0;y<dh;y++){ for(y=0;y<dh;y++){
for(x=0;x<dw;x++){ for(x=0;x<dw;x++){
dest[y*dw + x] = src[(sh - 1 - x)*sw + (sw - 1 - y)]; dest[y*dw + x] = src[(sh - 1 - x)*sw + (sw - 1 - y)];
} }
} }
break; break;
default: default:

View file

@ -40,7 +40,6 @@ typedef enum {
GST_VIDEOFLIP_METHOD_OTHER, GST_VIDEOFLIP_METHOD_OTHER,
} GstVideoflipMethod; } GstVideoflipMethod;
#define GST_TYPE_VIDEOFLIP \ #define GST_TYPE_VIDEOFLIP \
(gst_videoflip_get_type()) (gst_videoflip_get_type())
#define GST_VIDEOFLIP(obj) \ #define GST_VIDEOFLIP(obj) \