mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-12 11:26:39 +00:00
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.
This commit is contained in:
parent
1d00afde97
commit
a0369011e7
2 changed files with 36 additions and 12 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2008-05-08 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2008-05-08 Sebastian Dröge <slomo@circular-chaos.org>
|
2008-05-08 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
Patch by: Sjoerd Simons <sjoerd at luon dot net>
|
Patch by: Sjoerd Simons <sjoerd at luon dot net>
|
||||||
|
|
|
@ -21,15 +21,14 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:element-level
|
* SECTION:element-level
|
||||||
|
* @short_description: audio level analyzer
|
||||||
*
|
*
|
||||||
* <refsect2>
|
* <refsect2>
|
||||||
* <para>
|
* <para>
|
||||||
* Level analyses incoming audio buffers and, if the
|
* Level analyses incoming audio buffers and, if the #GstLevel:message property
|
||||||
* <link linkend="GstLevel--message">message property</link> is #TRUE,
|
* is #TRUE, generates an element message named
|
||||||
* generates an element message named
|
|
||||||
* <classname>"level"</classname>:
|
* <classname>"level"</classname>:
|
||||||
* after each interval of time given by the
|
* after each interval of time given by the #GstLevel:interval property.
|
||||||
* <link linkend="GstLevel--interval">interval property</link>.
|
|
||||||
* The message's structure contains four fields:
|
* The message's structure contains four fields:
|
||||||
* <itemizedlist>
|
* <itemizedlist>
|
||||||
* <listitem>
|
* <listitem>
|
||||||
|
@ -82,6 +81,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
|
/*#include <liboil/liboil.h>*/
|
||||||
|
|
||||||
#include "gstlevel.h"
|
#include "gstlevel.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (level_debug);
|
GST_DEBUG_CATEGORY_STATIC (level_debug);
|
||||||
|
@ -100,8 +101,8 @@ static GstStaticPadTemplate sink_template_factory =
|
||||||
"rate = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], "
|
||||||
"channels = (int) [ 1, MAX ], "
|
"channels = (int) [ 1, MAX ], "
|
||||||
"endianness = (int) BYTE_ORDER, "
|
"endianness = (int) BYTE_ORDER, "
|
||||||
"width = (int) { 8, 16 }, "
|
"width = (int) { 8, 16, 32 }, "
|
||||||
"depth = (int) { 8, 16 }, "
|
"depth = (int) { 8, 16, 32 }, "
|
||||||
"signed = (boolean) true; "
|
"signed = (boolean) true; "
|
||||||
"audio/x-raw-float, "
|
"audio/x-raw-float, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], "
|
||||||
|
@ -117,8 +118,8 @@ static GstStaticPadTemplate src_template_factory =
|
||||||
"rate = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], "
|
||||||
"channels = (int) [ 1, MAX ], "
|
"channels = (int) [ 1, MAX ], "
|
||||||
"endianness = (int) BYTE_ORDER, "
|
"endianness = (int) BYTE_ORDER, "
|
||||||
"width = (int) { 8, 16 }, "
|
"width = (int) { 8, 16, 32 }, "
|
||||||
"depth = (int) { 8, 16 }, "
|
"depth = (int) { 8, 16, 32 }, "
|
||||||
"signed = (boolean) true; "
|
"signed = (boolean) true; "
|
||||||
"audio/x-raw-float, "
|
"audio/x-raw-float, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], "
|
||||||
|
@ -324,9 +325,9 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \
|
||||||
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
||||||
/* *NPS = 0.0; Normalized Peask 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) \
|
for (j = 0; j < num; j += channels) \
|
||||||
{ \
|
{ \
|
||||||
square = ((gdouble) in[j]) * in[j]; \
|
square = ((gdouble) in[j]) * in[j]; \
|
||||||
|
@ -338,6 +339,7 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \
|
||||||
*NPS = peaksquare / normalizer; \
|
*NPS = peaksquare / normalizer; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_INT_LEVEL_CALCULATOR (gint32, 31);
|
||||||
DEFINE_INT_LEVEL_CALCULATOR (gint16, 15);
|
DEFINE_INT_LEVEL_CALCULATOR (gint16, 15);
|
||||||
DEFINE_INT_LEVEL_CALCULATOR (gint8, 7);
|
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 (gfloat);
|
||||||
DEFINE_FLOAT_LEVEL_CALCULATOR (gdouble);
|
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
|
static gint
|
||||||
structure_get_int (GstStructure * structure, const gchar * field)
|
structure_get_int (GstStructure * structure, const gchar * field)
|
||||||
{
|
{
|
||||||
|
@ -406,6 +419,9 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
||||||
case 16:
|
case 16:
|
||||||
filter->process = gst_level_calculate_gint16;
|
filter->process = gst_level_calculate_gint16;
|
||||||
break;
|
break;
|
||||||
|
case 32:
|
||||||
|
filter->process = gst_level_calculate_gint32;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
|
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
|
||||||
GST_DEBUG_OBJECT (filter, "use float, %u", filter->width);
|
GST_DEBUG_OBJECT (filter, "use float, %u", filter->width);
|
||||||
|
@ -649,6 +665,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
/*oil_init (); */
|
||||||
|
|
||||||
return gst_element_register (plugin, "level", GST_RANK_NONE, GST_TYPE_LEVEL);
|
return gst_element_register (plugin, "level", GST_RANK_NONE, GST_TYPE_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue