summaryrefslogtreecommitdiffstats
path: root/gst/audiofx/audioamplify.c
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-02-06 11:16:49 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-02-06 11:16:49 +0000
commitcdba2c4219705c69fffb7bc5c08bc1ffdd3a75b4 (patch)
tree7f78af050fcee5f41fec0cb8ec4872d0926fed97 /gst/audiofx/audioamplify.c
parentf7935f9a40fa99ef1cb40735688ccd1ad936702d (diff)
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
Diffstat (limited to 'gst/audiofx/audioamplify.c')
-rw-r--r--gst/audiofx/audioamplify.c110
1 files changed, 42 insertions, 68 deletions
diff --git a/gst/audiofx/audioamplify.c b/gst/audiofx/audioamplify.c
index 076aa431..e492c022 100644
--- a/gst/audiofx/audioamplify.c
+++ b/gst/audiofx/audioamplify.c
@@ -43,6 +43,8 @@
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
+#include <gst/audio/audio.h>
+#include <gst/audio/gstaudiofilter.h>
#include <gst/controller/gstcontroller.h>
#include "audioamplify.h"
@@ -100,47 +102,33 @@ gst_audio_amplify_clipping_method_get_type (void)
return gtype;
}
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- 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")
- );
-
-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 ALLOWED_CAPS \
+ "audio/x-raw-int," \
+ " depth=(int)16," \
+ " width=(int)16," \
+ " endianness=(int)BYTE_ORDER," \
+ " signed=(bool)TRUE," \
+ " rate=(int)[1,MAX]," \
+ " channels=(int)[1,MAX]; " \
+ "audio/x-raw-float," \
+ " width=(int)32," \
+ " endianness=(int)BYTE_ORDER," \
+ " rate=(int)[1,MAX]," \
+ " channels=(int)[1,MAX]"
#define DEBUG_INIT(bla) \
GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0, "audioamplify element");
-GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstBaseTransform,
- GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
+GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstAudioFilter,
+ GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
static void gst_audio_amplify_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_audio_amplify_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_audio_amplify_set_caps (GstBaseTransform * base,
- GstCaps * incaps, GstCaps * outcaps);
+static gboolean gst_audio_amplify_setup (GstAudioFilter * filter,
+ GstRingBufferSpec * format);
static GstFlowReturn gst_audio_amplify_transform_ip (GstBaseTransform * base,
GstBuffer * buf);
@@ -179,12 +167,14 @@ static void
gst_audio_amplify_base_init (gpointer 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);
+
+ 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
@@ -215,8 +205,8 @@ gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD, METHOD_CLIP,
G_PARAM_READWRITE));
- GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
- GST_DEBUG_FUNCPTR (gst_audio_amplify_set_caps);
+ GST_AUDIO_FILTER_CLASS (klass)->setup =
+ GST_DEBUG_FUNCPTR (gst_audio_amplify_setup);
GST_BASE_TRANSFORM_CLASS (klass)->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->clipping_method = METHOD_CLIP;
filter->width = 0;
- filter->format_float = FALSE;
+ filter->format_index = 0;
gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
}
static gboolean
gst_audio_amplify_set_process_function (GstAudioAmplify * filter)
{
- gint format_index, method_index;
+ gint method_index;
/* set processing function */
- format_index = (filter->format_float) ? 1 : 0;
-
method_index = filter->clipping_method;
if (method_index >= NUM_METHODS || method_index < 0)
method_index = METHOD_CLIP;
- filter->process = processing_functions[format_index][method_index];
+ filter->process = processing_functions[filter->format_index][method_index];
return TRUE;
}
@@ -289,43 +277,30 @@ gst_audio_amplify_get_property (GObject * object, guint prop_id,
}
}
-/* GstBaseTransform vmethod implementations */
-
+/* GstAudioFilter vmethod implementations */
static gboolean
-gst_audio_amplify_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps)
+gst_audio_amplify_setup (GstAudioFilter * base, GstRingBufferSpec * format)
{
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
- const GstStructure *structure;
gboolean ret;
- gint width;
- const gchar *fmt;
-
- /*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
- structure = gst_caps_get_structure (incaps, 0);
+ filter->width = format->width / 8;
- 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->format_float = FALSE;
+ if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
+ filter->format_index = 0;
+ else if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
+ filter->format_index = 1;
else
- filter->format_float = TRUE;
+ goto wrong_format;
- GST_DEBUG ("try to process %s input", fmt);
ret = gst_audio_amplify_set_process_function (filter);
if (!ret)
GST_WARNING ("can't process input");
- return TRUE;
+ return ret;
-no_width:
- GST_DEBUG ("no width in caps");
+wrong_format:
+ GST_DEBUG ("wrong format");
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
gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
{