[LAD] libsndfile-1.0.18pre7 patch

Fons Adriaensen fons at kokkinizita.net
Mon Jun 23 12:53:58 UTC 2008


Libsndfile-1.0.18pre7 has some regression w.r.t. earlier
prereleases.

- When writing a WAVEX it always writes the Ambisonic GUID,
  and sets the channel mask to 0. Since it can also read this
  and you can't get the channel mask value, this will go
  unnoticed until you use some other lib to read the file.

- When reading it always tells you the file is not Ambisionic.

The attached patch will fix this AFAICS.

Ciao,

-- 
FA

Laboratorio di Acustica ed Elettroacustica
Parma, Italia

Wie der Mond heute Nacht aussieht !
Ist es nicht ein seltsames Bild ?
-------------- next part --------------
Common subdirectories: libsndfile-1.0.18pre7.orig/src/FLAC and libsndfile-1.0.18pre7/src/FLAC
Common subdirectories: libsndfile-1.0.18pre7.orig/src/G72x and libsndfile-1.0.18pre7/src/G72x
Common subdirectories: libsndfile-1.0.18pre7.orig/src/GSM610 and libsndfile-1.0.18pre7/src/GSM610
Common subdirectories: libsndfile-1.0.18pre7.orig/src/OGG and libsndfile-1.0.18pre7/src/OGG
diff -u libsndfile-1.0.18pre7.orig/src/sndfile.h.in libsndfile-1.0.18pre7/src/sndfile.h.in
--- libsndfile-1.0.18pre7.orig/src/sndfile.h.in	2006-11-01 04:20:41.000000000 +0100
+++ libsndfile-1.0.18pre7/src/sndfile.h.in	2008-06-21 00:08:30.000000000 +0200
@@ -233,7 +233,7 @@
 	SFM_WRITE	= 0x20,
 	SFM_RDWR	= 0x30,
 
-	SF_AMBISONIC_NONE		= 0x40,
+	SF_AMBISONIC_NONE	= 0x40,
 	SF_AMBISONIC_B_FORMAT	= 0x41
 } ;
 
diff -u libsndfile-1.0.18pre7.orig/src/wav.c libsndfile-1.0.18pre7/src/wav.c
--- libsndfile-1.0.18pre7.orig/src/wav.c	2006-11-09 10:20:29.000000000 +0100
+++ libsndfile-1.0.18pre7/src/wav.c	2008-06-23 13:30:09.000000000 +0200
@@ -167,6 +167,7 @@
 wav_open	 (SF_PRIVATE *psf)
 {	int	format, subformat, error, blockalign = 0, framesperblock = 0 ;
 
+	psf->wavex_ambisonic = SF_AMBISONIC_NONE ;
 	if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
 	{	if ((error = wav_read_header (psf, &blockalign, &framesperblock)))
 			return error ;
@@ -178,7 +179,6 @@
 	{	if (psf->is_pipe)
 			return SFE_NO_PIPE_WRITE ;
 
-		psf->wavex_ambisonic = SF_AMBISONIC_NONE ;
 
 		format = psf->sf.format & SF_FORMAT_TYPEMASK ;
 		if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
@@ -1010,7 +1010,7 @@
 			/* For an Ambisonic file set the channel mask to zero.
 			** Otherwise use a default based on the channel count.
 			*/
-			if (psf->wavex_ambisonic)
+			if (psf->wavex_ambisonic != SF_AMBISONIC_NONE)
 				psf_binheader_writef (psf, "4", 0) ;
 			else
 			{	/*
@@ -1058,14 +1058,16 @@
 		case SF_FORMAT_PCM_16 :
 		case SF_FORMAT_PCM_24 :
 		case SF_FORMAT_PCM_32 :
-			wavex_write_guid (psf, psf->wavex_ambisonic ? &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM
-						: &MSGUID_SUBTYPE_PCM) ;
+		        wavex_write_guid (psf, (psf->wavex_ambisonic != SF_AMBISONIC_NONE)
+                                               ? &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM
+					       : &MSGUID_SUBTYPE_PCM) ;
 			break ;
 
 		case SF_FORMAT_FLOAT :
 		case SF_FORMAT_DOUBLE :
-			wavex_write_guid (psf, psf->wavex_ambisonic ? &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT
-						: &MSGUID_SUBTYPE_IEEE_FLOAT) ;
+		        wavex_write_guid (psf, (psf->wavex_ambisonic != SF_AMBISONIC_NONE)
+                                               ? &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT
+					       : &MSGUID_SUBTYPE_IEEE_FLOAT) ;
 			add_fact_chunk = SF_TRUE ;
 			break ;
 
diff -u libsndfile-1.0.18pre7.orig/src/wav_w64.c libsndfile-1.0.18pre7/src/wav_w64.c
--- libsndfile-1.0.18pre7.orig/src/wav_w64.c	2006-10-30 11:39:56.000000000 +0100
+++ libsndfile-1.0.18pre7/src/wav_w64.c	2008-06-23 13:50:01.000000000 +0200
@@ -78,7 +78,7 @@
 
 static int
 wavex_write_guid_equal (const EXT_SUBFORMAT * first, const EXT_SUBFORMAT * second)
-{	return !memcmp (first, second, sizeof (EXT_SUBFORMAT)) ;
+{      return !memcmp (first, second, sizeof (EXT_SUBFORMAT)) ;
 } /* wavex_write_guid_equal */
 
 
@@ -300,8 +300,11 @@
 				else
 					return SFE_UNIMPLEMENTED ;
 
-				psf->wavex_ambisonic = wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM)
-							|| wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ;
+				if (   wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM)
+				       || wavex_write_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT))
+				    {
+				        psf->wavex_ambisonic = SF_AMBISONIC_B_FORMAT;
+				    }
 				break ;
 
 		case WAVE_FORMAT_G721_ADPCM :


More information about the Linux-audio-dev mailing list