]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19131: The aifc module now correctly reads and writes sampwidth of
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 12 Oct 2013 15:21:33 +0000 (18:21 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 12 Oct 2013 15:21:33 +0000 (18:21 +0300)
compressed streams.

Lib/aifc.py
Misc/NEWS

index 3270047b11359a2efb9bdee16da178fba945dae9..86a5edc8c987ce4d9a6af68874af343d19fe3ecf 100644 (file)
@@ -457,15 +457,13 @@ class Aifc_read:
             if self._comptype != b'NONE':
                 if self._comptype == b'G722':
                     self._convert = self._adpcm2lin
-                    self._framesize = self._framesize // 4
                 elif self._comptype in (b'ulaw', b'ULAW'):
                     self._convert = self._ulaw2lin
-                    self._framesize = self._framesize // 2
                 elif self._comptype in (b'alaw', b'ALAW'):
                     self._convert = self._alaw2lin
-                    self._framesize = self._framesize // 2
                 else:
                     raise Error('unsupported compression type')
+                self._sampwidth = 2
         else:
             self._comptype = b'NONE'
             self._compname = b'not compressed'
@@ -787,7 +785,10 @@ class Aifc_write:
         _write_short(self._file, self._nchannels)
         self._nframes_pos = self._file.tell()
         _write_ulong(self._file, self._nframes)
-        _write_short(self._file, self._sampwidth * 8)
+        if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
+            _write_short(self._file, 8)
+        else:
+            _write_short(self._file, self._sampwidth * 8)
         _write_float(self._file, self._framerate)
         if self._aifc:
             self._file.write(self._comptype)
index 56fd0a560fc1072d90ae13cc4e07ed6cd092a154..08ebbbd987d08e1394ca9b52333eacb44109dfb5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -76,6 +76,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #19131: The aifc module now correctly reads and writes sampwidth of
+  compressed streams.
+
 - Issue #19158:  a rare race in BoundedSemaphore could allow .release() too
   often.