alpha: Minor cleanups and move declarations into a separate header file

This commit is contained in:
Sebastian Dröge 2010-03-15 19:07:28 +01:00
parent 6f80d41c04
commit 322a8f5e6d
4 changed files with 128 additions and 107 deletions

View file

@ -114,6 +114,7 @@ EXTRA_HFILES = \
$(top_srcdir)/ext/wavpack/gstwavpackdec.h \ $(top_srcdir)/ext/wavpack/gstwavpackdec.h \
$(top_srcdir)/ext/wavpack/gstwavpackenc.h \ $(top_srcdir)/ext/wavpack/gstwavpackenc.h \
$(top_srcdir)/ext/wavpack/gstwavpackparse.h \ $(top_srcdir)/ext/wavpack/gstwavpackparse.h \
$(top_srcdir)/gst/alpha/gstalpha.h \
$(top_srcdir)/gst/alpha/gstalphacolor.h \ $(top_srcdir)/gst/alpha/gstalphacolor.h \
$(top_srcdir)/gst/apetag/gstapedemux.h \ $(top_srcdir)/gst/apetag/gstapedemux.h \
$(top_srcdir)/gst/audiofx/audioamplify.h \ $(top_srcdir)/gst/audiofx/audioamplify.h \

View file

@ -16,4 +16,4 @@ libgstalphacolor_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINO
libgstalphacolor_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstalphacolor_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstalphacolor_la_LIBTOOLFLAGS = --tag=disable-static libgstalphacolor_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstalphacolor.h noinst_HEADERS = gstalpha.h gstalphacolor.h

View file

