mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #19641: Added the audioop.byteswap() function to convert big-endian
samples to little-endian and vice versa.
This commit is contained in:
parent
2b38fc187c
commit
3062c9a6c8
10 changed files with 80 additions and 78 deletions
|
@ -5,24 +5,6 @@ import io
|
|||
import pickle
|
||||
import sys
|
||||
|
||||
def byteswap2(data):
|
||||
a = array.array('h')
|
||||
a.frombytes(data)
|
||||
a.byteswap()
|
||||
return a.tobytes()
|
||||
|
||||
def byteswap3(data):
|
||||
ba = bytearray(data)
|
||||
ba[::3] = data[2::3]
|
||||
ba[2::3] = data[::3]
|
||||
return bytes(ba)
|
||||
|
||||
def byteswap4(data):
|
||||
a = array.array('i')
|
||||
a.frombytes(data)
|
||||
a.byteswap()
|
||||
return a.tobytes()
|
||||
|
||||
class UnseekableIO(io.FileIO):
|
||||
def tell(self):
|
||||
raise io.UnsupportedOperation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue