Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Apple AIFF-C pseudo compression in aifc.py #74263

Closed
thruston mannequin opened this issue Apr 15, 2017 · 8 comments
Closed

Support Apple AIFF-C pseudo compression in aifc.py #74263

thruston mannequin opened this issue Apr 15, 2017 · 8 comments
Assignees
Labels
3.11 only security fixes OS-mac stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@thruston
Copy link
Mannequin

thruston mannequin commented Apr 15, 2017

BPO 30077
Nosy @ronaldoussoren, @ned-deily, @ambv, @serhiy-storchaka, @zhangyangyu, @thruston, @dnknth
PRs
  • bpo-30077 Update aifc.py to support Apple AIFF-C "sowt" #1156
  • bpo-30077: Add aifc/sowt pseudo-compression #24449
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2021-08-13.11:33:51.235>
    created_at = <Date 2017-04-15.18:44:39.148>
    labels = ['OS-mac', 'type-feature', 'library', '3.11']
    title = 'Support Apple AIFF-C pseudo compression in aifc.py'
    updated_at = <Date 2021-08-13.20:44:39.965>
    user = 'https://github.com/thruston'

    bugs.python.org fields:

    activity = <Date 2021-08-13.20:44:39.965>
    actor = 'thruston'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2021-08-13.11:33:51.235>
    closer = 'lukasz.langa'
    components = ['Library (Lib)', 'macOS']
    creation = <Date 2017-04-15.18:44:39.148>
    creator = 'thruston'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30077
    keywords = ['patch']
    message_count = 8.0
    messages = ['291727', '291761', '291762', '291766', '386497', '399529', '399530', '399558']
    nosy_count = 7.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'lukasz.langa', 'serhiy.storchaka', 'xiang.zhang', 'thruston', 'yussuf.ozkan']
    pr_nums = ['1156', '24449']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue30077'
    versions = ['Python 3.11']

    @thruston
    Copy link
    Mannequin Author

    thruston mannequin commented Apr 15, 2017

    aifc.py fails to open AIFF files containing the compression type "sowt" in the COMM chunk with an "unsupported compression type" error.

    This compression type is an Apple specific extension that signals that the data is not actually compressed but is stored uncompressed in little Endian order.

    Supporting it would require a trivial change to allow the compression type as a byte-string and to add a do-nothing _convert routine.

    This would allow aifc.py to be used with AIFF files on Apple macOS.

    @thruston thruston mannequin added extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels Apr 15, 2017
    @zhangyangyu
    Copy link
    Member

    Anyway, such a function addition could only get into 3.7.

    @zhangyangyu zhangyangyu added stdlib Python modules in the Lib dir 3.7 (EOL) end of life and removed extension-modules C modules in the Modules dir labels Apr 16, 2017
    @serhiy-storchaka
    Copy link
    Member

    Seems the "sowt" compression is not just a no-op operation. Perhaps it should change a byte order.

    Needed tests and test files for the new compression.

    @serhiy-storchaka serhiy-storchaka self-assigned this Apr 16, 2017
    @thruston
    Copy link
    Mannequin Author

    thruston mannequin commented Apr 16, 2017

    I think it's probably better as a no-op. Currently in my patch I just put

        return data

    You could do

    return data[::-1]
    

    to reverse the sample, so that it came out as big endian, but if you leave it as a no-op then the data is returned in the native format for Intel Mac OS, which is the whole point of the "sowt" encoding. Either way, the user can easily reverse the data in a unpack format if they want to, but in my own testing it seemed easier and simpler just to leave it in the native format. Then basically "it just works".

    The patch as I've proposed it works fine on my MacOS boxes, but I have only tested it with AIFF-C files from one source.

    @ned-deily ned-deily added 3.8 only security fixes and removed 3.7 (EOL) end of life labels Mar 9, 2018
    @dnknth
    Copy link
    Mannequin

    dnknth mannequin commented Feb 4, 2021

    If you read a normal uncompressed AIFF with aifc, the samples are in big-endian order and need to be converted before they can be played on little-endian systems.

    As all other compression schemes produce big-endian data, so should 'SOWT' encoded AIFF. Therefore, the bytes of each sample should be swapped on read and write.

    See also: https://en.wikipedia.org/wiki/Audio_Interchange_File_Format#AIFF_on_Mac_OS_X

    @dnknth dnknth mannequin added the OS-mac label Feb 4, 2021
    @ambv
    Copy link
    Contributor

    ambv commented Aug 13, 2021

    New changeset e4ed9d2 by dnknth in branch 'main':
    bpo-30077: Add support for Apple aifc/sowt pseudo-compression (GH-24449)
    e4ed9d2

    @ambv
    Copy link
    Contributor

    ambv commented Aug 13, 2021

    Thanks for reporting and the initial patch, Toby. And thanks for pushing this across the finish line, Yussuf! ✨ 🍰 ✨

    @ambv ambv added 3.11 only security fixes and removed 3.8 only security fixes labels Aug 13, 2021
    @ambv ambv closed this as completed Aug 13, 2021
    @thruston
    Copy link
    Mannequin Author

    thruston mannequin commented Aug 13, 2021

    Hey! thanks for letting me know, glad it got there in the end. T.

    On Fri, 13 Aug 2021, at 12:33, Łukasz Langa wrote:

    Łukasz Langa <lukasz@langa.pl> added the comment:

    Thanks for reporting and the initial patch, Toby. And thanks for
    pushing this across the finish line, Yussuf! ✨ 🍰 ✨

    ----------
    resolution: -> fixed
    stage: patch review -> resolved
    status: open -> closed
    versions: +Python 3.11 -Python 3.8


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue30077\>


    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes OS-mac stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants