shithub: sox

Download patch

ref: f40e25a18472c0afc300c13d8363085cbec05b64
parent: b1d87fb89d426c759c71fe47ace9c025d6384a6c
author: robs <robs>
date: Thu Mar 6 15:37:40 EST 2008

Fix [1187257] wav MS-ADPCM block-align size incorrect

--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
   o Fix short noise at end of alsa playback.  (Morita Sho/Tim Munro/robs)
   o Fix wve seek accuracy.  (robs)
   o Fix lpc10 not working.  (robs)
+  o Fix [1187257] wav MS-ADPCM block-align size incorrect.  (robs)
   o For wav & au, fix [548256] size in header wrong when piping out.  (robs)
   o Writing aiff, aifc & dvms now repeatable with -R.  (robs)
   o Writing hcom no longer fails with unsupported rate--chooses
--- a/src/adpcm.c
+++ b/src/adpcm.c
@@ -311,7 +311,7 @@
         unsigned ch;
         unsigned char *p;
 
-        sox_debug("AdpcmMashI(chans %d, ip %p, n %d, st %p, obuff %p, bA %d)\n",
+        sox_debug_more("AdpcmMashI(chans %d, ip %p, n %d, st %p, obuff %p, bA %d)\n",
             chans, (void *)ip, n, (void *)st, obuff, blockAlign);
 
         for (p=obuff+7*chans; p<obuff+blockAlign; p++) *p=0;
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -159,7 +159,7 @@
 
   format1=wav1u
   convertToAndFrom smp s1 s1X s1N s1XN sndt
-  (rate=5512; convertToAndFrom hcom) || exit 1     # Fixed rate
+  (rate=11025; convertToAndFrom hcom) || exit 1     # Fixed rates
 
   format1=wve
   (rate=8000; convertToAndFrom al s2 u2 s4 raw Raw dat) || exit 1 # Fixed rate
--- a/src/wav.c
+++ b/src/wav.c
@@ -1263,7 +1263,8 @@
                 return SOX_EOF;
             }
             wFormatTag = WAVE_FORMAT_ADPCM;
-            wBlockAlign = wChannels * 128; /* reasonable default */
+            wBlockAlign = ft->signal.rate / 11008;
+            wBlockAlign = max(wBlockAlign, 1) * wChannels * 256;
             wBitsPerSample = 4;
             wExtSize = 4+4*7;      /* Ext fmt data length */
             wSamplesPerBlock = AdpcmSamplesIn(0, wChannels, wBlockAlign, 0);