diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:23:21 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-12 18:23:21 +0300 |
commit | 4ae423ded4741b303b7006dcdcd360bec5549fff (patch) | |
tree | 8bdcca607395df8b0f6d61f6dd0469d70b98f053 /Lib/aifc.py | |
parent | 34808e2237a77d88c3f21444e57c3ae68f4d19ca (diff) | |
parent | 4b5325963bd249479cb6b1abe8ffaa75ac5bb80a (diff) | |
download | cpython-git-4ae423ded4741b303b7006dcdcd360bec5549fff.tar.gz |
Issue #19131: The aifc module now correctly reads and writes sampwidth of
compressed streams.
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r-- | Lib/aifc.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index b08775485c..18f236da7a 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -468,15 +468,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' @@ -804,7 +802,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) |