shithub: sox

Download patch

ref: c0b0656453f5051c71db304537ce1aaaf798094f
parent: d25171d7bc90d6a9bc6bc85fed4ac89cfbbd4ecc
author: robs <robs>
date: Sun Dec 3 06:26:26 EST 2006

24-bit support for aiff.

--- a/Changelog
+++ b/Changelog
@@ -40,7 +40,7 @@
   o Fix wav file handler discarding the last PCM sample in certain
     circumstances. (robs)
   o Add support for 24-bit PCM raw, wav (WAVE_FORMAT_EXTENSIBLE) [FR# 801015],
-    & flac files. (robs)
+    aiff, & flac files. (robs)
   o Added alias -1 (for -b), -2 (for -w), -4 (for -l), -8 (for -d). (robs)
   o Remove old, optional rate change and alaw/ulaw conversion code.
     (Reuben Thomas)
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -423,6 +423,12 @@
                     if (bits < 16)
                         st_report("Forcing data size from %d bits to 16 bits",bits);
                 }
+                else if (bits <= 24)
+                {
+                    ft->info.size = ST_SIZE_24BIT;
+                    if (bits < 24)
+                        st_report("Forcing data size from %d bits to 24 bits",bits);
+                }
                 else if (bits <= 32)
                 {
                     ft->info.size = ST_SIZE_DWORD;
@@ -790,6 +796,9 @@
                  ft->info.size == ST_SIZE_WORD)
                 bits = 16;
         else if (ft->info.encoding == ST_ENCODING_SIGN2 && 
+                 ft->info.size == ST_SIZE_24BIT)
+                bits = 24;
+        else if (ft->info.encoding == ST_ENCODING_SIGN2 && 
                  ft->info.size == ST_SIZE_DWORD)
                 bits = 32;
         else
@@ -981,6 +990,9 @@
         else if (ft->info.encoding == ST_ENCODING_SIGN2 && 
                  ft->info.size == ST_SIZE_WORD)
                 bits = 16;
+        else if (ft->info.encoding == ST_ENCODING_SIGN2 && 
+                 ft->info.size == ST_SIZE_24BIT)
+                bits = 24;
         else if (ft->info.encoding == ST_ENCODING_SIGN2 && 
                  ft->info.size == ST_SIZE_DWORD)
                 bits = 32;
--- a/src/misc.c
+++ b/src/misc.c
@@ -344,9 +344,9 @@
 }
 
 
-uint32_t st_swap24(uint32_t udw)
+uint32_t st_swap24(uint24_t udw)
 {
-    return (udw >> 16) | (udw & 0xff00) | ((udw << 16) & 0xff0000L);
+    return ((udw >> 16) & 0xff) | (udw & 0xff00) | ((udw << 16) & 0xff0000L);
 }
 
 double st_swapd(double df)