@ -23,10 +23,8 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <gst/gst.h>
#include <gst/video/video.h> #include "gstalpha.h"
#include <gst/video/gstvideofilter.h>
#include <gst/controller/gstcontroller.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -36,79 +34,6 @@
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#endif #endif
#define GST_TYPE_ALPHA \
(gst_alpha_get_type())
#define GST_ALPHA(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALPHA,GstAlpha))
#define GST_ALPHA_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALPHA,GstAlphaClass))
#define GST_IS_ALPHA(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALPHA))
#define GST_IS_ALPHA_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALPHA))
typedef struct _GstAlpha GstAlpha;
typedef struct _GstAlphaClass GstAlphaClass;
typedef enum
{
ALPHA_METHOD_SET,
ALPHA_METHOD_GREEN,
ALPHA_METHOD_BLUE,
ALPHA_METHOD_CUSTOM,
}
GstAlphaMethod;
GST_DEBUG_CATEGORY_STATIC (gst_alpha_debug);
#define GST_CAT_DEFAULT gst_alpha_debug
struct _GstAlpha
{
GstVideoFilter parent;
/* caps */
GstVideoFormat format;
gint width, height;
gboolean ayuv;
gdouble alpha;
guint target_r;
guint target_g;
guint target_b;
GstAlphaMethod method;
gfloat angle;
gfloat noise_level;
guint black_sensitivity;
guint white_sensitivity;
gfloat y; /* chroma color */
gint8 cb, cr;
gint8 kg;
gfloat accept_angle_cos;
gfloat accept_angle_sin;
guint8 accept_angle_tg;
guint8 accept_angle_ctg;
guint8 one_over_kc;
guint8 kfgy_scale;
};
struct _GstAlphaClass
{
GstVideoFilterClass parent_class;
};
/* elementfactory information */
static const GstElementDetails gst_alpha_details =
GST_ELEMENT_DETAILS ("Alpha filter",
"Filter/Effect/Video",
"Adds an alpha channel to video - uniform or via chroma-keying",
"Wim Taymans <wim@fluendo.com>\n"
"Edward Hervey <edward.hervey@collabora.co.uk>\n"
"Jan Schmidt <thaytan@noraisin.net>");
/* Alpha signals and args */ /* Alpha signals and args */
enum enum
{ {
@ -199,7 +124,12 @@ gst_alpha_base_init (gpointer g_class)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_alpha_details); gst_element_class_set_details_simple (element_class, "Alpha filter",
"Filter/Effect/Video",
"Adds an alpha channel to video - uniform or via chroma-keying",
"Wim Taymans <wim@fluendo.com>\n"
"Edward Hervey <edward.hervey@collabora.co.uk>\n"
"Jan Schmidt <thaytan@noraisin.net>");
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_alpha_sink_template)); gst_static_pad_template_get (&gst_alpha_sink_template));
@ -213,11 +143,8 @@ gst_alpha_base_init (gpointer g_class)
static void static void
gst_alpha_class_init (GstAlphaClass * klass) gst_alpha_class_init (GstAlphaClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class = (GObjectClass *) klass;
GstBaseTransformClass *btrans_class; GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
gobject_class = (GObjectClass *) klass;
btrans_class = (GstBaseTransformClass *) klass;
gobject_class->set_property = gst_alpha_set_property; gobject_class->set_property = gst_alpha_set_property;
gobject_class->get_property = gst_alpha_get_property; gobject_class->get_property = gst_alpha_get_property;
@ -225,41 +152,41 @@ gst_alpha_class_init (GstAlphaClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_METHOD, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_METHOD,
g_param_spec_enum ("method", "Method", g_param_spec_enum ("method", "Method",
"How the alpha channels should be created", GST_TYPE_ALPHA_METHOD, "How the alpha channels should be created", GST_TYPE_ALPHA_METHOD,
DEFAULT_METHOD, (GParamFlags) G_PARAM_READWRITE)); DEFAULT_METHOD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ALPHA, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ALPHA,
g_param_spec_double ("alpha", "Alpha", "The value for the alpha channel", g_param_spec_double ("alpha", "Alpha", "The value for the alpha channel",
0.0, 1.0, DEFAULT_ALPHA, 0.0, 1.0, DEFAULT_ALPHA,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_R, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_R,
g_param_spec_uint ("target_r", "Target Red", "The Red target", 0, 255, g_param_spec_uint ("target-r", "Target Red", "The Red target", 0, 255,
DEFAULT_TARGET_R, DEFAULT_TARGET_R,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_G, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_G,
g_param_spec_uint ("target_g", "Target Green", "The Green target", 0, 255, g_param_spec_uint ("target-g", "Target Green", "The Green target", 0, 255,
DEFAULT_TARGET_G, DEFAULT_TARGET_G,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_B, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TARGET_B,
g_param_spec_uint ("target_b", "Target Blue", "The Blue target", 0, 255, g_param_spec_uint ("target-b", "Target Blue", "The Blue target", 0, 255,
DEFAULT_TARGET_B, DEFAULT_TARGET_B,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ANGLE, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ANGLE,
g_param_spec_float ("angle", "Angle", "Size of the colorcube to change", g_param_spec_float ("angle", "Angle", "Size of the colorcube to change",
0.0, 90.0, DEFAULT_ANGLE, 0.0, 90.0, DEFAULT_ANGLE,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NOISE_LEVEL, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NOISE_LEVEL,
g_param_spec_float ("noise_level", "Noise Level", "Size of noise radius", g_param_spec_float ("noise-level", "Noise Level", "Size of noise radius",
0.0, 64.0, DEFAULT_NOISE_LEVEL, 0.0, 64.0, DEFAULT_NOISE_LEVEL,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_BLACK_SENSITIVITY, g_param_spec_uint ("black-sensitivity", PROP_BLACK_SENSITIVITY, g_param_spec_uint ("black-sensitivity",
"Black Sensitivity", "Sensitivity to dark colors", 0, 128, "Black Sensitivity", "Sensitivity to dark colors", 0, 128,
DEFAULT_BLACK_SENSITIVITY, DEFAULT_BLACK_SENSITIVITY,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_WHITE_SENSITIVITY, g_param_spec_uint ("white-sensitivity", PROP_WHITE_SENSITIVITY, g_param_spec_uint ("white-sensitivity",
"Sensitivity", "Sensitivity to bright colors", 0, 128, "Sensitivity", "Sensitivity to bright colors", 0, 128,
DEFAULT_WHITE_SENSITIVITY, DEFAULT_WHITE_SENSITIVITY,
(GParamFlags) G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
btrans_class->start = GST_DEBUG_FUNCPTR (gst_alpha_start); btrans_class->start = GST_DEBUG_FUNCPTR (gst_alpha_start);
@ -288,11 +215,7 @@ static void
gst_alpha_set_property (GObject * object, guint prop_id, gst_alpha_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstAlpha *alpha; GstAlpha *alpha = GST_ALPHA (object);
g_return_if_fail (GST_IS_ALPHA (object));
alpha = GST_ALPHA (object);
switch (prop_id) { switch (prop_id) {
case PROP_METHOD: case PROP_METHOD:
@ -352,11 +275,7 @@ static void
gst_alpha_get_property (GObject * object, guint prop_id, GValue * value, gst_alpha_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec) GParamSpec * pspec)
{ {
GstAlpha *alpha; GstAlpha *alpha = GST_ALPHA (object);
g_return_if_fail (GST_IS_ALPHA (object));
alpha = GST_ALPHA (object);
switch (prop_id) { switch (prop_id) {
case PROP_METHOD: case PROP_METHOD:

101
gst/alpha/gstalpha.h Normal file
View file

@ -0,0 +1,101 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2007> Wim Taymans <wim.taymans@collabora.co.uk>
* Copyright (C) <2007> Edward Hervey <edward.hervey@collabora.co.uk>
* Copyright (C) <2007> Jan Schmidt <thaytan@noraisin.net>
*
* 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_ALPHA_H__
#define __GST_ALPHA_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
#include <gst/controller/gstcontroller.h>
G_BEGIN_DECLS
#define GST_TYPE_ALPHA \
(gst_alpha_get_type())
#define GST_ALPHA(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALPHA,GstAlpha))
#define GST_ALPHA_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALPHA,GstAlphaClass))
#define GST_IS_ALPHA(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALPHA))
#define GST_IS_ALPHA_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALPHA))
typedef struct _GstAlpha GstAlpha;
typedef struct _GstAlphaClass GstAlphaClass;
typedef enum
{
ALPHA_METHOD_SET,
ALPHA_METHOD_GREEN,
ALPHA_METHOD_BLUE,
ALPHA_METHOD_CUSTOM,
}
GstAlphaMethod;
GST_DEBUG_CATEGORY_STATIC (gst_alpha_debug);
#define GST_CAT_DEFAULT gst_alpha_debug
struct _GstAlpha
{
GstVideoFilter parent;
/* caps */
GstVideoFormat format;
gint width, height;
gboolean ayuv;
gdouble alpha;
guint target_r;
guint target_g;
guint target_b;
GstAlphaMethod method;
gfloat angle;
gfloat noise_level;
guint black_sensitivity;
guint white_sensitivity;
gfloat y; /* chroma color */
gint8 cb, cr;
gint8 kg;
gfloat accept_angle_cos;
gfloat accept_angle_sin;
guint8 accept_angle_tg;
guint8 accept_angle_ctg;
guint8 one_over_kc;
guint8 kfgy_scale;
};
struct _GstAlphaClass
{
GstVideoFilterClass parent_class;
};
GType gst_alpha_get_type (void);
G_END_DECLS
#endif /* __GST_ALPHA_H__ */