ref: 39fa1f39d257a6317141c6a3efb32ca103e47748
parent: 628b719fe32e26dd16c0b5694acf046da160305e
author: cbagwell <cbagwell>
date: Sun May 8 22:04:34 EDT 2005
Various bugfixes.
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,14 @@
o Gene Mar found typo in polyphase nuttall calculation.
o SMP buffer overflow (detected by gcc 4.0). Reported by Marcus Meissner
and Matthias Saou.
+ o Fixed URL in manpage to resample overviews.
+ o Fixed WAV handler so that it didn't think WAV chunks with max size
+ were invalid chunks. This allows WAV's to be used in pipes since
+ they have to default to max size.
+ o WAV files with alaw or ulaw data don't need extended format chunks.
+ (Lars Immisch)
+ o In AIFF files, fixed problem were short comments should cause
+ AIFF handler to get confused and become misaligned.
sox-12.17.7
-----------
--- a/sox.1
+++ b/sox.1
@@ -1062,7 +1062,7 @@
or
.B polyphase.
If you are wondering which rate changing effects to use, you will want to read a
-detailed analysis of all of them at http://eakaw2.et.tu-dresden.de/~wilde/resample/resample.html
+detailed analysis of all of them at http://leute.server.de/wilde/resample.html
.TP 10
repeat \fIcount\fR
Repeats the audio data \fIcount\fR times. Requires disk space to store the data to be repeated.
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -552,10 +552,12 @@
uint32_t timeStamp;
unsigned short markerId;
unsigned short totalCommentLength = 0;
+ unsigned int totalReadLength = 0;
unsigned int commentIndex;
st_readdw(ft, &chunksize);
st_readw(ft, &numComments);
+ totalReadLength += 2; /* chunksize doesn't count */
for(commentIndex = 0; commentIndex < numComments; commentIndex++) {
unsigned short commentLength;
@@ -580,6 +582,7 @@
return(ST_EOF);
}
*(*text + totalCommentLength) = '\0';
+ totalReadLength += totalCommentLength + 4 + 2 + 2; /* include header */
if (commentLength % 2) {
/* Read past pad byte */
char c;
@@ -590,6 +593,14 @@
}
}
st_report("%-10s \"%s\"\n", chunkDescription, *text);
+ /* make sure we read the whole chunk */
+ if (totalReadLength < chunksize) {
+ int i;
+ char c;
+ for (i=0; i < chunksize - totalReadLength; i++ ) {
+ st_read(ft, &c, 1, 1);
+ }
+ }
return(ST_SUCCESS);
}
--- a/src/wav.c
+++ b/src/wav.c
@@ -394,11 +394,9 @@
/****************************************************************************/
/* General Sox WAV file code */
/****************************************************************************/
-static st_ssize_t findChunk(ft_t ft, const char *Label)
+static int findChunk(ft_t ft, const char *Label, st_size_t *len)
{
char magic[5];
- st_ssize_t len;
- uint32_t tmp_len;
for (;;)
{
if (st_reads(ft, magic, 4) == ST_EOF)
@@ -407,21 +405,26 @@
Label);
return ST_EOF;
}
- st_readdw(ft, &tmp_len);
- len = tmp_len;
st_report("WAV Chunk %s", magic);
+ if (st_readdw(ft, len) == ST_EOF)
+ {
+ st_fail_errno(ft, ST_EHDR, "WAVE file %s chunk is to short",
+ magic);
+ return ST_EOF;
+ }
if (strncmp(Label, magic, 4) == 0)
break; /* Found the data chunk */
/* skip to next chunk */
- if (st_seek(ft, len, SEEK_CUR) != ST_SUCCESS)
+ if (st_seek(ft, *len, SEEK_CUR) != ST_SUCCESS)
{
- st_fail_errno(ft,ST_EHDR, "WAV chunk appears to have invalid size %d.", len);
+ st_fail_errno(ft,ST_EHDR,
+ "WAV chunk appears to have invalid size %d.", *len);
return ST_EOF;
}
}
- return len;
+ return ST_SUCCESS;
}
/*
@@ -480,8 +483,12 @@
}
/* Now look for the format chunk */
- wFmtSize = len = findChunk(ft, "fmt ");
- /* findChunk() only returns if chunk was found */
+ if (findChunk(ft, "fmt ", &len) == ST_EOF)
+ {
+ st_fail_errno(ft,ST_EHDR,"WAVE chunk fmt not found");
+ return ST_EOF;
+ }
+ wFmtSize = len;
if (wFmtSize < 16)
{
@@ -636,8 +643,12 @@
wav->packet = NULL;
wav->samples = NULL;
- /* non-PCM formats have extended fmt chunk. Check for those cases. */
- if (wav->formatTag != WAVE_FORMAT_PCM) {
+ /* non-PCM formats expect alaw and mulaw formats have extended fmt chunk.
+ * Check for those cases.
+ */
+ if (wav->formatTag != WAVE_FORMAT_PCM &&
+ wav->formatTag != WAVE_FORMAT_ALAW &&
+ wav->formatTag != WAVE_FORMAT_MULAW) {
if (len >= 2) {
st_readw(ft, &wExtSize);
len -= 2;
@@ -848,12 +859,12 @@
* the upcoming 'data' chunk */
/* Now look for the wave data chunk */
- dwDataLength = len = findChunk(ft, "data");
- if (len == ST_EOF)
+ if (findChunk(ft, "data", &len) == ST_EOF)
{
st_fail_errno(ft, ST_EOF, "Could not find data chunk.");
return ST_EOF;
}
+ dwDataLength = len;
/* Data starts here */
wav->dataStart = st_tell(ft);
@@ -935,7 +946,7 @@
* offset */
len = (len + 1) & ~1;
if (st_seek(ft, len, SEEK_CUR) == ST_SUCCESS &&
- findChunk(ft, "LIST") != ST_EOF)
+ findChunk(ft, "LIST", &len) != ST_EOF)
{
wav->found_cooledit = 1;
ft->comment = (char*)malloc(256);
@@ -1021,6 +1032,7 @@
else
{
st_report("Attempting to seek beyond unsupported chunk '%c%c%c%c' of length %d bytes\n", magic[0], magic[1], magic[2], magic[3], len);
+ len = (len + 1) & ~1;
st_seek(ft, len, SEEK_CUR);
}
}