gst/wavenc/gstwavenc.*: Add support for float/double as input and remove the (nowaday...
authorSebastian Dröge <slomo@circular-chaos.org>
Thu, 30 Oct 2008 15:08:49 +0000 (15:08 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Thu, 30 Oct 2008 15:08:49 +0000 (15:08 +0000)
Original commit message from CVS:
* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
(gst_wavenc_sink_setcaps), (gst_wavenc_change_state):
* gst/wavenc/gstwavenc.h:
Add support for float/double as input and remove the (nowadays)
useless parsing of the depth as we require width==depth.

ChangeLog
common
gst/wavenc/gstwavenc.c
gst/wavenc/gstwavenc.h

index fa19514..c70f004 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-30  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
+       (gst_wavenc_sink_setcaps), (gst_wavenc_change_state):
+       * gst/wavenc/gstwavenc.h:
+       Add support for float/double as input and remove the (nowadays)
+       useless parsing of the depth as we require width==depth.
+
 2008-10-30  Wim Taymans  <wim.taymans@collabora.co.uk>
 
        * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_setcaps):
diff --git a/common b/common
index 2802bb1..edfb4b4 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2802bb17517a6cfbbb1be6da61ec19151be0750b
+Subproject commit edfb4b44ea433b0b83b8a2f27a6e0bcbccdc3f2f
index b91ca12..f923580 100644 (file)
@@ -32,6 +32,7 @@ GST_DEBUG_CATEGORY_STATIC (wavenc_debug);
 #define GST_CAT_DEFAULT wavenc_debug
 
 #define WAVE_FORMAT_PCM 0x0001
+#define WAVE_FORMAT_FLOAT 0x0003
 
 struct riff_struct
 {
@@ -103,7 +104,13 @@ GST_ELEMENT_DETAILS ("WAV audio muxer",
     "channels = (int) [ 1, 2 ], "        \
     "width = (int) 8, "                  \
     "depth = (int) 8, "                  \
-    "signed = (boolean) false"
+    "signed = (boolean) false"           \
+    "; "                                 \
+    "audio/x-raw-float, "                \
+    "rate = (int) [ 1, MAX ], "          \
+    "channels = (int) [ 1, 2 ], "        \
+    "endianness = (int) LITTLE_ENDIAN, " \
+    "width = (int) { 32, 64 } "
 
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -183,7 +190,7 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
   memset (header, 0, WAV_HEADER_LEN);
 
   wave.common.wChannels = wavenc->channels;
-  wave.common.wBitsPerSample = wavenc->depth;
+  wave.common.wBitsPerSample = wavenc->width;
   wave.common.dwSamplesPerSec = wavenc->rate;
 
   /* Fill out our wav-header with some information */
@@ -194,7 +201,7 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
   memcpy (wave.format.id, "fmt ", 4);
   wave.format.len = 16;
 
-  wave.common.wFormatTag = WAVE_FORMAT_PCM;
+  wave.common.wFormatTag = (wavenc->fp) ? WAVE_FORMAT_FLOAT : WAVE_FORMAT_PCM;
   wave.common.wBlockAlign = (wavenc->width / 8) * wave.common.wChannels;
   wave.common.dwAvgBytesPerSec =
       wave.common.wBlockAlign * wave.common.dwSamplesPerSec;
@@ -252,7 +259,7 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
 {
   GstWavEnc *wavenc;
   GstStructure *structure;
-  gint chans, rate, width, depth;
+  gint chans, rate, width;
 
   wavenc = GST_WAVENC (gst_pad_get_parent (pad));
 
@@ -266,19 +273,21 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
   structure = gst_caps_get_structure (caps, 0);
   if (!gst_structure_get_int (structure, "channels", &chans) ||
       !gst_structure_get_int (structure, "rate", &rate) ||
-      !gst_structure_get_int (structure, "width", &width) ||
-      !gst_structure_get_int (structure, "depth", &depth)) {
+      !gst_structure_get_int (structure, "width", &width)) {
     GST_WARNING_OBJECT (wavenc, "caps incomplete");
     goto fail;
   }
 
+  wavenc->fp =
+      (g_str_equal (gst_structure_get_name (structure), "audio/x-raw-float"));
+
   wavenc->channels = chans;
-  wavenc->depth = depth;
   wavenc->width = width;
   wavenc->rate = rate;
 
-  GST_LOG_OBJECT (wavenc, "accepted caps: chans=%u width=%u depth=%u rate=%u",
-      wavenc->channels, wavenc->width, wavenc->depth, wavenc->rate);
+  GST_LOG_OBJECT (wavenc,
+      "accepted caps: chans=%u width=%u rate=%u floating point=%d",
+      wavenc->channels, wavenc->width, wavenc->rate, wavenc->fp);
 
   gst_object_unref (wavenc);
   return TRUE;
@@ -653,10 +662,10 @@ gst_wavenc_change_state (GstElement * element, GstStateChange transition)
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
       wavenc->channels = 0;
-      wavenc->depth = 0;
       wavenc->width = 0;
       wavenc->rate = 0;
       wavenc->length = 0;
+      wavenc->fp = FALSE;
       wavenc->sent_header = FALSE;
       break;
     default:
index 4185c0d..eef7e60 100644 (file)
@@ -48,10 +48,10 @@ struct _GstWavEnc {
 
   /* useful audio data */
   guint      width;
-  guint      depth;
   guint      rate;
   guint      channels;
   guint32    length;
+  gboolean   fp;
 
   gboolean   sent_header;
 };