gst/wavenc/gstwavenc.c: Correctly handle width!=depth input.
authorSebastian Dröge <slomo@circular-chaos.org>
Thu, 29 Mar 2007 12:14:22 +0000 (12:14 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Thu, 29 Mar 2007 12:14:22 +0000 (12:14 +0000)
Original commit message from CVS:
* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
(gst_wavenc_sink_setcaps):
Correctly handle width!=depth input.
* gst/wavparse/gstwavparse.c:
Already export in the caps that width==8 uses unsigned samples and
everything else uses signed samples.

ChangeLog
gst/wavenc/gstwavenc.c
gst/wavparse/gstwavparse.c

index d5c5ab2..a84ee4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-03-29  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
+       (gst_wavenc_sink_setcaps):
+       Correctly handle width!=depth input.
+       * gst/wavparse/gstwavparse.c:
+       Already export in the caps that width==8 uses unsigned samples and
+       everything else uses signed samples.
+
 2007-03-29  Wim Taymans  <wim@fluendo.com>
 
        Patch by: Laurent Glayal <spglegle at yahoo dot fr>
index 0ecf2af..d72664a 100644 (file)
@@ -78,14 +78,15 @@ GST_ELEMENT_DETAILS ("WAV audio muxer",
     "rate = (int) [ 1, MAX ], "          \
     "channels = (int) [ 1, 2 ], "        \
     "endianness = (int) LITTLE_ENDIAN, " \
-    "width = (int) 16, "                 \
-    "depth = (int) 16, "                 \
+    "width = (int) { 16, 24, 32 }, "     \
+    "depth = (int) [ 1, 32 ], "          \
     "signed = (boolean) true"            \
     "; "                                 \
     "audio/x-raw-int, "                  \
     "rate = (int) [ 1, MAX ], "          \
     "channels = (int) [ 1, 2 ], "        \
     "width = (int) 8, "                  \
+    "depth = (int) [ 1, 8 ], "           \
     "signed = (boolean) false"
 
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -154,7 +155,6 @@ gst_wavenc_init (GstWavEnc * wavenc, GstWavEncClass * klass)
 
 #define WAV_HEADER_LEN 44
 
-/* FIXME: we are probably not handling depth != width correctly here */
 static GstBuffer *
 gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
 {
@@ -179,11 +179,9 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
   wave.format.len = 16;
 
   wave.common.wFormatTag = WAVE_FORMAT_PCM;
-  wave.common.dwAvgBytesPerSec =
-      wave.common.wChannels * wave.common.dwSamplesPerSec *
-      (wave.common.wBitsPerSample >> 3);
-  wave.common.wBlockAlign =
-      wave.common.wChannels * (wave.common.wBitsPerSample >> 3);
+  wave.common.wBlockAlign = (wavenc->width / 8) * wave.common.wChannels;
+  wave.common.dwAvgBytesPerSec = wave.common.wBlockAlign *
+      wave.common.dwSamplesPerSec;
 
   memcpy (wave.data.id, "data", 4);
   wave.data.len = audio_data_size;
@@ -253,14 +251,14 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
   if (!gst_structure_get_int (structure, "channels", &chans) ||
       !gst_structure_get_int (structure, "rate", &rate) ||
       !gst_structure_get_int (structure, "width", &width) ||
-      (width != 8 && !gst_structure_get_int (structure, "depth", &depth))) {
+      !gst_structure_get_int (structure, "depth", &depth)) {
     GST_WARNING_OBJECT (wavenc, "caps incomplete");
     goto fail;
   }
 
   wavenc->channels = chans;
   wavenc->width = width;
-  wavenc->depth = (width == 8) ? 8 : depth;
+  wavenc->depth = depth;
   wavenc->rate = rate;
 
   GST_LOG_OBJECT (wavenc, "accepted caps: chans=%u width=%u depth=%u rate=%u",
index d3619ae..c0defcd 100644 (file)
@@ -110,11 +110,18 @@ static GstStaticPadTemplate src_template_factory =
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS ("audio/x-raw-int, "
         "endianness = (int) little_endian, "
-        "signed = (boolean) { true, false }, "
-        "width = (int) { 8, 16, 24, 32 }, "
+        "signed = (boolean) true, "
+        "width = (int) { 16, 24, 32 }, "
         "depth = (int) [ 1, 32 ], "
         "rate = (int) [ 8000, 96000 ], "
         "channels = (int) [ 1, 8 ]; "
+        "audio/x-raw-int, "
+        "endianness = (int) little_endian, "
+        "signed = (boolean) false, "
+        "width = (int) 8, "
+        "depth = (int) [ 1, 8 ], "
+        "rate = (int) [ 8000, 96000 ], "
+        "channels = (int) [ 1, 8 ]; "
         "audio/ms-gsm; "
         "audio/mpeg, "
         "mpegversion = (int) 1, "