ref: e07252d769a2990f8883c30db1c04c649a550376
parent: 2b1a302ecab9325dc84e1e6c91b45d5ff194978d
author: cbagwell <cbagwell>
date: Sat Apr 14 16:27:51 EDT 2001
Removing support for 12bit data type. AIFF's read 12-bit data as if it were 16-bit data since that is how its stored anyways.
--- a/Changelog
+++ b/Changelog
@@ -47,8 +47,7 @@
to use stderr.
o Corrected AU header length value when comments were less than
4 bytes.
- o Added initial support for 12-bit audio data. AIFF files can now read 12-bit audio
- data but can not write it (lacks command line support).
+ o Added support for reading non-standard bit size data from AIFF files.
sox-12.17.1
-----------
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -363,20 +363,28 @@
ft->info.channels = channels;
ft->info.rate = rate;
ft->info.encoding = ST_ENCODING_SIGN2;
- switch (bits) {
- case 8:
- ft->info.size = ST_SIZE_BYTE;
- break;
- case 12:
- ft->info.size = ST_SIZE_12BIT;
- break;
- case 16:
- ft->info.size = ST_SIZE_WORD;
- break;
- default:
- st_fail_errno(ft,ST_EFMT,"unsupported sample size in AIFF header: %d", bits);
- return(ST_EOF);
- /*NOTREACHED*/
+ if (bits <= 8)
+ {
+ ft->info.size = ST_SIZE_BYTE;
+ if (bits < 8)
+ st_report("Forcing data size from %d bits to 8 bits",bits);
+ }
+ else if (bits <= 16)
+ {
+ ft->info.size = ST_SIZE_WORD;
+ if (bits < 16)
+ st_report("Forcing data size from %d bits to 16 bits",bits);
+ }
+ else if (bits <= 32)
+ {
+ ft->info.size = ST_SIZE_DWORD;
+ if (bits < 32)
+ st_report("Forcing data size from %d bits to 32 bits",bits);
+ }
+ else
+ {
+ st_fail_errno(ft,ST_EFMT,"unsupported sample size in AIFF header: %d", bits);
+ return(ST_EOF);
}
} else {
if ((ft->info.channels == -1)
--- a/src/misc.c
+++ b/src/misc.c
@@ -31,7 +31,6 @@
"32-bit floats",
"64-bit floats",
"IEEE floats",
- "12-bit shorts"
};
const char *st_encodings_str[] = {
--- a/src/raw.c
+++ b/src/raw.c
@@ -44,9 +44,6 @@
case ST_SIZE_BYTE:
sample_size = 1;
break;
- case ST_SIZE_12BIT:
- sample_size = sizeof(short);
- break;
case ST_SIZE_WORD:
sample_size = sizeof(short);
break;
@@ -175,24 +172,6 @@
swapn(p,n);
}
-static int blockr_s12bit(p0, n, ft)
-LONG *p0,n;
-ft_t ft;
-{
- LONG x, done;
- short s;
-
- for (done=0; done < n;) {
- blockr(&s, sizeof(short), ft);
- x = s;
- if (ft->file.eof) break;
- /* scale signed up to long's range */
- *p0++ = LEFT(x, 20);
- done++;
- }
- return done;
-}
-
static int blockr_sw(p0, n, ft)
LONG *p0,n;
ft_t ft;
@@ -299,35 +278,6 @@
return 0;
}
break;
- case ST_SIZE_12BIT:
- switch(ft->info.encoding)
- {
- case ST_ENCODING_SIGN2:
- return blockr_s12bit(buf, nsamp, ft);
- case ST_ENCODING_UNSIGNED:
- while(done < nsamp) {
- LONG x;
- unsigned short s;
- blockr(&s, sizeof(short), ft);
- x = s;
- if (ft->file.eof)
- return done;
- /* Convert to signed */
- x ^= 0x8000;
- /* scale signed up to long's range */
- *buf++ = LEFT(x, 20);
- done++;
- }
- return done;
- case ST_ENCODING_ULAW:
- st_fail_errno(ft,ST_EFMT,"No U-Law support for shorts");
- return 0;
- case ST_ENCODING_ALAW:
- st_fail_errno(ft,ST_EFMT,"No A-Law support for shorts");
- return 0;
- }
- break;
-
case ST_SIZE_DWORD:
switch(ft->info.encoding)
{
--- a/src/st.h
+++ b/src/st.h
@@ -181,9 +181,8 @@
#define ST_SIZE_FLOAT 5
#define ST_SIZE_DOUBLE 6
#define ST_SIZE_IEEE 7 /* IEEE 80-bit floats. */
-#define ST_SIZE_12BIT 8
-#define ST_SIZE_MAX 8
+#define ST_SIZE_MAX 7
/* Style field */
#define ST_ENCODING_UNSIGNED 1 /* unsigned linear: Sound Blaster */