autoconvert: Rename autocolorspace to autovideoconvert

This doesn't just convert between color spaces.
This commit is contained in:
Sebastian Dröge 2010-12-16 09:56:00 +01:00
parent 7ae4aaaee6
commit 2561bb8fa7
4 changed files with 71 additions and 64 deletions

View file

@ -1,9 +1,10 @@
plugin_LTLIBRARIES = libgstautoconvert.la plugin_LTLIBRARIES = libgstautoconvert.la
libgstautoconvert_la_SOURCES = gstautoconvert.c gstautoconvert.h gstautocolorspace.c gstautcolorspace.h plugin.c libgstautoconvert_la_SOURCES = gstautoconvert.c gstautovideoconvert.c plugin.c
libgstautoconvert_la_CFLAGS = $(GST_CFLAGS) libgstautoconvert_la_CFLAGS = $(GST_CFLAGS)
libgstautoconvert_la_LIBADD = $(GST_LIBS) libgstautoconvert_la_LIBADD = $(GST_LIBS)
libgstautoconvert_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstautoconvert_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstautoconvert_la_LIBTOOLFLAGS = --tag=disable-static libgstautoconvert_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstautoconvert.h gstautovideoconvert.h

View file

@ -18,13 +18,13 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* /*
* test autocolorspace: * test autovideoconvert:
* if rgb2bayer is present * if rgb2bayer is present
* gst-launch videotestsrc num-buffers=2 ! "video/x-raw-rgb,width=100,height=100,framerate=10/1" ! autocolorspace ! "video/x-raw-bayer,width=100,height=100,format=bggr,framerate=10/1" ! fakesink -v * gst-launch videotestsrc num-buffers=2 ! "video/x-raw-rgb,width=100,height=100,framerate=10/1" ! autovideoconvert ! "video/x-raw-bayer,width=100,height=100,format=bggr,framerate=10/1" ! fakesink -v
* if bayer2rgb is present * if bayer2rgb is present
* gst-launch videotestsrc num-buffers=2 ! "video/x-raw-bayer,width=100,height=100,format=bggr,framerate=10/1" ! autocolorspace ! "video/x-raw-rgb,width=100,height=100,framerate=10/1" ! fakesink -v * gst-launch videotestsrc num-buffers=2 ! "video/x-raw-bayer,width=100,height=100,format=bggr,framerate=10/1" ! autovideoconvert ! "video/x-raw-rgb,width=100,height=100,framerate=10/1" ! fakesink -v
* test with ffmpegcolorspace * test with ffmpegvideoconvert
* gst-launch videotestsrc num-buffers=2 ! "video/x-raw-rgb,bpp=32,width=100,height=100,framerate=10/1" ! autocolorspace ! "video/x-raw-rgb,bpp=16,width=100,height=100,framerate=10/1" ! fakesink -v * gst-launch videotestsrc num-buffers=2 ! "video/x-raw-rgb,bpp=32,width=100,height=100,framerate=10/1" ! autovideoconvert ! "video/x-raw-rgb,bpp=16,width=100,height=100,framerate=10/1" ! fakesink -v
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
@ -32,10 +32,10 @@
#include <string.h> #include <string.h>
#include "gstautocolorspace.h" #include "gstautovideoconvert.h"
GST_DEBUG_CATEGORY (autocolorspace_debug); GST_DEBUG_CATEGORY (autovideoconvert_debug);
#define GST_CAT_DEFAULT (autocolorspace_debug) #define GST_CAT_DEFAULT (autovideoconvert_debug)
GStaticMutex factories_mutex = G_STATIC_MUTEX_INIT; GStaticMutex factories_mutex = G_STATIC_MUTEX_INIT;
guint32 factories_cookie = 0; /* Cookie from last time when factories was updated */ guint32 factories_cookie = 0; /* Cookie from last time when factories was updated */
@ -53,15 +53,15 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS_ANY); GST_STATIC_CAPS_ANY);
static GstStateChangeReturn gst_auto_color_space_change_state (GstElement * static GstStateChangeReturn gst_auto_video_convert_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
void gst_auto_color_space_update_factory_list (GstAutoColorSpace * void gst_auto_video_convert_update_factory_list (GstAutoVideoConvert *
autocolorspace); autovideoconvert);
static gboolean static gboolean
gst_auto_color_space_element_filter (GstPluginFeature * feature, gst_auto_video_convert_element_filter (GstPluginFeature * feature,
GstAutoColorSpace * autocolorspace) GstAutoVideoConvert * autovideoconvert)
{ {
const gchar *klass; const gchar *klass;
@ -73,8 +73,8 @@ gst_auto_color_space_element_filter (GstPluginFeature * feature,
/* only select color space converter */ /* only select color space converter */
if (strstr (klass, "Filter") && if (strstr (klass, "Filter") &&
strstr (klass, "Converter") && strstr (klass, "Video")) { strstr (klass, "Converter") && strstr (klass, "Video")) {
GST_DEBUG_OBJECT (autocolorspace, GST_DEBUG_OBJECT (autovideoconvert,
"gst_auto_color_space_element_filter found %s\n", "gst_auto_video_convert_element_filter found %s\n",
gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (feature))); gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (feature)));
return TRUE; return TRUE;
} }
@ -83,13 +83,14 @@ gst_auto_color_space_element_filter (GstPluginFeature * feature,
static GList * static GList *
gst_auto_color_space_create_factory_list (GstAutoColorSpace * autocolorspace) gst_auto_video_convert_create_factory_list (GstAutoVideoConvert *
autovideoconvert)
{ {
GList *result = NULL; GList *result = NULL;
/* get the feature list using the filter */ /* get the feature list using the filter */
result = gst_default_registry_feature_filter ((GstPluginFeatureFilter) result = gst_default_registry_feature_filter ((GstPluginFeatureFilter)
gst_auto_color_space_element_filter, FALSE, autocolorspace); gst_auto_video_convert_element_filter, FALSE, autovideoconvert);
/* sort on rank and name */ /* sort on rank and name */
result = g_list_sort (result, gst_plugin_feature_rank_compare_func); result = g_list_sort (result, gst_plugin_feature_rank_compare_func);
@ -98,7 +99,8 @@ gst_auto_color_space_create_factory_list (GstAutoColorSpace * autocolorspace)
} }
void void
gst_auto_color_space_update_factory_list (GstAutoColorSpace * autocolorspace) gst_auto_video_convert_update_factory_list (GstAutoVideoConvert *
autovideoconvert)
{ {
/* use a static mutex to protect factories list and factories cookie */ /* use a static mutex to protect factories list and factories cookie */
g_static_mutex_lock (&factories_mutex); g_static_mutex_lock (&factories_mutex);
@ -107,7 +109,7 @@ gst_auto_color_space_update_factory_list (GstAutoColorSpace * autocolorspace)
if (!factories) { if (!factories) {
/* no factories list create it */ /* no factories list create it */
factories_cookie = gst_default_registry_get_feature_list_cookie (); factories_cookie = gst_default_registry_get_feature_list_cookie ();
factories = gst_auto_color_space_create_factory_list (autocolorspace); factories = gst_auto_video_convert_create_factory_list (autovideoconvert);
} else { } else {
/* a factories list exist but is it up to date? */ /* a factories list exist but is it up to date? */
if (factories_cookie != gst_default_registry_get_feature_list_cookie ()) { if (factories_cookie != gst_default_registry_get_feature_list_cookie ()) {
@ -116,17 +118,18 @@ gst_auto_color_space_update_factory_list (GstAutoColorSpace * autocolorspace)
gst_plugin_feature_list_free (factories); gst_plugin_feature_list_free (factories);
/* then create an updated one */ /* then create an updated one */
factories_cookie = gst_default_registry_get_feature_list_cookie (); factories_cookie = gst_default_registry_get_feature_list_cookie ();
factories = gst_auto_color_space_create_factory_list (autocolorspace); factories = gst_auto_video_convert_create_factory_list (autovideoconvert);
} }
} }
g_static_mutex_unlock (&factories_mutex); g_static_mutex_unlock (&factories_mutex);
} }
GST_BOILERPLATE (GstAutoColorSpace, gst_auto_color_space, GstBin, GST_TYPE_BIN); GST_BOILERPLATE (GstAutoVideoConvert, gst_auto_video_convert, GstBin,
GST_TYPE_BIN);
static void static void
gst_auto_color_space_base_init (gpointer klass) gst_auto_video_convert_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -142,77 +145,80 @@ gst_auto_color_space_base_init (gpointer klass)
} }
static void static void
gst_auto_color_space_dispose (GObject * object) gst_auto_video_convert_dispose (GObject * object)
{ {
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
static void static void
gst_auto_color_space_class_init (GstAutoColorSpaceClass * klass) gst_auto_video_convert_class_init (GstAutoVideoConvertClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass; GstElementClass *gstelement_class = (GstElementClass *) klass;
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_auto_color_space_dispose); gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_auto_video_convert_dispose);
GST_DEBUG_CATEGORY_INIT (autocolorspace_debug, "autocolorspace", 0, GST_DEBUG_CATEGORY_INIT (autovideoconvert_debug, "autovideoconvert", 0,
"Auto color space converter"); "Auto color space converter");
gstelement_class->change_state = gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_auto_color_space_change_state); GST_DEBUG_FUNCPTR (gst_auto_video_convert_change_state);
} }
static void static void
gst_auto_color_space_add_autoconvert (GstAutoColorSpace * autocolorspace) gst_auto_video_convert_add_autoconvert (GstAutoVideoConvert * autovideoconvert)
{ {
GstPad *pad; GstPad *pad;
autocolorspace->autoconvert = autovideoconvert->autoconvert =
gst_element_factory_make ("autoconvert", "autoconvertchild"); gst_element_factory_make ("autoconvert", "autoconvertchild");
/* first add autoconvert in bin */ /* first add autoconvert in bin */
gst_bin_add (GST_BIN (autocolorspace), autocolorspace->autoconvert); gst_bin_add (GST_BIN (autovideoconvert), autovideoconvert->autoconvert);
/* get sinkpad and link it to ghost sink pad */ /* get sinkpad and link it to ghost sink pad */
pad = gst_element_get_static_pad (autocolorspace->autoconvert, "sink"); pad = gst_element_get_static_pad (autovideoconvert->autoconvert, "sink");
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (autocolorspace->sinkpad), pad); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (autovideoconvert->sinkpad),
pad);
gst_object_unref (pad); gst_object_unref (pad);
/* get srcpad and link it to ghost src pad */ /* get srcpad and link it to ghost src pad */
pad = gst_element_get_static_pad (autocolorspace->autoconvert, "src"); pad = gst_element_get_static_pad (autovideoconvert->autoconvert, "src");
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (autocolorspace->srcpad), pad); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (autovideoconvert->srcpad), pad);
gst_object_unref (pad); gst_object_unref (pad);
} }
static void static void
gst_auto_color_space_init (GstAutoColorSpace * autocolorspace, gst_auto_video_convert_init (GstAutoVideoConvert * autovideoconvert,
GstAutoColorSpaceClass * klass) GstAutoVideoConvertClass * klass)
{ {
GstPadTemplate *pad_tmpl; GstPadTemplate *pad_tmpl;
/* get sink pad template */ /* get sink pad template */
pad_tmpl = gst_static_pad_template_get (&sinktemplate); pad_tmpl = gst_static_pad_template_get (&sinktemplate);
autocolorspace->sinkpad = autovideoconvert->sinkpad =
gst_ghost_pad_new_no_target_from_template ("sink", pad_tmpl); gst_ghost_pad_new_no_target_from_template ("sink", pad_tmpl);
/* add sink ghost pad */ /* add sink ghost pad */
gst_element_add_pad (GST_ELEMENT (autocolorspace), autocolorspace->sinkpad); gst_element_add_pad (GST_ELEMENT (autovideoconvert),
autovideoconvert->sinkpad);
/* get src pad template */ /* get src pad template */
pad_tmpl = gst_static_pad_template_get (&srctemplate); pad_tmpl = gst_static_pad_template_get (&srctemplate);
autocolorspace->srcpad = autovideoconvert->srcpad =
gst_ghost_pad_new_no_target_from_template ("src", pad_tmpl); gst_ghost_pad_new_no_target_from_template ("src", pad_tmpl);
/* add src ghost pad */ /* add src ghost pad */
gst_element_add_pad (GST_ELEMENT (autocolorspace), autocolorspace->srcpad); gst_element_add_pad (GST_ELEMENT (autovideoconvert),
autovideoconvert->srcpad);
return; return;
} }
static GstStateChangeReturn static GstStateChangeReturn
gst_auto_color_space_change_state (GstElement * element, gst_auto_video_convert_change_state (GstElement * element,
GstStateChange transition) GstStateChange transition)
{ {
GstAutoColorSpace *autocolorspace = GST_AUTO_COLOR_SPACE (element); GstAutoVideoConvert *autovideoconvert = GST_AUTO_VIDEO_CONVERT (element);
GstStateChangeReturn ret; GstStateChangeReturn ret;
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
@ -223,15 +229,15 @@ gst_auto_color_space_change_state (GstElement * element,
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
{ {
/* create and add autoconvert in bin */ /* create and add autoconvert in bin */
gst_auto_color_space_add_autoconvert (autocolorspace); gst_auto_video_convert_add_autoconvert (autovideoconvert);
/* get an updated list of factories */ /* get an updated list of factories */
gst_auto_color_space_update_factory_list (autocolorspace); gst_auto_video_convert_update_factory_list (autovideoconvert);
GST_DEBUG_OBJECT (autocolorspace, "set factories list"); GST_DEBUG_OBJECT (autovideoconvert, "set factories list");
/* give factory list to autoconvert */ /* give factory list to autoconvert */
g_object_set (GST_ELEMENT (autocolorspace->autoconvert), "factories", g_object_set (GST_ELEMENT (autovideoconvert->autoconvert), "factories",
factories, NULL); factories, NULL);
/* synchronize autoconvert state with parent state */ /* synchronize autoconvert state with parent state */
gst_element_sync_state_with_parent (autocolorspace->autoconvert); gst_element_sync_state_with_parent (autovideoconvert->autoconvert);
break; break;
} }
default: default:

View file

@ -18,23 +18,23 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_AUTO_COLOR_SPACE_H__ #ifndef __GST_AUTO_VIDEO_CONVERT_H__
#define __GST_AUTO_COLOR_SPACE_H__ #define __GST_AUTO_VIDEO_CONVERT_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/gstbin.h> #include <gst/gstbin.h>
#include "gstautoconvert.h" #include "gstautoconvert.h"
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_AUTO_COLOR_SPACE (gst_auto_color_space_get_type()) #define GST_TYPE_AUTO_VIDEO_CONVERT (gst_auto_video_convert_get_type())
#define GST_AUTO_COLOR_SPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUTO_COLOR_SPACE,GstAutoColorSpace)) #define GST_AUTO_VIDEO_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUTO_VIDEO_CONVERT,GstAutoVideoConvert))
#define GST_AUTO_COLOR_SPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUTO_COLOR_SPACE,GstAutoColorSpaceClass)) #define GST_AUTO_VIDEO_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUTO_VIDEO_CONVERT,GstAutoVideoConvertClass))
#define GST_IS_AUTO_COLOR_SPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUTO_COLOR_SPACE)) #define GST_IS_AUTO_VIDEO_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUTO_VIDEO_CONVERT))
#define GST_IS_AUTO_COLOR_SPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUTO_COLOR_SPACE)) #define GST_IS_AUTO_VIDEO_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUTO_VIDEO_CONVERT))
typedef struct _GstAutoColorSpace GstAutoColorSpace; typedef struct _GstAutoVideoConvert GstAutoVideoConvert;
typedef struct _GstAutoColorSpaceClass GstAutoColorSpaceClass; typedef struct _GstAutoVideoConvertClass GstAutoVideoConvertClass;
struct _GstAutoColorSpace struct _GstAutoVideoConvert
{ {
/*< private > */ /*< private > */
GstBin bin; /* we extend GstBin */ GstBin bin; /* we extend GstBin */
@ -44,12 +44,12 @@ struct _GstAutoColorSpace
GstPad *srcpad; GstPad *srcpad;
}; };
struct _GstAutoColorSpaceClass struct _GstAutoVideoConvertClass
{ {
GstBinClass parent_class; GstBinClass parent_class;
}; };
GType gst_auto_color_space_get_type (void); GType gst_auto_video_convert_get_type (void);
G_END_DECLS G_END_DECLS
#endif /* __GST_AUTO_COLOR_SPACE_H__ */ #endif /* __GST_AUTO_VIDEO_CONVERT_H__ */

View file

@ -23,7 +23,7 @@
#endif #endif
#include "gstautoconvert.h" #include "gstautoconvert.h"
#include "gstautocolorspace.h" #include "gstautovideoconvert.h"
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
@ -33,8 +33,8 @@ plugin_init (GstPlugin * plugin)
ret = gst_element_register (plugin, "autoconvert", ret = gst_element_register (plugin, "autoconvert",
GST_RANK_NONE, GST_TYPE_AUTO_CONVERT); GST_RANK_NONE, GST_TYPE_AUTO_CONVERT);
ret &= gst_element_register (plugin, "autocolorspace", ret &= gst_element_register (plugin, "autovideoconvert",
GST_RANK_NONE, GST_TYPE_AUTO_COLOR_SPACE); GST_RANK_NONE, GST_TYPE_AUTO_VIDEO_CONVERT);
return ret; return ret;
} }