Below is my patch against the latest CVS version of vorbis-tools. It produces oggenc.exe and oggdec.exe that produce correct results for WAV that are not WAVEFORMATEXTENSIBLE, at least when playing in foobar2000 0.9.4.2. I tried the file 6CH.wav ("Left front.... center... right front.... right surround... left surround... LFE"):
6CH.wav -> oggenc.exe -> ENCODED.ogg -> oggdec.exe -> DECODED.wav -> oggenc.exe -> ENCODED2.ogg -> oggdec.exe -> DECODED2.wav
and played all sound files above in foobar2000. The channels sound identical.
I also tried to encode directly from within Foobar2000 and played the resulting file. The channels are placed in a way identical to the other files above.
vorbis-tools-channel-order.patch
diff -urNp vorbis-tools-svn.orig/oggdec/oggdec.c vorbis-tools-svn/oggdec/oggdec.c
--- vorbis-tools-svn.orig/oggdec/oggdec.c Sat Jun 30 00:42:17 2007
+++ vorbis-tools-svn/oggdec/oggdec.c Sat Jun 30 01:10:47 2007
@@ -230,8 +230,8 @@ static FILE *open_output(char *outfile)
static void
permute_channels(char *in, char *out, int len, int channels, int bytespersample)
{
- int permute[6][6] = {{0}, {0,1}, {0,2,1}, {0,1,2,3}, {0,1,2,3,4},
- {0,2,1,5,3,4}};
+ int permute[6][6] = {{0}, {0,1}, {0,2,1}, {0,1,2,3}, {0,2,1,3,4},
+ {0,2,1,4,5,3}};
int i,j,k;
int samples = len/channels/bytespersample;
diff -urNp vorbis-tools-svn.orig/oggenc/audio.c vorbis-tools-svn/oggenc/audio.c
--- vorbis-tools-svn.orig/oggenc/audio.c Sat Jun 30 00:42:18 2007
+++ vorbis-tools-svn/oggenc/audio.c Sat Jun 30 00:51:17 2007
@@ -371,14 +371,21 @@ int wav_id(unsigned char *buf, int len)
return 1;
}
+/*
+using the master channel layout at
+http://www.microsoft.com/whdc/device/audio/multichaud.mspx
+and Vorbis specification (4.3.9)
+http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#id2540617
+*/
+
static int wav_permute_matrix[6][6] =
{
{0},
{0,1},
{0,2,1},
{0,1,2,3},
- {0,1,2,3,4}, /* No equivalent in wav? */
- {0,2,1,5,3,4}
+ {0,2,1,3,4},
+ {0,2,1,4,5,3}
};
int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
I also had problems compiling libogg and libvorbis in MinGW, so, here are my patches for them too:
ogg_size_t.patch
diff -urNp ogg.orig/include/ogg/os_types.h ogg/include/ogg/os_types.h
--- ogg.orig/include/ogg/os_types.h Thu Jun 28 22:19:25 2007
+++ ogg/include/ogg/os_types.h Thu Jun 28 22:20:09 2007
@@ -16,6 +16,9 @@
********************************************************************/
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
+
+/* for size_t */
+#include <stddef.h>
/* make it easy on the folks that want to compile the libs with a
different malloc than stdlib */
vorbis-intl.patch
diff -urNp vorbis-tools.orig/oggdec/Makefile.am vorbis-tools/oggdec/Makefile.am
--- vorbis-tools.orig/oggdec/Makefile.am Fri Jun 29 00:12:20 2007
+++ vorbis-tools/oggdec/Makefile.am Fri Jun 29 00:13:10 2007
@@ -9,9 +9,9 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEF
bin_PROGRAMS = oggdec
-INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @SHARE_CFLAGS@
+INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @SHARE_CFLAGS@ @I18N_CFLAGS@
-oggdec_LDADD = @LIBICONV@ @SHARE_LIBS@ @VORBISFILE_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@
+oggdec_LDADD = @LIBICONV@ @SHARE_LIBS@ @VORBISFILE_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@ @I18N_LIBS@
oggdec_DEPENDENCIES = @SHARE_LIBS@
oggdec_SOURCES = $(oggdecsources)