diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 15:21:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 15:21:12 (GMT) |
commit | 986b5ee4d91e81382785b7100a6133ab30787487 (patch) | |
tree | ecc349086bb37b1f304353e2be71e4cba2aaa5d6 /Lib | |
parent | 8b1701d39484c332d57cefe8ce15e10f07b1261d (diff) | |
download | cpython-986b5ee4d91e81382785b7100a6133ab30787487.zip cpython-986b5ee4d91e81382785b7100a6133ab30787487.tar.gz cpython-986b5ee4d91e81382785b7100a6133ab30787487.tar.bz2 |
Issue #19131: The aifc module now correctly reads and writes sampwidth of
compressed streams.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/aifc.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index 12c665f..f4c196c 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -480,7 +480,7 @@ class Aifc_read: pass else: self._convert = self._adpcm2lin - self._framesize = self._framesize // 4 + self._sampwidth = 2 return # for ULAW and ALAW try Compression Library try: @@ -490,21 +490,20 @@ class Aifc_read: try: import audioop self._convert = self._ulaw2lin - self._framesize = self._framesize // 2 + self._sampwidth = 2 return except ImportError: pass raise Error, 'cannot read compressed AIFF-C files' if self._comptype == 'ULAW': scheme = cl.G711_ULAW - self._framesize = self._framesize // 2 elif self._comptype == 'ALAW': scheme = cl.G711_ALAW - self._framesize = self._framesize // 2 else: raise Error, 'unsupported compression type' self._decomp = cl.OpenDecompressor(scheme) self._convert = self._decomp_data + self._sampwidth = 2 else: self._comptype = 'NONE' self._compname = 'not compressed' @@ -867,7 +866,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 ('ULAW', 'ALAW', '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) |