Skip to content

Commit d3fbbd2

Browse files
committed
Make av/core pure
1 parent 7f52190 commit d3fbbd2

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

av/_core.pyx renamed to av/_core.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
cimport libav as lib
1+
import cython
2+
import cython.cimports.libav as lib
23

3-
# Initialise libraries.
44
lib.avdevice_register_all()
55

66
# Exports.
77
time_base = lib.AV_TIME_BASE
88

99

10-
cdef decode_version(v):
10+
@cython.cfunc
11+
def decode_version(v):
1112
if v < 0:
1213
return (-1, -1, -1)
1314

14-
cdef int major = (v >> 16) & 0xff
15-
cdef int minor = (v >> 8) & 0xff
16-
cdef int micro = (v) & 0xff
17-
15+
major: cython.int = (v >> 16) & 0xFF
16+
minor: cython.int = (v >> 8) & 0xFF
17+
micro: cython.int = (v) & 0xFF
1818
return (major, minor, micro)
1919

20+
2021
# Return an informative version string.
2122
# This usually is the actual release version number or a git commit
2223
# description. This string has no fixed format and can change any time. It
@@ -27,37 +28,37 @@
2728
"libavutil": dict(
2829
version=decode_version(lib.avutil_version()),
2930
configuration=lib.avutil_configuration(),
30-
license=lib.avutil_license()
31+
license=lib.avutil_license(),
3132
),
3233
"libavcodec": dict(
3334
version=decode_version(lib.avcodec_version()),
3435
configuration=lib.avcodec_configuration(),
35-
license=lib.avcodec_license()
36+
license=lib.avcodec_license(),
3637
),
3738
"libavformat": dict(
3839
version=decode_version(lib.avformat_version()),
3940
configuration=lib.avformat_configuration(),
40-
license=lib.avformat_license()
41+
license=lib.avformat_license(),
4142
),
4243
"libavdevice": dict(
4344
version=decode_version(lib.avdevice_version()),
4445
configuration=lib.avdevice_configuration(),
45-
license=lib.avdevice_license()
46+
license=lib.avdevice_license(),
4647
),
4748
"libavfilter": dict(
4849
version=decode_version(lib.avfilter_version()),
4950
configuration=lib.avfilter_configuration(),
50-
license=lib.avfilter_license()
51+
license=lib.avfilter_license(),
5152
),
5253
"libswscale": dict(
5354
version=decode_version(lib.swscale_version()),
5455
configuration=lib.swscale_configuration(),
55-
license=lib.swscale_license()
56+
license=lib.swscale_license(),
5657
),
5758
"libswresample": dict(
5859
version=decode_version(lib.swresample_version()),
5960
configuration=lib.swresample_configuration(),
60-
license=lib.swresample_license()
61+
license=lib.swresample_license(),
6162
),
6263
}
6364

0 commit comments

Comments
 (0)