From a0369011e70816aabf1f9934b31805da1f01b12c Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Thu, 8 May 2008 10:20:52 +0000 Subject: gst/level/gstlevel.c: Also support 32bit (e.g. whe having it after 'mad'). Add more notes about whats needed for libo... Original commit message from CVS: * gst/level/gstlevel.c: Also support 32bit (e.g. whe having it after 'mad'). Add more notes about whats needed for liboil acceleration. Simplify docs a bit. --- gst/level/gstlevel.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'gst/level') diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c index 86cbd5a1..3b14cdcc 100644 --- a/gst/level/gstlevel.c +++ b/gst/level/gstlevel.c @@ -21,15 +21,14 @@ /** * SECTION:element-level + * @short_description: audio level analyzer * * * - * Level analyses incoming audio buffers and, if the - * message property is #TRUE, - * generates an element message named + * Level analyses incoming audio buffers and, if the #GstLevel:message property + * is #TRUE, generates an element message named * "level": - * after each interval of time given by the - * interval property. + * after each interval of time given by the #GstLevel:interval property. * The message's structure contains four fields: * * @@ -82,6 +81,8 @@ #include #include #include +/*#include */ + #include "gstlevel.h" GST_DEBUG_CATEGORY_STATIC (level_debug); @@ -100,8 +101,8 @@ static GstStaticPadTemplate sink_template_factory = "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ], " "endianness = (int) BYTE_ORDER, " - "width = (int) { 8, 16 }, " - "depth = (int) { 8, 16 }, " + "width = (int) { 8, 16, 32 }, " + "depth = (int) { 8, 16, 32 }, " "signed = (boolean) true; " "audio/x-raw-float, " "rate = (int) [ 1, MAX ], " @@ -117,8 +118,8 @@ static GstStaticPadTemplate src_template_factory = "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ], " "endianness = (int) BYTE_ORDER, " - "width = (int) { 8, 16 }, " - "depth = (int) { 8, 16 }, " + "width = (int) { 8, 16, 32 }, " + "depth = (int) { 8, 16, 32 }, " "signed = (boolean) true; " "audio/x-raw-float, " "rate = (int) [ 1, MAX ], " @@ -310,7 +311,7 @@ gst_level_get_property (GObject * object, guint prop_id, */ #define DEFINE_INT_LEVEL_CALCULATOR(TYPE, RESOLUTION) \ -static void inline \ +static void inline \ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \ gdouble *NCS, gdouble *NPS) \ { \ @@ -324,9 +325,9 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \ /* *NCS = 0.0; Normalized Cumulative Square */ \ /* *NPS = 0.0; Normalized Peask Square */ \ \ - normalizer = (gdouble) (1 << (RESOLUTION * 2)); \ + normalizer = (gdouble) (G_GINT64_CONSTANT(1) << (RESOLUTION * 2)); \ \ - /* oil_squaresum_f64(&squaresum,in,num); */ \ + /* oil_squaresum_shifted_s16(&squaresum,in,num); */ \ for (j = 0; j < num; j += channels) \ { \ square = ((gdouble) in[j]) * in[j]; \ @@ -338,6 +339,7 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \ *NPS = peaksquare / normalizer; \ } +DEFINE_INT_LEVEL_CALCULATOR (gint32, 31); DEFINE_INT_LEVEL_CALCULATOR (gint16, 15); DEFINE_INT_LEVEL_CALCULATOR (gint8, 7); @@ -370,6 +372,17 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \ DEFINE_FLOAT_LEVEL_CALCULATOR (gfloat); DEFINE_FLOAT_LEVEL_CALCULATOR (gdouble); +/* we would need stride to deinterleave also +static void inline +gst_level_calculate_gdouble (gpointer data, guint num, guint channels, + gdouble *NCS, gdouble *NPS) +{ + oil_squaresum_f64(NCS,(gdouble *)data,num); + *NPS = 0.0; +} +*/ + + static gint structure_get_int (GstStructure * structure, const gchar * field) { @@ -406,6 +419,9 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) case 16: filter->process = gst_level_calculate_gint16; break; + case 32: + filter->process = gst_level_calculate_gint32; + break; } } else if (strcmp (mimetype, "audio/x-raw-float") == 0) { GST_DEBUG_OBJECT (filter, "use float, %u", filter->width); @@ -649,6 +665,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in) static gboolean plugin_init (GstPlugin * plugin) { + /*oil_init (); */ + return gst_element_register (plugin, "level", GST_RANK_NONE, GST_TYPE_LEVEL); } -- cgit