This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Broken support of compressed AIFC files
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-09-29 19:24 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
aifc_sampwidth.patch serhiy.storchaka, 2013-09-29 19:24 review
pluck-ulaw.aifc serhiy.storchaka, 2013-09-29 19:24 Sample u-law compressed file
Messages (2)
msg198631 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-29 19:24
In u-law and A-law compressed AIFC files the sampleSize field is equal to 8 (bits). The aifc module transparently compress/uncompress audio data to 16-bit, but doesn't support the samplewidth parameter in consistency. This causes two bugs:

1. On read getsampwidth() returns 1, but should return 2 (bytes per sample in uncompressed audio data). readframes() returns twice less data than expected.

>>> import aifc
>>> f = aifc.open('pluck-ulaw.aifc', 'r')
>>> f.getparams()
_aifc_params(nchannels=2, sampwidth=1, framerate=11025, nframes=3307, comptype=b'ulaw', compname=b'')
>>> f.readframes(1)
b',\x02'

f.readframes(1) should return 4 bytes (2 channels, 16-bit uncompressed data).

2. On write wrong value 2 is saved in the sampleSize field. Resulting file is invalid and can't be read in other programs.

Here is a patch and sample file. For tests see issue18919.

I'm sure G722 support is broken too, but I have no any testing files.
msg199576 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-12 15:25
New changeset 567241d794bd by Serhiy Storchaka in branch '2.7':
Issue #19131: The aifc module now correctly reads and writes sampwidth of
http://hg.python.org/cpython/rev/567241d794bd

New changeset 863a92cc9e03 by Serhiy Storchaka in branch '3.3':
Issue #19131: The aifc module now correctly reads and writes sampwidth of
http://hg.python.org/cpython/rev/863a92cc9e03

New changeset cff4dd674efe by Serhiy Storchaka in branch 'default':
Issue #19131: The aifc module now correctly reads and writes sampwidth of
http://hg.python.org/cpython/rev/cff4dd674efe
History
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63330
2013-10-12 18:23:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-10-12 15:25:57python-devsetnosy: + python-dev
messages: + msg199576
2013-10-12 12:55:01serhiy.storchakasetassignee: serhiy.storchaka
2013-09-29 19:31:40serhiy.storchakalinkissue18919 dependencies
2013-09-29 19:24:56serhiy.storchakasetfiles: + pluck-ulaw.aifc
2013-09-29 19:24:02serhiy.storchakacreate