Skip to content

Allow specifying code packing order in audioop adpcm functions #76185

Description

@MosesofEgypt
BPO 32004
Nosy @ncoghlan, @serhiy-storchaka
Files
  • adpcm_test.zip: Zip containing an audio file and script to reproduce the issue
  • 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 = None
    closed_at = None
    created_at = <Date 2017-11-10.23:40:07.435>
    labels = ['3.8', 'type-bug', '3.7']
    title = 'Allow specifying code packing order in audioop adpcm functions'
    updated_at = <Date 2018-01-11.00:02:56.035>
    user = 'https://bugs.python.org/MosesofEgypt'

    bugs.python.org fields:

    activity = <Date 2018-01-11.00:02:56.035>
    actor = 'ncoghlan'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2017-11-10.23:40:07.435>
    creator = 'MosesofEgypt'
    dependencies = []
    files = ['47258']
    hgrepos = []
    issue_num = 32004
    keywords = []
    message_count = 4.0
    messages = ['306063', '306488', '308225', '309786']
    nosy_count = 3.0
    nosy_names = ['ncoghlan', 'serhiy.storchaka', 'MosesofEgypt']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32004'
    versions = ['Python 3.7', 'Python 3.8']

    Activity

    1. MosesofEgypt commented on Nov 10, 2017

      MosesofEgyptmannequin
      MannequinAuthor

      --- Issue ---
      audioop.adpcm2lin and audioop.lin2adpcm currently treat the high 4 bits of each byte as the first code and the low 4 as the second code. In practice this is often the opposite.
      http://www.drdobbs.com/database/algorithm-alley/184410326
      https://wiki.multimedia.cx/index.php/Microsoft_IMA_ADPCM

      --- Steps to reproduce ---
      Run the attached script to decompress the attached wav to two different 16bit signed pcm wav files. The "GOOD" one had the nibbles of each code swapped before being decoded, while the "BAD" one didnt.

      --- Suggested fix ---
      I propose an additional optional boolean parameter to these functions to specify which nibble is the first code and which is the second.

      NOTE: I haven't compiled my changes to test as I do not know how to set up a cpython build environment. This commit is more intended to show how to implement the fix.
      https://github.com/MosesofEgypt/cpython/commit/4a5ca65833ec79857f065546ae0d90661ce26f5f

    2. MosesofEgypt commented on Nov 18, 2017

      MosesofEgyptmannequin
      MannequinAuthor

      Changed type to behavior as this is more of a bug fix than an enhancement.

    3. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-featureA feature request or enhancement
      on Nov 18, 2017
    4. MosesofEgypt commented on Dec 13, 2017

      MosesofEgyptmannequin
      MannequinAuthor

      Added serhiy.storchaka to nosy list as the issue has been open for over a month without response(not sure if I should have done this in the first place).

    5. ncoghlan commented on Jan 11, 2018

      @ncoghlan
      Contributor

      Adjusting target versions, as even though the status quo leads to mishandling some input data, the fix is a feature request to make the behaviour configurable, which restricts the change to 3.7+.

    6. transferred this issue fromon Apr 10, 2022
    7. hugovk commented on Apr 11, 2022

      @hugovk
      Member

      Closing, as the audioop module is deprecated in 3.11 and set for removal in 3.13.

      See PEP 594 – Removing dead batteries from the standard library, #91217 and #32392.

    8. AlexWaygood commented on Apr 12, 2022

      @AlexWaygood
      Member

      Closing, as the audioop module is deprecated in 3.11 and set for removal in 3.13.

      See PEP 594 – Removing dead batteries from the standard library, #91217 and #32392.

      Cc. @MosesofEgypt

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of lifetype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions