shithub: sox

Download patch

ref: 3f144c8151678710061922aade7463c1007a9e36
parent: 9b077b5918c053b2ac4d109be02cb27bac3cf27b
author: cbagwell <cbagwell>
date: Wed May 29 22:45:37 EDT 2002

Commited patches from Richard Bannister

--- a/Changelog
+++ b/Changelog
@@ -24,6 +24,8 @@
     effect.
   o Jimen Ching sent in a fix for multi-channel sound file processing
     using the avg effect.
+  o Richards Bannister added patches to clean up prototypes and filter
+    private sizes being to small.
 
 sox-12.17.3
 -----------
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -95,7 +95,7 @@
 	double rate = 0.0;
 	uint32_t offset = 0;
 	uint32_t blocksize = 0;
-	int foundcomm = 0, foundmark = 0, foundinstr = 0;
+	int foundcomm = 0, foundmark = 0, foundinstr = 0, is_sowt = 0;
 	struct mark {
 		unsigned short id;
 		uint32_t position;
@@ -145,7 +145,9 @@
 		if (st_reads(ft, buf, 4) == ST_EOF)
 		{
 			if (ssndsize > 0)
+			{
 				break;
+			}
 			else
 			{
 				st_fail_errno(ft,ST_EHDR,"Missing SSND chunk in AIFF file");
@@ -164,8 +166,14 @@
 			{
 			    st_reads(ft, buf, 4);
 			    chunksize -= 4;
-			    if (strncmp(buf, "NONE", 4) != 0)
+			    if (strncmp(buf, "sowt", 4) == 0)
 			    {
+			    	/* CD audio as read on Mac OS machines */
+			    	/* Need to endian swap all the data */
+			    	is_sowt = 1;
+			    }
+			    else if (strncmp(buf, "NONE", 4) != 0)
+			    {
 				buf[4] = 0;
 				st_fail_errno(ft,ST_EHDR,"Can not support AIFC files that contain compressed data: %s",buf);
 				return(ST_EOF);
@@ -213,7 +221,7 @@
 				st_readb(ft, &len);
 				chunksize -= len + 1;
 				for(j = 0; j < len ; j++) 
-				    st_readb(ft, &(marks[i].name[j]));
+				    st_readb(ft, (unsigned char *)&(marks[i].name[j]));
 				marks[i].name[j] = 0;
 				if ((len & 1) == 0) {
 					chunksize--;
@@ -229,10 +237,10 @@
 		else if (strncmp(buf, "INST", 4) == 0) {
 			/* INST chunk */
 			st_readdw(ft, &chunksize);
-			st_readb(ft, &(ft->instr.MIDInote));
+			st_readb(ft, (unsigned char *)&(ft->instr.MIDInote));
 			st_readb(ft, (unsigned char *)&trash8);
-			st_readb(ft, &(ft->instr.MIDIlow));
-			st_readb(ft, &(ft->instr.MIDIhi));
+			st_readb(ft, (unsigned char *)&(ft->instr.MIDIlow));
+			st_readb(ft, (unsigned char *)&(ft->instr.MIDIhi));
 			/* Low  velocity */
 			st_readb(ft, (unsigned char *)&trash8);
 			/* Hi  velocity */
@@ -402,6 +410,13 @@
 
 	aiff->nsamples = ssndsize / ft->info.size;	/* leave out channels */
 
+	/* Cope with 'sowt' CD tracks as read on Macs */
+	if (is_sowt)
+	{
+		aiff->nsamples -= 4;
+		ft->swap = ft->swap ? 0 : 1;
+	}
+	
 	if (foundmark && !foundinstr)
 	{
 	    st_report("Ignoring MARK chunk since no INSTR found.");
@@ -841,7 +856,7 @@
 		st_fail_errno(ft,ST_EOF,"EOF while reading IEEE extended number");
 		return(ST_EOF);
 	}
-	return ConvertFromIeeeExtended(buf);
+	return ConvertFromIeeeExtended((unsigned char *)buf);
 }
 
 static void write_ieee_extended(ft_t ft, double x)
--- a/src/au.c
+++ b/src/au.c
@@ -225,7 +225,7 @@
                 /* Allocate comment buffer */
 		buf = (char *) malloc(hdr_size+1);		
 		for(i = 0; i < hdr_size; i++) {
-		    	st_readb(ft, &(buf[i]));
+		    	st_readb(ft, (unsigned char *)&(buf[i]));
 			if (feof(ft->fp))
 			{
 				st_fail_errno(ft,ST_EOF,"Unexpected EOF in Sun/NeXT header info.");
--- a/src/auto.c
+++ b/src/auto.c
@@ -57,7 +57,9 @@
 		{
 		    if (strncmp(header + 4, "AIFF", 4) == 0)
 			type = "aiff";
-		    else if (strncmp(header + 4, "8SVX", 4) == 0)
+		    else if (strncmp(header + 4, "AIFC", 4) == 0)
+			type = "aiff";
+			else if (strncmp(header + 4, "8SVX", 4) == 0)
 			type = "8svx";
 		    else if (strncmp(header + 4, "MAUD", 4) == 0)
 			type = "maud";
@@ -118,6 +120,10 @@
 		    }
 		}
 	    }
+	    else if (strncmp(header, "Ogg", 3) == 0)
+	    {
+	    	type = "ogg";
+          }
 	} /* read 4-byte header */
 
 	/* If we didn't find type yet then start looking for file
--- a/src/filter.c
+++ b/src/filter.c
@@ -255,7 +255,7 @@
 		st_sample_t Isamp, Osamp;
 		Isamp = isamp_res;
 		Osamp = osamp_res;
-		st_filter_flow(effp, NULL, Obuf, &Isamp, &Osamp);
+		st_filter_flow(effp, NULL, Obuf, (st_size_t *)&Isamp, (st_size_t *)&Osamp);
 	  /* fprintf(stderr,"DRAIN isamp,osamp  (%d,%d) -> (%d,%d)\n",
 		 * isamp_res,osamp_res,Isamp,Osamp); */
 		Obuf += Osamp;
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -137,8 +137,8 @@
 
 	/* Read dictionary */
 	for(i = 0; i < dictsize; i++) {
-		st_readw(ft, &(p->dictionary[i].dict_leftson));
-		st_readw(ft, &(p->dictionary[i].dict_rightson));
+		st_readw(ft, (unsigned short *)&(p->dictionary[i].dict_leftson));
+		st_readw(ft, (unsigned short *)&(p->dictionary[i].dict_rightson));
 		/*
 		st_report("%d %d",
 		       p->dictionary[i].dict_leftson,
@@ -531,7 +531,7 @@
 	int rc;
 
 	/* Compress it all at once */
-	rc = compress(&compressed_data, &compressed_len, (double) ft->info.rate);
+	rc = compress(&compressed_data, (long *)&compressed_len, (double) ft->info.rate);
 	free((char *) p->data);
 
 	if (rc){
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -14,6 +14,8 @@
 
 #include <string.h>
 
+#if defined(HAVE_LIBMAD) || defined(HAVE_LAME)
+
 #if defined(HAVE_LIBMAD)
 #include <mad.h>
 #endif
@@ -465,3 +467,4 @@
   return ST_EOF;
 }
 #endif /* HAVE_LAME */
+#endif
--- a/src/resample.c
+++ b/src/resample.c
@@ -393,7 +393,7 @@
 		st_sample_t Isamp, Osamp;
 		Isamp = isamp_res;
 		Osamp = osamp_res;
-		rc = st_resample_flow(effp, NULL, Obuf, &Isamp, &Osamp);
+		rc = st_resample_flow(effp, NULL, Obuf, (st_size_t *)&Isamp, (st_size_t *)&Osamp);
 		if (rc)
 		    return rc;
 	  /* fprintf(stderr,"DRAIN isamp,osamp  (%d,%d) -> (%d,%d)\n",
--- a/src/smp.c
+++ b/src/smp.c
@@ -86,9 +86,9 @@
 		st_readdw(ft, &(trailer->loops[i].end));
 		ft->loops[i].length = 
 			trailer->loops[i].end - trailer->loops[i].start;
-		st_readb(ft, &(trailer->loops[i].type));
+		st_readb(ft, (unsigned char *)&(trailer->loops[i].type));
 		ft->loops[i].type = trailer->loops[i].type;
-		st_readw(ft, &(trailer->loops[i].count));
+		st_readw(ft, (unsigned short *)&(trailer->loops[i].count));
 		ft->loops[i].count = trailer->loops[i].count;
 	}
 	for(i = 0; i < 8; i++) {	/* read the 8 markers */
@@ -99,7 +99,7 @@
 		}
 		st_readdw(ft, &(trailer->markers[i].position));
 	}
-	st_readb(ft, &(trailer->MIDInote));
+	st_readb(ft, (unsigned char *)&(trailer->MIDInote));
 	st_readdw(ft, &(trailer->rate));
 	st_readdw(ft, &(trailer->SMPTEoffset));
 	st_readdw(ft, &(trailer->CycleSize));
--- a/src/st.h
+++ b/src/st.h
@@ -114,8 +114,8 @@
  *  Format information for input and output files.
  */
 
-#define ST_MAX_FILE_PRIVSIZE 330
-#define ST_MAX_EFFECT_PRIVSIZE 330
+#define ST_MAX_FILE_PRIVSIZE	1000
+#define ST_MAX_EFFECT_PRIVSIZE 1000
 
 #define ST_MAX_NLOOPS           8
 
--- a/src/stat.c
+++ b/src/stat.c
@@ -429,10 +429,7 @@
    dir =  1 gives forward transform
    dir = -1 gives reverse transform
 */
-int FFT(dir,m,re,im)
-short dir;
-long m;
-double *re,*im;
+int FFT(short dir,long m,double *re,double *im)
 {
    long n,i,i1,j,k,i2,l,l1,l2;
    double c1,c2,tre,tim,t1,t2,u1,u2,z;
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -101,23 +101,23 @@
   sk->rest = num_samp_bytes;	/* set how many sample bytes to read */
 
   /* first 6 bytes are file type ID LM8953 */
-  st_readb(ft, &filetype[0]);
-  st_readb(ft, &filetype[1]);
-  st_readb(ft, &filetype[2]);
-  st_readb(ft, &filetype[3]);
-  st_readb(ft, &filetype[4]);
-  st_readb(ft, &filetype[5]);
+  st_readb(ft, (unsigned char *)&filetype[0]);
+  st_readb(ft, (unsigned char *)&filetype[1]);
+  st_readb(ft, (unsigned char *)&filetype[2]);
+  st_readb(ft, (unsigned char *)&filetype[3]);
+  st_readb(ft, (unsigned char *)&filetype[4]);
+  st_readb(ft, (unsigned char *)&filetype[5]);
   filetype[6] = '\0';
   for( c = 16; c > 0 ; c-- )	/* Discard next 16 bytes */
       st_readb(ft, (unsigned char *)&trash);
-  st_readb(ft, &format);
-  st_readb(ft, &sample_rate);
+  st_readb(ft, (unsigned char *)&format);
+  st_readb(ft, (unsigned char *)&sample_rate);
   /*
    * save next 8 bytes - if sample rate is 0, then we need
    *  to look at gunk[2] and gunk[5] to get real rate
    */
   for( c = 0; c < 8; c++ )
-      st_readb(ft, &(gunk[c]));
+      st_readb(ft, (unsigned char *)&(gunk[c]));
   /*
    * We should now be pointing at start of raw sample data in file 
    */
--- a/src/voc.c
+++ b/src/voc.c
@@ -387,7 +387,7 @@
                     }
                     break;
                 case ST_SIZE_WORD:
-                    st_readw(ft, &sw);
+                    st_readw(ft, (unsigned short *)&sw);
                     if (feof(ft->fp))
                         {
                             st_warn("VOC input: short file");
--- a/src/wav.c
+++ b/src/wav.c
@@ -690,7 +690,7 @@
 	{
 	    int i, errct=0;
 	    for (i=0; len>=2 && i < 2*wav->nCoefs; i++) {
-		st_readw(ft, &(wav->iCoefs[i]));
+		st_readw(ft, (unsigned short *)&(wav->iCoefs[i]));
 		len -= 2;
 		if (i<14) errct += (wav->iCoefs[i] != iCoef[i/2][i%2]);
 		/* fprintf(stderr,"iCoefs[%2d] %4d\n",i,wav->iCoefs[i]); */
--- a/src/wve.c
+++ b/src/wve.c
@@ -67,7 +67,7 @@
                 return (ST_EOF);
         }
 
-        st_readw(ft, &version);
+        st_readw(ft, (unsigned short *)&version);
 
         /* Check for what type endian machine its read on */
         if (version == PSION_INV_VERSION)
@@ -91,9 +91,9 @@
 
         st_readdw(ft, &(p->length));
 
-        st_readw(ft, &(p->padding));
+        st_readw(ft, (unsigned short *)&(p->padding));
 
-        st_readw(ft, &(p->repeats));
+        st_readw(ft, (unsigned short *)&(p->repeats));
 
         (void)st_readw(ft, (unsigned short *)&trash);
         (void)st_readw(ft, (unsigned short *)&trash);