Commit 77ad0a13 authored by Wim Taymans's avatar Wim Taymans

port more elements to new audio caps and API

parent 90f5b31b
......@@ -802,13 +802,9 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
if (param != NULL)
rate = atol (param);
src->src_caps = gst_caps_new_simple ("audio/x-raw-int",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, rate,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"signed", G_TYPE_BOOLEAN, TRUE,
"endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
src->src_caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S16_BE",
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
} else {
/* Set the Content-Type field on the caps */
if (src->src_caps)
......
......@@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include <gst/tag/tag.h>
#include <gst/audio/audio.h>
GST_DEBUG_CATEGORY_STATIC (speexdec_debug);
#define GST_CAT_DEFAULT speexdec_debug
......@@ -58,15 +59,15 @@ enum
ARG_ENH
};
#define FORMAT_STR GST_AUDIO_NE(S16)
static GstStaticPadTemplate speex_dec_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 6000, 48000 ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, " "width = (int) 16, " "depth = (int) 16")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMAT_STR ", "
"rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate speex_dec_sink_factory =
......@@ -597,12 +598,10 @@ speex_dec_chain_parse_header (GstSpeexDec * dec, GstBuffer * buf)
speex_bits_init (&dec->bits);
/* set caps */
caps = gst_caps_new_simple ("audio/x-raw-int",
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, FORMAT_STR,
"rate", G_TYPE_INT, dec->header->rate,
"channels", G_TYPE_INT, dec->header->nb_channels,
"signed", G_TYPE_BOOLEAN, TRUE,
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
"channels", G_TYPE_INT, dec->header->nb_channels, NULL);
if (!gst_pad_set_caps (dec->srcpad, caps))
goto nego_failed;
......
......@@ -52,14 +52,14 @@
GST_DEBUG_CATEGORY_STATIC (speexenc_debug);
#define GST_CAT_DEFAULT speexenc_debug
#define FORMAT_STR GST_AUDIO_NE(S16)
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 6000, 48000 ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMAT_STR ", "
"rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
......
......@@ -43,6 +43,14 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-au")
);
#define GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS \
"audio/x-raw, " \
"format= (string) { S8, S16_LE, S16_BE, S24_3LE, S24_3BE, " \
"S32_LE, S32_BE, F32_LE, F32_BE, " \
"F64_LE, F64_BE }, " \
"rate = (int) [ 8000, 192000 ], " \
"channels = (int) [ 1, 2 ]"
#define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
"audio/x-alaw, " \
"rate = (int) [ 8000, 192000 ], " \
......@@ -61,8 +69,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS ";"
GST_STATIC_CAPS (GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS "; "
GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS ";"
GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS ";"
GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS));
......@@ -180,7 +187,9 @@ gst_au_parse_parse_header (GstAuParse * auparse)
guint32 size;
guint8 *head;
gchar layout[7] = { 0, };
gint law = 0, depth = 0, ieee = 0;
GstAudioFormat format = GST_AUDIO_FORMAT_UNKNOWN;
gint law = 0;
guint endianness;
head = (guint8 *) gst_adapter_map (auparse->adapter, 24);
g_assert (head != NULL);
......@@ -190,14 +199,14 @@ gst_au_parse_parse_header (GstAuParse * auparse)
switch (GST_READ_UINT32_BE (head)) {
/* normal format is big endian (au is a Sparc format) */
case 0x2e736e64:{ /* ".snd" */
auparse->endianness = G_BIG_ENDIAN;
endianness = G_BIG_ENDIAN;
break;
}
/* and of course, someone had to invent a little endian
* version. Used by DEC systems. */
case 0x646e732e: /* dns. */
case 0x0064732e:{ /* other source say it is "dns." */
auparse->endianness = G_LITTLE_ENDIAN;
endianness = G_LITTLE_ENDIAN;
break;
}
default:{
......@@ -237,33 +246,50 @@ gst_au_parse_parse_header (GstAuParse * auparse)
switch (auparse->encoding) {
case 1: /* 8-bit ISDN mu-law G.711 */
law = 1;
depth = 8;
break;
case 27: /* 8-bit ISDN A-law G.711 */
law = 2;
depth = 8;
break;
case 2: /* 8-bit linear PCM */
depth = 8;
case 2: /* 8-bit linear PCM, FIXME signed? */
format = GST_AUDIO_FORMAT_S8;
auparse->sample_size = auparse->channels;
break;
case 3: /* 16-bit linear PCM */
depth = 16;
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S16_LE;
else
format = GST_AUDIO_FORMAT_S16_BE;
auparse->sample_size = auparse->channels * 2;
break;
case 4: /* 24-bit linear PCM */
depth = 24;
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S24_3LE;
else
format = GST_AUDIO_FORMAT_S24_3BE;
auparse->sample_size = auparse->channels * 3;
break;
case 5: /* 32-bit linear PCM */
depth = 32;
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S32_LE;
else
format = GST_AUDIO_FORMAT_S32_BE;
auparse->sample_size = auparse->channels * 4;
break;
case 6: /* 32-bit IEEE floating point */
ieee = 1;
depth = 32;
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_F32_LE;
else
format = GST_AUDIO_FORMAT_F32_BE;
auparse->sample_size = auparse->channels * 4;
break;
case 7: /* 64-bit IEEE floating point */
ieee = 1;
depth = 64;
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_F64_LE;
else
format = GST_AUDIO_FORMAT_F64_BE;
auparse->sample_size = auparse->channels * 8;
break;
case 23: /* 4-bit CCITT G.721 ADPCM 32kbps -> modplug/libsndfile (compressed 8-bit mu-law) */
......@@ -308,27 +334,17 @@ gst_au_parse_parse_header (GstAuParse * auparse)
"rate", G_TYPE_INT, auparse->samplerate,
"channels", G_TYPE_INT, auparse->channels, NULL);
auparse->sample_size = auparse->channels;
} else if (ieee) {
tempcaps = gst_caps_new_simple ("audio/x-raw-float",
} else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
tempcaps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
"rate", G_TYPE_INT, auparse->samplerate,
"channels", G_TYPE_INT, auparse->channels,
"endianness", G_TYPE_INT, auparse->endianness,
"width", G_TYPE_INT, depth, NULL);
auparse->sample_size = auparse->channels * depth / 8;
"channels", G_TYPE_INT, auparse->channels, NULL);
} else if (layout[0]) {
tempcaps = gst_caps_new_simple ("audio/x-adpcm",
"layout", G_TYPE_STRING, layout, NULL);
auparse->sample_size = 0;
} else {
tempcaps = gst_caps_new_simple ("audio/x-raw-int",
"rate", G_TYPE_INT, auparse->samplerate,
"channels", G_TYPE_INT, auparse->channels,
"endianness", G_TYPE_INT, auparse->endianness,
"depth", G_TYPE_INT, depth, "width", G_TYPE_INT, depth,
/* FIXME: signed TRUE even for 8-bit PCM? */
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
auparse->sample_size = auparse->channels * depth / 8;
}
} else
goto unknown_format;
GST_DEBUG_OBJECT (auparse, "sample_size=%d", auparse->sample_size);
......
......@@ -60,7 +60,6 @@ struct _GstAuParse {
guint sample_size;
guint encoding;
guint samplerate;
guint endianness;
guint channels;
};
......
......@@ -68,12 +68,9 @@ GST_DEBUG_CATEGORY_STATIC (cutter_debug);
static GstStaticPadTemplate cutter_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, " "signed = (boolean) true")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate cutter_sink_factory =
......@@ -81,11 +78,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, " "signed = (boolean) true")
"format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
enum
......@@ -363,6 +357,7 @@ gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
{
GstCaps *caps;
GstStructure *structure;
const gchar *format;
caps = gst_pad_get_current_caps (pad);
if (!caps) {
......@@ -370,8 +365,12 @@ gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
return FALSE;
}
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &filter->width);
filter->max_sample = 1 << (filter->width - 1); /* signed */
format = gst_structure_get_string (structure, "format");
if (g_str_has_prefix (format, "S16"))
filter->width = 16;
else
filter->width = 8;
filter->have_caps = TRUE;
gst_caps_unref (caps);
......
......@@ -43,22 +43,15 @@ static void gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
static void gst_iir_equalizer_finalize (GObject * object);
static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter,
GstRingBufferSpec * fmt);
GstAudioInfo * info);
static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
GstBuffer * buf);
#define ALLOWED_CAPS \
"audio/x-raw-int," \
" depth=(int)16," \
" width=(int)16," \
" endianness=(int)BYTE_ORDER," \
" signed=(bool)TRUE," \
" rate=(int)[1000,MAX]," \
" channels=(int)[1,MAX]; " \
"audio/x-raw-float," \
" width=(int) { 32, 64 } ," \
" endianness=(int)BYTE_ORDER," \
" rate=(int)[1000,MAX]," \
"audio/x-raw," \
" format=(string) {"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)"," \
GST_AUDIO_NE(F64)" }, " \
" rate=(int)[1000,MAX]," \
" channels=(int)[1,MAX]"
#define gst_iir_equalizer_parent_class parent_class
......@@ -465,15 +458,17 @@ calculate_bw (GstIirEqualizerBand * band, gint rate)
static void
setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
{
g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
gint rate = GST_AUDIO_FILTER_RATE (equ);
g_return_if_fail (rate);
{
gdouble gain, omega, bw;
gdouble alpha, alpha1, alpha2, b0;
gain = arg_to_scale (band->gain);
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
omega = calculate_omega (band->freq, rate);
bw = calculate_bw (band, rate);
if (bw == 0.0)
goto out;
......@@ -501,7 +496,9 @@ setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
static void
setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
{
g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
gint rate = GST_AUDIO_FILTER_RATE (equ);
g_return_if_fail (rate);
{
gdouble gain, omega, bw;
......@@ -509,8 +506,8 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
gdouble egp, egm;
gain = arg_to_scale (band->gain);
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
omega = calculate_omega (band->freq, rate);
bw = calculate_bw (band, rate);
if (bw == 0.0)
goto out;
......@@ -539,7 +536,9 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
static void
setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
{
g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
gint rate = GST_AUDIO_FILTER_RATE (equ);
g_return_if_fail (rate);
{
gdouble gain, omega, bw;
......@@ -547,8 +546,8 @@ setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
gdouble egp, egm;
gain = arg_to_scale (band->gain);
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
omega = calculate_omega (band->freq, rate);
bw = calculate_bw (band, rate);
if (bw == 0.0)
goto out;
......@@ -614,7 +613,7 @@ alloc_history (GstIirEqualizer * equ)
/* free + alloc = no memcpy */
g_free (equ->history);
equ->history =
g_malloc0 (equ->history_size * GST_AUDIO_FILTER (equ)->format.channels *
g_malloc0 (equ->history_size * GST_AUDIO_FILTER_CHANNELS (equ) *
equ->freq_band_count);
}
......@@ -819,8 +818,9 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
GstClockTime timestamp;
guint8 *data;
gsize size;
gint channels = GST_AUDIO_FILTER_CHANNELS (filter);
if (G_UNLIKELY (filter->format.channels < 1 || equ->process == NULL))
if (G_UNLIKELY (channels < 1 || equ->process == NULL))
return GST_FLOW_NOT_NEGOTIATED;
BANDS_LOCK (equ);
......@@ -841,41 +841,29 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
gst_object_sync_values (G_OBJECT (equ), timestamp);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
equ->process (equ, data, size, filter->format.channels);
equ->process (equ, data, size, channels);
gst_buffer_unmap (buf, data, size);
return GST_FLOW_OK;
}
static gboolean
gst_iir_equalizer_setup (GstAudioFilter * audio, GstRingBufferSpec * fmt)
gst_iir_equalizer_setup (GstAudioFilter * audio, GstAudioInfo * info)
{
GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio);
switch (fmt->type) {
case GST_BUFTYPE_LINEAR:
switch (fmt->width) {
case 16:
equ->history_size = history_size_gint16;
equ->process = gst_iir_equ_process_gint16;
break;
default:
return FALSE;
}
switch (GST_AUDIO_INFO_FORMAT (info)) {
case GST_AUDIO_FORMAT_S16:
equ->history_size = history_size_gint16;
equ->process = gst_iir_equ_process_gint16;
break;
case GST_BUFTYPE_FLOAT:
switch (fmt->width) {
case 32:
equ->history_size = history_size_gfloat;
equ->process = gst_iir_equ_process_gfloat;
break;
case 64:
equ->history_size = history_size_gdouble;
equ->process = gst_iir_equ_process_gdouble;
break;
default:
return FALSE;
}
case GST_AUDIO_FORMAT_F32:
equ->history_size = history_size_gfloat;
equ->process = gst_iir_equ_process_gfloat;
break;
case GST_AUDIO_FORMAT_F64:
equ->history_size = history_size_gdouble;
equ->process = gst_iir_equ_process_gdouble;
break;
default:
return FALSE;
......
......@@ -117,37 +117,23 @@ GST_DEBUG_CATEGORY_STATIC (level_debug);
#define EPSILON 1e-35f
static GstStaticPadTemplate sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16, 32 }, "
"depth = (int) { 8, 16, 32 }, "
"signed = (boolean) true; "
"audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, " "width = (int) {32, 64} ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) { 8, 16, 32 }, "
"depth = (int) { 8, 16, 32 }, "
"signed = (boolean) true; "
"audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, MAX ], "
"endianness = (int) BYTE_ORDER, " "width = (int) {32, 64} ")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
enum
......@@ -228,9 +214,7 @@ gst_level_init (GstLevel * filter)
filter->CS = NULL;
filter->peak = NULL;
filter->rate = 0;
filter->width = 0;
filter->channels = 0;
gst_audio_info_init (&filter->info);
filter->interval = GST_SECOND / 10;
filter->decay_peak_ttl = GST_SECOND / 10 * 3;
......@@ -277,9 +261,10 @@ gst_level_set_property (GObject * object, guint prop_id,
break;
case PROP_SIGNAL_INTERVAL:
filter->interval = g_value_get_uint64 (value);
if (filter->rate) {
if (GST_AUDIO_INFO_RATE (&filter->info)) {
filter->interval_frames =
GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate);
GST_CLOCK_TIME_TO_FRAMES (filter->interval,
GST_AUDIO_INFO_RATE (&filter->info));
}
break;
case PROP_PEAK_TTL:
......@@ -410,58 +395,42 @@ gst_level_calculate_gdouble (gpointer data, guint num, guint channels,
*/
static gint
structure_get_int (GstStructure * structure, const gchar * field)
{
gint ret;
if (!gst_structure_get_int (structure, field, &ret))
g_assert_not_reached ();
return ret;
}
static gboolean
gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
{
GstLevel *filter = GST_LEVEL (trans);
const gchar *mimetype;
GstStructure *structure;
gint i;
GstAudioInfo info;
gint i, channels, rate;
structure = gst_caps_get_structure (in, 0);
filter->rate = structure_get_int (structure, "rate");
filter->width = structure_get_int (structure, "width");
filter->channels = structure_get_int (structure, "channels");
mimetype = gst_structure_get_name (structure);
if (!gst_audio_info_from_caps (&info, in))
return FALSE;
/* FIXME: set calculator func depending on caps */
filter->process = NULL;
if (strcmp (mimetype, "audio/x-raw-int") == 0) {
GST_DEBUG_OBJECT (filter, "use int: %u", filter->width);
switch (filter->width) {
case 8:
filter->process = gst_level_calculate_gint8;
break;
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);
switch (filter->width) {
case 32:
filter->process = gst_level_calculate_gfloat;
break;
case 64:
filter->process = gst_level_calculate_gdouble;
break;
}
switch (GST_AUDIO_INFO_FORMAT (&info)) {
case GST_AUDIO_FORMAT_S8:
filter->process = gst_level_calculate_gint8;
break;
case GST_AUDIO_FORMAT_S16:
filter->process = gst_level_calculate_gint16;
break;
case GST_AUDIO_FORMAT_S32:
filter->process = gst_level_calculate_gint32;
break;
case GST_AUDIO_FORMAT_F32:
filter->process = gst_level_calculate_gfloat;
break;
case GST_AUDIO_FORMAT_F64:
filter->process = gst_level_calculate_gdouble;
break;
default:
filter->process = NULL;
break;
}
filter->info = info;
channels = GST_AUDIO_INFO_CHANNELS (&info);
rate = GST_AUDIO_INFO_RATE (&info);
/* allocate channel variable arrays */
g_free (filter->CS);
g_free (filter->peak);
......@@ -469,22 +438,21 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
g_free (filter->decay_peak);
g_free (filter->decay_peak_base);
g_free (filter->decay_peak_age);
filter->CS = g_new (gdouble, filter->channels);
filter->peak = g_new (gdouble, filter->channels);
filter->last_peak = g_new (gdouble, filter->channels);
filter->decay_peak = g_new (gdouble, filter->channels);
filter->decay_peak_base = g_new (gdouble, filter->channels);
filter->CS = g_new (gdouble, channels);
filter->peak = g_new (gdouble, channels);
filter->last_peak = g_new (gdouble, channels);
filter->decay_peak = g_new (gdouble, channels);
filter->decay_peak_base = g_new (gdouble, channels);
filter->decay_peak_age = g_new (GstClockTime, filter->channels);
filter->decay_peak_age = g_new (GstClockTime, channels);
for (i = 0; i < filter->channels; ++i) {
for (i = 0; i < channels; ++i) {
filter->CS[i] = filter->peak[i] = filter->last_peak[i] =
filter->decay_peak[i] = filter->decay_peak_base[i] = 0.0;
filter->decay_peak_age[i] = G_GUINT64_CONSTANT (0);
}
filter->interval_frames =
GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate);
filter->interval_frames = GST_CLOCK_TIME_TO_FRAMES (filter->interval, rate);