Issue #19131: The aifc module now correctly reads and writes sampwidth of

compressed streams.
This commit is contained in:
Serhiy Storchaka 2013-10-12 18:23:21 +03:00
commit 4ae423ded4
2 changed files with 8 additions and 4 deletions

View File

@ -468,15 +468,13 @@ class Aifc_read:
if self._comptype != b'NONE': if self._comptype != b'NONE':
if self._comptype == b'G722': if self._comptype == b'G722':
self._convert = self._adpcm2lin self._convert = self._adpcm2lin
self._framesize = self._framesize // 4
elif self._comptype in (b'ulaw', b'ULAW'): elif self._comptype in (b'ulaw', b'ULAW'):
self._convert = self._ulaw2lin self._convert = self._ulaw2lin
self._framesize = self._framesize // 2
elif self._comptype in (b'alaw', b'ALAW'): elif self._comptype in (b'alaw', b'ALAW'):
self._convert = self._alaw2lin self._convert = self._alaw2lin
self._framesize = self._framesize // 2
else: else:
raise Error('unsupported compression type') raise Error('unsupported compression type')
self._sampwidth = 2
else: else:
self._comptype = b'NONE' self._comptype = b'NONE'
self._compname = b'not compressed' self._compname = b'not compressed'
@ -804,7 +802,10 @@ class Aifc_write:
_write_short(self._file, self._nchannels) _write_short(self._file, self._nchannels)
self._nframes_pos = self._file.tell() self._nframes_pos = self._file.tell()
_write_ulong(self._file, self._nframes) _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) _write_float(self._file, self._framerate)
if self._aifc: if self._aifc:
self._file.write(self._comptype) self._file.write(self._comptype)

View File

@ -36,6 +36,9 @@ Core and Builtins
Library Library
------- -------
- Issue #19131: The aifc module now correctly reads and writes sampwidth of
compressed streams.
- Issue #19209: Remove import of copyreg from the os module to speed up - Issue #19209: Remove import of copyreg from the os module to speed up
interpreter startup. stat_result and statvfs_result are now hard-coded to interpreter startup. stat_result and statvfs_result are now hard-coded to
reside in the os module. reside in the os module.