opuslib-next 1.3.1__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/PKG-INFO +4 -2
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/README.md +2 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/benchmarks/compare_versions.py +4 -2
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/decoder.py +4 -3
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/multistream_decoder.py +4 -3
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/projection_decoder.py +4 -3
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/pyproject.toml +1 -1
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/hl_decoder.py +9 -2
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/hl_multistream.py +4 -2
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/hl_projection.py +4 -2
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/uv.lock +1 -1
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/.github/workflows/ci.yml +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/.github/workflows/performance.yml +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/.github/workflows/release.yml +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/.gitignore +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/LICENSE +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/benchmarks/render_summary.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/__init__.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/__init__.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/ctl.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/encoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/info.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/multistream_encoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/api/projection_encoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/classes.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/constants.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/opuslib_next/exceptions.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/decoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/encoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/hl_encoder.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/multistream.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/projection.py +0 -0
- {opuslib_next-1.3.1 → opuslib_next-1.3.2}/tests/test_exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: opuslib-next
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Python bindings to the libopus, IETF low-delay audio codec
|
|
5
5
|
Project-URL: Homepage, https://github.com/kalicyh/opuslib-next
|
|
6
6
|
Project-URL: Documentation, https://github.com/kalicyh/opuslib-next
|
|
@@ -27,6 +27,8 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
# opuslib-next
|
|
29
29
|
|
|
30
|
+
[](https://pypistats.org/packages/opuslib-next)
|
|
31
|
+
|
|
30
32
|
Python bindings to the libopus, IETF low-delay audio codec.
|
|
31
33
|
|
|
32
34
|
## Installation
|
|
@@ -10,6 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
BENCHMARK_CODE = r"""
|
|
12
12
|
import array
|
|
13
|
+
from importlib.metadata import version
|
|
13
14
|
import json
|
|
14
15
|
import math
|
|
15
16
|
import statistics
|
|
@@ -99,7 +100,8 @@ results = [
|
|
|
99
100
|
]
|
|
100
101
|
|
|
101
102
|
print(json.dumps({
|
|
102
|
-
"package_version":
|
|
103
|
+
"package_version": version("opuslib-next"),
|
|
104
|
+
"package_path": opuslib_next.__file__,
|
|
103
105
|
"results": results,
|
|
104
106
|
}))
|
|
105
107
|
"""
|
|
@@ -147,7 +149,7 @@ def install_requirement(
|
|
|
147
149
|
|
|
148
150
|
|
|
149
151
|
def run_benchmark(python_path: Path) -> dict:
|
|
150
|
-
completed = run([str(python_path), "-c", BENCHMARK_CODE])
|
|
152
|
+
completed = run([str(python_path), "-I", "-c", BENCHMARK_CODE])
|
|
151
153
|
return json.loads(completed.stdout)
|
|
152
154
|
|
|
153
155
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
CTypes mapping between libopus functions and Python.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import array
|
|
6
5
|
import ctypes
|
|
7
6
|
import typing
|
|
8
7
|
|
|
@@ -239,7 +238,8 @@ def decode(
|
|
|
239
238
|
if result < 0:
|
|
240
239
|
raise opuslib_next.exceptions.OpusError(result)
|
|
241
240
|
|
|
242
|
-
|
|
241
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_int16)
|
|
242
|
+
return ctypes.string_at(pcm, byte_count)
|
|
243
243
|
|
|
244
244
|
|
|
245
245
|
libopus_decode_float = opuslib_next.api.libopus.opus_decode_float
|
|
@@ -287,7 +287,8 @@ def decode_float(
|
|
|
287
287
|
if result < 0:
|
|
288
288
|
raise opuslib_next.exceptions.OpusError(result)
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_float)
|
|
291
|
+
return ctypes.string_at(pcm, byte_count)
|
|
291
292
|
|
|
292
293
|
|
|
293
294
|
libopus_ctl = opuslib_next.api.libopus.opus_decoder_ctl
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
CTypes mapping between libopus multistream decoder functions and Python.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import array
|
|
6
5
|
import ctypes
|
|
7
6
|
import functools
|
|
8
7
|
import typing
|
|
@@ -129,7 +128,8 @@ def decode(
|
|
|
129
128
|
if result < 0:
|
|
130
129
|
raise opuslib_next.exceptions.OpusError(result)
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_int16)
|
|
132
|
+
return ctypes.string_at(pcm, byte_count)
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
@functools.lru_cache(maxsize=None)
|
|
@@ -174,7 +174,8 @@ def decode_float(
|
|
|
174
174
|
if result < 0:
|
|
175
175
|
raise opuslib_next.exceptions.OpusError(result)
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_float)
|
|
178
|
+
return ctypes.string_at(pcm, byte_count)
|
|
178
179
|
|
|
179
180
|
|
|
180
181
|
@functools.lru_cache(maxsize=None)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
CTypes mapping between libopus projection decoder functions and Python.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import array
|
|
6
5
|
import ctypes
|
|
7
6
|
import functools
|
|
8
7
|
import typing
|
|
@@ -141,7 +140,8 @@ def decode(
|
|
|
141
140
|
if result < 0:
|
|
142
141
|
raise opuslib_next.OpusError(result)
|
|
143
142
|
|
|
144
|
-
|
|
143
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_int16)
|
|
144
|
+
return ctypes.string_at(pcm, byte_count)
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
@functools.lru_cache(maxsize=None)
|
|
@@ -186,7 +186,8 @@ def decode_float(
|
|
|
186
186
|
if result < 0:
|
|
187
187
|
raise opuslib_next.OpusError(result)
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
byte_count = result * channels * ctypes.sizeof(ctypes.c_float)
|
|
190
|
+
return ctypes.string_at(pcm, byte_count)
|
|
190
191
|
|
|
191
192
|
|
|
192
193
|
@functools.lru_cache(maxsize=None)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Tests for a high-level Decoder object"""
|
|
2
2
|
|
|
3
|
+
import ctypes
|
|
3
4
|
import unittest
|
|
4
5
|
|
|
5
6
|
import opuslib_next
|
|
@@ -79,15 +80,21 @@ class DecoderTest(unittest.TestCase):
|
|
|
79
80
|
self.assertEqual(exc.code, opuslib_next.BUFFER_TOO_SMALL)
|
|
80
81
|
|
|
81
82
|
try:
|
|
82
|
-
decoder.decode(packet, frame_size=
|
|
83
|
+
decoded = decoder.decode(packet, frame_size=1920)
|
|
83
84
|
except opuslib_next.OpusError:
|
|
84
85
|
self.fail('Decode failed')
|
|
85
86
|
|
|
87
|
+
self.assertIsInstance(decoded, bytes)
|
|
88
|
+
self.assertEqual(len(decoded), 960 * 2 * ctypes.sizeof(ctypes.c_int16))
|
|
89
|
+
|
|
86
90
|
def test_decode_float(self):
|
|
87
91
|
decoder = opuslib_next.Decoder(48000, 2)
|
|
88
92
|
packet = bytes([252, 0, 0])
|
|
89
93
|
|
|
90
94
|
try:
|
|
91
|
-
decoder.decode_float(packet, frame_size=
|
|
95
|
+
decoded = decoder.decode_float(packet, frame_size=1920)
|
|
92
96
|
except opuslib_next.OpusError:
|
|
93
97
|
self.fail('Decode failed')
|
|
98
|
+
|
|
99
|
+
self.assertIsInstance(decoded, bytes)
|
|
100
|
+
self.assertEqual(len(decoded), 960 * 2 * ctypes.sizeof(ctypes.c_float))
|
|
@@ -40,9 +40,10 @@ class HighLevelMultiStreamTest(unittest.TestCase):
|
|
|
40
40
|
pcm = b'\x00' * ctypes.sizeof(ctypes.c_int16) * channels * frame_size
|
|
41
41
|
|
|
42
42
|
packet = encoder.encode(pcm, frame_size)
|
|
43
|
-
decoded = decoder.decode(packet, frame_size)
|
|
43
|
+
decoded = decoder.decode(packet, frame_size * 2)
|
|
44
44
|
|
|
45
45
|
self.assertGreater(len(packet), 0)
|
|
46
|
+
self.assertIsInstance(decoded, bytes)
|
|
46
47
|
self.assertEqual(
|
|
47
48
|
len(decoded),
|
|
48
49
|
ctypes.sizeof(ctypes.c_int16) * channels * frame_size
|
|
@@ -58,9 +59,10 @@ class HighLevelMultiStreamTest(unittest.TestCase):
|
|
|
58
59
|
pcm = b'\x00' * ctypes.sizeof(ctypes.c_float) * channels * frame_size
|
|
59
60
|
|
|
60
61
|
packet = encoder.encode_float(pcm, frame_size)
|
|
61
|
-
decoded = decoder.decode_float(packet, frame_size)
|
|
62
|
+
decoded = decoder.decode_float(packet, frame_size * 2)
|
|
62
63
|
|
|
63
64
|
self.assertGreater(len(packet), 0)
|
|
65
|
+
self.assertIsInstance(decoded, bytes)
|
|
64
66
|
self.assertEqual(
|
|
65
67
|
len(decoded),
|
|
66
68
|
ctypes.sizeof(ctypes.c_float) * channels * frame_size
|
|
@@ -72,9 +72,10 @@ class HighLevelProjectionTest(unittest.TestCase):
|
|
|
72
72
|
pcm = b'\x00' * ctypes.sizeof(ctypes.c_int16) * CHANNELS * frame_size
|
|
73
73
|
|
|
74
74
|
packet = encoder.encode(pcm, frame_size)
|
|
75
|
-
decoded = decoder.decode(packet, frame_size)
|
|
75
|
+
decoded = decoder.decode(packet, frame_size * 2)
|
|
76
76
|
|
|
77
77
|
self.assertGreater(len(packet), 0)
|
|
78
|
+
self.assertIsInstance(decoded, bytes)
|
|
78
79
|
self.assertEqual(
|
|
79
80
|
len(decoded),
|
|
80
81
|
ctypes.sizeof(ctypes.c_int16) * CHANNELS * frame_size
|
|
@@ -86,9 +87,10 @@ class HighLevelProjectionTest(unittest.TestCase):
|
|
|
86
87
|
pcm = b'\x00' * ctypes.sizeof(ctypes.c_float) * CHANNELS * frame_size
|
|
87
88
|
|
|
88
89
|
packet = encoder.encode_float(pcm, frame_size)
|
|
89
|
-
decoded = decoder.decode_float(packet, frame_size)
|
|
90
|
+
decoded = decoder.decode_float(packet, frame_size * 2)
|
|
90
91
|
|
|
91
92
|
self.assertGreater(len(packet), 0)
|
|
93
|
+
self.assertIsInstance(decoded, bytes)
|
|
92
94
|
self.assertEqual(
|
|
93
95
|
len(decoded),
|
|
94
96
|
ctypes.sizeof(ctypes.c_float) * CHANNELS * frame_size
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|