mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-09 05:38:58 +00:00
ext/twolame/gsttwolame.*: Allow raw float samples as input for encoding.
Original commit message from CVS: * ext/twolame/gsttwolame.c: (gst_two_lame_sink_setcaps), (gst_two_lame_chain): * ext/twolame/gsttwolame.h: Allow raw float samples as input for encoding.
This commit is contained in:
parent
2e1e65e154
commit
eea5ff778f
3 changed files with 47 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-08-07 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
|
* ext/twolame/gsttwolame.c: (gst_two_lame_sink_setcaps),
|
||||||
|
(gst_two_lame_chain):
|
||||||
|
* ext/twolame/gsttwolame.h:
|
||||||
|
Allow raw float samples as input for encoding.
|
||||||
|
|
||||||
2008-08-07 Stefan Kost <ensonic@users.sf.net>
|
2008-08-07 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* ext/jack/gstjackaudiosrc.c:
|
* ext/jack/gstjackaudiosrc.c:
|
||||||
|
|
|
@ -65,8 +65,13 @@ static GstStaticPadTemplate gst_two_lame_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-float, "
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
"endianness = (int) BYTE_ORDER, "
|
||||||
|
"width = (int) 32, "
|
||||||
|
"rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
|
||||||
|
"channels = (int) [ 1, 2 ]; "
|
||||||
|
"audio/x-raw-int, "
|
||||||
|
"endianness = (int) BYTE_ORDER, "
|
||||||
"signed = (boolean) true, "
|
"signed = (boolean) true, "
|
||||||
"width = (int) 16, "
|
"width = (int) 16, "
|
||||||
"depth = (int) 16, "
|
"depth = (int) 16, "
|
||||||
|
@ -355,6 +360,11 @@ gst_two_lame_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
twolame = GST_TWO_LAME (GST_PAD_PARENT (pad));
|
twolame = GST_TWO_LAME (GST_PAD_PARENT (pad));
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
|
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0)
|
||||||
|
twolame->float_input = FALSE;
|
||||||
|
else
|
||||||
|
twolame->float_input = TRUE;
|
||||||
|
|
||||||
if (!gst_structure_get_int (structure, "rate", &twolame->samplerate))
|
if (!gst_structure_get_int (structure, "rate", &twolame->samplerate))
|
||||||
goto no_rate;
|
goto no_rate;
|
||||||
if (!gst_structure_get_int (structure, "channels", &twolame->num_channels))
|
if (!gst_structure_get_int (structure, "channels", &twolame->num_channels))
|
||||||
|
@ -720,6 +730,9 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf)
|
||||||
data = GST_BUFFER_DATA (buf);
|
data = GST_BUFFER_DATA (buf);
|
||||||
size = GST_BUFFER_SIZE (buf);
|
size = GST_BUFFER_SIZE (buf);
|
||||||
|
|
||||||
|
if (twolame->float_input)
|
||||||
|
num_samples = size / 4;
|
||||||
|
else
|
||||||
num_samples = size / 2;
|
num_samples = size / 2;
|
||||||
|
|
||||||
/* allocate space for output */
|
/* allocate space for output */
|
||||||
|
@ -727,10 +740,20 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf)
|
||||||
mp3_data = g_malloc (mp3_buffer_size);
|
mp3_data = g_malloc (mp3_buffer_size);
|
||||||
|
|
||||||
if (twolame->num_channels == 1) {
|
if (twolame->num_channels == 1) {
|
||||||
|
if (twolame->float_input)
|
||||||
|
mp3_size = twolame_encode_buffer_float32 (twolame->glopts,
|
||||||
|
(float *) data,
|
||||||
|
(float *) data, num_samples, mp3_data, mp3_buffer_size);
|
||||||
|
else
|
||||||
mp3_size = twolame_encode_buffer (twolame->glopts,
|
mp3_size = twolame_encode_buffer (twolame->glopts,
|
||||||
(short int *) data,
|
(short int *) data,
|
||||||
(short int *) data, num_samples, mp3_data, mp3_buffer_size);
|
(short int *) data, num_samples, mp3_data, mp3_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
|
if (twolame->float_input)
|
||||||
|
mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts,
|
||||||
|
(float *) data,
|
||||||
|
num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);
|
||||||
|
else
|
||||||
mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,
|
mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,
|
||||||
(short int *) data,
|
(short int *) data,
|
||||||
num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);
|
num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);
|
||||||
|
@ -739,6 +762,10 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3",
|
GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3",
|
||||||
size, mp3_size);
|
size, mp3_size);
|
||||||
|
|
||||||
|
if (twolame->float_input)
|
||||||
|
duration = gst_util_uint64_scale_int (size, GST_SECOND,
|
||||||
|
4 * twolame->samplerate * twolame->num_channels);
|
||||||
|
else
|
||||||
duration = gst_util_uint64_scale_int (size, GST_SECOND,
|
duration = gst_util_uint64_scale_int (size, GST_SECOND,
|
||||||
2 * twolame->samplerate * twolame->num_channels);
|
2 * twolame->samplerate * twolame->num_channels);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct _GstTwoLame {
|
||||||
|
|
||||||
gint samplerate;
|
gint samplerate;
|
||||||
gint num_channels;
|
gint num_channels;
|
||||||
|
gboolean float_input;
|
||||||
gboolean setup;
|
gboolean setup;
|
||||||
|
|
||||||
gint mode;
|
gint mode;
|
||||||
|
|
Loading…
Reference in a new issue