mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
gst/audiofx/: Some small cleanups and port both elements to the new GstAudioFilter base class to save a few lines of ...
Original commit message from CVS: * gst/audiofx/audioamplify.c: (gst_audio_amplify_base_init), (gst_audio_amplify_class_init), (gst_audio_amplify_init), (gst_audio_amplify_set_process_function), (gst_audio_amplify_setup): * gst/audiofx/audioamplify.h: * gst/audiofx/audioinvert.c: (gst_audio_invert_base_init), (gst_audio_invert_class_init), (gst_audio_invert_setup): * gst/audiofx/audioinvert.h: Some small cleanups and port both elements to the new GstAudioFilter base class to save a few lines of common code. * gst/audiofx/Makefile.am: Link against libgstaudio for the above changes
This commit is contained in:
parent
f7935f9a40
commit
cdba2c4219
6 changed files with 116 additions and 148 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2007-02-06 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* gst/audiofx/audioamplify.c: (gst_audio_amplify_base_init),
|
||||||
|
(gst_audio_amplify_class_init), (gst_audio_amplify_init),
|
||||||
|
(gst_audio_amplify_set_process_function),
|
||||||
|
(gst_audio_amplify_setup):
|
||||||
|
* gst/audiofx/audioamplify.h:
|
||||||
|
* gst/audiofx/audioinvert.c: (gst_audio_invert_base_init),
|
||||||
|
(gst_audio_invert_class_init), (gst_audio_invert_setup):
|
||||||
|
* gst/audiofx/audioinvert.h:
|
||||||
|
Some small cleanups and port both elements to the new GstAudioFilter
|
||||||
|
base class to save a few lines of common code.
|
||||||
|
* gst/audiofx/Makefile.am:
|
||||||
|
Link against libgstaudio for the above changes
|
||||||
|
|
||||||
2007-01-29 Wim Taymans <wim@fluendo.com>
|
2007-01-29 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* tests/check/elements/.cvsignore:
|
* tests/check/elements/.cvsignore:
|
||||||
|
|
|
@ -11,10 +11,13 @@ libgstaudiofx_la_SOURCES = audiofx.c\
|
||||||
# flags used to compile this plugin
|
# flags used to compile this plugin
|
||||||
libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \
|
libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \
|
||||||
$(GST_BASE_CFLAGS) \
|
$(GST_BASE_CFLAGS) \
|
||||||
$(GST_CONTROLLER_CFLAGS)
|
$(GST_CONTROLLER_CFLAGS) \
|
||||||
|
$(GST_PLUGINS_BASE_CFLAGS)
|
||||||
libgstaudiofx_la_LIBADD = $(GST_LIBS) \
|
libgstaudiofx_la_LIBADD = $(GST_LIBS) \
|
||||||
$(GST_BASE_LIBS) \
|
$(GST_BASE_LIBS) \
|
||||||
$(GST_CONTROLLER_LIBS)
|
$(GST_CONTROLLER_LIBS) \
|
||||||
|
$(GST_PLUGINS_BASE_LIBS) \
|
||||||
|
-lgstaudio-$(GST_MAJORMINOR)
|
||||||
libgstaudiofx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstaudiofx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
# headers we need but don't want installed
|
# headers we need but don't want installed
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
#include <gst/controller/gstcontroller.h>
|
#include <gst/controller/gstcontroller.h>
|
||||||
|
|
||||||
#include "audioamplify.h"
|
#include "audioamplify.h"
|
||||||
|
@ -100,47 +102,33 @@ gst_audio_amplify_clipping_method_get_type (void)
|
||||||
return gtype;
|
return gtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
#define ALLOWED_CAPS \
|
||||||
GST_PAD_SINK,
|
"audio/x-raw-int," \
|
||||||
GST_PAD_ALWAYS,
|
" depth=(int)16," \
|
||||||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
" width=(int)16," \
|
||||||
"rate = (int) [ 1, MAX ], "
|
" endianness=(int)BYTE_ORDER," \
|
||||||
"channels = (int) [ 1, MAX ], "
|
" signed=(bool)TRUE," \
|
||||||
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
|
" rate=(int)[1,MAX]," \
|
||||||
"audio/x-raw-int, "
|
" channels=(int)[1,MAX]; " \
|
||||||
"rate = (int) [ 1, MAX ], "
|
"audio/x-raw-float," \
|
||||||
"channels = (int) [ 1, MAX ], "
|
" width=(int)32," \
|
||||||
"endianness = (int) BYTE_ORDER, "
|
" endianness=(int)BYTE_ORDER," \
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
" rate=(int)[1,MAX]," \
|
||||||
);
|
" channels=(int)[1,MAX]"
|
||||||
|
|
||||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
|
||||||
"rate = (int) [ 1, MAX ], "
|
|
||||||
"channels = (int) [ 1, MAX], "
|
|
||||||
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
|
|
||||||
"audio/x-raw-int, "
|
|
||||||
"rate = (int) [ 1, MAX ], "
|
|
||||||
"channels = (int) [ 1, MAX ], "
|
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
|
||||||
);
|
|
||||||
|
|
||||||
#define DEBUG_INIT(bla) \
|
#define DEBUG_INIT(bla) \
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0, "audioamplify element");
|
GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0, "audioamplify element");
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstBaseTransform,
|
GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstAudioFilter,
|
||||||
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
|
||||||
|
|
||||||
static void gst_audio_amplify_set_property (GObject * object, guint prop_id,
|
static void gst_audio_amplify_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_audio_amplify_get_property (GObject * object, guint prop_id,
|
static void gst_audio_amplify_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static gboolean gst_audio_amplify_set_caps (GstBaseTransform * base,
|
static gboolean gst_audio_amplify_setup (GstAudioFilter * filter,
|
||||||
GstCaps * incaps, GstCaps * outcaps);
|
GstRingBufferSpec * format);
|
||||||
static GstFlowReturn gst_audio_amplify_transform_ip (GstBaseTransform * base,
|
static GstFlowReturn gst_audio_amplify_transform_ip (GstBaseTransform * base,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
|
|
||||||
|
@ -179,12 +167,14 @@ static void
|
||||||
gst_audio_amplify_base_init (gpointer klass)
|
gst_audio_amplify_base_init (gpointer klass)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_template));
|
|
||||||
gst_element_class_set_details (element_class, &element_details);
|
gst_element_class_set_details (element_class, &element_details);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string (ALLOWED_CAPS);
|
||||||
|
gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
|
||||||
|
caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -215,8 +205,8 @@ gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
|
||||||
GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD, METHOD_CLIP,
|
GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD, METHOD_CLIP,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
|
GST_AUDIO_FILTER_CLASS (klass)->setup =
|
||||||
GST_DEBUG_FUNCPTR (gst_audio_amplify_set_caps);
|
GST_DEBUG_FUNCPTR (gst_audio_amplify_setup);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
|
||||||
GST_DEBUG_FUNCPTR (gst_audio_amplify_transform_ip);
|
GST_DEBUG_FUNCPTR (gst_audio_amplify_transform_ip);
|
||||||
}
|
}
|
||||||
|
@ -227,24 +217,22 @@ gst_audio_amplify_init (GstAudioAmplify * filter, GstAudioAmplifyClass * klass)
|
||||||
filter->amplification = 1.0;
|
filter->amplification = 1.0;
|
||||||
filter->clipping_method = METHOD_CLIP;
|
filter->clipping_method = METHOD_CLIP;
|
||||||
filter->width = 0;
|
filter->width = 0;
|
||||||
filter->format_float = FALSE;
|
filter->format_index = 0;
|
||||||
gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
|
gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audio_amplify_set_process_function (GstAudioAmplify * filter)
|
gst_audio_amplify_set_process_function (GstAudioAmplify * filter)
|
||||||
{
|
{
|
||||||
gint format_index, method_index;
|
gint method_index;
|
||||||
|
|
||||||
/* set processing function */
|
/* set processing function */
|
||||||
|
|
||||||
format_index = (filter->format_float) ? 1 : 0;
|
|
||||||
|
|
||||||
method_index = filter->clipping_method;
|
method_index = filter->clipping_method;
|
||||||
if (method_index >= NUM_METHODS || method_index < 0)
|
if (method_index >= NUM_METHODS || method_index < 0)
|
||||||
method_index = METHOD_CLIP;
|
method_index = METHOD_CLIP;
|
||||||
|
|
||||||
filter->process = processing_functions[format_index][method_index];
|
filter->process = processing_functions[filter->format_index][method_index];
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,43 +277,30 @@ gst_audio_amplify_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GstBaseTransform vmethod implementations */
|
/* GstAudioFilter vmethod implementations */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audio_amplify_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
gst_audio_amplify_setup (GstAudioFilter * base, GstRingBufferSpec * format)
|
||||||
GstCaps * outcaps)
|
|
||||||
{
|
{
|
||||||
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
|
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
|
||||||
const GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
gint width;
|
|
||||||
const gchar *fmt;
|
|
||||||
|
|
||||||
/*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
|
filter->width = format->width / 8;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (incaps, 0);
|
if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
|
||||||
|
filter->format_index = 0;
|
||||||
ret = gst_structure_get_int (structure, "width", &width);
|
else if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
|
||||||
if (!ret)
|
filter->format_index = 1;
|
||||||
goto no_width;
|
|
||||||
filter->width = width / 8;
|
|
||||||
|
|
||||||
|
|
||||||
fmt = gst_structure_get_name (structure);
|
|
||||||
if (!strcmp (fmt, "audio/x-raw-int"))
|
|
||||||
filter->format_float = FALSE;
|
|
||||||
else
|
else
|
||||||
filter->format_float = TRUE;
|
goto wrong_format;
|
||||||
|
|
||||||
GST_DEBUG ("try to process %s input", fmt);
|
|
||||||
ret = gst_audio_amplify_set_process_function (filter);
|
ret = gst_audio_amplify_set_process_function (filter);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
GST_WARNING ("can't process input");
|
GST_WARNING ("can't process input");
|
||||||
|
|
||||||
return TRUE;
|
return ret;
|
||||||
|
|
||||||
no_width:
|
wrong_format:
|
||||||
GST_DEBUG ("no width in caps");
|
GST_DEBUG ("wrong format");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,8 +409,7 @@ gst_audio_amplify_transform_float_wrap_positive (GstAudioAmplify * filter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function does the actual processing
|
/* GstBaseTransform vmethod implementations */
|
||||||
*/
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define GST_TYPE_AUDIO_AMPLIFY (gst_audio_amplify_get_type())
|
#define GST_TYPE_AUDIO_AMPLIFY (gst_audio_amplify_get_type())
|
||||||
|
@ -39,7 +41,7 @@ typedef void (*GstAudioAmplifyProcessFunc) (GstAudioAmplify *, guint8 *, guint);
|
||||||
|
|
||||||
struct _GstAudioAmplify
|
struct _GstAudioAmplify
|
||||||
{
|
{
|
||||||
GstBaseTransform element;
|
GstAudioFilter audiofilter;
|
||||||
|
|
||||||
gfloat amplification;
|
gfloat amplification;
|
||||||
|
|
||||||
|
@ -47,12 +49,12 @@ struct _GstAudioAmplify
|
||||||
GstAudioAmplifyProcessFunc process;
|
GstAudioAmplifyProcessFunc process;
|
||||||
gint clipping_method;
|
gint clipping_method;
|
||||||
gint width;
|
gint width;
|
||||||
gboolean format_float;
|
gint format_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAudioAmplifyClass
|
struct _GstAudioAmplifyClass
|
||||||
{
|
{
|
||||||
GstBaseTransformClass parent;
|
GstAudioFilterClass parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_audio_amplify_get_type (void);
|
GType gst_audio_amplify_get_type (void);
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
#include <gst/controller/gstcontroller.h>
|
#include <gst/controller/gstcontroller.h>
|
||||||
|
|
||||||
#include "audioinvert.h"
|
#include "audioinvert.h"
|
||||||
|
@ -70,47 +72,33 @@ enum
|
||||||
PROP_DEGREE
|
PROP_DEGREE
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
#define ALLOWED_CAPS \
|
||||||
GST_PAD_SINK,
|
"audio/x-raw-int," \
|
||||||
GST_PAD_ALWAYS,
|
" depth=(int)16," \
|
||||||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
" width=(int)16," \
|
||||||
"rate = (int) [ 1, MAX ], "
|
" endianness=(int)BYTE_ORDER," \
|
||||||
"channels = (int) [ 1, MAX ], "
|
" signed=(bool)TRUE," \
|
||||||
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
|
" rate=(int)[1,MAX]," \
|
||||||
"audio/x-raw-int, "
|
" channels=(int)[1,MAX]; " \
|
||||||
"rate = (int) [ 1, MAX ], "
|
"audio/x-raw-float," \
|
||||||
"channels = (int) [ 1, MAX ], "
|
" width=(int)32," \
|
||||||
"endianness = (int) BYTE_ORDER, "
|
" endianness=(int)BYTE_ORDER," \
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
" rate=(int)[1,MAX]," \
|
||||||
);
|
" channels=(int)[1,MAX]"
|
||||||
|
|
||||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
|
||||||
"rate = (int) [ 1, MAX ], "
|
|
||||||
"channels = (int) [ 1, MAX], "
|
|
||||||
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
|
|
||||||
"audio/x-raw-int, "
|
|
||||||
"rate = (int) [ 1, MAX ], "
|
|
||||||
"channels = (int) [ 1, MAX ], "
|
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
|
||||||
);
|
|
||||||
|
|
||||||
#define DEBUG_INIT(bla) \
|
#define DEBUG_INIT(bla) \
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_audio_invert_debug, "audioinvert", 0, "audioinvert element");
|
GST_DEBUG_CATEGORY_INIT (gst_audio_invert_debug, "audioinvert", 0, "audioinvert element");
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstAudioInvert, gst_audio_invert, GstBaseTransform,
|
GST_BOILERPLATE_FULL (GstAudioInvert, gst_audio_invert, GstAudioFilter,
|
||||||
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
|
||||||
|
|
||||||
static void gst_audio_invert_set_property (GObject * object, guint prop_id,
|
static void gst_audio_invert_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_audio_invert_get_property (GObject * object, guint prop_id,
|
static void gst_audio_invert_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static gboolean gst_audio_invert_set_caps (GstBaseTransform * base,
|
static gboolean gst_audio_invert_setup (GstAudioFilter * filter,
|
||||||
GstCaps * incaps, GstCaps * outcaps);
|
GstRingBufferSpec * format);
|
||||||
static GstFlowReturn gst_audio_invert_transform_ip (GstBaseTransform * base,
|
static GstFlowReturn gst_audio_invert_transform_ip (GstBaseTransform * base,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
|
|
||||||
|
@ -125,12 +113,14 @@ static void
|
||||||
gst_audio_invert_base_init (gpointer klass)
|
gst_audio_invert_base_init (gpointer klass)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_template));
|
|
||||||
gst_element_class_set_details (element_class, &element_details);
|
gst_element_class_set_details (element_class, &element_details);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string (ALLOWED_CAPS);
|
||||||
|
gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
|
||||||
|
caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -147,8 +137,8 @@ gst_audio_invert_class_init (GstAudioInvertClass * klass)
|
||||||
"Degree of inversion", 0.0, 1.0,
|
"Degree of inversion", 0.0, 1.0,
|
||||||
0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
||||||
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
|
GST_AUDIO_FILTER_CLASS (klass)->setup =
|
||||||
GST_DEBUG_FUNCPTR (gst_audio_invert_set_caps);
|
GST_DEBUG_FUNCPTR (gst_audio_invert_setup);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
|
||||||
GST_DEBUG_FUNCPTR (gst_audio_invert_transform_ip);
|
GST_DEBUG_FUNCPTR (gst_audio_invert_transform_ip);
|
||||||
}
|
}
|
||||||
|
@ -195,41 +185,26 @@ gst_audio_invert_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GstBaseTransform vmethod implementations */
|
/* GstAudioFilter vmethod implementations */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audio_invert_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
gst_audio_invert_setup (GstAudioFilter * base, GstRingBufferSpec * format)
|
||||||
GstCaps * outcaps)
|
|
||||||
{
|
{
|
||||||
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
|
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
|
||||||
const GstStructure *structure;
|
gboolean ret = TRUE;
|
||||||
gboolean ret;
|
|
||||||
gint width;
|
|
||||||
const gchar *fmt;
|
|
||||||
|
|
||||||
/*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
|
if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
|
||||||
|
filter->process = (GstAudioInvertProcessFunc)
|
||||||
structure = gst_caps_get_structure (incaps, 0);
|
gst_audio_invert_transform_float;
|
||||||
|
else if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
|
||||||
ret = gst_structure_get_int (structure, "width", &width);
|
|
||||||
if (!ret)
|
|
||||||
goto no_width;
|
|
||||||
filter->width = width / 8;
|
|
||||||
|
|
||||||
|
|
||||||
fmt = gst_structure_get_name (structure);
|
|
||||||
if (!strcmp (fmt, "audio/x-raw-int"))
|
|
||||||
filter->process = (GstAudioInvertProcessFunc)
|
filter->process = (GstAudioInvertProcessFunc)
|
||||||
gst_audio_invert_transform_int;
|
gst_audio_invert_transform_int;
|
||||||
else
|
else
|
||||||
filter->process = (GstAudioInvertProcessFunc)
|
ret = FALSE;
|
||||||
gst_audio_invert_transform_float;
|
|
||||||
|
|
||||||
return TRUE;
|
filter->width = format->width / 8;
|
||||||
|
|
||||||
no_width:
|
return ret;
|
||||||
GST_DEBUG ("no width in caps");
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -260,9 +235,7 @@ gst_audio_invert_transform_float (GstAudioInvert * filter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GstBaseTransform vmethod implementations */
|
||||||
/* this function does the actual processing
|
|
||||||
*/
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,23 +24,24 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_AUDIO_INVERT (gst_audio_invert_get_type())
|
#define GST_TYPE_AUDIO_INVERT (gst_audio_invert_get_type())
|
||||||
#define GST_AUDIO_INVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_INVERT,GstAudioInvert))
|
#define GST_AUDIO_INVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_INVERT,GstAudioInvert))
|
||||||
#define GST_IS_AUDIO_INVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_INVERT))
|
#define GST_IS_AUDIO_INVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_INVERT))
|
||||||
#define GST_AUDIO_INVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AUDIO_INVERT,GstAudioInvertClass))
|
#define GST_AUDIO_INVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AUDIO_INVERT,GstAudioInvertClass))
|
||||||
#define GST_IS_AUDIO_INVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AUDIO_INVERT))
|
#define GST_IS_AUDIO_INVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AUDIO_INVERT))
|
||||||
#define GST_AUDIO_INVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AUDIO_INVERT,GstAudioInvertClass))
|
#define GST_AUDIO_INVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AUDIO_INVERT,GstAudioInvertClass))
|
||||||
|
|
||||||
typedef struct _GstAudioInvert GstAudioInvert;
|
typedef struct _GstAudioInvert GstAudioInvert;
|
||||||
typedef struct _GstAudioInvertClass GstAudioInvertClass;
|
typedef struct _GstAudioInvertClass GstAudioInvertClass;
|
||||||
|
|
||||||
typedef void (*GstAudioInvertProcessFunc) (GstAudioInvert *, guint8 *, guint);
|
typedef void (*GstAudioInvertProcessFunc) (GstAudioInvert *, guint8 *, guint);
|
||||||
|
|
||||||
struct _GstAudioInvert {
|
struct _GstAudioInvert
|
||||||
GstBaseTransform element;
|
{
|
||||||
|
GstAudioFilter audiofilter;
|
||||||
|
|
||||||
gfloat degree;
|
gfloat degree;
|
||||||
|
|
||||||
|
@ -49,12 +50,12 @@ struct _GstAudioInvert {
|
||||||
gint width;
|
gint width;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAudioInvertClass {
|
struct _GstAudioInvertClass
|
||||||
GstBaseTransformClass parent;
|
{
|
||||||
|
GstAudioFilterClass parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_audio_invert_get_type (void);
|
GType gst_audio_invert_get_type (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_AUDIO_INVERT_H__ */
|
#endif /* __GST_AUDIO_INVERT_H__ */
|
||||||
|
|
Loading…
Reference in a new issue