opuslib-next 1.3.0__tar.gz → 1.3.1__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.0 → opuslib_next-1.3.1}/.github/workflows/ci.yml +0 -14
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/.github/workflows/release.yml +0 -14
- opuslib_next-1.3.1/.gitignore +9 -0
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/PKG-INFO +2 -2
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/README.md +1 -1
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/benchmarks/compare_versions.py +0 -2
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/benchmarks/render_summary.py +0 -2
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/__init__.py +3 -12
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/__init__.py +2 -11
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/ctl.py +7 -15
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/decoder.py +4 -13
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/encoder.py +2 -11
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/info.py +1 -10
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/multistream_decoder.py +3 -12
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/multistream_encoder.py +2 -11
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/projection_decoder.py +3 -12
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/api/projection_encoder.py +2 -11
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/classes.py +0 -7
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/constants.py +0 -7
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/opuslib_next/exceptions.py +0 -7
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/pyproject.toml +2 -6
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/decoder.py +3 -15
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/encoder.py +1 -19
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/hl_decoder.py +0 -9
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/hl_encoder.py +0 -9
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/hl_multistream.py +1 -6
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/hl_projection.py +1 -6
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/multistream.py +1 -6
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/projection.py +1 -6
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/tests/test_exceptions.py +0 -3
- opuslib_next-1.3.1/uv.lock +156 -0
- opuslib_next-1.3.0/.gitignore +0 -34
- opuslib_next-1.3.0/Makefile +0 -19
- opuslib_next-1.3.0/tests/__init__.py +0 -8
- opuslib_next-1.3.0/uv.lock +0 -695
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/.github/workflows/performance.yml +0 -0
- {opuslib_next-1.3.0 → opuslib_next-1.3.1}/LICENSE +0 -0
|
@@ -40,20 +40,6 @@ jobs:
|
|
|
40
40
|
- name: Sync dependencies
|
|
41
41
|
run: uv sync --dev --frozen --python ${{ matrix.python-version }}
|
|
42
42
|
|
|
43
|
-
- name: Verify libopus APIs
|
|
44
|
-
run: |
|
|
45
|
-
uv run --python ${{ matrix.python-version }} python - <<'PY'
|
|
46
|
-
import opuslib_next.api.multistream_decoder as msd
|
|
47
|
-
import opuslib_next.api.multistream_encoder as mse
|
|
48
|
-
import opuslib_next.api.projection_decoder as pd
|
|
49
|
-
import opuslib_next.api.projection_encoder as pe
|
|
50
|
-
|
|
51
|
-
print("multistream encoder size:", mse.get_size(1, 1))
|
|
52
|
-
print("multistream decoder size:", msd.get_size(1, 1))
|
|
53
|
-
print("projection encoder size:", pe.get_size(4, 3))
|
|
54
|
-
print("projection decoder size:", pd.get_size(4, 2, 2))
|
|
55
|
-
PY
|
|
56
|
-
|
|
57
43
|
- name: Run tests
|
|
58
44
|
run: uv run --python ${{ matrix.python-version }} pytest -q
|
|
59
45
|
|
|
@@ -36,20 +36,6 @@ jobs:
|
|
|
36
36
|
- name: Sync dependencies
|
|
37
37
|
run: uv sync --dev --frozen --python 3.12
|
|
38
38
|
|
|
39
|
-
- name: Verify libopus APIs
|
|
40
|
-
run: |
|
|
41
|
-
uv run --python 3.12 python - <<'PY'
|
|
42
|
-
import opuslib_next.api.multistream_decoder as msd
|
|
43
|
-
import opuslib_next.api.multistream_encoder as mse
|
|
44
|
-
import opuslib_next.api.projection_decoder as pd
|
|
45
|
-
import opuslib_next.api.projection_encoder as pe
|
|
46
|
-
|
|
47
|
-
print("multistream encoder size:", mse.get_size(1, 1))
|
|
48
|
-
print("multistream decoder size:", msd.get_size(1, 1))
|
|
49
|
-
print("projection encoder size:", pe.get_size(4, 3))
|
|
50
|
-
print("projection decoder size:", pd.get_size(4, 2, 2))
|
|
51
|
-
PY
|
|
52
|
-
|
|
53
39
|
- name: Run tests
|
|
54
40
|
run: uv run --python 3.12 pytest -q
|
|
55
41
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opuslib-next
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.1
|
|
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
|
|
@@ -25,7 +25,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
25
25
|
Requires-Python: >=3.10
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
|
|
28
|
-
#
|
|
28
|
+
# opuslib-next
|
|
29
29
|
|
|
30
30
|
Python bindings to the libopus, IETF low-delay audio codec.
|
|
31
31
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
1
|
# OpusLib Python Module.
|
|
5
2
|
|
|
6
3
|
"""
|
|
@@ -16,13 +13,11 @@ Python bindings to the libopus, IETF low-delay audio codec
|
|
|
16
13
|
|
|
17
14
|
"""
|
|
18
15
|
|
|
19
|
-
from .exceptions import OpusError
|
|
20
|
-
|
|
21
|
-
from .constants import * # NOQA
|
|
16
|
+
from .exceptions import OpusError
|
|
22
17
|
|
|
23
|
-
from .constants import
|
|
18
|
+
from .constants import *
|
|
24
19
|
|
|
25
|
-
from .classes import (
|
|
20
|
+
from .classes import (
|
|
26
21
|
Decoder,
|
|
27
22
|
Encoder,
|
|
28
23
|
MultiStreamDecoder,
|
|
@@ -30,7 +25,3 @@ from .classes import ( # NOQA
|
|
|
30
25
|
ProjectionDecoder,
|
|
31
26
|
ProjectionEncoder,
|
|
32
27
|
)
|
|
33
|
-
|
|
34
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
35
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
36
|
-
__license__ = 'BSD 3-Clause License'
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""OpusLib Package."""
|
|
7
2
|
|
|
8
|
-
import ctypes
|
|
3
|
+
import ctypes
|
|
9
4
|
import os
|
|
10
5
|
import platform
|
|
11
|
-
from ctypes.util import find_library
|
|
12
|
-
|
|
13
|
-
__author__ = "kalicyh <kalicyh@qq.com>"
|
|
14
|
-
__copyright__ = "Copyright (c) 2025, Kalicyh"
|
|
15
|
-
__license__ = "BSD 3-Clause License"
|
|
6
|
+
from ctypes.util import find_library
|
|
16
7
|
|
|
17
8
|
|
|
18
9
|
lib_location = find_library("opus")
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
|
|
5
1
|
"""CTL macros rewritten to Python
|
|
6
2
|
|
|
7
3
|
Usage example:
|
|
8
4
|
|
|
9
|
-
>>> import
|
|
10
|
-
>>> import
|
|
11
|
-
>>> dec =
|
|
12
|
-
>>>
|
|
13
|
-
>>> gain_value =
|
|
5
|
+
>>> import opuslib_next.api.decoder
|
|
6
|
+
>>> import opuslib_next.api.ctl
|
|
7
|
+
>>> dec = opuslib_next.api.decoder.create_state(48000, 2)
|
|
8
|
+
>>> opuslib_next.api.decoder.decoder_ctl(dec, opuslib_next.api.ctl.set_gain, -15)
|
|
9
|
+
>>> gain_value = opuslib_next.api.decoder.decoder_ctl(dec, opuslib_next.api.ctl.get_gain)
|
|
14
10
|
|
|
15
11
|
"""
|
|
16
12
|
|
|
17
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
18
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
19
|
-
__license__ = 'BSD 3-Clause License'
|
|
20
|
-
|
|
21
13
|
|
|
22
|
-
import ctypes
|
|
14
|
+
import ctypes
|
|
23
15
|
|
|
24
16
|
import opuslib_next.api
|
|
25
17
|
import opuslib_next.exceptions
|
|
@@ -72,7 +64,7 @@ def ctl_set(request):
|
|
|
72
64
|
#
|
|
73
65
|
|
|
74
66
|
# Resets the codec state to be equivalent to a freshly initialized state
|
|
75
|
-
reset_state = query(opuslib_next.RESET_STATE)
|
|
67
|
+
reset_state = query(opuslib_next.RESET_STATE)
|
|
76
68
|
|
|
77
69
|
# Gets the final state of the codec's entropy coder
|
|
78
70
|
get_final_range = get(
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name,too-few-public-methods
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import typing
|
|
13
8
|
|
|
14
9
|
import opuslib_next
|
|
15
10
|
import opuslib_next.api
|
|
16
11
|
|
|
17
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
18
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
19
|
-
__license__ = 'BSD 3-Clause License'
|
|
20
|
-
|
|
21
12
|
|
|
22
13
|
class Decoder(ctypes.Structure):
|
|
23
14
|
"""Opus decoder state.
|
|
@@ -95,7 +86,7 @@ def packet_get_bandwidth(data: bytes) -> typing.Union[int, typing.Any]:
|
|
|
95
86
|
return result
|
|
96
87
|
|
|
97
88
|
|
|
98
|
-
libopus_packet_get_nb_channels = opuslib_next.api.libopus.opus_packet_get_nb_channels
|
|
89
|
+
libopus_packet_get_nb_channels = opuslib_next.api.libopus.opus_packet_get_nb_channels
|
|
99
90
|
# `argtypes` must be a sequence (,) of types!
|
|
100
91
|
libopus_packet_get_nb_channels.argtypes = (ctypes.c_char_p,)
|
|
101
92
|
libopus_packet_get_nb_channels.restype = ctypes.c_int
|
|
@@ -215,7 +206,7 @@ libopus_decode.restype = ctypes.c_int
|
|
|
215
206
|
|
|
216
207
|
|
|
217
208
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
218
|
-
def decode(
|
|
209
|
+
def decode(
|
|
219
210
|
decoder_state: ctypes.Structure,
|
|
220
211
|
opus_data: bytes,
|
|
221
212
|
length: int,
|
|
@@ -264,7 +255,7 @@ libopus_decode_float.restype = ctypes.c_int
|
|
|
264
255
|
|
|
265
256
|
|
|
266
257
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
267
|
-
def decode_float(
|
|
258
|
+
def decode_float(
|
|
268
259
|
decoder_state: ctypes.Structure,
|
|
269
260
|
opus_data: bytes,
|
|
270
261
|
length: int,
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import typing
|
|
13
8
|
|
|
14
9
|
import opuslib_next
|
|
15
10
|
import opuslib_next.api
|
|
16
11
|
|
|
17
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
18
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
19
|
-
__license__ = 'BSD 3-Clause License'
|
|
20
|
-
|
|
21
12
|
|
|
22
|
-
class Encoder(ctypes.Structure):
|
|
13
|
+
class Encoder(ctypes.Structure):
|
|
23
14
|
"""Opus encoder state.
|
|
24
15
|
This contains the complete state of an Opus encoder.
|
|
25
16
|
"""
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
import ctypes # type: ignore
|
|
1
|
+
import ctypes
|
|
7
2
|
|
|
8
3
|
import opuslib_next.api
|
|
9
4
|
|
|
10
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
11
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
12
|
-
__license__ = 'BSD 3-Clause License'
|
|
13
|
-
|
|
14
5
|
|
|
15
6
|
strerror = opuslib_next.api.libopus.opus_strerror
|
|
16
7
|
strerror.argtypes = (ctypes.c_int,) # must be sequence (,) of types!
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name,too-few-public-methods
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus multistream decoder functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import functools
|
|
13
8
|
import typing
|
|
14
9
|
|
|
15
10
|
import opuslib_next
|
|
16
11
|
import opuslib_next.api
|
|
17
12
|
|
|
18
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
19
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
20
|
-
__license__ = 'BSD 3-Clause License'
|
|
21
|
-
|
|
22
13
|
|
|
23
14
|
class MultiStreamDecoder(ctypes.Structure):
|
|
24
15
|
"""Opus multistream decoder state."""
|
|
@@ -113,7 +104,7 @@ def _libopus_decode():
|
|
|
113
104
|
|
|
114
105
|
|
|
115
106
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
116
|
-
def decode(
|
|
107
|
+
def decode(
|
|
117
108
|
decoder_state: ctypes.Structure,
|
|
118
109
|
opus_data: bytes,
|
|
119
110
|
length: int,
|
|
@@ -158,7 +149,7 @@ def _libopus_decode_float():
|
|
|
158
149
|
|
|
159
150
|
|
|
160
151
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
161
|
-
def decode_float(
|
|
152
|
+
def decode_float(
|
|
162
153
|
decoder_state: ctypes.Structure,
|
|
163
154
|
opus_data: bytes,
|
|
164
155
|
length: int,
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus multistream encoder functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import functools
|
|
13
8
|
import typing
|
|
14
9
|
|
|
15
10
|
import opuslib_next
|
|
16
11
|
import opuslib_next.api
|
|
17
12
|
|
|
18
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
19
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
20
|
-
__license__ = 'BSD 3-Clause License'
|
|
21
|
-
|
|
22
13
|
|
|
23
|
-
class MultiStreamEncoder(ctypes.Structure):
|
|
14
|
+
class MultiStreamEncoder(ctypes.Structure):
|
|
24
15
|
"""Opus multistream encoder state."""
|
|
25
16
|
pass
|
|
26
17
|
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name,too-few-public-methods
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus projection decoder functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import functools
|
|
13
8
|
import typing
|
|
14
9
|
|
|
15
10
|
import opuslib_next
|
|
16
11
|
import opuslib_next.api
|
|
17
12
|
|
|
18
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
19
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
20
|
-
__license__ = 'BSD 3-Clause License'
|
|
21
|
-
|
|
22
13
|
|
|
23
14
|
class ProjectionDecoder(ctypes.Structure):
|
|
24
15
|
"""Opus projection decoder state."""
|
|
@@ -125,7 +116,7 @@ def _libopus_decode():
|
|
|
125
116
|
|
|
126
117
|
|
|
127
118
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
128
|
-
def decode(
|
|
119
|
+
def decode(
|
|
129
120
|
decoder_state: ctypes.Structure,
|
|
130
121
|
opus_data: bytes,
|
|
131
122
|
length: int,
|
|
@@ -170,7 +161,7 @@ def _libopus_decode_float():
|
|
|
170
161
|
|
|
171
162
|
|
|
172
163
|
# FIXME: Remove typing.Any once we have a stub for ctypes
|
|
173
|
-
def decode_float(
|
|
164
|
+
def decode_float(
|
|
174
165
|
decoder_state: ctypes.Structure,
|
|
175
166
|
opus_data: bytes,
|
|
176
167
|
length: int,
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=invalid-name
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""
|
|
7
2
|
CTypes mapping between libopus projection encoder functions and Python.
|
|
8
3
|
"""
|
|
9
4
|
|
|
10
5
|
import array
|
|
11
|
-
import ctypes
|
|
6
|
+
import ctypes
|
|
12
7
|
import functools
|
|
13
8
|
import typing
|
|
14
9
|
|
|
15
10
|
import opuslib_next
|
|
16
11
|
import opuslib_next.api
|
|
17
12
|
|
|
18
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
19
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
20
|
-
__license__ = 'BSD 3-Clause License'
|
|
21
|
-
|
|
22
13
|
|
|
23
|
-
class ProjectionEncoder(ctypes.Structure):
|
|
14
|
+
class ProjectionEncoder(ctypes.Structure):
|
|
24
15
|
"""Opus projection encoder state."""
|
|
25
16
|
pass
|
|
26
17
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
1
|
"""High-level interface to a Opus decoder functions"""
|
|
5
2
|
|
|
6
3
|
import typing
|
|
@@ -15,10 +12,6 @@ import opuslib_next.api.multistream_encoder
|
|
|
15
12
|
import opuslib_next.api.projection_decoder
|
|
16
13
|
import opuslib_next.api.projection_encoder
|
|
17
14
|
|
|
18
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
19
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
20
|
-
__license__ = 'BSD 3-Clause License'
|
|
21
|
-
|
|
22
15
|
|
|
23
16
|
class Decoder(object):
|
|
24
17
|
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
1
|
"""
|
|
5
2
|
OpusLib constants.
|
|
6
3
|
Matches to `opus_defines.h`
|
|
7
4
|
"""
|
|
8
5
|
|
|
9
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
10
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
11
|
-
__license__ = 'BSD 3-Clause License'
|
|
12
|
-
|
|
13
6
|
|
|
14
7
|
# No Error
|
|
15
8
|
OK = 0
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
1
|
"""
|
|
5
2
|
Exceptions for OpusLib.
|
|
6
3
|
"""
|
|
@@ -9,10 +6,6 @@ import typing
|
|
|
9
6
|
|
|
10
7
|
import opuslib_next.api.info
|
|
11
8
|
|
|
12
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
13
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
14
|
-
__license__ = 'BSD 3-Clause License'
|
|
15
|
-
|
|
16
9
|
|
|
17
10
|
class OpusError(Exception):
|
|
18
11
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "opuslib-next"
|
|
7
|
-
version = "1.3.
|
|
7
|
+
version = "1.3.1"
|
|
8
8
|
description = "Python bindings to the libopus, IETF low-delay audio codec"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -35,11 +35,7 @@ Repository = "https://github.com/kalicyh/opuslib-next"
|
|
|
35
35
|
Issues = "https://github.com/kalicyh/opuslib-next/issues"
|
|
36
36
|
|
|
37
37
|
[dependency-groups]
|
|
38
|
-
dev = [
|
|
39
|
-
"build>=1.2.2",
|
|
40
|
-
"pytest>=8.3.5",
|
|
41
|
-
"twine>=6.1.0",
|
|
42
|
-
]
|
|
38
|
+
dev = ["pytest>=8.3.5"]
|
|
43
39
|
|
|
44
40
|
[tool.hatch.build.targets.wheel]
|
|
45
41
|
packages = ["opuslib_next"]
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=missing-docstring
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
import sys
|
|
7
2
|
import unittest
|
|
8
3
|
|
|
@@ -10,10 +5,6 @@ import opuslib_next.api
|
|
|
10
5
|
import opuslib_next.api.decoder
|
|
11
6
|
import opuslib_next.api.ctl
|
|
12
7
|
|
|
13
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
14
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
15
|
-
__license__ = 'BSD 3-Clause License'
|
|
16
|
-
|
|
17
8
|
|
|
18
9
|
class DecoderTest(unittest.TestCase):
|
|
19
10
|
"""Decoder basic API tests
|
|
@@ -67,9 +58,6 @@ class DecoderTest(unittest.TestCase):
|
|
|
67
58
|
else:
|
|
68
59
|
opuslib_next.api.decoder.destroy(dec)
|
|
69
60
|
|
|
70
|
-
# TODO: rewrite this code
|
|
71
|
-
# VG_CHECK(dec,opus_decoder_get_size(2));
|
|
72
|
-
|
|
73
61
|
@classmethod
|
|
74
62
|
def test_get_final_range(cls):
|
|
75
63
|
dec = opuslib_next.api.decoder.create_state(48000, 2)
|
|
@@ -193,19 +181,19 @@ class DecoderTest(unittest.TestCase):
|
|
|
193
181
|
packet = bytes([ixc, jxc])
|
|
194
182
|
|
|
195
183
|
self.assertEqual(
|
|
196
|
-
expected_result if expected_result != 3 else (packet[1] & 63),
|
|
184
|
+
expected_result if expected_result != 3 else (packet[1] & 63),
|
|
197
185
|
opuslib_next.api.decoder.packet_get_nb_frames(packet, 2)
|
|
198
186
|
)
|
|
199
187
|
|
|
200
188
|
def test_packet_get_bandwidth(self):
|
|
201
|
-
"""Tests `
|
|
189
|
+
"""Tests `opuslib_next.api.decoder.packet_get_bandwidth()`."""
|
|
202
190
|
|
|
203
191
|
for ixc in range(0, 256):
|
|
204
192
|
packet = bytes([ixc])
|
|
205
193
|
bwx = ixc >> 4
|
|
206
194
|
|
|
207
195
|
# Very cozy code from the test_opus_api.c
|
|
208
|
-
_bwx = opuslib_next.BANDWIDTH_NARROWBAND + (((((bwx & 7) * 9) & (63 - (bwx & 8))) + 2 + 12 * ((bwx & 8) != 0)) >> 4)
|
|
196
|
+
_bwx = opuslib_next.BANDWIDTH_NARROWBAND + (((((bwx & 7) * 9) & (63 - (bwx & 8))) + 2 + 12 * ((bwx & 8) != 0)) >> 4)
|
|
209
197
|
|
|
210
198
|
self.assertEqual(
|
|
211
199
|
_bwx, opuslib_next.api.decoder.packet_get_bandwidth(packet)
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=missing-docstring
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
import ctypes # type: ignore
|
|
1
|
+
import ctypes
|
|
7
2
|
import sys
|
|
8
3
|
import unittest
|
|
9
4
|
|
|
@@ -11,10 +6,6 @@ import opuslib_next.api
|
|
|
11
6
|
import opuslib_next.api.encoder
|
|
12
7
|
import opuslib_next.api.ctl
|
|
13
8
|
|
|
14
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
15
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
16
|
-
__license__ = 'BSD 3-Clause License'
|
|
17
|
-
|
|
18
9
|
|
|
19
10
|
class EncoderTest(unittest.TestCase):
|
|
20
11
|
"""Encoder basic API tests
|
|
@@ -56,19 +47,10 @@ class EncoderTest(unittest.TestCase):
|
|
|
56
47
|
|
|
57
48
|
enc = opuslib_next.api.encoder.create_state(
|
|
58
49
|
48000, 2, opuslib_next.APPLICATION_RESTRICTED_LOWDELAY)
|
|
59
|
-
# TODO: rewrite that code
|
|
60
|
-
# i = opuslib.api.encoder.encoder_ctl(
|
|
61
|
-
# enc, opuslib.api.ctl.get_lookahead)
|
|
62
|
-
# if(err!=OPUS_OK || i<0 || i>32766)test_failed();
|
|
63
50
|
opuslib_next.api.encoder.destroy(enc)
|
|
64
51
|
|
|
65
52
|
enc = opuslib_next.api.encoder.create_state(
|
|
66
53
|
48000, 2, opuslib_next.APPLICATION_AUDIO)
|
|
67
|
-
# TODO: rewrite that code
|
|
68
|
-
# i = opuslib.api.encoder.encoder_ctl(
|
|
69
|
-
# enc, opuslib.api.ctl.get_lookahead)
|
|
70
|
-
# err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
|
|
71
|
-
# if(err!=OPUS_OK || i<0 || i>32766)test_failed();
|
|
72
54
|
opuslib_next.api.encoder.destroy(enc)
|
|
73
55
|
|
|
74
56
|
@classmethod
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=missing-docstring
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""Tests for a high-level Decoder object"""
|
|
7
2
|
|
|
8
3
|
import unittest
|
|
9
4
|
|
|
10
5
|
import opuslib_next
|
|
11
6
|
|
|
12
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
13
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
14
|
-
__license__ = 'BSD 3-Clause License'
|
|
15
|
-
|
|
16
7
|
|
|
17
8
|
class DecoderTest(unittest.TestCase):
|
|
18
9
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# pylint: disable=missing-docstring
|
|
4
|
-
#
|
|
5
|
-
|
|
6
1
|
"""Tests for a high-level Decoder object"""
|
|
7
2
|
|
|
8
3
|
import unittest
|
|
9
4
|
|
|
10
5
|
import opuslib_next
|
|
11
6
|
|
|
12
|
-
__author__ = 'kalicyh <kalicyh@qq.com>'
|
|
13
|
-
__copyright__ = 'Copyright (c) 2025, Kalicyh'
|
|
14
|
-
__license__ = 'BSD 3-Clause License'
|
|
15
|
-
|
|
16
7
|
|
|
17
8
|
class EncoderTest(unittest.TestCase):
|
|
18
9
|
|