mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
port more elements to new audio caps and API
This commit is contained in:
parent
90f5b31b4b
commit
77ad0a1363
22 changed files with 270 additions and 502 deletions
|
@ -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);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -572,35 +540,38 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
|||
guint num_int_samples = 0; /* number of interleaved samples
|
||||
* ie. total count for all channels combined */
|
||||
GstClockTimeDiff falloff_time;
|
||||
gint channels, rate, bps;
|
||||
|
||||
filter = GST_LEVEL (trans);
|
||||
|
||||
channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
|
||||
bps = GST_AUDIO_INFO_BPS (&filter->info);
|
||||
rate = GST_AUDIO_INFO_RATE (&filter->info);
|
||||
|
||||
in_data = data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
|
||||
num_int_samples = in_size / (filter->width / 8);
|
||||
num_int_samples = in_size / bps;
|
||||
|
||||
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
||||
num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
|
||||
|
||||
g_return_val_if_fail (num_int_samples % filter->channels == 0,
|
||||
GST_FLOW_ERROR);
|
||||
g_return_val_if_fail (num_int_samples % channels == 0, GST_FLOW_ERROR);
|
||||
|
||||
num_frames = num_int_samples / filter->channels;
|
||||
num_frames = num_int_samples / channels;
|
||||
|
||||
for (i = 0; i < filter->channels; ++i) {
|
||||
for (i = 0; i < channels; ++i) {
|
||||
if (!GST_BUFFER_FLAG_IS_SET (in, GST_BUFFER_FLAG_GAP)) {
|
||||
filter->process (in_data, num_int_samples, filter->channels, &CS,
|
||||
filter->process (in_data, num_int_samples, channels, &CS,
|
||||
&filter->peak[i]);
|
||||
GST_LOG_OBJECT (filter,
|
||||
"channel %d, cumulative sum %f, peak %f, over %d samples/%d channels",
|
||||
i, CS, filter->peak[i], num_int_samples, filter->channels);
|
||||
i, CS, filter->peak[i], num_int_samples, channels);
|
||||
filter->CS[i] += CS;
|
||||
} else {
|
||||
filter->peak[i] = 0.0;
|
||||
}
|
||||
in_data += (filter->width / 8);
|
||||
in_data += bps;
|
||||
|
||||
filter->decay_peak_age[i] +=
|
||||
GST_FRAMES_TO_CLOCK_TIME (num_frames, filter->rate);
|
||||
filter->decay_peak_age[i] += GST_FRAMES_TO_CLOCK_TIME (num_frames, rate);
|
||||
GST_LOG_OBJECT (filter, "filter peak info [%d]: decay peak %f, age %"
|
||||
GST_TIME_FORMAT, i,
|
||||
filter->decay_peak[i], GST_TIME_ARGS (filter->decay_peak_age[i]));
|
||||
|
@ -656,7 +627,7 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
|||
if (filter->message) {
|
||||
GstMessage *m;
|
||||
GstClockTime duration =
|
||||
GST_FRAMES_TO_CLOCK_TIME (filter->num_frames, filter->rate);
|
||||
GST_FRAMES_TO_CLOCK_TIME (filter->num_frames, rate);
|
||||
|
||||
m = gst_level_message_new (filter, filter->message_ts, duration);
|
||||
|
||||
|
@ -664,7 +635,7 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
|||
"message: ts %" GST_TIME_FORMAT ", num_frames %d",
|
||||
GST_TIME_ARGS (filter->message_ts), filter->num_frames);
|
||||
|
||||
for (i = 0; i < filter->channels; ++i) {
|
||||
for (i = 0; i < channels; ++i) {
|
||||
gdouble RMS;
|
||||
gdouble RMSdB, lastdB, decaydB;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstbasetransform.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -59,9 +59,7 @@ struct _GstLevel {
|
|||
gboolean message; /* whether or not to post messages */
|
||||
guint64 interval; /* how many seconds between emits */
|
||||
|
||||
gint rate; /* caps variables */
|
||||
gint width;
|
||||
gint channels;
|
||||
GstAudioInfo info;
|
||||
|
||||
gdouble decay_peak_ttl; /* time to live for peak in seconds */
|
||||
gdouble decay_peak_falloff; /* falloff in dB/sec */
|
||||
|
@ -79,7 +77,7 @@ struct _GstLevel {
|
|||
gdouble *MS; /* normalized Mean Square of buffer */
|
||||
gdouble *RMS_dB; /* RMS in dB to emit */
|
||||
GstClockTime *decay_peak_age; /* age of last peak */
|
||||
|
||||
|
||||
void (*process)(gpointer, guint, guint, gdouble*, gdouble*);
|
||||
};
|
||||
|
||||
|
|
|
@ -37,11 +37,8 @@ static GstStaticPadTemplate gst_rtp_L16_depay_src_template =
|
|||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"endianness = (int) BIG_ENDIAN, "
|
||||
"signed = (boolean) true, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) S16_BE, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||
);
|
||||
|
||||
|
@ -177,11 +174,8 @@ gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
|||
rtpL16depay->rate = clock_rate;
|
||||
rtpL16depay->channels = channels;
|
||||
|
||||
srccaps = gst_caps_new_simple ("audio/x-raw-int",
|
||||
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
|
||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||
"width", G_TYPE_INT, 16,
|
||||
"depth", G_TYPE_INT, 16,
|
||||
srccaps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, "S16_BE",
|
||||
"rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
|
||||
|
||||
/* add channel positions */
|
||||
|
|
|
@ -37,11 +37,8 @@ static GstStaticPadTemplate gst_rtp_L16_pay_sink_template =
|
|||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"endianness = (int) BIG_ENDIAN, "
|
||||
"signed = (boolean) true, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) S16_BE, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||
);
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug);
|
|||
#define GST_CAT_DEFAULT (rtpvrawdepay_debug)
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb; video/x-raw-yuv")
|
||||
GST_STATIC_CAPS ("video/x-raw")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_vraw_depay_sink_template =
|
||||
|
|
|
@ -110,37 +110,17 @@ GST_DEBUG_CATEGORY_STATIC (gst_spectrum_debug);
|
|||
#define GST_CAT_DEFAULT gst_spectrum_debug
|
||||
|
||||
/* elementfactory information */
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
# define FORMATS "{ S16_LE, S24_3LE, S32_LE, F32_LE, F64_LE }"
|
||||
#else
|
||||
# define FORMATS "{ S16_BE, S24_3BE, S32_BE, F32_BE, F64_BE }"
|
||||
#endif
|
||||
|
||||
#define ALLOWED_CAPS \
|
||||
"audio/x-raw-int, " \
|
||||
" width = (int) 16, " \
|
||||
" depth = (int) [ 1, 16 ], " \
|
||||
" signed = (boolean) true, " \
|
||||
" endianness = (int) BYTE_ORDER, " \
|
||||
" rate = (int) [ 1, MAX ], " \
|
||||
" channels = (int) [ 1, MAX ]; " \
|
||||
"audio/x-raw-int, " \
|
||||
" width = (int) 24, " \
|
||||
" depth = (int) [ 1, 24 ], " \
|
||||
" signed = (boolean) true, " \
|
||||
" endianness = (int) BYTE_ORDER, " \
|
||||
" rate = (int) [ 1, MAX ], " \
|
||||
" channels = (int) [ 1, MAX ]; " \
|
||||
"audio/x-raw-int, " \
|
||||
" width = (int) 32, " \
|
||||
" depth = (int) [ 1, 32 ], " \
|
||||
" signed = (boolean) true, " \
|
||||
" endianness = (int) BYTE_ORDER, " \
|
||||
" rate = (int) [ 1, MAX ], " \
|
||||
" channels = (int) [ 1, MAX ]; " \
|
||||
"audio/x-raw-float, " \
|
||||
" width = (int) { 32, 64 }, " \
|
||||
" endianness = (int) BYTE_ORDER, " \
|
||||
" rate = (int) [ 1, MAX ], " \
|
||||
" channels = (int) [ 1, MAX ]"
|
||||
GST_AUDIO_CAPS_MAKE (FORMATS)
|
||||
|
||||
/* Spectrum properties */
|
||||
#define DEFAULT_POST_MESSAGES TRUE
|
||||
#define DEFAULT_POST_MESSAGES TRUE
|
||||
#define DEFAULT_MESSAGE_MAGNITUDE TRUE
|
||||
#define DEFAULT_MESSAGE_PHASE FALSE
|
||||
#define DEFAULT_INTERVAL (GST_SECOND / 10)
|
||||
|
@ -172,8 +152,7 @@ static gboolean gst_spectrum_start (GstBaseTransform * trans);
|
|||
static gboolean gst_spectrum_stop (GstBaseTransform * trans);
|
||||
static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
|
||||
GstBuffer * in);
|
||||
static gboolean gst_spectrum_setup (GstAudioFilter * base,
|
||||
GstRingBufferSpec * format);
|
||||
static gboolean gst_spectrum_setup (GstAudioFilter * base, GstAudioInfo * info);
|
||||
|
||||
static void
|
||||
gst_spectrum_class_init (GstSpectrumClass * klass)
|
||||
|
@ -287,7 +266,7 @@ gst_spectrum_alloc_channel_data (GstSpectrum * spectrum)
|
|||
g_assert (spectrum->channel_data == NULL);
|
||||
|
||||
spectrum->num_channels = (spectrum->multi_channel) ?
|
||||
GST_AUDIO_FILTER (spectrum)->format.channels : 1;
|
||||
GST_AUDIO_FILTER_CHANNELS (spectrum) : 1;
|
||||
|
||||
GST_DEBUG_OBJECT (spectrum, "allocating data for %d channels",
|
||||
spectrum->num_channels);
|
||||
|
@ -502,23 +481,6 @@ input_data_mixed_double (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int32 (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint i, j, ip = 0;
|
||||
gint32 *in = (gint32 *) _in;
|
||||
gfloat v;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
v = in[ip++] * 2 + 1;
|
||||
for (i = 1; i < channels; i++)
|
||||
v += in[ip++] * 2 + 1;
|
||||
out[op] = v / channels;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -536,30 +498,6 @@ input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int24 (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint i, j;
|
||||
gfloat v = 0.0;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
for (i = 0; i < channels; i++) {
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
gint32 value = GST_READ_UINT24_BE (_in);
|
||||
#else
|
||||
gint32 value = GST_READ_UINT24_LE (_in);
|
||||
#endif
|
||||
if (value & 0x00800000)
|
||||
value |= 0xff000000;
|
||||
v += value * 2 + 1;
|
||||
_in += 3;
|
||||
}
|
||||
out[op] = v / channels;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -584,23 +522,6 @@ input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int16 (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint i, j, ip = 0;
|
||||
gint16 *in = (gint16 *) _in;
|
||||
gfloat v;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
v = in[ip++] * 2 + 1;
|
||||
for (i = 1; i < channels; i++)
|
||||
v += in[ip++] * 2 + 1;
|
||||
out[op] = v / channels;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_mixed_int16_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -646,19 +567,6 @@ input_data_double (const guint8 * _in, gfloat * out, guint len, guint channels,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int32 (const guint8 * _in, gfloat * out, guint len, guint channels,
|
||||
gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint j, ip;
|
||||
gint32 *in = (gint32 *) _in;
|
||||
|
||||
for (j = 0, ip = 0; j < len; j++, ip += channels) {
|
||||
out[op] = in[ip] * 2 + 1;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -672,26 +580,6 @@ input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int24 (const guint8 * _in, gfloat * out, guint len, guint channels,
|
||||
gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint j;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
gint32 v = GST_READ_UINT24_BE (_in);
|
||||
#else
|
||||
gint32 v = GST_READ_UINT24_LE (_in);
|
||||
#endif
|
||||
if (v & 0x00800000)
|
||||
v |= 0xff000000;
|
||||
_in += 3 * channels;
|
||||
out[op] = v * 2 + 1;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -712,19 +600,6 @@ input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int16 (const guint8 * _in, gfloat * out, guint len, guint channels,
|
||||
gfloat max_value, guint op, guint nfft)
|
||||
{
|
||||
guint j, ip;
|
||||
gint16 *in = (gint16 *) _in;
|
||||
|
||||
for (j = 0, ip = 0; j < len; j++, ip += channels) {
|
||||
out[op] = in[ip] * 2 + 1;
|
||||
op = (op + 1) % nfft;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
|
||||
guint channels, gfloat max_value, guint op, guint nfft)
|
||||
|
@ -739,54 +614,39 @@ input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_spectrum_setup (GstAudioFilter * base, GstRingBufferSpec * format)
|
||||
gst_spectrum_setup (GstAudioFilter * base, GstAudioInfo * info)
|
||||
{
|
||||
GstSpectrum *spectrum = GST_SPECTRUM (base);
|
||||
guint width = format->width / 8;
|
||||
gboolean is_float = (format->type == GST_BUFTYPE_FLOAT);
|
||||
/* max_value will be 0 when depth is 1,
|
||||
* interpret -1 and 0 as -1 and +1 if that's the case. */
|
||||
guint max_value = (1UL << (format->depth - 1)) - 1;
|
||||
gboolean multi_channel = spectrum->multi_channel;
|
||||
GstSpectrumInputData input_data = NULL;
|
||||
|
||||
if (is_float) {
|
||||
if (width == 4) {
|
||||
switch (GST_AUDIO_INFO_FORMAT (info)) {
|
||||
case GST_AUDIO_FORMAT_S16:
|
||||
input_data =
|
||||
multi_channel ? input_data_int16_max : input_data_mixed_int16_max;
|
||||
break;
|
||||
case GST_AUDIO_FORMAT_S24_3:
|
||||
input_data =
|
||||
multi_channel ? input_data_int24_max : input_data_mixed_int24_max;
|
||||
break;
|
||||
case GST_AUDIO_FORMAT_S32:
|
||||
input_data =
|
||||
multi_channel ? input_data_int32_max : input_data_mixed_int32_max;
|
||||
break;
|
||||
case GST_AUDIO_FORMAT_F32:
|
||||
input_data = multi_channel ? input_data_float : input_data_mixed_float;
|
||||
} else if (width == 8) {
|
||||
break;
|
||||
case GST_AUDIO_FORMAT_F64:
|
||||
input_data = multi_channel ? input_data_double : input_data_mixed_double;
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
} else {
|
||||
if (width == 4) {
|
||||
if (max_value) {
|
||||
input_data =
|
||||
multi_channel ? input_data_int32_max : input_data_mixed_int32_max;
|
||||
} else {
|
||||
input_data = multi_channel ? input_data_int32 : input_data_mixed_int32;
|
||||
}
|
||||
} else if (width == 3) {
|
||||
if (max_value) {
|
||||
input_data =
|
||||
multi_channel ? input_data_int24_max : input_data_mixed_int24_max;
|
||||
} else {
|
||||
input_data = multi_channel ? input_data_int24 : input_data_mixed_int24;
|
||||
}
|
||||
} else if (width == 2) {
|
||||
if (max_value) {
|
||||
input_data =
|
||||
multi_channel ? input_data_int16_max : input_data_mixed_int16_max;
|
||||
} else {
|
||||
input_data = multi_channel ? input_data_int16 : input_data_mixed_int16;
|
||||
}
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
spectrum->input_data = input_data;
|
||||
|
||||
gst_spectrum_reset_state (spectrum);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -878,7 +738,7 @@ gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime timestamp,
|
|||
}
|
||||
} else {
|
||||
guint c;
|
||||
guint channels = GST_AUDIO_FILTER (spectrum)->format.channels;
|
||||
guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
|
||||
|
||||
if (spectrum->message_magnitude) {
|
||||
mcv = gst_spectrum_message_add_container (s, GST_TYPE_ARRAY, "magnitude");
|
||||
|
@ -984,20 +844,19 @@ static GstFlowReturn
|
|||
gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||
{
|
||||
GstSpectrum *spectrum = GST_SPECTRUM (trans);
|
||||
GstRingBufferSpec *format = &GST_AUDIO_FILTER (spectrum)->format;
|
||||
guint rate = format->rate;
|
||||
guint channels = format->channels;
|
||||
guint rate = GST_AUDIO_FILTER_RATE (spectrum);
|
||||
guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
|
||||
guint bps = GST_AUDIO_FILTER_BPS (spectrum);
|
||||
guint bpf = GST_AUDIO_FILTER_BPF (spectrum);
|
||||
guint output_channels = spectrum->multi_channel ? channels : 1;
|
||||
guint c;
|
||||
guint width = format->width / 8;
|
||||
gfloat max_value = (1UL << (format->depth - 1)) - 1;
|
||||
gfloat max_value = (1UL << ((bps << 3) - 1)) - 1;
|
||||
guint bands = spectrum->bands;
|
||||
guint nfft = 2 * bands - 2;
|
||||
guint input_pos;
|
||||
gfloat *input;
|
||||
const guint8 *data, *mdata;
|
||||
gsize size;
|
||||
guint frame_size = width * channels;
|
||||
guint fft_todo, msg_todo, block_size;
|
||||
gboolean have_full_interval;
|
||||
GstSpectrumChannel *cd;
|
||||
|
@ -1047,16 +906,16 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
input_pos = spectrum->input_pos;
|
||||
input_data = spectrum->input_data;
|
||||
|
||||
while (size >= frame_size) {
|
||||
while (size >= bpf) {
|
||||
/* run input_data for a chunk of data */
|
||||
fft_todo = nfft - (spectrum->num_frames % nfft);
|
||||
msg_todo = spectrum->frames_todo - spectrum->num_frames;
|
||||
GST_LOG_OBJECT (spectrum,
|
||||
"message frames todo: %u, fft frames todo: %u, input frames %u",
|
||||
msg_todo, fft_todo, (size / frame_size));
|
||||
msg_todo, fft_todo, (size / bpf));
|
||||
block_size = msg_todo;
|
||||
if (block_size > (size / frame_size))
|
||||
block_size = (size / frame_size);
|
||||
if (block_size > (size / bpf))
|
||||
block_size = (size / bpf);
|
||||
if (block_size > fft_todo)
|
||||
block_size = fft_todo;
|
||||
|
||||
|
@ -1064,11 +923,11 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
cd = &spectrum->channel_data[c];
|
||||
input = cd->input;
|
||||
/* Move the current frames into our ringbuffers */
|
||||
input_data (data + c * width, input, block_size, channels, max_value,
|
||||
input_data (data + c * bps, input, block_size, channels, max_value,
|
||||
input_pos, nfft);
|
||||
}
|
||||
data += block_size * frame_size;
|
||||
size -= block_size * frame_size;
|
||||
data += block_size * bpf;
|
||||
size -= block_size * bpf;
|
||||
input_pos = (input_pos + block_size) % nfft;
|
||||
spectrum->num_frames += block_size;
|
||||
|
||||
|
|
|
@ -169,53 +169,34 @@ static GstStructure *
|
|||
gst_oss_helper_get_format_structure (unsigned int format_bit)
|
||||
{
|
||||
GstStructure *structure;
|
||||
int endianness;
|
||||
gboolean sign;
|
||||
int width;
|
||||
const gchar *format;
|
||||
|
||||
switch (format_bit) {
|
||||
case AFMT_U8:
|
||||
endianness = 0;
|
||||
sign = FALSE;
|
||||
width = 8;
|
||||
format = "U8";
|
||||
break;
|
||||
case AFMT_S16_LE:
|
||||
endianness = G_LITTLE_ENDIAN;
|
||||
sign = TRUE;
|
||||
width = 16;
|
||||
format = "S16_LE";
|
||||
break;
|
||||
case AFMT_S16_BE:
|
||||
endianness = G_BIG_ENDIAN;
|
||||
sign = TRUE;
|
||||
width = 16;
|
||||
format = "S16_BE";
|
||||
break;
|
||||
case AFMT_S8:
|
||||
endianness = 0;
|
||||
sign = TRUE;
|
||||
width = 8;
|
||||
format = "S8";
|
||||
break;
|
||||
case AFMT_U16_LE:
|
||||
endianness = G_LITTLE_ENDIAN;
|
||||
sign = FALSE;
|
||||
width = 16;
|
||||
format = "U16_LE";
|
||||
break;
|
||||
case AFMT_U16_BE:
|
||||
endianness = G_BIG_ENDIAN;
|
||||
sign = FALSE;
|
||||
width = 16;
|
||||
format = "U16_BE";
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
structure = gst_structure_new ("audio/x-raw-int",
|
||||
"width", G_TYPE_INT, width,
|
||||
"depth", G_TYPE_INT, width, "signed", G_TYPE_BOOLEAN, sign, NULL);
|
||||
|
||||
if (endianness) {
|
||||
gst_structure_set (structure, "endianness", G_TYPE_INT, endianness, NULL);
|
||||
}
|
||||
structure = gst_structure_new ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, format, NULL);
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
|
|
@ -110,20 +110,14 @@ enum
|
|||
PROP_DEVICE,
|
||||
};
|
||||
|
||||
#define FORMATS "{" GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
|
||||
|
||||
static GstStaticPadTemplate osssink_sink_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
|
||||
"signed = (boolean) { TRUE, FALSE }, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
|
||||
"audio/x-raw-int, "
|
||||
"signed = (boolean) { TRUE, FALSE }, "
|
||||
"width = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) " FORMATS ", "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
||||
);
|
||||
|
||||
|
|
|
@ -101,25 +101,16 @@ static guint gst_oss_src_read (GstAudioSrc * asrc, gpointer data, guint length);
|
|||
static guint gst_oss_src_delay (GstAudioSrc * asrc);
|
||||
static void gst_oss_src_reset (GstAudioSrc * asrc);
|
||||
|
||||
|
||||
#define FORMATS "{" GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
|
||||
|
||||
static GstStaticPadTemplate osssrc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
|
||||
"signed = (boolean) { TRUE, FALSE }, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
|
||||
"audio/x-raw-int, "
|
||||
"signed = (boolean) { TRUE, FALSE }, "
|
||||
"width = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) " FORMATS ", "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
||||
);
|
||||
|
||||
|
||||
static void
|
||||
gst_oss_src_dispose (GObject * object)
|
||||
{
|
||||
|
|
|
@ -37,31 +37,24 @@ GstPad *mysrcpad, *mysinkpad;
|
|||
|
||||
|
||||
#define INVERT_CAPS_STRING \
|
||||
"audio/x-raw-int, " \
|
||||
"audio/x-raw, " \
|
||||
"format = (string) "GST_AUDIO_NE(S16)", " \
|
||||
"channels = (int) 1, " \
|
||||
"rate = (int) 44100, " \
|
||||
"endianness = (int) BYTE_ORDER, " \
|
||||
"width = (int) 16, " \
|
||||
"depth = (int) 16, " \
|
||||
"signed = (bool) TRUE"
|
||||
"rate = (int) 44100"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"channels = (int) 1, "
|
||||
"rate = (int) [ 1, MAX ], "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) " GST_AUDIO_NE (S16) ", "
|
||||
"channels = (int) 1, " "rate = (int) [ 1, MAX ]")
|
||||
);
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"channels = (int) 1, "
|
||||
"rate = (int) [ 1, MAX ], "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
|
||||
GST_STATIC_CAPS ("audio/x-raw, "
|
||||
"format = (string) " GST_AUDIO_NE (S16) ", "
|
||||
"channels = (int) 1, " "rate = (int) [ 1, MAX ]")
|
||||
);
|
||||
|
||||
static GstElement *
|
||||
|
|
|
@ -33,23 +33,16 @@ gboolean have_eos = FALSE;
|
|||
GstPad *mysrcpad, *mysinkpad;
|
||||
|
||||
#define LEVEL_CAPS_TEMPLATE_STRING \
|
||||
"audio/x-raw-int, " \
|
||||
"audio/x-raw, " \
|
||||
"format = (string) { S8, "GST_AUDIO_NE(S16)" }, " \
|
||||
"rate = (int) [ 1, MAX ], " \
|
||||
"channels = (int) [ 1, 8 ], " \
|
||||
"endianness = (int) BYTE_ORDER, " \
|
||||
"width = (int) {8, 16}, " \
|
||||
"depth = (int) {8, 16}, " \
|
||||
"signed = (boolean) true"
|
||||
"channels = (int) [ 1, 8 ]"
|
||||
|
||||
#define LEVEL_CAPS_STRING \
|
||||
"audio/x-raw-int, " \
|
||||
"audio/x-raw, " \
|
||||
"format = (string) "GST_AUDIO_NE(S16)", " \
|
||||
"rate = (int) 1000, " \
|
||||
"channels = (int) 2, " \
|
||||
"endianness = (int) BYTE_ORDER, " \
|
||||
"width = (int) 16, " \
|
||||
"depth = (int) 16, " \
|
||||
"signed = (boolean) true"
|
||||
|
||||
"channels = (int) 2"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
|
|
|
@ -600,7 +600,7 @@ GST_START_TEST (rtp_L16)
|
|||
{
|
||||
rtp_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
|
||||
rtp_L16_frame_count,
|
||||
"audio/x-raw-int,endianess=4321,signed=true,width=16,depth=16,rate=1,channels=1",
|
||||
"audio/x-raw,format=S16_BE,rate=1,channels=1",
|
||||
"rtpL16pay", "rtpL16depay", 0, 0, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ setup_jitterbuffer (gint num_buffers)
|
|||
GstBuffer *buffer;
|
||||
GstCaps *caps;
|
||||
/* a 20 sample audio block (2,5 ms) generated with
|
||||
* gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 !
|
||||
* "audio/x-raw-int,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
|
||||
* gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 !
|
||||
* "audio/x-raw,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
|
||||
* fakesink dump=1
|
||||
*/
|
||||
guint8 in[] = { /* first 4 bytes are rtp-header, next 4 bytes are timestamp */
|
||||
|
|
|
@ -87,7 +87,7 @@ main (int argc, char *argv[])
|
|||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
caps = gst_caps_from_string ("audio/x-raw-int,channels=2");
|
||||
caps = gst_caps_from_string ("audio/x-raw,channels=2");
|
||||
|
||||
pipeline = gst_pipeline_new (NULL);
|
||||
g_assert (pipeline);
|
||||
|
|
|
@ -95,7 +95,7 @@ main (int argc, char *argv[])
|
|||
|
||||
gst_bin_add_many (GST_BIN (bin), src, audioconvert, spectrum, sink, NULL);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw-int",
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"rate", G_TYPE_INT, AUDIOFREQ, NULL);
|
||||
|
||||
if (!gst_element_link (src, audioconvert) ||
|
||||
|
|
Loading…
Reference in a new issue