slomo gst-plugins-good: gst-plugins-good/ gst-plugins-good/gst/wavenc/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-good
Changes by:     slomo
Date:           Thu Nov 27 2008  12:13:54 UTC

Log message:
Patch by: Pepijn Van Eeckhoudt
<pepijn dot vaneeckhoudt at luciad dot com>
* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
(gst_wavenc_sink_setcaps), (gst_wavenc_change_state):
* gst/wavenc/gstwavenc.h:
* gst/wavenc/riff.h:
Add support for a-law and mu-law encoded wav files. Fixes bug #562434.

Modified files:
    .               : ChangeLog
    gst/wavenc      : gstwavenc.c gstwavenc.h riff.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3838&r2=1.3839
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/wavenc/gstwavenc.c.diff?r1=1.64&r2=1.65
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/wavenc/gstwavenc.h.diff?r1=1.14&r2=1.15
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/wavenc/riff.h.diff?r1=1.9&r2=1.10

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v
retrieving revision 1.3838
retrieving revision 1.3839
diff -u -d -r1.3838 -r1.3839
--- ChangeLog	27 Nov 2008 11:22:54 -0000	1.3838
+++ ChangeLog	27 Nov 2008 12:13:37 -0000	1.3839
@@ -1,3 +1,14 @@
+2008-11-27  Sebastian Dröge  <[email protected]>
+
+	Patch by: Pepijn Van Eeckhoudt
+	              <pepijn dot vaneeckhoudt at luciad dot com>
+	* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
+	(gst_wavenc_sink_setcaps), (gst_wavenc_change_state):
+	* gst/wavenc/gstwavenc.h:
+	* gst/wavenc/riff.h:
+	Add support for a-law and mu-law encoded wav files. Fixes bug #562434.
 2008-11-27  Wim Taymans  <[email protected]>
 
 	Patch by: 이문형 <iwings at gmail dot com>
Index: gstwavenc.c
RCS file: /cvs/gstreamer/gst-plugins-good/gst/wavenc/gstwavenc.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- gstwavenc.c	30 Oct 2008 15:08:49 -0000	1.64
+++ gstwavenc.c	27 Nov 2008 12:13:39 -0000	1.65
@@ -31,9 +31,6 @@
 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
 {
   guint8 id[4];                 /* RIFF */
@@ -110,7 +107,20 @@
     "rate = (int) [ 1, MAX ], "          \
     "channels = (int) [ 1, 2 ], "        \
     "endianness = (int) LITTLE_ENDIAN, " \
-    "width = (int) { 32, 64 } "
+    "width = (int) { 32, 64 }; "         \
+    "audio/x-alaw, "                     \
+    "rate = (int) [ 8000, 192000 ], "    \
+    "channels = (int) [ 1, 2 ], "        \
+    "width = (int) 8, "                  \
+    "depth = (int) 8, "                  \
+    "signed = (boolean) false; "         \
+    "audio/x-mulaw, "                    \
+    "signed = (boolean) false"
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -201,7 +211,7 @@
   memcpy (wave.format.id, "fmt ", 4);
   wave.format.len = 16;
-  wave.common.wFormatTag = (wavenc->fp) ? WAVE_FORMAT_FLOAT : WAVE_FORMAT_PCM;
+  wave.common.wFormatTag = wavenc->format;
   wave.common.wBlockAlign = (wavenc->width / 8) * wave.common.wChannels;
   wave.common.dwAvgBytesPerSec =
       wave.common.wBlockAlign * wave.common.dwSamplesPerSec;
@@ -259,6 +269,7 @@
   GstWavEnc *wavenc;
   GstStructure *structure;
+  const gchar *name;
   gint chans, rate, width;
   wavenc = GST_WAVENC (gst_pad_get_parent (pad));
@@ -271,23 +282,45 @@
   GST_DEBUG_OBJECT (wavenc, "got caps: %" GST_PTR_FORMAT, caps);
   structure = gst_caps_get_structure (caps, 0);
+  name = gst_structure_get_name (structure);
   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, "rate", &rate)) {
     GST_WARNING_OBJECT (wavenc, "caps incomplete");
     goto fail;
   }
-  wavenc->fp =
-      (g_str_equal (gst_structure_get_name (structure), "audio/x-raw-float"));
+  if (strcmp (name, "audio/x-raw-int") == 0) {
+    if (!gst_structure_get_int (structure, "width", &width)) {
+      GST_WARNING_OBJECT (wavenc, "caps incomplete");
+      goto fail;
+    }
+    wavenc->format = GST_RIFF_WAVE_FORMAT_PCM;
+    wavenc->width = width;
+  } else if (strcmp (name, "audio/x-raw-float") == 0) {
+    wavenc->format = GST_RIFF_WAVE_FORMAT_FLOAT;
+  } else if (strcmp (name, "audio/x-alaw") == 0) {
+    wavenc->format = GST_RIFF_WAVE_FORMAT_ALAW;
+    wavenc->width = 8;
+  } else if (strcmp (name, "audio/x-mulaw") == 0) {
+    wavenc->format = GST_RIFF_WAVE_FORMAT_MULAW;
+  } else {
+    GST_WARNING_OBJECT (wavenc, "Unsupported format %s", name);
+    goto fail;
+  }
   wavenc->channels = chans;
-  wavenc->width = width;
   wavenc->rate = rate;
   GST_LOG_OBJECT (wavenc,
-      "accepted caps: chans=%u width=%u rate=%u floating point=%d",
-      wavenc->channels, wavenc->width, wavenc->rate, wavenc->fp);
+      "accepted caps: format=0x%04x chans=%u width=%u rate=%u",
+      wavenc->format, wavenc->channels, wavenc->width, wavenc->rate);
   gst_object_unref (wavenc);
   return TRUE;
@@ -661,11 +694,11 @@
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+      wavenc->format = 0;
       wavenc->channels = 0;
       wavenc->width = 0;
       wavenc->rate = 0;
       wavenc->length = 0;
-      wavenc->fp = FALSE;
       wavenc->sent_header = FALSE;
       break;
     default:
Index: gstwavenc.h
RCS file: /cvs/gstreamer/gst-plugins-good/gst/wavenc/gstwavenc.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gstwavenc.h	30 Oct 2008 15:08:49 -0000	1.14
+++ gstwavenc.h	27 Nov 2008 12:13:39 -0000	1.15
@@ -47,11 +47,11 @@
   GstPad    *srcpad;
   /* useful audio data */
+  guint16    format;
   guint      width;
   guint      rate;
   guint      channels;
   guint32    length;
-  gboolean   fp;
   gboolean   sent_header;
 };
Index: riff.h
RCS file: /cvs/gstreamer/gst-plugins-good/gst/wavenc/riff.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- riff.h	6 Dec 2005 19:44:56 -0000	1.9
+++ riff.h	27 Nov 2008 12:13:39 -0000	1.10
@@ -300,6 +300,7 @@
 #define GST_RIFF_WAVE_FORMAT_UNKNOWN        (0x0000)
 #define GST_RIFF_WAVE_FORMAT_PCM            (0x0001)
 #define GST_RIFF_WAVE_FORMAT_ADPCM          (0x0002)
+#define GST_RIFF_WAVE_FORMAT_FLOAT          (0x0003)
 #define GST_RIFF_WAVE_FORMAT_IBM_CVSD       (0x0005)
 #define GST_RIFF_WAVE_FORMAT_ALAW           (0x0006)
 #define GST_RIFF_WAVE_FORMAT_MULAW          (0x0007)

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.