mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +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)
|
if (param != NULL)
|
||||||
rate = atol (param);
|
rate = atol (param);
|
||||||
|
|
||||||
src->src_caps = gst_caps_new_simple ("audio/x-raw-int",
|
src->src_caps = gst_caps_new_simple ("audio/x-raw",
|
||||||
"channels", G_TYPE_INT, channels,
|
"format", G_TYPE_STRING, "S16_BE",
|
||||||
"rate", G_TYPE_INT, rate,
|
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
|
||||||
"width", G_TYPE_INT, 16,
|
|
||||||
"depth", G_TYPE_INT, 16,
|
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
|
||||||
"endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
|
|
||||||
} else {
|
} else {
|
||||||
/* Set the Content-Type field on the caps */
|
/* Set the Content-Type field on the caps */
|
||||||
if (src->src_caps)
|
if (src->src_caps)
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/tag/tag.h>
|
#include <gst/tag/tag.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (speexdec_debug);
|
GST_DEBUG_CATEGORY_STATIC (speexdec_debug);
|
||||||
#define GST_CAT_DEFAULT speexdec_debug
|
#define GST_CAT_DEFAULT speexdec_debug
|
||||||
|
@ -58,15 +59,15 @@ enum
|
||||||
ARG_ENH
|
ARG_ENH
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FORMAT_STR GST_AUDIO_NE(S16)
|
||||||
|
|
||||||
static GstStaticPadTemplate speex_dec_src_factory =
|
static GstStaticPadTemplate speex_dec_src_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"rate = (int) [ 6000, 48000 ], "
|
"format = (string) " FORMAT_STR ", "
|
||||||
"channels = (int) [ 1, 2 ], "
|
"rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"signed = (boolean) true, " "width = (int) 16, " "depth = (int) 16")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate speex_dec_sink_factory =
|
static GstStaticPadTemplate speex_dec_sink_factory =
|
||||||
|
@ -597,12 +598,10 @@ speex_dec_chain_parse_header (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
speex_bits_init (&dec->bits);
|
speex_bits_init (&dec->bits);
|
||||||
|
|
||||||
/* set caps */
|
/* 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,
|
"rate", G_TYPE_INT, dec->header->rate,
|
||||||
"channels", G_TYPE_INT, dec->header->nb_channels,
|
"channels", G_TYPE_INT, dec->header->nb_channels, NULL);
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
|
||||||
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
||||||
"width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
|
|
||||||
|
|
||||||
if (!gst_pad_set_caps (dec->srcpad, caps))
|
if (!gst_pad_set_caps (dec->srcpad, caps))
|
||||||
goto nego_failed;
|
goto nego_failed;
|
||||||
|
|
|
@ -52,14 +52,14 @@
|
||||||
GST_DEBUG_CATEGORY_STATIC (speexenc_debug);
|
GST_DEBUG_CATEGORY_STATIC (speexenc_debug);
|
||||||
#define GST_CAT_DEFAULT speexenc_debug
|
#define GST_CAT_DEFAULT speexenc_debug
|
||||||
|
|
||||||
|
#define FORMAT_STR GST_AUDIO_NE(S16)
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"rate = (int) [ 6000, 48000 ], "
|
"format = (string) " FORMAT_STR ", "
|
||||||
"channels = (int) [ 1, 2 ], "
|
"rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
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")
|
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 \
|
#define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
|
||||||
"audio/x-alaw, " \
|
"audio/x-alaw, " \
|
||||||
"rate = (int) [ 8000, 192000 ], " \
|
"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",
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
|
GST_STATIC_CAPS (GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS "; "
|
||||||
GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS ";"
|
|
||||||
GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS ";"
|
GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS ";"
|
||||||
GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS ";"
|
GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS ";"
|
||||||
GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS));
|
GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS));
|
||||||
|
@ -180,7 +187,9 @@ gst_au_parse_parse_header (GstAuParse * auparse)
|
||||||
guint32 size;
|
guint32 size;
|
||||||
guint8 *head;
|
guint8 *head;
|
||||||
gchar layout[7] = { 0, };
|
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);
|
head = (guint8 *) gst_adapter_map (auparse->adapter, 24);
|
||||||
g_assert (head != NULL);
|
g_assert (head != NULL);
|
||||||
|
@ -190,14 +199,14 @@ gst_au_parse_parse_header (GstAuParse * auparse)
|
||||||
switch (GST_READ_UINT32_BE (head)) {
|
switch (GST_READ_UINT32_BE (head)) {
|
||||||
/* normal format is big endian (au is a Sparc format) */
|
/* normal format is big endian (au is a Sparc format) */
|
||||||
case 0x2e736e64:{ /* ".snd" */
|
case 0x2e736e64:{ /* ".snd" */
|
||||||
auparse->endianness = G_BIG_ENDIAN;
|
endianness = G_BIG_ENDIAN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* and of course, someone had to invent a little endian
|
/* and of course, someone had to invent a little endian
|
||||||
* version. Used by DEC systems. */
|
* version. Used by DEC systems. */
|
||||||
case 0x646e732e: /* dns. */
|
case 0x646e732e: /* dns. */
|
||||||
case 0x0064732e:{ /* other source say it is "dns." */
|
case 0x0064732e:{ /* other source say it is "dns." */
|
||||||
auparse->endianness = G_LITTLE_ENDIAN;
|
endianness = G_LITTLE_ENDIAN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default:{
|
||||||
|
@ -237,33 +246,50 @@ gst_au_parse_parse_header (GstAuParse * auparse)
|
||||||
switch (auparse->encoding) {
|
switch (auparse->encoding) {
|
||||||
case 1: /* 8-bit ISDN mu-law G.711 */
|
case 1: /* 8-bit ISDN mu-law G.711 */
|
||||||
law = 1;
|
law = 1;
|
||||||
depth = 8;
|
|
||||||
break;
|
break;
|
||||||
case 27: /* 8-bit ISDN A-law G.711 */
|
case 27: /* 8-bit ISDN A-law G.711 */
|
||||||
law = 2;
|
law = 2;
|
||||||
depth = 8;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* 8-bit linear PCM */
|
case 2: /* 8-bit linear PCM, FIXME signed? */
|
||||||
depth = 8;
|
format = GST_AUDIO_FORMAT_S8;
|
||||||
|
auparse->sample_size = auparse->channels;
|
||||||
break;
|
break;
|
||||||
case 3: /* 16-bit linear PCM */
|
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;
|
break;
|
||||||
case 4: /* 24-bit linear PCM */
|
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;
|
break;
|
||||||
case 5: /* 32-bit linear PCM */
|
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;
|
break;
|
||||||
|
|
||||||
case 6: /* 32-bit IEEE floating point */
|
case 6: /* 32-bit IEEE floating point */
|
||||||
ieee = 1;
|
if (endianness == G_LITTLE_ENDIAN)
|
||||||
depth = 32;
|
format = GST_AUDIO_FORMAT_F32_LE;
|
||||||
|
else
|
||||||
|
format = GST_AUDIO_FORMAT_F32_BE;
|
||||||
|
auparse->sample_size = auparse->channels * 4;
|
||||||
break;
|
break;
|
||||||
case 7: /* 64-bit IEEE floating point */
|
case 7: /* 64-bit IEEE floating point */
|
||||||
ieee = 1;
|
if (endianness == G_LITTLE_ENDIAN)
|
||||||
depth = 64;
|
format = GST_AUDIO_FORMAT_F64_LE;
|
||||||
|
else
|
||||||
|
format = GST_AUDIO_FORMAT_F64_BE;
|
||||||
|
auparse->sample_size = auparse->channels * 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 23: /* 4-bit CCITT G.721 ADPCM 32kbps -> modplug/libsndfile (compressed 8-bit mu-law) */
|
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,
|
"rate", G_TYPE_INT, auparse->samplerate,
|
||||||
"channels", G_TYPE_INT, auparse->channels, NULL);
|
"channels", G_TYPE_INT, auparse->channels, NULL);
|
||||||
auparse->sample_size = auparse->channels;
|
auparse->sample_size = auparse->channels;
|
||||||
} else if (ieee) {
|
} else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
|
||||||
tempcaps = gst_caps_new_simple ("audio/x-raw-float",
|
tempcaps = gst_caps_new_simple ("audio/x-raw",
|
||||||
|
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
|
||||||
"rate", G_TYPE_INT, auparse->samplerate,
|
"rate", G_TYPE_INT, auparse->samplerate,
|
||||||
"channels", G_TYPE_INT, auparse->channels,
|
"channels", G_TYPE_INT, auparse->channels, NULL);
|
||||||
"endianness", G_TYPE_INT, auparse->endianness,
|
|
||||||
"width", G_TYPE_INT, depth, NULL);
|
|
||||||
auparse->sample_size = auparse->channels * depth / 8;
|
|
||||||
} else if (layout[0]) {
|
} else if (layout[0]) {
|
||||||
tempcaps = gst_caps_new_simple ("audio/x-adpcm",
|
tempcaps = gst_caps_new_simple ("audio/x-adpcm",
|
||||||
"layout", G_TYPE_STRING, layout, NULL);
|
"layout", G_TYPE_STRING, layout, NULL);
|
||||||
auparse->sample_size = 0;
|
auparse->sample_size = 0;
|
||||||
} else {
|
} else
|
||||||
tempcaps = gst_caps_new_simple ("audio/x-raw-int",
|
goto unknown_format;
|
||||||
"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;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (auparse, "sample_size=%d", auparse->sample_size);
|
GST_DEBUG_OBJECT (auparse, "sample_size=%d", auparse->sample_size);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ struct _GstAuParse {
|
||||||
guint sample_size;
|
guint sample_size;
|
||||||
guint encoding;
|
guint encoding;
|
||||||
guint samplerate;
|
guint samplerate;
|
||||||
guint endianness;
|
|
||||||
guint channels;
|
guint channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,9 @@ GST_DEBUG_CATEGORY_STATIC (cutter_debug);
|
||||||
static GstStaticPadTemplate cutter_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate cutter_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
|
||||||
"channels = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) { 8, 16 }, "
|
|
||||||
"depth = (int) { 8, 16 }, " "signed = (boolean) true")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate cutter_sink_factory =
|
static GstStaticPadTemplate cutter_sink_factory =
|
||||||
|
@ -81,11 +78,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
|
||||||
"channels = (int) [ 1, MAX ], "
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) { 8, 16 }, "
|
|
||||||
"depth = (int) { 8, 16 }, " "signed = (boolean) true")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -363,6 +357,7 @@ gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
const gchar *format;
|
||||||
|
|
||||||
caps = gst_pad_get_current_caps (pad);
|
caps = gst_pad_get_current_caps (pad);
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
|
@ -370,8 +365,12 @@ gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
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;
|
filter->have_caps = TRUE;
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
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 void gst_iir_equalizer_finalize (GObject * object);
|
||||||
|
|
||||||
static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter,
|
static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter,
|
||||||
GstRingBufferSpec * fmt);
|
GstAudioInfo * info);
|
||||||
static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
|
static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
|
|
||||||
#define ALLOWED_CAPS \
|
#define ALLOWED_CAPS \
|
||||||
"audio/x-raw-int," \
|
"audio/x-raw," \
|
||||||
" depth=(int)16," \
|
" format=(string) {"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)"," \
|
||||||
" width=(int)16," \
|
GST_AUDIO_NE(F64)" }, " \
|
||||||
" endianness=(int)BYTE_ORDER," \
|
" rate=(int)[1000,MAX]," \
|
||||||
" 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]," \
|
|
||||||
" channels=(int)[1,MAX]"
|
" channels=(int)[1,MAX]"
|
||||||
|
|
||||||
#define gst_iir_equalizer_parent_class parent_class
|
#define gst_iir_equalizer_parent_class parent_class
|
||||||
|
@ -465,15 +458,17 @@ calculate_bw (GstIirEqualizerBand * band, gint rate)
|
||||||
static void
|
static void
|
||||||
setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
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 gain, omega, bw;
|
||||||
gdouble alpha, alpha1, alpha2, b0;
|
gdouble alpha, alpha1, alpha2, b0;
|
||||||
|
|
||||||
gain = arg_to_scale (band->gain);
|
gain = arg_to_scale (band->gain);
|
||||||
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
|
omega = calculate_omega (band->freq, rate);
|
||||||
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
|
bw = calculate_bw (band, rate);
|
||||||
if (bw == 0.0)
|
if (bw == 0.0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -501,7 +496,9 @@ setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
||||||
static void
|
static void
|
||||||
setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
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;
|
gdouble gain, omega, bw;
|
||||||
|
@ -509,8 +506,8 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
||||||
gdouble egp, egm;
|
gdouble egp, egm;
|
||||||
|
|
||||||
gain = arg_to_scale (band->gain);
|
gain = arg_to_scale (band->gain);
|
||||||
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
|
omega = calculate_omega (band->freq, rate);
|
||||||
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
|
bw = calculate_bw (band, rate);
|
||||||
if (bw == 0.0)
|
if (bw == 0.0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -539,7 +536,9 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
||||||
static void
|
static void
|
||||||
setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
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;
|
gdouble gain, omega, bw;
|
||||||
|
@ -547,8 +546,8 @@ setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
|
||||||
gdouble egp, egm;
|
gdouble egp, egm;
|
||||||
|
|
||||||
gain = arg_to_scale (band->gain);
|
gain = arg_to_scale (band->gain);
|
||||||
omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
|
omega = calculate_omega (band->freq, rate);
|
||||||
bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
|
bw = calculate_bw (band, rate);
|
||||||
if (bw == 0.0)
|
if (bw == 0.0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -614,7 +613,7 @@ alloc_history (GstIirEqualizer * equ)
|
||||||
/* free + alloc = no memcpy */
|
/* free + alloc = no memcpy */
|
||||||
g_free (equ->history);
|
g_free (equ->history);
|
||||||
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);
|
equ->freq_band_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,8 +818,9 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
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;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
|
||||||
BANDS_LOCK (equ);
|
BANDS_LOCK (equ);
|
||||||
|
@ -841,41 +841,29 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
gst_object_sync_values (G_OBJECT (equ), timestamp);
|
gst_object_sync_values (G_OBJECT (equ), timestamp);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
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);
|
gst_buffer_unmap (buf, data, size);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_iir_equalizer_setup (GstAudioFilter * audio, GstRingBufferSpec * fmt)
|
gst_iir_equalizer_setup (GstAudioFilter * audio, GstAudioInfo * info)
|
||||||
{
|
{
|
||||||
GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio);
|
GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio);
|
||||||
|
|
||||||
switch (fmt->type) {
|
switch (GST_AUDIO_INFO_FORMAT (info)) {
|
||||||
case GST_BUFTYPE_LINEAR:
|
case GST_AUDIO_FORMAT_S16:
|
||||||
switch (fmt->width) {
|
equ->history_size = history_size_gint16;
|
||||||
case 16:
|
equ->process = gst_iir_equ_process_gint16;
|
||||||
equ->history_size = history_size_gint16;
|
|
||||||
equ->process = gst_iir_equ_process_gint16;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GST_BUFTYPE_FLOAT:
|
case GST_AUDIO_FORMAT_F32:
|
||||||
switch (fmt->width) {
|
equ->history_size = history_size_gfloat;
|
||||||
case 32:
|
equ->process = gst_iir_equ_process_gfloat;
|
||||||
equ->history_size = history_size_gfloat;
|
break;
|
||||||
equ->process = gst_iir_equ_process_gfloat;
|
case GST_AUDIO_FORMAT_F64:
|
||||||
break;
|
equ->history_size = history_size_gdouble;
|
||||||
case 64:
|
equ->process = gst_iir_equ_process_gdouble;
|
||||||
equ->history_size = history_size_gdouble;
|
|
||||||
equ->process = gst_iir_equ_process_gdouble;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -117,37 +117,23 @@ GST_DEBUG_CATEGORY_STATIC (level_debug);
|
||||||
#define EPSILON 1e-35f
|
#define EPSILON 1e-35f
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template_factory =
|
static GstStaticPadTemplate sink_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
|
||||||
"channels = (int) [ 1, MAX ], "
|
GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
|
||||||
"endianness = (int) BYTE_ORDER, "
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||||
"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} ")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate src_template_factory =
|
static GstStaticPadTemplate src_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
|
||||||
"channels = (int) [ 1, MAX ], "
|
GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
|
||||||
"endianness = (int) BYTE_ORDER, "
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||||
"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} ")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -228,9 +214,7 @@ gst_level_init (GstLevel * filter)
|
||||||
filter->CS = NULL;
|
filter->CS = NULL;
|
||||||
filter->peak = NULL;
|
filter->peak = NULL;
|
||||||
|
|
||||||
filter->rate = 0;
|
gst_audio_info_init (&filter->info);
|
||||||
filter->width = 0;
|
|
||||||
filter->channels = 0;
|
|
||||||
|
|
||||||
filter->interval = GST_SECOND / 10;
|
filter->interval = GST_SECOND / 10;
|
||||||
filter->decay_peak_ttl = GST_SECOND / 10 * 3;
|
filter->decay_peak_ttl = GST_SECOND / 10 * 3;
|
||||||
|
@ -277,9 +261,10 @@ gst_level_set_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
case PROP_SIGNAL_INTERVAL:
|
case PROP_SIGNAL_INTERVAL:
|
||||||
filter->interval = g_value_get_uint64 (value);
|
filter->interval = g_value_get_uint64 (value);
|
||||||
if (filter->rate) {
|
if (GST_AUDIO_INFO_RATE (&filter->info)) {
|
||||||
filter->interval_frames =
|
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;
|
break;
|
||||||
case PROP_PEAK_TTL:
|
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
|
static gboolean
|
||||||
gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
||||||
{
|
{
|
||||||
GstLevel *filter = GST_LEVEL (trans);
|
GstLevel *filter = GST_LEVEL (trans);
|
||||||
const gchar *mimetype;
|
GstAudioInfo info;
|
||||||
GstStructure *structure;
|
gint i, channels, rate;
|
||||||
gint i;
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (in, 0);
|
if (!gst_audio_info_from_caps (&info, in))
|
||||||
filter->rate = structure_get_int (structure, "rate");
|
return FALSE;
|
||||||
filter->width = structure_get_int (structure, "width");
|
|
||||||
filter->channels = structure_get_int (structure, "channels");
|
|
||||||
mimetype = gst_structure_get_name (structure);
|
|
||||||
|
|
||||||
/* FIXME: set calculator func depending on caps */
|
switch (GST_AUDIO_INFO_FORMAT (&info)) {
|
||||||
filter->process = NULL;
|
case GST_AUDIO_FORMAT_S8:
|
||||||
if (strcmp (mimetype, "audio/x-raw-int") == 0) {
|
filter->process = gst_level_calculate_gint8;
|
||||||
GST_DEBUG_OBJECT (filter, "use int: %u", filter->width);
|
break;
|
||||||
switch (filter->width) {
|
case GST_AUDIO_FORMAT_S16:
|
||||||
case 8:
|
filter->process = gst_level_calculate_gint16;
|
||||||
filter->process = gst_level_calculate_gint8;
|
break;
|
||||||
break;
|
case GST_AUDIO_FORMAT_S32:
|
||||||
case 16:
|
filter->process = gst_level_calculate_gint32;
|
||||||
filter->process = gst_level_calculate_gint16;
|
break;
|
||||||
break;
|
case GST_AUDIO_FORMAT_F32:
|
||||||
case 32:
|
filter->process = gst_level_calculate_gfloat;
|
||||||
filter->process = gst_level_calculate_gint32;
|
break;
|
||||||
break;
|
case GST_AUDIO_FORMAT_F64:
|
||||||
}
|
filter->process = gst_level_calculate_gdouble;
|
||||||
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
|
break;
|
||||||
GST_DEBUG_OBJECT (filter, "use float, %u", filter->width);
|
default:
|
||||||
switch (filter->width) {
|
filter->process = NULL;
|
||||||
case 32:
|
break;
|
||||||
filter->process = gst_level_calculate_gfloat;
|
|
||||||
break;
|
|
||||||
case 64:
|
|
||||||
filter->process = gst_level_calculate_gdouble;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter->info = info;
|
||||||
|
|
||||||
|
channels = GST_AUDIO_INFO_CHANNELS (&info);
|
||||||
|
rate = GST_AUDIO_INFO_RATE (&info);
|
||||||
|
|
||||||
/* allocate channel variable arrays */
|
/* allocate channel variable arrays */
|
||||||
g_free (filter->CS);
|
g_free (filter->CS);
|
||||||
g_free (filter->peak);
|
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);
|
||||||
g_free (filter->decay_peak_base);
|
g_free (filter->decay_peak_base);
|
||||||
g_free (filter->decay_peak_age);
|
g_free (filter->decay_peak_age);
|
||||||
filter->CS = g_new (gdouble, filter->channels);
|
filter->CS = g_new (gdouble, channels);
|
||||||
filter->peak = g_new (gdouble, filter->channels);
|
filter->peak = g_new (gdouble, channels);
|
||||||
filter->last_peak = g_new (gdouble, filter->channels);
|
filter->last_peak = g_new (gdouble, channels);
|
||||||
filter->decay_peak = g_new (gdouble, filter->channels);
|
filter->decay_peak = g_new (gdouble, channels);
|
||||||
filter->decay_peak_base = g_new (gdouble, filter->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->CS[i] = filter->peak[i] = filter->last_peak[i] =
|
||||||
filter->decay_peak[i] = filter->decay_peak_base[i] = 0.0;
|
filter->decay_peak[i] = filter->decay_peak_base[i] = 0.0;
|
||||||
filter->decay_peak_age[i] = G_GUINT64_CONSTANT (0);
|
filter->decay_peak_age[i] = G_GUINT64_CONSTANT (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
filter->interval_frames =
|
filter->interval_frames = GST_CLOCK_TIME_TO_FRAMES (filter->interval, rate);
|
||||||
GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -572,35 +540,38 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
guint num_int_samples = 0; /* number of interleaved samples
|
guint num_int_samples = 0; /* number of interleaved samples
|
||||||
* ie. total count for all channels combined */
|
* ie. total count for all channels combined */
|
||||||
GstClockTimeDiff falloff_time;
|
GstClockTimeDiff falloff_time;
|
||||||
|
gint channels, rate, bps;
|
||||||
|
|
||||||
filter = GST_LEVEL (trans);
|
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);
|
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,
|
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
||||||
num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
|
num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
|
||||||
|
|
||||||
g_return_val_if_fail (num_int_samples % filter->channels == 0,
|
g_return_val_if_fail (num_int_samples % channels == 0, GST_FLOW_ERROR);
|
||||||
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)) {
|
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]);
|
&filter->peak[i]);
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
"channel %d, cumulative sum %f, peak %f, over %d samples/%d channels",
|
"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;
|
filter->CS[i] += CS;
|
||||||
} else {
|
} else {
|
||||||
filter->peak[i] = 0.0;
|
filter->peak[i] = 0.0;
|
||||||
}
|
}
|
||||||
in_data += (filter->width / 8);
|
in_data += bps;
|
||||||
|
|
||||||
filter->decay_peak_age[i] +=
|
filter->decay_peak_age[i] += GST_FRAMES_TO_CLOCK_TIME (num_frames, rate);
|
||||||
GST_FRAMES_TO_CLOCK_TIME (num_frames, filter->rate);
|
|
||||||
GST_LOG_OBJECT (filter, "filter peak info [%d]: decay peak %f, age %"
|
GST_LOG_OBJECT (filter, "filter peak info [%d]: decay peak %f, age %"
|
||||||
GST_TIME_FORMAT, i,
|
GST_TIME_FORMAT, i,
|
||||||
filter->decay_peak[i], GST_TIME_ARGS (filter->decay_peak_age[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) {
|
if (filter->message) {
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
GstClockTime duration =
|
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);
|
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",
|
"message: ts %" GST_TIME_FORMAT ", num_frames %d",
|
||||||
GST_TIME_ARGS (filter->message_ts), filter->num_frames);
|
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 RMS;
|
||||||
gdouble RMSdB, lastdB, decaydB;
|
gdouble RMSdB, lastdB, decaydB;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -59,9 +59,7 @@ struct _GstLevel {
|
||||||
gboolean message; /* whether or not to post messages */
|
gboolean message; /* whether or not to post messages */
|
||||||
guint64 interval; /* how many seconds between emits */
|
guint64 interval; /* how many seconds between emits */
|
||||||
|
|
||||||
gint rate; /* caps variables */
|
GstAudioInfo info;
|
||||||
gint width;
|
|
||||||
gint channels;
|
|
||||||
|
|
||||||
gdouble decay_peak_ttl; /* time to live for peak in seconds */
|
gdouble decay_peak_ttl; /* time to live for peak in seconds */
|
||||||
gdouble decay_peak_falloff; /* falloff in dB/sec */
|
gdouble decay_peak_falloff; /* falloff in dB/sec */
|
||||||
|
@ -79,7 +77,7 @@ struct _GstLevel {
|
||||||
gdouble *MS; /* normalized Mean Square of buffer */
|
gdouble *MS; /* normalized Mean Square of buffer */
|
||||||
gdouble *RMS_dB; /* RMS in dB to emit */
|
gdouble *RMS_dB; /* RMS in dB to emit */
|
||||||
GstClockTime *decay_peak_age; /* age of last peak */
|
GstClockTime *decay_peak_age; /* age of last peak */
|
||||||
|
|
||||||
void (*process)(gpointer, guint, guint, gdouble*, gdouble*);
|
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_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"endianness = (int) BIG_ENDIAN, "
|
"format = (string) S16_BE, "
|
||||||
"signed = (boolean) true, "
|
|
||||||
"width = (int) 16, "
|
|
||||||
"depth = (int) 16, "
|
|
||||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
"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->rate = clock_rate;
|
||||||
rtpL16depay->channels = channels;
|
rtpL16depay->channels = channels;
|
||||||
|
|
||||||
srccaps = gst_caps_new_simple ("audio/x-raw-int",
|
srccaps = gst_caps_new_simple ("audio/x-raw",
|
||||||
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
|
"format", G_TYPE_STRING, "S16_BE",
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
|
||||||
"width", G_TYPE_INT, 16,
|
|
||||||
"depth", G_TYPE_INT, 16,
|
|
||||||
"rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
|
"rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
|
||||||
|
|
||||||
/* add channel positions */
|
/* add channel positions */
|
||||||
|
|
|
@ -37,11 +37,8 @@ static GstStaticPadTemplate gst_rtp_L16_pay_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"endianness = (int) BIG_ENDIAN, "
|
"format = (string) S16_BE, "
|
||||||
"signed = (boolean) true, "
|
|
||||||
"width = (int) 16, "
|
|
||||||
"depth = (int) 16, "
|
|
||||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug);
|
||||||
#define GST_CAT_DEFAULT (rtpvrawdepay_debug)
|
#define GST_CAT_DEFAULT (rtpvrawdepay_debug)
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
|
static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
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 =
|
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
|
#define GST_CAT_DEFAULT gst_spectrum_debug
|
||||||
|
|
||||||
/* elementfactory information */
|
/* 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 \
|
#define ALLOWED_CAPS \
|
||||||
"audio/x-raw-int, " \
|
GST_AUDIO_CAPS_MAKE (FORMATS)
|
||||||
" 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 ]"
|
|
||||||
|
|
||||||
/* Spectrum properties */
|
/* Spectrum properties */
|
||||||
#define DEFAULT_POST_MESSAGES TRUE
|
#define DEFAULT_POST_MESSAGES TRUE
|
||||||
#define DEFAULT_MESSAGE_MAGNITUDE TRUE
|
#define DEFAULT_MESSAGE_MAGNITUDE TRUE
|
||||||
#define DEFAULT_MESSAGE_PHASE FALSE
|
#define DEFAULT_MESSAGE_PHASE FALSE
|
||||||
#define DEFAULT_INTERVAL (GST_SECOND / 10)
|
#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 gboolean gst_spectrum_stop (GstBaseTransform * trans);
|
||||||
static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
|
static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
|
||||||
GstBuffer * in);
|
GstBuffer * in);
|
||||||
static gboolean gst_spectrum_setup (GstAudioFilter * base,
|
static gboolean gst_spectrum_setup (GstAudioFilter * base, GstAudioInfo * info);
|
||||||
GstRingBufferSpec * format);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_spectrum_class_init (GstSpectrumClass * klass)
|
gst_spectrum_class_init (GstSpectrumClass * klass)
|
||||||
|
@ -287,7 +266,7 @@ gst_spectrum_alloc_channel_data (GstSpectrum * spectrum)
|
||||||
g_assert (spectrum->channel_data == NULL);
|
g_assert (spectrum->channel_data == NULL);
|
||||||
|
|
||||||
spectrum->num_channels = (spectrum->multi_channel) ?
|
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",
|
GST_DEBUG_OBJECT (spectrum, "allocating data for %d channels",
|
||||||
spectrum->num_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
|
static void
|
||||||
input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static void
|
||||||
input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static void
|
||||||
input_data_mixed_int16_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_mixed_int16_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static void
|
||||||
input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static void
|
||||||
input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static void
|
||||||
input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
|
input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
|
||||||
guint channels, gfloat max_value, guint op, guint nfft)
|
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
|
static gboolean
|
||||||
gst_spectrum_setup (GstAudioFilter * base, GstRingBufferSpec * format)
|
gst_spectrum_setup (GstAudioFilter * base, GstAudioInfo * info)
|
||||||
{
|
{
|
||||||
GstSpectrum *spectrum = GST_SPECTRUM (base);
|
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;
|
gboolean multi_channel = spectrum->multi_channel;
|
||||||
GstSpectrumInputData input_data = NULL;
|
GstSpectrumInputData input_data = NULL;
|
||||||
|
|
||||||
if (is_float) {
|
switch (GST_AUDIO_INFO_FORMAT (info)) {
|
||||||
if (width == 4) {
|
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;
|
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;
|
input_data = multi_channel ? input_data_double : input_data_mixed_double;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
break;
|
||||||
} 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 ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spectrum->input_data = input_data;
|
spectrum->input_data = input_data;
|
||||||
|
|
||||||
gst_spectrum_reset_state (spectrum);
|
gst_spectrum_reset_state (spectrum);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,7 +738,7 @@ gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime timestamp,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
guint c;
|
guint c;
|
||||||
guint channels = GST_AUDIO_FILTER (spectrum)->format.channels;
|
guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
|
||||||
|
|
||||||
if (spectrum->message_magnitude) {
|
if (spectrum->message_magnitude) {
|
||||||
mcv = gst_spectrum_message_add_container (s, GST_TYPE_ARRAY, "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)
|
gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstSpectrum *spectrum = GST_SPECTRUM (trans);
|
GstSpectrum *spectrum = GST_SPECTRUM (trans);
|
||||||
GstRingBufferSpec *format = &GST_AUDIO_FILTER (spectrum)->format;
|
guint rate = GST_AUDIO_FILTER_RATE (spectrum);
|
||||||
guint rate = format->rate;
|
guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
|
||||||
guint channels = format->channels;
|
guint bps = GST_AUDIO_FILTER_BPS (spectrum);
|
||||||
|
guint bpf = GST_AUDIO_FILTER_BPF (spectrum);
|
||||||
guint output_channels = spectrum->multi_channel ? channels : 1;
|
guint output_channels = spectrum->multi_channel ? channels : 1;
|
||||||
guint c;
|
guint c;
|
||||||
guint width = format->width / 8;
|
gfloat max_value = (1UL << ((bps << 3) - 1)) - 1;
|
||||||
gfloat max_value = (1UL << (format->depth - 1)) - 1;
|
|
||||||
guint bands = spectrum->bands;
|
guint bands = spectrum->bands;
|
||||||
guint nfft = 2 * bands - 2;
|
guint nfft = 2 * bands - 2;
|
||||||
guint input_pos;
|
guint input_pos;
|
||||||
gfloat *input;
|
gfloat *input;
|
||||||
const guint8 *data, *mdata;
|
const guint8 *data, *mdata;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint frame_size = width * channels;
|
|
||||||
guint fft_todo, msg_todo, block_size;
|
guint fft_todo, msg_todo, block_size;
|
||||||
gboolean have_full_interval;
|
gboolean have_full_interval;
|
||||||
GstSpectrumChannel *cd;
|
GstSpectrumChannel *cd;
|
||||||
|
@ -1047,16 +906,16 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||||
input_pos = spectrum->input_pos;
|
input_pos = spectrum->input_pos;
|
||||||
input_data = spectrum->input_data;
|
input_data = spectrum->input_data;
|
||||||
|
|
||||||
while (size >= frame_size) {
|
while (size >= bpf) {
|
||||||
/* run input_data for a chunk of data */
|
/* run input_data for a chunk of data */
|
||||||
fft_todo = nfft - (spectrum->num_frames % nfft);
|
fft_todo = nfft - (spectrum->num_frames % nfft);
|
||||||
msg_todo = spectrum->frames_todo - spectrum->num_frames;
|
msg_todo = spectrum->frames_todo - spectrum->num_frames;
|
||||||
GST_LOG_OBJECT (spectrum,
|
GST_LOG_OBJECT (spectrum,
|
||||||
"message frames todo: %u, fft frames todo: %u, input frames %u",
|
"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;
|
block_size = msg_todo;
|
||||||
if (block_size > (size / frame_size))
|
if (block_size > (size / bpf))
|
||||||
block_size = (size / frame_size);
|
block_size = (size / bpf);
|
||||||
if (block_size > fft_todo)
|
if (block_size > fft_todo)
|
||||||
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];
|
cd = &spectrum->channel_data[c];
|
||||||
input = cd->input;
|
input = cd->input;
|
||||||
/* Move the current frames into our ringbuffers */
|
/* 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);
|
input_pos, nfft);
|
||||||
}
|
}
|
||||||
data += block_size * frame_size;
|
data += block_size * bpf;
|
||||||
size -= block_size * frame_size;
|
size -= block_size * bpf;
|
||||||
input_pos = (input_pos + block_size) % nfft;
|
input_pos = (input_pos + block_size) % nfft;
|
||||||
spectrum->num_frames += block_size;
|
spectrum->num_frames += block_size;
|
||||||
|
|
||||||
|
|
|
@ -169,53 +169,34 @@ static GstStructure *
|
||||||
gst_oss_helper_get_format_structure (unsigned int format_bit)
|
gst_oss_helper_get_format_structure (unsigned int format_bit)
|
||||||
{
|
{
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
int endianness;
|
const gchar *format;
|
||||||
gboolean sign;
|
|
||||||
int width;
|
|
||||||
|
|
||||||
switch (format_bit) {
|
switch (format_bit) {
|
||||||
case AFMT_U8:
|
case AFMT_U8:
|
||||||
endianness = 0;
|
format = "U8";
|
||||||
sign = FALSE;
|
|
||||||
width = 8;
|
|
||||||
break;
|
break;
|
||||||
case AFMT_S16_LE:
|
case AFMT_S16_LE:
|
||||||
endianness = G_LITTLE_ENDIAN;
|
format = "S16_LE";
|
||||||
sign = TRUE;
|
|
||||||
width = 16;
|
|
||||||
break;
|
break;
|
||||||
case AFMT_S16_BE:
|
case AFMT_S16_BE:
|
||||||
endianness = G_BIG_ENDIAN;
|
format = "S16_BE";
|
||||||
sign = TRUE;
|
|
||||||
width = 16;
|
|
||||||
break;
|
break;
|
||||||
case AFMT_S8:
|
case AFMT_S8:
|
||||||
endianness = 0;
|
format = "S8";
|
||||||
sign = TRUE;
|
|
||||||
width = 8;
|
|
||||||
break;
|
break;
|
||||||
case AFMT_U16_LE:
|
case AFMT_U16_LE:
|
||||||
endianness = G_LITTLE_ENDIAN;
|
format = "U16_LE";
|
||||||
sign = FALSE;
|
|
||||||
width = 16;
|
|
||||||
break;
|
break;
|
||||||
case AFMT_U16_BE:
|
case AFMT_U16_BE:
|
||||||
endianness = G_BIG_ENDIAN;
|
format = "U16_BE";
|
||||||
sign = FALSE;
|
|
||||||
width = 16;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
structure = gst_structure_new ("audio/x-raw-int",
|
structure = gst_structure_new ("audio/x-raw",
|
||||||
"width", G_TYPE_INT, width,
|
"format", G_TYPE_STRING, format, NULL);
|
||||||
"depth", G_TYPE_INT, width, "signed", G_TYPE_BOOLEAN, sign, NULL);
|
|
||||||
|
|
||||||
if (endianness) {
|
|
||||||
gst_structure_set (structure, "endianness", G_TYPE_INT, endianness, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return structure;
|
return structure;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,20 +110,14 @@ enum
|
||||||
PROP_DEVICE,
|
PROP_DEVICE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FORMATS "{" GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
|
||||||
|
|
||||||
static GstStaticPadTemplate osssink_sink_factory =
|
static GstStaticPadTemplate osssink_sink_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
|
"format = (string) " FORMATS ", "
|
||||||
"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, "
|
|
||||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
"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 guint gst_oss_src_delay (GstAudioSrc * asrc);
|
||||||
static void gst_oss_src_reset (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",
|
static GstStaticPadTemplate osssrc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
|
"format = (string) " FORMATS ", "
|
||||||
"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, "
|
|
||||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_oss_src_dispose (GObject * object)
|
gst_oss_src_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,31 +37,24 @@ GstPad *mysrcpad, *mysinkpad;
|
||||||
|
|
||||||
|
|
||||||
#define INVERT_CAPS_STRING \
|
#define INVERT_CAPS_STRING \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw, " \
|
||||||
|
"format = (string) "GST_AUDIO_NE(S16)", " \
|
||||||
"channels = (int) 1, " \
|
"channels = (int) 1, " \
|
||||||
"rate = (int) 44100, " \
|
"rate = (int) 44100"
|
||||||
"endianness = (int) BYTE_ORDER, " \
|
|
||||||
"width = (int) 16, " \
|
|
||||||
"depth = (int) 16, " \
|
|
||||||
"signed = (bool) TRUE"
|
|
||||||
|
|
||||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"channels = (int) 1, "
|
"format = (string) " GST_AUDIO_NE (S16) ", "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"channels = (int) 1, " "rate = (int) [ 1, MAX ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
|
|
||||||
);
|
);
|
||||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"channels = (int) 1, "
|
"format = (string) " GST_AUDIO_NE (S16) ", "
|
||||||
"rate = (int) [ 1, MAX ], "
|
"channels = (int) 1, " "rate = (int) [ 1, MAX ]")
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
|
|
|
@ -33,23 +33,16 @@ gboolean have_eos = FALSE;
|
||||||
GstPad *mysrcpad, *mysinkpad;
|
GstPad *mysrcpad, *mysinkpad;
|
||||||
|
|
||||||
#define LEVEL_CAPS_TEMPLATE_STRING \
|
#define LEVEL_CAPS_TEMPLATE_STRING \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw, " \
|
||||||
|
"format = (string) { S8, "GST_AUDIO_NE(S16)" }, " \
|
||||||
"rate = (int) [ 1, MAX ], " \
|
"rate = (int) [ 1, MAX ], " \
|
||||||
"channels = (int) [ 1, 8 ], " \
|
"channels = (int) [ 1, 8 ]"
|
||||||
"endianness = (int) BYTE_ORDER, " \
|
|
||||||
"width = (int) {8, 16}, " \
|
|
||||||
"depth = (int) {8, 16}, " \
|
|
||||||
"signed = (boolean) true"
|
|
||||||
|
|
||||||
#define LEVEL_CAPS_STRING \
|
#define LEVEL_CAPS_STRING \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw, " \
|
||||||
|
"format = (string) "GST_AUDIO_NE(S16)", " \
|
||||||
"rate = (int) 1000, " \
|
"rate = (int) 1000, " \
|
||||||
"channels = (int) 2, " \
|
"channels = (int) 2"
|
||||||
"endianness = (int) BYTE_ORDER, " \
|
|
||||||
"width = (int) 16, " \
|
|
||||||
"depth = (int) 16, " \
|
|
||||||
"signed = (boolean) true"
|
|
||||||
|
|
||||||
|
|
||||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_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_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
|
||||||
rtp_L16_frame_count,
|
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);
|
"rtpL16pay", "rtpL16depay", 0, 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ setup_jitterbuffer (gint num_buffers)
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
/* a 20 sample audio block (2,5 ms) generated with
|
/* a 20 sample audio block (2,5 ms) generated with
|
||||||
* gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 !
|
* gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 !
|
||||||
* "audio/x-raw-int,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
|
* "audio/x-raw,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
|
||||||
* fakesink dump=1
|
* fakesink dump=1
|
||||||
*/
|
*/
|
||||||
guint8 in[] = { /* first 4 bytes are rtp-header, next 4 bytes are timestamp */
|
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);
|
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);
|
pipeline = gst_pipeline_new (NULL);
|
||||||
g_assert (pipeline);
|
g_assert (pipeline);
|
||||||
|
|
|
@ -95,7 +95,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
gst_bin_add_many (GST_BIN (bin), src, audioconvert, spectrum, sink, NULL);
|
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);
|
"rate", G_TYPE_INT, AUDIOFREQ, NULL);
|
||||||
|
|
||||||
if (!gst_element_link (src, audioconvert) ||
|
if (!gst_element_link (src, audioconvert) ||
|
||||||
|
|
Loading…
Reference in a new issue