From: <sl...@ke...> - 2008-08-07 14:34:06
|
CVS Root: /cvs/gstreamer Module: gst-plugins-bad Changes by: slomo Date: Thu Aug 07 2008 14:34:17 UTC Log message: * 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. Modified files: . : ChangeLog ext/twolame : gsttwolame.c gsttwolame.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3481&r2=1.3482 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/twolame/gsttwolame.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/twolame/gsttwolame.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v retrieving revision 1.3481 retrieving revision 1.3482 diff -u -d -r1.3481 -r1.3482 --- ChangeLog 7 Aug 2008 13:15:20 -0000 1.3481 +++ ChangeLog 7 Aug 2008 14:34:01 -0000 1.3482 @@ -1,3 +1,10 @@ +2008-08-07 Sebastian Dröge <seb...@co...> + + * 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 <en...@us...> * ext/jack/gstjackaudiosrc.c: Index: gsttwolame.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/twolame/gsttwolame.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gsttwolame.c 2 Aug 2008 17:39:13 -0000 1.1 +++ gsttwolame.c 7 Aug 2008 14:34:02 -0000 1.2 @@ -62,11 +62,16 @@ /* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible * sample rates it supports */ static GstStaticPadTemplate gst_two_lame_sink_template = -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) ", " + GST_STATIC_CAPS ("audio/x-raw-float, " + "endianness = (int) BYTE_ORDER, " + "width = (int) 32, " + "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " + "channels = (int) [ 1, 2 ]; " + "audio/x-raw-int, " "signed = (boolean) true, " "width = (int) 16, " "depth = (int) 16, " @@ -355,6 +360,11 @@ twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); 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)) goto no_rate; if (!gst_structure_get_int (structure, "channels", &twolame->num_channels)) @@ -720,27 +730,44 @@ data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); - num_samples = size / 2; + if (twolame->float_input) + num_samples = size / 4; + num_samples = size / 2; /* allocate space for output */ mp3_buffer_size = 1.25 * num_samples + 16384; mp3_data = g_malloc (mp3_buffer_size); if (twolame->num_channels == 1) { - mp3_size = twolame_encode_buffer (twolame->glopts, - (short int *) data, - (short int *) data, num_samples, mp3_data, mp3_buffer_size); + 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, + (short int *) data, + (short int *) data, num_samples, mp3_data, mp3_buffer_size); } else { - mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, - num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts, + num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, } GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", size, mp3_size); - duration = gst_util_uint64_scale_int (size, GST_SECOND, - 2 * twolame->samplerate * twolame->num_channels); + duration = gst_util_uint64_scale_int (size, GST_SECOND, + 4 * twolame->samplerate * twolame->num_channels); + 2 * twolame->samplerate * twolame->num_channels); if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION (buf) != duration) { Index: gsttwolame.h RCS file: /cvs/gstreamer/gst-plugins-bad/ext/twolame/gsttwolame.h,v --- gsttwolame.h 2 Aug 2008 17:39:13 -0000 1.1 +++ gsttwolame.h 7 Aug 2008 14:34:03 -0000 1.2 @@ -56,6 +56,7 @@ gint samplerate; gint num_channels; + gboolean float_input; gboolean setup; gint mode; |