1 /* Generated by Cython 0.29.21 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "depends": [
7 "/opt/hostedtoolcache/Python/3.7.9/x64/include/python3.7m/Python.h",
8 "/tmp/vendor/include/libavcodec/avcodec.h",
9 "/tmp/vendor/include/libavdevice/avdevice.h",
10 "/tmp/vendor/include/libavfilter/avfilter.h",
11 "/tmp/vendor/include/libavfilter/buffersink.h",
12 "/tmp/vendor/include/libavfilter/buffersrc.h",
13 "/tmp/vendor/include/libavformat/avformat.h",
14 "/tmp/vendor/include/libavutil/audio_fifo.h",
15 "/tmp/vendor/include/libavutil/avutil.h",
16 "/tmp/vendor/include/libavutil/channel_layout.h",
17 "/tmp/vendor/include/libavutil/dict.h",
18 "/tmp/vendor/include/libavutil/error.h",
19 "/tmp/vendor/include/libavutil/frame.h",
20 "/tmp/vendor/include/libavutil/imgutils.h",
21 "/tmp/vendor/include/libavutil/log.h",
22 "/tmp/vendor/include/libavutil/mathematics.h",
23 "/tmp/vendor/include/libavutil/motion_vector.h",
24 "/tmp/vendor/include/libavutil/opt.h",
25 "/tmp/vendor/include/libavutil/pixdesc.h",
26 "/tmp/vendor/include/libavutil/rational.h",
27 "/tmp/vendor/include/libavutil/samplefmt.h",
28 "/tmp/vendor/include/libswresample/swresample.h",
29 "/tmp/vendor/include/libswscale/swscale.h",
30 "build/temp.linux-x86_64-3.7/include/pyav/config.h"
31 ],
32 "include_dirs": [
33 "/tmp/vendor/include",
34 "build/temp.linux-x86_64-3.7/include",
35 "/opt/hostedtoolcache/Python/3.7.9/x64/include/python3.7m",
36 "include"
37 ],
38 "libraries": [
39 "avutil",
40 "avcodec",
41 "avdevice",
42 "swscale",
43 "swresample",
44 "avformat",
45 "avfilter"
46 ],
47 "library_dirs": [
48 "/opt/hostedtoolcache/Python/3.7.9/x64/lib",
49 "/tmp/vendor/lib"
50 ],
51 "name": "av.video.reformatter",
52 "sources": [
53 "av/video/reformatter.pyx"
54 ]
55 },
56 "module_name": "av.video.reformatter"
57 }
58 END: Cython Metadata */
59
60 #define PY_SSIZE_T_CLEAN
61 #include "Python.h"
62 #ifndef Py_PYTHON_H
63 #error Python headers needed to compile C extensions, please install development version of Python.
64 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
65 #error Cython requires Python 2.6+ or Python 3.3+.
66 #else
67 #define CYTHON_ABI "0_29_21"
68 #define CYTHON_HEX_VERSION 0x001D15F0
69 #define CYTHON_FUTURE_DIVISION 0
70 #include <stddef.h>
71 #ifndef offsetof
72 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
73 #endif
74 #if !defined(WIN32) && !defined(MS_WINDOWS)
75 #ifndef __stdcall
76 #define __stdcall
77 #endif
78 #ifndef __cdecl
79 #define __cdecl
80 #endif
81 #ifndef __fastcall
82 #define __fastcall
83 #endif
84 #endif
85 #ifndef DL_IMPORT
86 #define DL_IMPORT(t) t
87 #endif
88 #ifndef DL_EXPORT
89 #define DL_EXPORT(t) t
90 #endif
91 #define __PYX_COMMA ,
92 #ifndef HAVE_LONG_LONG
93 #if PY_VERSION_HEX >= 0x02070000
94 #define HAVE_LONG_LONG
95 #endif
96 #endif
97 #ifndef PY_LONG_LONG
98 #define PY_LONG_LONG LONG_LONG
99 #endif
100 #ifndef Py_HUGE_VAL
101 #define Py_HUGE_VAL HUGE_VAL
102 #endif
103 #ifdef PYPY_VERSION
104 #define CYTHON_COMPILING_IN_PYPY 1
105 #define CYTHON_COMPILING_IN_PYSTON 0
106 #define CYTHON_COMPILING_IN_CPYTHON 0
107 #undef CYTHON_USE_TYPE_SLOTS
108 #define CYTHON_USE_TYPE_SLOTS 0
109 #undef CYTHON_USE_PYTYPE_LOOKUP
110 #define CYTHON_USE_PYTYPE_LOOKUP 0
111 #if PY_VERSION_HEX < 0x03050000
112 #undef CYTHON_USE_ASYNC_SLOTS
113 #define CYTHON_USE_ASYNC_SLOTS 0
114 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
115 #define CYTHON_USE_ASYNC_SLOTS 1
116 #endif
117 #undef CYTHON_USE_PYLIST_INTERNALS
118 #define CYTHON_USE_PYLIST_INTERNALS 0
119 #undef CYTHON_USE_UNICODE_INTERNALS
120 #define CYTHON_USE_UNICODE_INTERNALS 0
121 #undef CYTHON_USE_UNICODE_WRITER
122 #define CYTHON_USE_UNICODE_WRITER 0
123 #undef CYTHON_USE_PYLONG_INTERNALS
124 #define CYTHON_USE_PYLONG_INTERNALS 0
125 #undef CYTHON_AVOID_BORROWED_REFS
126 #define CYTHON_AVOID_BORROWED_REFS 1
127 #undef CYTHON_ASSUME_SAFE_MACROS
128 #define CYTHON_ASSUME_SAFE_MACROS 0
129 #undef CYTHON_UNPACK_METHODS
130 #define CYTHON_UNPACK_METHODS 0
131 #undef CYTHON_FAST_THREAD_STATE
132 #define CYTHON_FAST_THREAD_STATE 0
133 #undef CYTHON_FAST_PYCALL
134 #define CYTHON_FAST_PYCALL 0
135 #undef CYTHON_PEP489_MULTI_PHASE_INIT
136 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
137 #undef CYTHON_USE_TP_FINALIZE
138 #define CYTHON_USE_TP_FINALIZE 0
139 #undef CYTHON_USE_DICT_VERSIONS
140 #define CYTHON_USE_DICT_VERSIONS 0
141 #undef CYTHON_USE_EXC_INFO_STACK
142 #define CYTHON_USE_EXC_INFO_STACK 0
143 #elif defined(PYSTON_VERSION)
144 #define CYTHON_COMPILING_IN_PYPY 0
145 #define CYTHON_COMPILING_IN_PYSTON 1
146 #define CYTHON_COMPILING_IN_CPYTHON 0
147 #ifndef CYTHON_USE_TYPE_SLOTS
148 #define CYTHON_USE_TYPE_SLOTS 1
149 #endif
150 #undef CYTHON_USE_PYTYPE_LOOKUP
151 #define CYTHON_USE_PYTYPE_LOOKUP 0
152 #undef CYTHON_USE_ASYNC_SLOTS
153 #define CYTHON_USE_ASYNC_SLOTS 0
154 #undef CYTHON_USE_PYLIST_INTERNALS
155 #define CYTHON_USE_PYLIST_INTERNALS 0
156 #ifndef CYTHON_USE_UNICODE_INTERNALS
157 #define CYTHON_USE_UNICODE_INTERNALS 1
158 #endif
159 #undef CYTHON_USE_UNICODE_WRITER
160 #define CYTHON_USE_UNICODE_WRITER 0
161 #undef CYTHON_USE_PYLONG_INTERNALS
162 #define CYTHON_USE_PYLONG_INTERNALS 0
163 #ifndef CYTHON_AVOID_BORROWED_REFS
164 #define CYTHON_AVOID_BORROWED_REFS 0
165 #endif
166 #ifndef CYTHON_ASSUME_SAFE_MACROS
167 #define CYTHON_ASSUME_SAFE_MACROS 1
168 #endif
169 #ifndef CYTHON_UNPACK_METHODS
170 #define CYTHON_UNPACK_METHODS 1
171 #endif
172 #undef CYTHON_FAST_THREAD_STATE
173 #define CYTHON_FAST_THREAD_STATE 0
174 #undef CYTHON_FAST_PYCALL
175 #define CYTHON_FAST_PYCALL 0
176 #undef CYTHON_PEP489_MULTI_PHASE_INIT
177 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
178 #undef CYTHON_USE_TP_FINALIZE
179 #define CYTHON_USE_TP_FINALIZE 0
180 #undef CYTHON_USE_DICT_VERSIONS
181 #define CYTHON_USE_DICT_VERSIONS 0
182 #undef CYTHON_USE_EXC_INFO_STACK
183 #define CYTHON_USE_EXC_INFO_STACK 0
184 #else
185 #define CYTHON_COMPILING_IN_PYPY 0
186 #define CYTHON_COMPILING_IN_PYSTON 0
187 #define CYTHON_COMPILING_IN_CPYTHON 1
188 #ifndef CYTHON_USE_TYPE_SLOTS
189 #define CYTHON_USE_TYPE_SLOTS 1
190 #endif
191 #if PY_VERSION_HEX < 0x02070000
192 #undef CYTHON_USE_PYTYPE_LOOKUP
193 #define CYTHON_USE_PYTYPE_LOOKUP 0
194 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
195 #define CYTHON_USE_PYTYPE_LOOKUP 1
196 #endif
197 #if PY_MAJOR_VERSION < 3
198 #undef CYTHON_USE_ASYNC_SLOTS
199 #define CYTHON_USE_ASYNC_SLOTS 0
200 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
201 #define CYTHON_USE_ASYNC_SLOTS 1
202 #endif
203 #if PY_VERSION_HEX < 0x02070000
204 #undef CYTHON_USE_PYLONG_INTERNALS
205 #define CYTHON_USE_PYLONG_INTERNALS 0
206 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
207 #define CYTHON_USE_PYLONG_INTERNALS 1
208 #endif
209 #ifndef CYTHON_USE_PYLIST_INTERNALS
210 #define CYTHON_USE_PYLIST_INTERNALS 1
211 #endif
212 #ifndef CYTHON_USE_UNICODE_INTERNALS
213 #define CYTHON_USE_UNICODE_INTERNALS 1
214 #endif
215 #if PY_VERSION_HEX < 0x030300F0
216 #undef CYTHON_USE_UNICODE_WRITER
217 #define CYTHON_USE_UNICODE_WRITER 0
218 #elif !defined(CYTHON_USE_UNICODE_WRITER)
219 #define CYTHON_USE_UNICODE_WRITER 1
220 #endif
221 #ifndef CYTHON_AVOID_BORROWED_REFS
222 #define CYTHON_AVOID_BORROWED_REFS 0
223 #endif
224 #ifndef CYTHON_ASSUME_SAFE_MACROS
225 #define CYTHON_ASSUME_SAFE_MACROS 1
226 #endif
227 #ifndef CYTHON_UNPACK_METHODS
228 #define CYTHON_UNPACK_METHODS 1
229 #endif
230 #ifndef CYTHON_FAST_THREAD_STATE
231 #define CYTHON_FAST_THREAD_STATE 1
232 #endif
233 #ifndef CYTHON_FAST_PYCALL
234 #define CYTHON_FAST_PYCALL 1
235 #endif
236 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
237 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
238 #endif
239 #ifndef CYTHON_USE_TP_FINALIZE
240 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
241 #endif
242 #ifndef CYTHON_USE_DICT_VERSIONS
243 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
244 #endif
245 #ifndef CYTHON_USE_EXC_INFO_STACK
246 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
247 #endif
248 #endif
249 #if !defined(CYTHON_FAST_PYCCALL)
250 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
251 #endif
252 #if CYTHON_USE_PYLONG_INTERNALS
253 #include "longintrepr.h"
254 #undef SHIFT
255 #undef BASE
256 #undef MASK
257 #ifdef SIZEOF_VOID_P
258 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
259 #endif
260 #endif
261 #ifndef __has_attribute
262 #define __has_attribute(x) 0
263 #endif
264 #ifndef __has_cpp_attribute
265 #define __has_cpp_attribute(x) 0
266 #endif
267 #ifndef CYTHON_RESTRICT
268 #if defined(__GNUC__)
269 #define CYTHON_RESTRICT __restrict__
270 #elif defined(_MSC_VER) && _MSC_VER >= 1400
271 #define CYTHON_RESTRICT __restrict
272 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
273 #define CYTHON_RESTRICT restrict
274 #else
275 #define CYTHON_RESTRICT
276 #endif
277 #endif
278 #ifndef CYTHON_UNUSED
279 # if defined(__GNUC__)
280 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
281 # define CYTHON_UNUSED __attribute__ ((__unused__))
282 # else
283 # define CYTHON_UNUSED
284 # endif
285 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
286 # define CYTHON_UNUSED __attribute__ ((__unused__))
287 # else
288 # define CYTHON_UNUSED
289 # endif
290 #endif
291 #ifndef CYTHON_MAYBE_UNUSED_VAR
292 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)293 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
294 # else
295 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
296 # endif
297 #endif
298 #ifndef CYTHON_NCP_UNUSED
299 # if CYTHON_COMPILING_IN_CPYTHON
300 # define CYTHON_NCP_UNUSED
301 # else
302 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
303 # endif
304 #endif
305 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
306 #ifdef _MSC_VER
307 #ifndef _MSC_STDINT_H_
308 #if _MSC_VER < 1300
309 typedef unsigned char uint8_t;
310 typedef unsigned int uint32_t;
311 #else
312 typedef unsigned __int8 uint8_t;
313 typedef unsigned __int32 uint32_t;
314 #endif
315 #endif
316 #else
317 #include <stdint.h>
318 #endif
319 #ifndef CYTHON_FALLTHROUGH
320 #if defined(__cplusplus) && __cplusplus >= 201103L
321 #if __has_cpp_attribute(fallthrough)
322 #define CYTHON_FALLTHROUGH [[fallthrough]]
323 #elif __has_cpp_attribute(clang::fallthrough)
324 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
325 #elif __has_cpp_attribute(gnu::fallthrough)
326 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
327 #endif
328 #endif
329 #ifndef CYTHON_FALLTHROUGH
330 #if __has_attribute(fallthrough)
331 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
332 #else
333 #define CYTHON_FALLTHROUGH
334 #endif
335 #endif
336 #if defined(__clang__ ) && defined(__apple_build_version__)
337 #if __apple_build_version__ < 7000000
338 #undef CYTHON_FALLTHROUGH
339 #define CYTHON_FALLTHROUGH
340 #endif
341 #endif
342 #endif
343
344 #ifndef CYTHON_INLINE
345 #if defined(__clang__)
346 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
347 #elif defined(__GNUC__)
348 #define CYTHON_INLINE __inline__
349 #elif defined(_MSC_VER)
350 #define CYTHON_INLINE __inline
351 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
352 #define CYTHON_INLINE inline
353 #else
354 #define CYTHON_INLINE
355 #endif
356 #endif
357
358 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
359 #define Py_OptimizeFlag 0
360 #endif
361 #define __PYX_BUILD_PY_SSIZE_T "n"
362 #define CYTHON_FORMAT_SSIZE_T "z"
363 #if PY_MAJOR_VERSION < 3
364 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
365 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
366 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
367 #define __Pyx_DefaultClassType PyClass_Type
368 #else
369 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
370 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
371 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
372 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
373 #else
374 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
375 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
376 #endif
377 #define __Pyx_DefaultClassType PyType_Type
378 #endif
379 #ifndef Py_TPFLAGS_CHECKTYPES
380 #define Py_TPFLAGS_CHECKTYPES 0
381 #endif
382 #ifndef Py_TPFLAGS_HAVE_INDEX
383 #define Py_TPFLAGS_HAVE_INDEX 0
384 #endif
385 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
386 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
387 #endif
388 #ifndef Py_TPFLAGS_HAVE_FINALIZE
389 #define Py_TPFLAGS_HAVE_FINALIZE 0
390 #endif
391 #ifndef METH_STACKLESS
392 #define METH_STACKLESS 0
393 #endif
394 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
395 #ifndef METH_FASTCALL
396 #define METH_FASTCALL 0x80
397 #endif
398 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
399 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
400 Py_ssize_t nargs, PyObject *kwnames);
401 #else
402 #define __Pyx_PyCFunctionFast _PyCFunctionFast
403 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
404 #endif
405 #if CYTHON_FAST_PYCCALL
406 #define __Pyx_PyFastCFunction_Check(func)\
407 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
408 #else
409 #define __Pyx_PyFastCFunction_Check(func) 0
410 #endif
411 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
412 #define PyObject_Malloc(s) PyMem_Malloc(s)
413 #define PyObject_Free(p) PyMem_Free(p)
414 #define PyObject_Realloc(p) PyMem_Realloc(p)
415 #endif
416 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
417 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
418 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
419 #define PyMem_RawFree(p) PyMem_Free(p)
420 #endif
421 #if CYTHON_COMPILING_IN_PYSTON
422 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
423 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
424 #else
425 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
426 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
427 #endif
428 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
429 #define __Pyx_PyThreadState_Current PyThreadState_GET()
430 #elif PY_VERSION_HEX >= 0x03060000
431 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
432 #elif PY_VERSION_HEX >= 0x03000000
433 #define __Pyx_PyThreadState_Current PyThreadState_GET()
434 #else
435 #define __Pyx_PyThreadState_Current _PyThreadState_Current
436 #endif
437 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
438 #include "pythread.h"
439 #define Py_tss_NEEDS_INIT 0
440 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)441 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
442 *key = PyThread_create_key();
443 return 0;
444 }
PyThread_tss_alloc(void)445 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
446 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
447 *key = Py_tss_NEEDS_INIT;
448 return key;
449 }
PyThread_tss_free(Py_tss_t * key)450 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
451 PyObject_Free(key);
452 }
PyThread_tss_is_created(Py_tss_t * key)453 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
454 return *key != Py_tss_NEEDS_INIT;
455 }
PyThread_tss_delete(Py_tss_t * key)456 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
457 PyThread_delete_key(*key);
458 *key = Py_tss_NEEDS_INIT;
459 }
PyThread_tss_set(Py_tss_t * key,void * value)460 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
461 return PyThread_set_key_value(*key, value);
462 }
PyThread_tss_get(Py_tss_t * key)463 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
464 return PyThread_get_key_value(*key);
465 }
466 #endif
467 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
468 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
469 #else
470 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
471 #endif
472 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
473 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
474 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
475 #else
476 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
477 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
478 #endif
479 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
480 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
481 #else
482 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
483 #endif
484 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
485 #define CYTHON_PEP393_ENABLED 1
486 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
487 0 : _PyUnicode_Ready((PyObject *)(op)))
488 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
489 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
490 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
491 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
492 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
493 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
494 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
495 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
496 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
497 #else
498 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
499 #endif
500 #else
501 #define CYTHON_PEP393_ENABLED 0
502 #define PyUnicode_1BYTE_KIND 1
503 #define PyUnicode_2BYTE_KIND 2
504 #define PyUnicode_4BYTE_KIND 4
505 #define __Pyx_PyUnicode_READY(op) (0)
506 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
507 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
508 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
509 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
510 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
511 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
512 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
513 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
514 #endif
515 #if CYTHON_COMPILING_IN_PYPY
516 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
517 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
518 #else
519 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
520 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
521 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
522 #endif
523 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
524 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
525 #endif
526 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
527 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
528 #endif
529 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
530 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
531 #endif
532 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
533 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
534 #if PY_MAJOR_VERSION >= 3
535 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
536 #else
537 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
538 #endif
539 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
540 #define PyObject_ASCII(o) PyObject_Repr(o)
541 #endif
542 #if PY_MAJOR_VERSION >= 3
543 #define PyBaseString_Type PyUnicode_Type
544 #define PyStringObject PyUnicodeObject
545 #define PyString_Type PyUnicode_Type
546 #define PyString_Check PyUnicode_Check
547 #define PyString_CheckExact PyUnicode_CheckExact
548 #ifndef PyObject_Unicode
549 #define PyObject_Unicode PyObject_Str
550 #endif
551 #endif
552 #if PY_MAJOR_VERSION >= 3
553 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
554 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
555 #else
556 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
557 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
558 #endif
559 #ifndef PySet_CheckExact
560 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
561 #endif
562 #if PY_VERSION_HEX >= 0x030900A4
563 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
564 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
565 #else
566 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
567 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
568 #endif
569 #if CYTHON_ASSUME_SAFE_MACROS
570 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
571 #else
572 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
573 #endif
574 #if PY_MAJOR_VERSION >= 3
575 #define PyIntObject PyLongObject
576 #define PyInt_Type PyLong_Type
577 #define PyInt_Check(op) PyLong_Check(op)
578 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
579 #define PyInt_FromString PyLong_FromString
580 #define PyInt_FromUnicode PyLong_FromUnicode
581 #define PyInt_FromLong PyLong_FromLong
582 #define PyInt_FromSize_t PyLong_FromSize_t
583 #define PyInt_FromSsize_t PyLong_FromSsize_t
584 #define PyInt_AsLong PyLong_AsLong
585 #define PyInt_AS_LONG PyLong_AS_LONG
586 #define PyInt_AsSsize_t PyLong_AsSsize_t
587 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
588 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
589 #define PyNumber_Int PyNumber_Long
590 #endif
591 #if PY_MAJOR_VERSION >= 3
592 #define PyBoolObject PyLongObject
593 #endif
594 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
595 #ifndef PyUnicode_InternFromString
596 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
597 #endif
598 #endif
599 #if PY_VERSION_HEX < 0x030200A4
600 typedef long Py_hash_t;
601 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
602 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
603 #else
604 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
605 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
606 #endif
607 #if PY_MAJOR_VERSION >= 3
608 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
609 #else
610 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
611 #endif
612 #if CYTHON_USE_ASYNC_SLOTS
613 #if PY_VERSION_HEX >= 0x030500B1
614 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
615 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
616 #else
617 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
618 #endif
619 #else
620 #define __Pyx_PyType_AsAsync(obj) NULL
621 #endif
622 #ifndef __Pyx_PyAsyncMethodsStruct
623 typedef struct {
624 unaryfunc am_await;
625 unaryfunc am_aiter;
626 unaryfunc am_anext;
627 } __Pyx_PyAsyncMethodsStruct;
628 #endif
629
630 #if defined(WIN32) || defined(MS_WINDOWS)
631 #define _USE_MATH_DEFINES
632 #endif
633 #include <math.h>
634 #ifdef NAN
635 #define __PYX_NAN() ((float) NAN)
636 #else
__PYX_NAN()637 static CYTHON_INLINE float __PYX_NAN() {
638 float value;
639 memset(&value, 0xFF, sizeof(value));
640 return value;
641 }
642 #endif
643 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
644 #define __Pyx_truncl trunc
645 #else
646 #define __Pyx_truncl truncl
647 #endif
648
649 #define __PYX_MARK_ERR_POS(f_index, lineno) \
650 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
651 #define __PYX_ERR(f_index, lineno, Ln_error) \
652 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
653
654 #ifndef __PYX_EXTERN_C
655 #ifdef __cplusplus
656 #define __PYX_EXTERN_C extern "C"
657 #else
658 #define __PYX_EXTERN_C extern
659 #endif
660 #endif
661
662 #define __PYX_HAVE__av__video__reformatter
663 #define __PYX_HAVE_API__av__video__reformatter
664 /* Early includes */
665 #include "pyav/config.h"
666 #include <stdint.h>
667 #include "libavutil/mathematics.h"
668 #include "libavutil/rational.h"
669 #include "libavutil/avutil.h"
670 #include "libavutil/pixdesc.h"
671 #include "libavutil/channel_layout.h"
672 #include "libavutil/audio_fifo.h"
673 #include "stdarg.h"
674 #include "libavutil/opt.h"
675 #include "libavutil/imgutils.h"
676 #include "libavutil/log.h"
677 #include "libavutil/dict.h"
678 #include "libavutil/error.h"
679 #include "libavutil/frame.h"
680 #include "libavutil/samplefmt.h"
681 #include "libavutil/motion_vector.h"
682 #include "libavcodec/avcodec.h"
683 #include "libavdevice/avdevice.h"
684 #include "libavformat/avformat.h"
685 #include "libswresample/swresample.h"
686 #include "libswscale/swscale.h"
687 #include "libavfilter/avfilter.h"
688 #include "libavfilter/buffersink.h"
689 #include "libavfilter/buffersrc.h"
690 #include "stdio.h"
691 #ifdef _OPENMP
692 #include <omp.h>
693 #endif /* _OPENMP */
694
695 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
696 #define CYTHON_WITHOUT_ASSERTIONS
697 #endif
698
699 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
700 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
701
702 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 1
703 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
704 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
705 #define __PYX_DEFAULT_STRING_ENCODING "ascii"
706 #define __Pyx_PyObject_FromString __Pyx_PyStr_FromString
707 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyStr_FromStringAndSize
708 #define __Pyx_uchar_cast(c) ((unsigned char)c)
709 #define __Pyx_long_cast(x) ((long)x)
710 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
711 (sizeof(type) < sizeof(Py_ssize_t)) ||\
712 (sizeof(type) > sizeof(Py_ssize_t) &&\
713 likely(v < (type)PY_SSIZE_T_MAX ||\
714 v == (type)PY_SSIZE_T_MAX) &&\
715 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
716 v == (type)PY_SSIZE_T_MIN))) ||\
717 (sizeof(type) == sizeof(Py_ssize_t) &&\
718 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
719 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)720 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
721 return (size_t) i < (size_t) limit;
722 }
723 #if defined (__cplusplus) && __cplusplus >= 201103L
724 #include <cstdlib>
725 #define __Pyx_sst_abs(value) std::abs(value)
726 #elif SIZEOF_INT >= SIZEOF_SIZE_T
727 #define __Pyx_sst_abs(value) abs(value)
728 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
729 #define __Pyx_sst_abs(value) labs(value)
730 #elif defined (_MSC_VER)
731 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
732 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
733 #define __Pyx_sst_abs(value) llabs(value)
734 #elif defined (__GNUC__)
735 #define __Pyx_sst_abs(value) __builtin_llabs(value)
736 #else
737 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
738 #endif
739 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
740 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
741 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
742 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
743 #define __Pyx_PyBytes_FromString PyBytes_FromString
744 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
745 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
746 #if PY_MAJOR_VERSION < 3
747 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
748 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
749 #else
750 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
751 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
752 #endif
753 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
754 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
755 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
756 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
757 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
758 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
759 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
760 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
761 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
762 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
763 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
764 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
765 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
766 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
767 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
768 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)769 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
770 const Py_UNICODE *u_end = u;
771 while (*u_end++) ;
772 return (size_t)(u_end - u - 1);
773 }
774 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
775 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
776 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
777 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
778 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
779 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
780 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
781 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
782 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
783 #define __Pyx_PySequence_Tuple(obj)\
784 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
785 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
786 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
787 #if CYTHON_ASSUME_SAFE_MACROS
788 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
789 #else
790 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
791 #endif
792 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
793 #if PY_MAJOR_VERSION >= 3
794 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
795 #else
796 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
797 #endif
798 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
799 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
800 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)801 static int __Pyx_init_sys_getdefaultencoding_params(void) {
802 PyObject* sys;
803 PyObject* default_encoding = NULL;
804 PyObject* ascii_chars_u = NULL;
805 PyObject* ascii_chars_b = NULL;
806 const char* default_encoding_c;
807 sys = PyImport_ImportModule("sys");
808 if (!sys) goto bad;
809 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
810 Py_DECREF(sys);
811 if (!default_encoding) goto bad;
812 default_encoding_c = PyBytes_AsString(default_encoding);
813 if (!default_encoding_c) goto bad;
814 if (strcmp(default_encoding_c, "ascii") == 0) {
815 __Pyx_sys_getdefaultencoding_not_ascii = 0;
816 } else {
817 char ascii_chars[128];
818 int c;
819 for (c = 0; c < 128; c++) {
820 ascii_chars[c] = c;
821 }
822 __Pyx_sys_getdefaultencoding_not_ascii = 1;
823 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
824 if (!ascii_chars_u) goto bad;
825 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
826 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
827 PyErr_Format(
828 PyExc_ValueError,
829 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
830 default_encoding_c);
831 goto bad;
832 }
833 Py_DECREF(ascii_chars_u);
834 Py_DECREF(ascii_chars_b);
835 }
836 Py_DECREF(default_encoding);
837 return 0;
838 bad:
839 Py_XDECREF(default_encoding);
840 Py_XDECREF(ascii_chars_u);
841 Py_XDECREF(ascii_chars_b);
842 return -1;
843 }
844 #endif
845 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
846 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
847 #else
848 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
849 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
850 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)851 static int __Pyx_init_sys_getdefaultencoding_params(void) {
852 PyObject* sys;
853 PyObject* default_encoding = NULL;
854 char* default_encoding_c;
855 sys = PyImport_ImportModule("sys");
856 if (!sys) goto bad;
857 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
858 Py_DECREF(sys);
859 if (!default_encoding) goto bad;
860 default_encoding_c = PyBytes_AsString(default_encoding);
861 if (!default_encoding_c) goto bad;
862 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
863 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
864 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
865 Py_DECREF(default_encoding);
866 return 0;
867 bad:
868 Py_XDECREF(default_encoding);
869 return -1;
870 }
871 #endif
872 #endif
873
874
875 /* Test for GCC > 2.95 */
876 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
877 #define likely(x) __builtin_expect(!!(x), 1)
878 #define unlikely(x) __builtin_expect(!!(x), 0)
879 #else /* !__GNUC__ or GCC < 2.95 */
880 #define likely(x) (x)
881 #define unlikely(x) (x)
882 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)883 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
884
885 static PyObject *__pyx_m = NULL;
886 static PyObject *__pyx_d;
887 static PyObject *__pyx_b;
888 static PyObject *__pyx_cython_runtime = NULL;
889 static PyObject *__pyx_empty_tuple;
890 static PyObject *__pyx_empty_bytes;
891 static PyObject *__pyx_empty_unicode;
892 static int __pyx_lineno;
893 static int __pyx_clineno = 0;
894 static const char * __pyx_cfilenm= __FILE__;
895 static const char *__pyx_filename;
896
897
898 static const char *__pyx_f[] = {
899 "av/video/reformatter.pyx",
900 "stringsource",
901 "av/buffer.pxd",
902 "av/bytesource.pxd",
903 "av/codec/codec.pxd",
904 "av/codec/context.pxd",
905 "av/container/streams.pxd",
906 "av/dictionary.pxd",
907 "av/format.pxd",
908 "av/container/core.pxd",
909 "av/stream.pxd",
910 "av/packet.pxd",
911 "av/sidedata/sidedata.pxd",
912 "av/frame.pxd",
913 "av/video/format.pxd",
914 "av/video/frame.pxd",
915 };
916 /* NoFastGil.proto */
917 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
918 #define __Pyx_PyGILState_Release PyGILState_Release
919 #define __Pyx_FastGIL_Remember()
920 #define __Pyx_FastGIL_Forget()
921 #define __Pyx_FastGilFuncInit()
922
923 /* ForceInitThreads.proto */
924 #ifndef __PYX_FORCE_INIT_THREADS
925 #define __PYX_FORCE_INIT_THREADS 0
926 #endif
927
928
929 /*--- Type declarations ---*/
930 struct __pyx_obj_2av_6buffer_Buffer;
931 struct __pyx_obj_2av_10bytesource_ByteSource;
932 struct __pyx_obj_2av_5codec_5codec_Codec;
933 struct __pyx_obj_2av_5codec_7context_CodecContext;
934 struct __pyx_obj_2av_9container_7streams_StreamContainer;
935 struct __pyx_obj_2av_10dictionary__Dictionary;
936 struct __pyx_obj_2av_6format_ContainerFormat;
937 struct __pyx_obj_2av_9container_4core_Container;
938 struct __pyx_obj_2av_6stream_Stream;
939 struct __pyx_obj_2av_6packet_Packet;
940 struct __pyx_obj_2av_8sidedata_8sidedata_SideData;
941 struct __pyx_obj_2av_8sidedata_8sidedata__SideDataContainer;
942 struct __pyx_obj_2av_5frame_Frame;
943 struct __pyx_obj_2av_5video_6format_VideoFormat;
944 struct __pyx_obj_2av_5video_6format_VideoFormatComponent;
945 struct __pyx_obj_2av_5video_5frame_VideoFrame;
946 struct __pyx_obj_2av_5video_11reformatter_VideoReformatter;
947 struct __pyx_opt_args_2av_10bytesource_bytesource;
948
949 /* "av/bytesource.pxd":14
950 * cdef size_t length
951 *
952 * cdef ByteSource bytesource(object, bint allow_none=*) # <<<<<<<<<<<<<<
953 */
954 struct __pyx_opt_args_2av_10bytesource_bytesource {
955 int __pyx_n;
956 int allow_none;
957 };
958 struct __pyx_opt_args_2av_5codec_5codec_5Codec__init;
959
960 /* "av/codec/codec.pxd":10
961 * cdef readonly bint is_encoder
962 *
963 * cdef _init(self, name=?) # <<<<<<<<<<<<<<
964 *
965 *
966 */
967 struct __pyx_opt_args_2av_5codec_5codec_5Codec__init {
968 int __pyx_n;
969 PyObject *name;
970 };
971 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_open;
972 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_close;
973 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_encode;
974 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_decode;
975
976 /* "av/codec/context.pxd":34
977 *
978 * # Public API.
979 * cpdef open(self, bint strict=?) # <<<<<<<<<<<<<<
980 * cpdef close(self, bint strict=?)
981 *
982 */
983 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_open {
984 int __pyx_n;
985 int strict;
986 };
987
988 /* "av/codec/context.pxd":35
989 * # Public API.
990 * cpdef open(self, bint strict=?)
991 * cpdef close(self, bint strict=?) # <<<<<<<<<<<<<<
992 *
993 * cdef _set_default_time_base(self)
994 */
995 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_close {
996 int __pyx_n;
997 int strict;
998 };
999
1000 /* "av/codec/context.pxd":40
1001 *
1002 * # Wraps both versions of the transcode API, returning lists.
1003 * cpdef encode(self, Frame frame=?) # <<<<<<<<<<<<<<
1004 * cpdef decode(self, Packet packet=?)
1005 *
1006 */
1007 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_encode {
1008 int __pyx_n;
1009 struct __pyx_obj_2av_5frame_Frame *frame;
1010 };
1011
1012 /* "av/codec/context.pxd":41
1013 * # Wraps both versions of the transcode API, returning lists.
1014 * cpdef encode(self, Frame frame=?)
1015 * cpdef decode(self, Packet packet=?) # <<<<<<<<<<<<<<
1016 *
1017 * # Used by both transcode APIs to setup user-land objects.
1018 */
1019 struct __pyx_opt_args_2av_5codec_7context_12CodecContext_decode {
1020 int __pyx_n;
1021 struct __pyx_obj_2av_6packet_Packet *packet;
1022 };
1023 struct __pyx_t_2av_9container_4core_timeout_info;
1024 typedef struct __pyx_t_2av_9container_4core_timeout_info __pyx_t_2av_9container_4core_timeout_info;
1025
1026 /* "av/container/core.pxd":10
1027 *
1028 * # Interrupt callback information, times are in seconds.
1029 * ctypedef struct timeout_info: # <<<<<<<<<<<<<<
1030 * double start_time
1031 * double timeout
1032 */
1033 struct __pyx_t_2av_9container_4core_timeout_info {
1034 double start_time;
1035 double timeout;
1036 };
1037 struct __pyx_opt_args_2av_5frame_5Frame__copy_internal_attributes;
1038
1039 /* "av/frame.pxd":19
1040 * cdef readonly int index
1041 *
1042 * cdef _copy_internal_attributes(self, Frame source, bint data_layout=?) # <<<<<<<<<<<<<<
1043 *
1044 * cdef _init_user_attributes(self)
1045 */
1046 struct __pyx_opt_args_2av_5frame_5Frame__copy_internal_attributes {
1047 int __pyx_n;
1048 int data_layout;
1049 };
1050 struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_width;
1051 struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_height;
1052
1053 /* "av/video/format.pxd":14
1054 * cdef _init(self, lib.AVPixelFormat pix_fmt, unsigned int width, unsigned int height)
1055 *
1056 * cpdef chroma_width(self, int luma_width=?) # <<<<<<<<<<<<<<
1057 * cpdef chroma_height(self, int luma_height=?)
1058 *
1059 */
1060 struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_width {
1061 int __pyx_n;
1062 int luma_width;
1063 };
1064
1065 /* "av/video/format.pxd":15
1066 *
1067 * cpdef chroma_width(self, int luma_width=?)
1068 * cpdef chroma_height(self, int luma_height=?) # <<<<<<<<<<<<<<
1069 *
1070 *
1071 */
1072 struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_height {
1073 int __pyx_n;
1074 int luma_height;
1075 };
1076 struct __pyx_opt_args_2av_4enum_define_enum;
1077
1078 /* "av/enum.pxd":2
1079 * cpdef define_enum(
1080 * name, module, items, # <<<<<<<<<<<<<<
1081 * bint is_flags=*
1082 * )
1083 */
1084 struct __pyx_opt_args_2av_4enum_define_enum {
1085 int __pyx_n;
1086 int is_flags;
1087 };
1088 struct __pyx_opt_args_2av_5error_stash_exception;
1089 struct __pyx_opt_args_2av_5error_err_check;
1090 struct __pyx_opt_args_2av_5error_make_error;
1091
1092 /* "av/error.pxd":2
1093 *
1094 * cdef int stash_exception(exc_info=*) # <<<<<<<<<<<<<<
1095 *
1096 * cpdef int err_check(int res, filename=*) except -1
1097 */
1098 struct __pyx_opt_args_2av_5error_stash_exception {
1099 int __pyx_n;
1100 PyObject *exc_info;
1101 };
1102
1103 /* "av/error.pxd":4
1104 * cdef int stash_exception(exc_info=*)
1105 *
1106 * cpdef int err_check(int res, filename=*) except -1 # <<<<<<<<<<<<<<
1107 * cpdef make_error(int res, filename=*, log=*)
1108 */
1109 struct __pyx_opt_args_2av_5error_err_check {
1110 int __pyx_n;
1111 PyObject *filename;
1112 };
1113
1114 /* "av/error.pxd":5
1115 *
1116 * cpdef int err_check(int res, filename=*) except -1
1117 * cpdef make_error(int res, filename=*, log=*) # <<<<<<<<<<<<<<
1118 */
1119 struct __pyx_opt_args_2av_5error_make_error {
1120 int __pyx_n;
1121 PyObject *filename;
1122 PyObject *log;
1123 };
1124
1125 /* "av/buffer.pxd":2
1126 *
1127 * cdef class Buffer(object): # <<<<<<<<<<<<<<
1128 *
1129 * cdef size_t _buffer_size(self)
1130 */
1131 struct __pyx_obj_2av_6buffer_Buffer {
1132 PyObject_HEAD
1133 struct __pyx_vtabstruct_2av_6buffer_Buffer *__pyx_vtab;
1134 };
1135
1136
1137 /* "av/bytesource.pxd":4
1138 *
1139 *
1140 * cdef class ByteSource(object): # <<<<<<<<<<<<<<
1141 *
1142 * cdef object owner
1143 */
1144 struct __pyx_obj_2av_10bytesource_ByteSource {
1145 PyObject_HEAD
1146 PyObject *owner;
1147 int has_view;
1148 Py_buffer view;
1149 unsigned char *ptr;
1150 size_t length;
1151 };
1152
1153
1154 /* "av/codec/codec.pxd":4
1155 *
1156 *
1157 * cdef class Codec(object): # <<<<<<<<<<<<<<
1158 *
1159 * cdef const lib.AVCodec *ptr
1160 */
1161 struct __pyx_obj_2av_5codec_5codec_Codec {
1162 PyObject_HEAD
1163 struct __pyx_vtabstruct_2av_5codec_5codec_Codec *__pyx_vtab;
1164 struct AVCodec const *ptr;
1165 struct AVCodecDescriptor const *desc;
1166 int is_encoder;
1167 };
1168
1169
1170 /* "av/codec/context.pxd":10
1171 *
1172 *
1173 * cdef class CodecContext(object): # <<<<<<<<<<<<<<
1174 *
1175 * cdef lib.AVCodecContext *ptr
1176 */
1177 struct __pyx_obj_2av_5codec_7context_CodecContext {
1178 PyObject_HEAD
1179 struct __pyx_vtabstruct_2av_5codec_7context_CodecContext *__pyx_vtab;
1180 struct AVCodecContext *ptr;
1181 int allocated;
1182 int stream_index;
1183 struct AVCodecParserContext *parser;
1184 struct __pyx_obj_2av_10bytesource_ByteSource *extradata_source;
1185 struct __pyx_obj_2av_5codec_5codec_Codec *codec;
1186 PyObject *options;
1187 struct __pyx_obj_2av_5frame_Frame *_next_frame;
1188 };
1189
1190
1191 /* "av/container/streams.pxd":4
1192 *
1193 *
1194 * cdef class StreamContainer(object): # <<<<<<<<<<<<<<
1195 *
1196 * cdef list _streams
1197 */
1198 struct __pyx_obj_2av_9container_7streams_StreamContainer {
1199 PyObject_HEAD
1200 struct __pyx_vtabstruct_2av_9container_7streams_StreamContainer *__pyx_vtab;
1201 PyObject *_streams;
1202 PyObject *video;
1203 PyObject *audio;
1204 PyObject *subtitles;
1205 PyObject *data;
1206 PyObject *other;
1207 };
1208
1209
1210 /* "av/dictionary.pxd":4
1211 *
1212 *
1213 * cdef class _Dictionary(object): # <<<<<<<<<<<<<<
1214 *
1215 * cdef lib.AVDictionary *ptr
1216 */
1217 struct __pyx_obj_2av_10dictionary__Dictionary {
1218 PyObject_HEAD
1219 struct __pyx_vtabstruct_2av_10dictionary__Dictionary *__pyx_vtab;
1220 AVDictionary *ptr;
1221 };
1222
1223
1224 /* "av/format.pxd":4
1225 *
1226 *
1227 * cdef class ContainerFormat(object): # <<<<<<<<<<<<<<
1228 *
1229 * cdef readonly str name
1230 */
1231 struct __pyx_obj_2av_6format_ContainerFormat {
1232 PyObject_HEAD
1233 PyObject *name;
1234 struct AVInputFormat *iptr;
1235 struct AVOutputFormat *optr;
1236 };
1237
1238
1239 /* "av/container/core.pxd":15
1240 *
1241 *
1242 * cdef class Container(object): # <<<<<<<<<<<<<<
1243 *
1244 * cdef readonly bint writeable
1245 */
1246 struct __pyx_obj_2av_9container_4core_Container {
1247 PyObject_HEAD
1248 struct __pyx_vtabstruct_2av_9container_4core_Container *__pyx_vtab;
1249 int writeable;
1250 struct AVFormatContext *ptr;
1251 PyObject *name;
1252 PyObject *metadata_encoding;
1253 PyObject *metadata_errors;
1254 PyObject *file;
1255 PyObject *fread;
1256 PyObject *fwrite;
1257 PyObject *fseek;
1258 PyObject *ftell;
1259 struct AVIOContext *iocontext;
1260 unsigned char *buffer;
1261 long pos;
1262 int pos_is_valid;
1263 int input_was_opened;
1264 struct __pyx_obj_2av_6format_ContainerFormat *format;
1265 PyObject *options;
1266 PyObject *container_options;
1267 PyObject *stream_options;
1268 struct __pyx_obj_2av_9container_7streams_StreamContainer *streams;
1269 PyObject *metadata;
1270 PyObject *open_timeout;
1271 PyObject *read_timeout;
1272 __pyx_t_2av_9container_4core_timeout_info interrupt_callback_info;
1273 };
1274
1275
1276 /* "av/stream.pxd":10
1277 *
1278 *
1279 * cdef class Stream(object): # <<<<<<<<<<<<<<
1280 *
1281 * # Stream attributes.
1282 */
1283 struct __pyx_obj_2av_6stream_Stream {
1284 PyObject_HEAD
1285 struct __pyx_vtabstruct_2av_6stream_Stream *__pyx_vtab;
1286 struct __pyx_obj_2av_9container_4core_Container *container;
1287 struct AVStream *_stream;
1288 PyObject *metadata;
1289 struct AVCodecContext *_codec_context;
1290 struct AVCodec const *_codec;
1291 struct __pyx_obj_2av_5codec_7context_CodecContext *codec_context;
1292 };
1293
1294
1295 /* "av/packet.pxd":8
1296 *
1297 *
1298 * cdef class Packet(Buffer): # <<<<<<<<<<<<<<
1299 *
1300 * cdef lib.AVPacket struct
1301 */
1302 struct __pyx_obj_2av_6packet_Packet {
1303 struct __pyx_obj_2av_6buffer_Buffer __pyx_base;
1304 struct AVPacket __pyx_struct;
1305 struct __pyx_obj_2av_6stream_Stream *_stream;
1306 AVRational _time_base;
1307 struct __pyx_obj_2av_10bytesource_ByteSource *source;
1308 };
1309
1310
1311 /* "av/sidedata/sidedata.pxd":9
1312 *
1313 *
1314 * cdef class SideData(Buffer): # <<<<<<<<<<<<<<
1315 *
1316 * cdef Frame frame
1317 */
1318 struct __pyx_obj_2av_8sidedata_8sidedata_SideData {
1319 struct __pyx_obj_2av_6buffer_Buffer __pyx_base;
1320 struct __pyx_obj_2av_5frame_Frame *frame;
1321 struct AVFrameSideData *ptr;
1322 struct __pyx_obj_2av_10dictionary__Dictionary *metadata;
1323 };
1324
1325
1326 /* "av/sidedata/sidedata.pxd":18
1327 * cdef SideData wrap_side_data(Frame frame, int index)
1328 *
1329 * cdef class _SideDataContainer(object): # <<<<<<<<<<<<<<
1330 *
1331 * cdef Frame frame
1332 */
1333 struct __pyx_obj_2av_8sidedata_8sidedata__SideDataContainer {
1334 PyObject_HEAD
1335 struct __pyx_obj_2av_5frame_Frame *frame;
1336 PyObject *_by_index;
1337 PyObject *_by_type;
1338 };
1339
1340
1341 /* "av/frame.pxd":7
1342 *
1343 *
1344 * cdef class Frame(object): # <<<<<<<<<<<<<<
1345 *
1346 * cdef lib.AVFrame *ptr
1347 */
1348 struct __pyx_obj_2av_5frame_Frame {
1349 PyObject_HEAD
1350 struct __pyx_vtabstruct_2av_5frame_Frame *__pyx_vtab;
1351 struct AVFrame *ptr;
1352 AVRational _time_base;
1353 struct __pyx_obj_2av_8sidedata_8sidedata__SideDataContainer *_side_data;
1354 int index;
1355 };
1356
1357
1358 /* "av/video/format.pxd":4
1359 *
1360 *
1361 * cdef class VideoFormat(object): # <<<<<<<<<<<<<<
1362 *
1363 * cdef lib.AVPixelFormat pix_fmt
1364 */
1365 struct __pyx_obj_2av_5video_6format_VideoFormat {
1366 PyObject_HEAD
1367 struct __pyx_vtabstruct_2av_5video_6format_VideoFormat *__pyx_vtab;
1368 enum AVPixelFormat pix_fmt;
1369 struct AVPixFmtDescriptor const *ptr;
1370 unsigned int width;
1371 unsigned int height;
1372 PyObject *components;
1373 };
1374
1375
1376 /* "av/video/format.pxd":18
1377 *
1378 *
1379 * cdef class VideoFormatComponent(object): # <<<<<<<<<<<<<<
1380 *
1381 * cdef VideoFormat format
1382 */
1383 struct __pyx_obj_2av_5video_6format_VideoFormatComponent {
1384 PyObject_HEAD
1385 struct __pyx_obj_2av_5video_6format_VideoFormat *format;
1386 unsigned int index;
1387 struct AVComponentDescriptor const *ptr;
1388 };
1389
1390
1391 /* "av/video/frame.pxd":9
1392 *
1393 *
1394 * cdef class VideoFrame(Frame): # <<<<<<<<<<<<<<
1395 *
1396 * # This is the buffer that is used to back everything in the AVFrame.
1397 */
1398 struct __pyx_obj_2av_5video_5frame_VideoFrame {
1399 struct __pyx_obj_2av_5frame_Frame __pyx_base;
1400 uint8_t *_buffer;
1401 struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *reformatter;
1402 struct __pyx_obj_2av_5video_6format_VideoFormat *format;
1403 };
1404
1405
1406 /* "av/video/reformatter.pxd":6
1407 *
1408 *
1409 * cdef class VideoReformatter(object): # <<<<<<<<<<<<<<
1410 *
1411 * cdef lib.SwsContext *ptr
1412 */
1413 struct __pyx_obj_2av_5video_11reformatter_VideoReformatter {
1414 PyObject_HEAD
1415 struct __pyx_vtabstruct_2av_5video_11reformatter_VideoReformatter *__pyx_vtab;
1416 struct SwsContext *ptr;
1417 };
1418
1419
1420
1421 /* "av/buffer.pxd":2
1422 *
1423 * cdef class Buffer(object): # <<<<<<<<<<<<<<
1424 *
1425 * cdef size_t _buffer_size(self)
1426 */
1427
1428 struct __pyx_vtabstruct_2av_6buffer_Buffer {
1429 size_t (*_buffer_size)(struct __pyx_obj_2av_6buffer_Buffer *);
1430 void *(*_buffer_ptr)(struct __pyx_obj_2av_6buffer_Buffer *);
1431 int (*_buffer_writable)(struct __pyx_obj_2av_6buffer_Buffer *);
1432 };
1433 static struct __pyx_vtabstruct_2av_6buffer_Buffer *__pyx_vtabptr_2av_6buffer_Buffer;
1434
1435
1436 /* "av/codec/codec.pxd":4
1437 *
1438 *
1439 * cdef class Codec(object): # <<<<<<<<<<<<<<
1440 *
1441 * cdef const lib.AVCodec *ptr
1442 */
1443
1444 struct __pyx_vtabstruct_2av_5codec_5codec_Codec {
1445 PyObject *(*_init)(struct __pyx_obj_2av_5codec_5codec_Codec *, struct __pyx_opt_args_2av_5codec_5codec_5Codec__init *__pyx_optional_args);
1446 };
1447 static struct __pyx_vtabstruct_2av_5codec_5codec_Codec *__pyx_vtabptr_2av_5codec_5codec_Codec;
1448
1449
1450 /* "av/codec/context.pxd":10
1451 *
1452 *
1453 * cdef class CodecContext(object): # <<<<<<<<<<<<<<
1454 *
1455 * cdef lib.AVCodecContext *ptr
1456 */
1457
1458 struct __pyx_vtabstruct_2av_5codec_7context_CodecContext {
1459 PyObject *(*_init)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct AVCodecContext *, struct AVCodec const *);
1460 PyObject *(*open)(struct __pyx_obj_2av_5codec_7context_CodecContext *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5codec_7context_12CodecContext_open *__pyx_optional_args);
1461 PyObject *(*close)(struct __pyx_obj_2av_5codec_7context_CodecContext *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5codec_7context_12CodecContext_close *__pyx_optional_args);
1462 PyObject *(*_set_default_time_base)(struct __pyx_obj_2av_5codec_7context_CodecContext *);
1463 PyObject *(*encode)(struct __pyx_obj_2av_5codec_7context_CodecContext *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5codec_7context_12CodecContext_encode *__pyx_optional_args);
1464 PyObject *(*decode)(struct __pyx_obj_2av_5codec_7context_CodecContext *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5codec_7context_12CodecContext_decode *__pyx_optional_args);
1465 PyObject *(*_prepare_frames_for_encode)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct __pyx_obj_2av_5frame_Frame *);
1466 PyObject *(*_setup_encoded_packet)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct __pyx_obj_2av_6packet_Packet *);
1467 PyObject *(*_setup_decoded_frame)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct __pyx_obj_2av_5frame_Frame *, struct __pyx_obj_2av_6packet_Packet *);
1468 PyObject *(*_send_frame_and_recv)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct __pyx_obj_2av_5frame_Frame *);
1469 PyObject *(*_recv_packet)(struct __pyx_obj_2av_5codec_7context_CodecContext *);
1470 PyObject *(*_send_packet_and_recv)(struct __pyx_obj_2av_5codec_7context_CodecContext *, struct __pyx_obj_2av_6packet_Packet *);
1471 PyObject *(*_recv_frame)(struct __pyx_obj_2av_5codec_7context_CodecContext *);
1472 struct __pyx_obj_2av_5frame_Frame *(*_alloc_next_frame)(struct __pyx_obj_2av_5codec_7context_CodecContext *);
1473 };
1474 static struct __pyx_vtabstruct_2av_5codec_7context_CodecContext *__pyx_vtabptr_2av_5codec_7context_CodecContext;
1475
1476
1477 /* "av/container/streams.pxd":4
1478 *
1479 *
1480 * cdef class StreamContainer(object): # <<<<<<<<<<<<<<
1481 *
1482 * cdef list _streams
1483 */
1484
1485 struct __pyx_vtabstruct_2av_9container_7streams_StreamContainer {
1486 PyObject *(*add_stream)(struct __pyx_obj_2av_9container_7streams_StreamContainer *, struct __pyx_obj_2av_6stream_Stream *);
1487 };
1488 static struct __pyx_vtabstruct_2av_9container_7streams_StreamContainer *__pyx_vtabptr_2av_9container_7streams_StreamContainer;
1489
1490
1491 /* "av/dictionary.pxd":4
1492 *
1493 *
1494 * cdef class _Dictionary(object): # <<<<<<<<<<<<<<
1495 *
1496 * cdef lib.AVDictionary *ptr
1497 */
1498
1499 struct __pyx_vtabstruct_2av_10dictionary__Dictionary {
1500 struct __pyx_obj_2av_10dictionary__Dictionary *(*copy)(struct __pyx_obj_2av_10dictionary__Dictionary *, int __pyx_skip_dispatch);
1501 };
1502 static struct __pyx_vtabstruct_2av_10dictionary__Dictionary *__pyx_vtabptr_2av_10dictionary__Dictionary;
1503
1504
1505 /* "av/container/core.pxd":15
1506 *
1507 *
1508 * cdef class Container(object): # <<<<<<<<<<<<<<
1509 *
1510 * cdef readonly bint writeable
1511 */
1512
1513 struct __pyx_vtabstruct_2av_9container_4core_Container {
1514 int (*err_check)(struct __pyx_obj_2av_9container_4core_Container *, int);
1515 PyObject *(*set_timeout)(struct __pyx_obj_2av_9container_4core_Container *, PyObject *);
1516 PyObject *(*start_timeout)(struct __pyx_obj_2av_9container_4core_Container *);
1517 };
1518 static struct __pyx_vtabstruct_2av_9container_4core_Container *__pyx_vtabptr_2av_9container_4core_Container;
1519
1520
1521 /* "av/stream.pxd":10
1522 *
1523 *
1524 * cdef class Stream(object): # <<<<<<<<<<<<<<
1525 *
1526 * # Stream attributes.
1527 */
1528
1529 struct __pyx_vtabstruct_2av_6stream_Stream {
1530 PyObject *(*_init)(struct __pyx_obj_2av_6stream_Stream *, struct __pyx_obj_2av_9container_4core_Container *, struct AVStream *);
1531 PyObject *(*_finalize_for_output)(struct __pyx_obj_2av_6stream_Stream *);
1532 };
1533 static struct __pyx_vtabstruct_2av_6stream_Stream *__pyx_vtabptr_2av_6stream_Stream;
1534
1535
1536 /* "av/packet.pxd":8
1537 *
1538 *
1539 * cdef class Packet(Buffer): # <<<<<<<<<<<<<<
1540 *
1541 * cdef lib.AVPacket struct
1542 */
1543
1544 struct __pyx_vtabstruct_2av_6packet_Packet {
1545 struct __pyx_vtabstruct_2av_6buffer_Buffer __pyx_base;
1546 PyObject *(*_rebase_time)(struct __pyx_obj_2av_6packet_Packet *, AVRational);
1547 };
1548 static struct __pyx_vtabstruct_2av_6packet_Packet *__pyx_vtabptr_2av_6packet_Packet;
1549
1550
1551 /* "av/sidedata/sidedata.pxd":9
1552 *
1553 *
1554 * cdef class SideData(Buffer): # <<<<<<<<<<<<<<
1555 *
1556 * cdef Frame frame
1557 */
1558
1559 struct __pyx_vtabstruct_2av_8sidedata_8sidedata_SideData {
1560 struct __pyx_vtabstruct_2av_6buffer_Buffer __pyx_base;
1561 };
1562 static struct __pyx_vtabstruct_2av_8sidedata_8sidedata_SideData *__pyx_vtabptr_2av_8sidedata_8sidedata_SideData;
1563
1564
1565 /* "av/frame.pxd":7
1566 *
1567 *
1568 * cdef class Frame(object): # <<<<<<<<<<<<<<
1569 *
1570 * cdef lib.AVFrame *ptr
1571 */
1572
1573 struct __pyx_vtabstruct_2av_5frame_Frame {
1574 PyObject *(*_rebase_time)(struct __pyx_obj_2av_5frame_Frame *, AVRational);
1575 PyObject *(*_copy_internal_attributes)(struct __pyx_obj_2av_5frame_Frame *, struct __pyx_obj_2av_5frame_Frame *, struct __pyx_opt_args_2av_5frame_5Frame__copy_internal_attributes *__pyx_optional_args);
1576 PyObject *(*_init_user_attributes)(struct __pyx_obj_2av_5frame_Frame *);
1577 };
1578 static struct __pyx_vtabstruct_2av_5frame_Frame *__pyx_vtabptr_2av_5frame_Frame;
1579
1580
1581 /* "av/video/format.pxd":4
1582 *
1583 *
1584 * cdef class VideoFormat(object): # <<<<<<<<<<<<<<
1585 *
1586 * cdef lib.AVPixelFormat pix_fmt
1587 */
1588
1589 struct __pyx_vtabstruct_2av_5video_6format_VideoFormat {
1590 PyObject *(*_init)(struct __pyx_obj_2av_5video_6format_VideoFormat *, enum AVPixelFormat, unsigned int, unsigned int);
1591 PyObject *(*chroma_width)(struct __pyx_obj_2av_5video_6format_VideoFormat *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_width *__pyx_optional_args);
1592 PyObject *(*chroma_height)(struct __pyx_obj_2av_5video_6format_VideoFormat *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5video_6format_11VideoFormat_chroma_height *__pyx_optional_args);
1593 };
1594 static struct __pyx_vtabstruct_2av_5video_6format_VideoFormat *__pyx_vtabptr_2av_5video_6format_VideoFormat;
1595
1596
1597 /* "av/video/frame.pxd":9
1598 *
1599 *
1600 * cdef class VideoFrame(Frame): # <<<<<<<<<<<<<<
1601 *
1602 * # This is the buffer that is used to back everything in the AVFrame.
1603 */
1604
1605 struct __pyx_vtabstruct_2av_5video_5frame_VideoFrame {
1606 struct __pyx_vtabstruct_2av_5frame_Frame __pyx_base;
1607 PyObject *(*_init)(struct __pyx_obj_2av_5video_5frame_VideoFrame *, enum AVPixelFormat, unsigned int, unsigned int);
1608 };
1609 static struct __pyx_vtabstruct_2av_5video_5frame_VideoFrame *__pyx_vtabptr_2av_5video_5frame_VideoFrame;
1610
1611
1612 /* "av/video/reformatter.pyx":45
1613 *
1614 *
1615 * cdef class VideoReformatter(object): # <<<<<<<<<<<<<<
1616 *
1617 * """An object for reformatting size and pixel format of :class:`.VideoFrame`.
1618 */
1619
1620 struct __pyx_vtabstruct_2av_5video_11reformatter_VideoReformatter {
1621 PyObject *(*_reformat)(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *, struct __pyx_obj_2av_5video_5frame_VideoFrame *, int, int, enum AVPixelFormat, int, int, int);
1622 };
1623 static struct __pyx_vtabstruct_2av_5video_11reformatter_VideoReformatter *__pyx_vtabptr_2av_5video_11reformatter_VideoReformatter;
1624
1625 /* --- Runtime support code (head) --- */
1626 /* Refnanny.proto */
1627 #ifndef CYTHON_REFNANNY
1628 #define CYTHON_REFNANNY 0
1629 #endif
1630 #if CYTHON_REFNANNY
1631 typedef struct {
1632 void (*INCREF)(void*, PyObject*, int);
1633 void (*DECREF)(void*, PyObject*, int);
1634 void (*GOTREF)(void*, PyObject*, int);
1635 void (*GIVEREF)(void*, PyObject*, int);
1636 void* (*SetupContext)(const char*, int, const char*);
1637 void (*FinishContext)(void**);
1638 } __Pyx_RefNannyAPIStruct;
1639 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1640 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1641 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1642 #ifdef WITH_THREAD
1643 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1644 if (acquire_gil) {\
1645 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1646 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1647 PyGILState_Release(__pyx_gilstate_save);\
1648 } else {\
1649 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1650 }
1651 #else
1652 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1653 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1654 #endif
1655 #define __Pyx_RefNannyFinishContext()\
1656 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1657 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1658 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1659 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1660 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1661 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1662 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1663 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1664 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1665 #else
1666 #define __Pyx_RefNannyDeclarations
1667 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1668 #define __Pyx_RefNannyFinishContext()
1669 #define __Pyx_INCREF(r) Py_INCREF(r)
1670 #define __Pyx_DECREF(r) Py_DECREF(r)
1671 #define __Pyx_GOTREF(r)
1672 #define __Pyx_GIVEREF(r)
1673 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1674 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1675 #define __Pyx_XGOTREF(r)
1676 #define __Pyx_XGIVEREF(r)
1677 #endif
1678 #define __Pyx_XDECREF_SET(r, v) do {\
1679 PyObject *tmp = (PyObject *) r;\
1680 r = v; __Pyx_XDECREF(tmp);\
1681 } while (0)
1682 #define __Pyx_DECREF_SET(r, v) do {\
1683 PyObject *tmp = (PyObject *) r;\
1684 r = v; __Pyx_DECREF(tmp);\
1685 } while (0)
1686 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1687 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1688
1689 /* PyObjectGetAttrStr.proto */
1690 #if CYTHON_USE_TYPE_SLOTS
1691 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1692 #else
1693 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1694 #endif
1695
1696 /* GetBuiltinName.proto */
1697 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1698
1699 /* RaiseDoubleKeywords.proto */
1700 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1701
1702 /* ParseKeywords.proto */
1703 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1704 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1705 const char* function_name);
1706
1707 /* RaiseArgTupleInvalid.proto */
1708 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1709 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1710
1711 /* ArgTypeTest.proto */
1712 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1713 ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1714 __Pyx__ArgTypeTest(obj, type, name, exact))
1715 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1716
1717 /* PyCFunctionFastCall.proto */
1718 #if CYTHON_FAST_PYCCALL
1719 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1720 #else
1721 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1722 #endif
1723
1724 /* PyFunctionFastCall.proto */
1725 #if CYTHON_FAST_PYCALL
1726 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1727 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1728 #if 1 || PY_VERSION_HEX < 0x030600B1
1729 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1730 #else
1731 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1732 #endif
1733 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1734 (sizeof(char [1 - 2*!(cond)]) - 1)
1735 #ifndef Py_MEMBER_SIZE
1736 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1737 #endif
1738 static size_t __pyx_pyframe_localsplus_offset = 0;
1739 #include "frameobject.h"
1740 #define __Pxy_PyFrame_Initialize_Offsets()\
1741 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1742 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1743 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1744 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1745 #endif
1746
1747 /* PyObjectCall.proto */
1748 #if CYTHON_COMPILING_IN_CPYTHON
1749 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1750 #else
1751 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1752 #endif
1753
1754 /* PyObjectCallMethO.proto */
1755 #if CYTHON_COMPILING_IN_CPYTHON
1756 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1757 #endif
1758
1759 /* PyObjectCallOneArg.proto */
1760 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1761
1762 /* PyDictVersioning.proto */
1763 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1764 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1765 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1766 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1767 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1768 (cache_var) = (value);
1769 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1770 static PY_UINT64_T __pyx_dict_version = 0;\
1771 static PyObject *__pyx_dict_cached_value = NULL;\
1772 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1773 (VAR) = __pyx_dict_cached_value;\
1774 } else {\
1775 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1776 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1777 }\
1778 }
1779 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1780 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1781 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1782 #else
1783 #define __PYX_GET_DICT_VERSION(dict) (0)
1784 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1785 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1786 #endif
1787
1788 /* GetModuleGlobalName.proto */
1789 #if CYTHON_USE_DICT_VERSIONS
1790 #define __Pyx_GetModuleGlobalName(var, name) {\
1791 static PY_UINT64_T __pyx_dict_version = 0;\
1792 static PyObject *__pyx_dict_cached_value = NULL;\
1793 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1794 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1795 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1796 }
1797 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1798 PY_UINT64_T __pyx_dict_version;\
1799 PyObject *__pyx_dict_cached_value;\
1800 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1801 }
1802 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1803 #else
1804 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1805 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1806 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1807 #endif
1808
1809 /* GetItemInt.proto */
1810 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1811 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1812 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1813 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1814 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1815 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1816 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1817 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1818 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1819 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1820 int wraparound, int boundscheck);
1821 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1822 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1823 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1824 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1825 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1826 int wraparound, int boundscheck);
1827 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1828 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1829 int is_list, int wraparound, int boundscheck);
1830
1831 /* ObjectGetItem.proto */
1832 #if CYTHON_USE_TYPE_SLOTS
1833 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1834 #else
1835 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
1836 #endif
1837
1838 /* PyThreadStateGet.proto */
1839 #if CYTHON_FAST_THREAD_STATE
1840 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1841 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1842 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1843 #else
1844 #define __Pyx_PyThreadState_declare
1845 #define __Pyx_PyThreadState_assign
1846 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1847 #endif
1848
1849 /* PyErrFetchRestore.proto */
1850 #if CYTHON_FAST_THREAD_STATE
1851 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1852 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1853 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1854 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1855 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1856 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1857 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1858 #if CYTHON_COMPILING_IN_CPYTHON
1859 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1860 #else
1861 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1862 #endif
1863 #else
1864 #define __Pyx_PyErr_Clear() PyErr_Clear()
1865 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1866 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1867 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1868 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1869 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1870 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1871 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1872 #endif
1873
1874 /* RaiseException.proto */
1875 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1876
1877 /* PyObject_GenericGetAttrNoDict.proto */
1878 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1879 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1880 #else
1881 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1882 #endif
1883
1884 /* PyObject_GenericGetAttr.proto */
1885 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1886 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1887 #else
1888 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1889 #endif
1890
1891 /* SetVTable.proto */
1892 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1893
1894 /* PyErrExceptionMatches.proto */
1895 #if CYTHON_FAST_THREAD_STATE
1896 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1897 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1898 #else
1899 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1900 #endif
1901
1902 /* PyObjectGetAttrStrNoError.proto */
1903 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1904
1905 /* SetupReduce.proto */
1906 static int __Pyx_setup_reduce(PyObject* type_obj);
1907
1908 /* TypeImport.proto */
1909 #ifndef __PYX_HAVE_RT_ImportType_proto
1910 #define __PYX_HAVE_RT_ImportType_proto
1911 enum __Pyx_ImportType_CheckSize {
1912 __Pyx_ImportType_CheckSize_Error = 0,
1913 __Pyx_ImportType_CheckSize_Warn = 1,
1914 __Pyx_ImportType_CheckSize_Ignore = 2
1915 };
1916 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1917 #endif
1918
1919 /* GetVTable.proto */
1920 static void* __Pyx_GetVtable(PyObject *dict);
1921
1922 /* CLineInTraceback.proto */
1923 #ifdef CYTHON_CLINE_IN_TRACEBACK
1924 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1925 #else
1926 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1927 #endif
1928
1929 /* CodeObjectCache.proto */
1930 typedef struct {
1931 PyCodeObject* code_object;
1932 int code_line;
1933 } __Pyx_CodeObjectCacheEntry;
1934 struct __Pyx_CodeObjectCache {
1935 int count;
1936 int max_count;
1937 __Pyx_CodeObjectCacheEntry* entries;
1938 };
1939 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1940 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1941 static PyCodeObject *__pyx_find_code_object(int code_line);
1942 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1943
1944 /* AddTraceback.proto */
1945 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1946 int py_line, const char *filename);
1947
1948 /* CIntToPy.proto */
1949 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1950
1951 /* CIntFromPy.proto */
1952 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1953
1954 /* CIntToPy.proto */
1955 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1956
1957 /* CIntFromPy.proto */
1958 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1959
1960 /* FastTypeChecks.proto */
1961 #if CYTHON_COMPILING_IN_CPYTHON
1962 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1963 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1964 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1965 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1966 #else
1967 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1968 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1969 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1970 #endif
1971 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1972
1973 /* CheckBinaryVersion.proto */
1974 static int __Pyx_check_binary_version(void);
1975
1976 /* FunctionImport.proto */
1977 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
1978
1979 /* InitStrings.proto */
1980 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1981
1982 static PyObject *__pyx_f_2av_5video_11reformatter_16VideoReformatter__reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_frame, int __pyx_v_width, int __pyx_v_height, enum AVPixelFormat __pyx_v_dst_format, int __pyx_v_src_colorspace, int __pyx_v_dst_colorspace, int __pyx_v_interpolation); /* proto*/
1983
1984 /* Module declarations from 'libc.stdint' */
1985
1986 /* Module declarations from 'libav' */
1987
1988 /* Module declarations from 'av.buffer' */
1989 static PyTypeObject *__pyx_ptype_2av_6buffer_Buffer = 0;
1990
1991 /* Module declarations from 'cpython.buffer' */
1992
1993 /* Module declarations from 'av.bytesource' */
1994 static PyTypeObject *__pyx_ptype_2av_10bytesource_ByteSource = 0;
1995
1996 /* Module declarations from 'av.codec.codec' */
1997 static PyTypeObject *__pyx_ptype_2av_5codec_5codec_Codec = 0;
1998
1999 /* Module declarations from 'av.codec.context' */
2000 static PyTypeObject *__pyx_ptype_2av_5codec_7context_CodecContext = 0;
2001
2002 /* Module declarations from 'av.container.streams' */
2003 static PyTypeObject *__pyx_ptype_2av_9container_7streams_StreamContainer = 0;
2004
2005 /* Module declarations from 'av.dictionary' */
2006 static PyTypeObject *__pyx_ptype_2av_10dictionary__Dictionary = 0;
2007 static struct __pyx_obj_2av_10dictionary__Dictionary *(*__pyx_f_2av_10dictionary_wrap_dictionary)(AVDictionary *); /*proto*/
2008
2009 /* Module declarations from 'av.format' */
2010 static PyTypeObject *__pyx_ptype_2av_6format_ContainerFormat = 0;
2011
2012 /* Module declarations from 'av.container.core' */
2013 static PyTypeObject *__pyx_ptype_2av_9container_4core_Container = 0;
2014
2015 /* Module declarations from 'av.stream' */
2016 static PyTypeObject *__pyx_ptype_2av_6stream_Stream = 0;
2017
2018 /* Module declarations from 'av.packet' */
2019 static PyTypeObject *__pyx_ptype_2av_6packet_Packet = 0;
2020
2021 /* Module declarations from 'av.sidedata.sidedata' */
2022 static PyTypeObject *__pyx_ptype_2av_8sidedata_8sidedata_SideData = 0;
2023 static PyTypeObject *__pyx_ptype_2av_8sidedata_8sidedata__SideDataContainer = 0;
2024
2025 /* Module declarations from 'av.frame' */
2026 static PyTypeObject *__pyx_ptype_2av_5frame_Frame = 0;
2027
2028 /* Module declarations from 'av.video.format' */
2029 static PyTypeObject *__pyx_ptype_2av_5video_6format_VideoFormat = 0;
2030 static PyTypeObject *__pyx_ptype_2av_5video_6format_VideoFormatComponent = 0;
2031
2032 /* Module declarations from 'av.video.frame' */
2033 static PyTypeObject *__pyx_ptype_2av_5video_5frame_VideoFrame = 0;
2034 static struct __pyx_obj_2av_5video_5frame_VideoFrame *(*__pyx_f_2av_5video_5frame_alloc_video_frame)(void); /*proto*/
2035
2036 /* Module declarations from 'av.enum' */
2037 static PyObject *(*__pyx_f_2av_4enum_define_enum)(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_4enum_define_enum *__pyx_optional_args); /*proto*/
2038
2039 /* Module declarations from 'av.error' */
2040 static int (*__pyx_f_2av_5error_err_check)(int, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5error_err_check *__pyx_optional_args); /*proto*/
2041
2042 /* Module declarations from 'av.video.reformatter' */
2043 static PyTypeObject *__pyx_ptype_2av_5video_11reformatter_VideoReformatter = 0;
2044 #define __Pyx_MODULE_NAME "av.video.reformatter"
2045 extern int __pyx_module_is_main_av__video__reformatter;
2046 int __pyx_module_is_main_av__video__reformatter = 0;
2047
2048 /* Implementation of 'av.video.reformatter' */
2049 static PyObject *__pyx_builtin_ValueError;
2050 static PyObject *__pyx_builtin_TypeError;
2051 static const char __pyx_k_X[] = "X";
2052 static const char __pyx_k_FCC[] = "FCC";
2053 static const char __pyx_k_fcc[] = "fcc";
2054 static const char __pyx_k_AREA[] = "AREA";
2055 static const char __pyx_k_SINC[] = "SINC";
2056 static const char __pyx_k_Sinc[] = "Sinc";
2057 static const char __pyx_k_main[] = "__main__";
2058 static const char __pyx_k_name[] = "__name__";
2059 static const char __pyx_k_test[] = "__test__";
2060 static const char __pyx_k_GAUSS[] = "GAUSS";
2061 static const char __pyx_k_POINT[] = "POINT";
2062 static const char __pyx_k_frame[] = "frame";
2063 static const char __pyx_k_value[] = "value";
2064 static const char __pyx_k_width[] = "width";
2065 static const char __pyx_k_ITU601[] = "ITU601";
2066 static const char __pyx_k_ITU624[] = "ITU624";
2067 static const char __pyx_k_ITU709[] = "ITU709";
2068 static const char __pyx_k_SPLINE[] = "SPLINE";
2069 static const char __pyx_k_format[] = "format";
2070 static const char __pyx_k_height[] = "height";
2071 static const char __pyx_k_itu601[] = "itu601";
2072 static const char __pyx_k_itu624[] = "itu624";
2073 static const char __pyx_k_itu709[] = "itu709";
2074 static const char __pyx_k_reduce[] = "__reduce__";
2075 static const char __pyx_k_BICUBIC[] = "BICUBIC";
2076 static const char __pyx_k_Bicubic[] = "Bicubic";
2077 static const char __pyx_k_DEFAULT[] = "DEFAULT";
2078 static const char __pyx_k_LANCZOS[] = "LANCZOS";
2079 static const char __pyx_k_Lanczos[] = "Lanczos";
2080 static const char __pyx_k_default[] = "default";
2081 static const char __pyx_k_BICUBLIN[] = "BICUBLIN";
2082 static const char __pyx_k_BILINEAR[] = "BILINEAR";
2083 static const char __pyx_k_Bilinear[] = "Bilinear";
2084 static const char __pyx_k_Gaussian[] = "Gaussian";
2085 static const char __pyx_k_getstate[] = "__getstate__";
2086 static const char __pyx_k_setstate[] = "__setstate__";
2087 static const char __pyx_k_smpte240[] = "smpte240";
2088 static const char __pyx_k_SMPTE170M[] = "SMPTE170M";
2089 static const char __pyx_k_SMPTE240M[] = "SMPTE240M";
2090 static const char __pyx_k_TypeError[] = "TypeError";
2091 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2092 static const char __pyx_k_Colorspace[] = "Colorspace";
2093 static const char __pyx_k_ValueError[] = "ValueError";
2094 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2095 static const char __pyx_k_Experimental[] = "Experimental";
2096 static const char __pyx_k_FAST_BILINEAR[] = "FAST_BILINEAR";
2097 static const char __pyx_k_Fast_bilinear[] = "Fast bilinear";
2098 static const char __pyx_k_Interpolation[] = "Interpolation";
2099 static const char __pyx_k_interpolation[] = "interpolation";
2100 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2101 static const char __pyx_k_Area_averaging[] = "Area averaging";
2102 static const char __pyx_k_Bicubic_spline[] = "Bicubic spline";
2103 static const char __pyx_k_dst_colorspace[] = "dst_colorspace";
2104 static const char __pyx_k_src_colorspace[] = "src_colorspace";
2105 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2106 static const char __pyx_k_VideoReformatter[] = "VideoReformatter";
2107 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2108 static const char __pyx_k_Nearest_neighbor_point[] = "Nearest neighbor / point";
2109 static const char __pyx_k_Luma_bicubic_chroma_bilinear[] = "Luma bicubic / chroma bilinear";
2110 static const char __pyx_k_Frame_does_not_have_format_set[] = "Frame does not have format set.";
2111 static const char __pyx_k_self_ptr_cannot_be_converted_to[] = "self.ptr cannot be converted to a Python object for pickling";
2112 static PyObject *__pyx_n_s_AREA;
2113 static PyObject *__pyx_kp_s_Area_averaging;
2114 static PyObject *__pyx_n_s_BICUBIC;
2115 static PyObject *__pyx_n_s_BICUBLIN;
2116 static PyObject *__pyx_n_s_BILINEAR;
2117 static PyObject *__pyx_n_s_Bicubic;
2118 static PyObject *__pyx_kp_s_Bicubic_spline;
2119 static PyObject *__pyx_n_s_Bilinear;
2120 static PyObject *__pyx_n_s_Colorspace;
2121 static PyObject *__pyx_n_s_DEFAULT;
2122 static PyObject *__pyx_n_s_Experimental;
2123 static PyObject *__pyx_n_s_FAST_BILINEAR;
2124 static PyObject *__pyx_n_s_FCC;
2125 static PyObject *__pyx_kp_s_Fast_bilinear;
2126 static PyObject *__pyx_kp_s_Frame_does_not_have_format_set;
2127 static PyObject *__pyx_n_s_GAUSS;
2128 static PyObject *__pyx_n_s_Gaussian;
2129 static PyObject *__pyx_n_s_ITU601;
2130 static PyObject *__pyx_n_s_ITU624;
2131 static PyObject *__pyx_n_s_ITU709;
2132 static PyObject *__pyx_n_s_Interpolation;
2133 static PyObject *__pyx_n_s_LANCZOS;
2134 static PyObject *__pyx_n_s_Lanczos;
2135 static PyObject *__pyx_kp_s_Luma_bicubic_chroma_bilinear;
2136 static PyObject *__pyx_kp_s_Nearest_neighbor_point;
2137 static PyObject *__pyx_n_s_POINT;
2138 static PyObject *__pyx_n_s_SINC;
2139 static PyObject *__pyx_n_s_SMPTE170M;
2140 static PyObject *__pyx_n_s_SMPTE240M;
2141 static PyObject *__pyx_n_s_SPLINE;
2142 static PyObject *__pyx_n_s_Sinc;
2143 static PyObject *__pyx_n_s_TypeError;
2144 static PyObject *__pyx_n_s_ValueError;
2145 static PyObject *__pyx_n_s_VideoReformatter;
2146 static PyObject *__pyx_n_s_X;
2147 static PyObject *__pyx_n_s_cline_in_traceback;
2148 static PyObject *__pyx_n_s_default;
2149 static PyObject *__pyx_n_s_dst_colorspace;
2150 static PyObject *__pyx_n_s_fcc;
2151 static PyObject *__pyx_n_s_format;
2152 static PyObject *__pyx_n_s_frame;
2153 static PyObject *__pyx_n_s_getstate;
2154 static PyObject *__pyx_n_s_height;
2155 static PyObject *__pyx_n_s_interpolation;
2156 static PyObject *__pyx_n_s_itu601;
2157 static PyObject *__pyx_n_s_itu624;
2158 static PyObject *__pyx_n_s_itu709;
2159 static PyObject *__pyx_n_s_main;
2160 static PyObject *__pyx_n_s_name;
2161 static PyObject *__pyx_n_s_pyx_vtable;
2162 static PyObject *__pyx_n_s_reduce;
2163 static PyObject *__pyx_n_s_reduce_cython;
2164 static PyObject *__pyx_n_s_reduce_ex;
2165 static PyObject *__pyx_kp_s_self_ptr_cannot_be_converted_to;
2166 static PyObject *__pyx_n_s_setstate;
2167 static PyObject *__pyx_n_s_setstate_cython;
2168 static PyObject *__pyx_n_s_smpte240;
2169 static PyObject *__pyx_n_s_src_colorspace;
2170 static PyObject *__pyx_n_s_test;
2171 static PyObject *__pyx_n_s_value;
2172 static PyObject *__pyx_n_s_width;
2173 static void __pyx_pf_2av_5video_11reformatter_16VideoReformatter___dealloc__(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self); /* proto */
2174 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_2reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_frame, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_format, PyObject *__pyx_v_src_colorspace, PyObject *__pyx_v_dst_colorspace, PyObject *__pyx_v_interpolation); /* proto */
2175 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self); /* proto */
2176 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
2177 static PyObject *__pyx_tp_new_2av_5video_11reformatter_VideoReformatter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2178 static PyObject *__pyx_tuple_;
2179 static PyObject *__pyx_tuple__2;
2180 static PyObject *__pyx_tuple__3;
2181 /* Late includes */
2182
2183 /* "av/video/reformatter.pyx":54
2184 * """
2185 *
2186 * def __dealloc__(self): # <<<<<<<<<<<<<<
2187 * with nogil:
2188 * lib.sws_freeContext(self.ptr)
2189 */
2190
2191 /* Python wrapper */
2192 static void __pyx_pw_2av_5video_11reformatter_16VideoReformatter_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_2av_5video_11reformatter_16VideoReformatter_1__dealloc__(PyObject * __pyx_v_self)2193 static void __pyx_pw_2av_5video_11reformatter_16VideoReformatter_1__dealloc__(PyObject *__pyx_v_self) {
2194 __Pyx_RefNannyDeclarations
2195 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
2196 __pyx_pf_2av_5video_11reformatter_16VideoReformatter___dealloc__(((struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *)__pyx_v_self));
2197
2198 /* function exit code */
2199 __Pyx_RefNannyFinishContext();
2200 }
2201
__pyx_pf_2av_5video_11reformatter_16VideoReformatter___dealloc__(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter * __pyx_v_self)2202 static void __pyx_pf_2av_5video_11reformatter_16VideoReformatter___dealloc__(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self) {
2203 __Pyx_RefNannyDeclarations
2204 __Pyx_RefNannySetupContext("__dealloc__", 0);
2205
2206 /* "av/video/reformatter.pyx":55
2207 *
2208 * def __dealloc__(self):
2209 * with nogil: # <<<<<<<<<<<<<<
2210 * lib.sws_freeContext(self.ptr)
2211 *
2212 */
2213 {
2214 #ifdef WITH_THREAD
2215 PyThreadState *_save;
2216 Py_UNBLOCK_THREADS
2217 __Pyx_FastGIL_Remember();
2218 #endif
2219 /*try:*/ {
2220
2221 /* "av/video/reformatter.pyx":56
2222 * def __dealloc__(self):
2223 * with nogil:
2224 * lib.sws_freeContext(self.ptr) # <<<<<<<<<<<<<<
2225 *
2226 * def reformat(self, VideoFrame frame not None, width=None, height=None,
2227 */
2228 sws_freeContext(__pyx_v_self->ptr);
2229 }
2230
2231 /* "av/video/reformatter.pyx":55
2232 *
2233 * def __dealloc__(self):
2234 * with nogil: # <<<<<<<<<<<<<<
2235 * lib.sws_freeContext(self.ptr)
2236 *
2237 */
2238 /*finally:*/ {
2239 /*normal exit:*/{
2240 #ifdef WITH_THREAD
2241 __Pyx_FastGIL_Forget();
2242 Py_BLOCK_THREADS
2243 #endif
2244 goto __pyx_L5;
2245 }
2246 __pyx_L5:;
2247 }
2248 }
2249
2250 /* "av/video/reformatter.pyx":54
2251 * """
2252 *
2253 * def __dealloc__(self): # <<<<<<<<<<<<<<
2254 * with nogil:
2255 * lib.sws_freeContext(self.ptr)
2256 */
2257
2258 /* function exit code */
2259 __Pyx_RefNannyFinishContext();
2260 }
2261
2262 /* "av/video/reformatter.pyx":58
2263 * lib.sws_freeContext(self.ptr)
2264 *
2265 * def reformat(self, VideoFrame frame not None, width=None, height=None, # <<<<<<<<<<<<<<
2266 * format=None, src_colorspace=None, dst_colorspace=None,
2267 * interpolation=None):
2268 */
2269
2270 /* Python wrapper */
2271 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_3reformat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2272 static char __pyx_doc_2av_5video_11reformatter_16VideoReformatter_2reformat[] = "VideoReformatter.reformat(VideoFrame frame, width=None, height=None, format=None, src_colorspace=None, dst_colorspace=None, interpolation=None)\nCreate a new :class:`VideoFrame` with the given width/height/format/colorspace.\n\n Returns the same frame untouched if nothing needs to be done to it.\n\n :param int width: New width, or ``None`` for the same width.\n :param int height: New height, or ``None`` for the same height.\n :param format: New format, or ``None`` for the same format.\n :type format: :class:`.VideoFormat` or ``str``\n :param src_colorspace: Current colorspace, or ``None`` for ``DEFAULT``.\n :type src_colorspace: :class:`Colorspace` or ``str``\n :param dst_colorspace: Desired colorspace, or ``None`` for ``DEFAULT``.\n :type dst_colorspace: :class:`Colorspace` or ``str``\n :param interpolation: The interpolation method to use, or ``None`` for ``BILINEAR``.\n :type interpolation: :class:`Interpolation` or ``str``\n\n ";
__pyx_pw_2av_5video_11reformatter_16VideoReformatter_3reformat(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2273 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_3reformat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2274 struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_frame = 0;
2275 PyObject *__pyx_v_width = 0;
2276 PyObject *__pyx_v_height = 0;
2277 PyObject *__pyx_v_format = 0;
2278 PyObject *__pyx_v_src_colorspace = 0;
2279 PyObject *__pyx_v_dst_colorspace = 0;
2280 PyObject *__pyx_v_interpolation = 0;
2281 int __pyx_lineno = 0;
2282 const char *__pyx_filename = NULL;
2283 int __pyx_clineno = 0;
2284 PyObject *__pyx_r = 0;
2285 __Pyx_RefNannyDeclarations
2286 __Pyx_RefNannySetupContext("reformat (wrapper)", 0);
2287 {
2288 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_frame,&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_format,&__pyx_n_s_src_colorspace,&__pyx_n_s_dst_colorspace,&__pyx_n_s_interpolation,0};
2289 PyObject* values[7] = {0,0,0,0,0,0,0};
2290 values[1] = ((PyObject *)Py_None);
2291 values[2] = ((PyObject *)Py_None);
2292
2293 /* "av/video/reformatter.pyx":59
2294 *
2295 * def reformat(self, VideoFrame frame not None, width=None, height=None,
2296 * format=None, src_colorspace=None, dst_colorspace=None, # <<<<<<<<<<<<<<
2297 * interpolation=None):
2298 * """Create a new :class:`VideoFrame` with the given width/height/format/colorspace.
2299 */
2300 values[3] = ((PyObject *)Py_None);
2301 values[4] = ((PyObject *)Py_None);
2302 values[5] = ((PyObject *)Py_None);
2303
2304 /* "av/video/reformatter.pyx":60
2305 * def reformat(self, VideoFrame frame not None, width=None, height=None,
2306 * format=None, src_colorspace=None, dst_colorspace=None,
2307 * interpolation=None): # <<<<<<<<<<<<<<
2308 * """Create a new :class:`VideoFrame` with the given width/height/format/colorspace.
2309 *
2310 */
2311 values[6] = ((PyObject *)Py_None);
2312 if (unlikely(__pyx_kwds)) {
2313 Py_ssize_t kw_args;
2314 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2315 switch (pos_args) {
2316 case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
2317 CYTHON_FALLTHROUGH;
2318 case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
2319 CYTHON_FALLTHROUGH;
2320 case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
2321 CYTHON_FALLTHROUGH;
2322 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2323 CYTHON_FALLTHROUGH;
2324 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2325 CYTHON_FALLTHROUGH;
2326 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2327 CYTHON_FALLTHROUGH;
2328 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2329 CYTHON_FALLTHROUGH;
2330 case 0: break;
2331 default: goto __pyx_L5_argtuple_error;
2332 }
2333 kw_args = PyDict_Size(__pyx_kwds);
2334 switch (pos_args) {
2335 case 0:
2336 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_frame)) != 0)) kw_args--;
2337 else goto __pyx_L5_argtuple_error;
2338 CYTHON_FALLTHROUGH;
2339 case 1:
2340 if (kw_args > 0) {
2341 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_width);
2342 if (value) { values[1] = value; kw_args--; }
2343 }
2344 CYTHON_FALLTHROUGH;
2345 case 2:
2346 if (kw_args > 0) {
2347 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_height);
2348 if (value) { values[2] = value; kw_args--; }
2349 }
2350 CYTHON_FALLTHROUGH;
2351 case 3:
2352 if (kw_args > 0) {
2353 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
2354 if (value) { values[3] = value; kw_args--; }
2355 }
2356 CYTHON_FALLTHROUGH;
2357 case 4:
2358 if (kw_args > 0) {
2359 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_src_colorspace);
2360 if (value) { values[4] = value; kw_args--; }
2361 }
2362 CYTHON_FALLTHROUGH;
2363 case 5:
2364 if (kw_args > 0) {
2365 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dst_colorspace);
2366 if (value) { values[5] = value; kw_args--; }
2367 }
2368 CYTHON_FALLTHROUGH;
2369 case 6:
2370 if (kw_args > 0) {
2371 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interpolation);
2372 if (value) { values[6] = value; kw_args--; }
2373 }
2374 }
2375 if (unlikely(kw_args > 0)) {
2376 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reformat") < 0)) __PYX_ERR(0, 58, __pyx_L3_error)
2377 }
2378 } else {
2379 switch (PyTuple_GET_SIZE(__pyx_args)) {
2380 case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
2381 CYTHON_FALLTHROUGH;
2382 case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
2383 CYTHON_FALLTHROUGH;
2384 case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
2385 CYTHON_FALLTHROUGH;
2386 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2387 CYTHON_FALLTHROUGH;
2388 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2389 CYTHON_FALLTHROUGH;
2390 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2391 CYTHON_FALLTHROUGH;
2392 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2393 break;
2394 default: goto __pyx_L5_argtuple_error;
2395 }
2396 }
2397 __pyx_v_frame = ((struct __pyx_obj_2av_5video_5frame_VideoFrame *)values[0]);
2398 __pyx_v_width = values[1];
2399 __pyx_v_height = values[2];
2400 __pyx_v_format = values[3];
2401 __pyx_v_src_colorspace = values[4];
2402 __pyx_v_dst_colorspace = values[5];
2403 __pyx_v_interpolation = values[6];
2404 }
2405 goto __pyx_L4_argument_unpacking_done;
2406 __pyx_L5_argtuple_error:;
2407 __Pyx_RaiseArgtupleInvalid("reformat", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 58, __pyx_L3_error)
2408 __pyx_L3_error:;
2409 __Pyx_AddTraceback("av.video.reformatter.VideoReformatter.reformat", __pyx_clineno, __pyx_lineno, __pyx_filename);
2410 __Pyx_RefNannyFinishContext();
2411 return NULL;
2412 __pyx_L4_argument_unpacking_done:;
2413 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_frame), __pyx_ptype_2av_5video_5frame_VideoFrame, 0, "frame", 0))) __PYX_ERR(0, 58, __pyx_L1_error)
2414 __pyx_r = __pyx_pf_2av_5video_11reformatter_16VideoReformatter_2reformat(((struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *)__pyx_v_self), __pyx_v_frame, __pyx_v_width, __pyx_v_height, __pyx_v_format, __pyx_v_src_colorspace, __pyx_v_dst_colorspace, __pyx_v_interpolation);
2415
2416 /* "av/video/reformatter.pyx":58
2417 * lib.sws_freeContext(self.ptr)
2418 *
2419 * def reformat(self, VideoFrame frame not None, width=None, height=None, # <<<<<<<<<<<<<<
2420 * format=None, src_colorspace=None, dst_colorspace=None,
2421 * interpolation=None):
2422 */
2423
2424 /* function exit code */
2425 goto __pyx_L0;
2426 __pyx_L1_error:;
2427 __pyx_r = NULL;
2428 __pyx_L0:;
2429 __Pyx_RefNannyFinishContext();
2430 return __pyx_r;
2431 }
2432
__pyx_pf_2av_5video_11reformatter_16VideoReformatter_2reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter * __pyx_v_self,struct __pyx_obj_2av_5video_5frame_VideoFrame * __pyx_v_frame,PyObject * __pyx_v_width,PyObject * __pyx_v_height,PyObject * __pyx_v_format,PyObject * __pyx_v_src_colorspace,PyObject * __pyx_v_dst_colorspace,PyObject * __pyx_v_interpolation)2433 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_2reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_frame, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_format, PyObject *__pyx_v_src_colorspace, PyObject *__pyx_v_dst_colorspace, PyObject *__pyx_v_interpolation) {
2434 struct __pyx_obj_2av_5video_6format_VideoFormat *__pyx_v_video_format = 0;
2435 int __pyx_v_c_src_colorspace;
2436 int __pyx_v_c_dst_colorspace;
2437 int __pyx_v_c_interpolation;
2438 PyObject *__pyx_r = NULL;
2439 __Pyx_RefNannyDeclarations
2440 PyObject *__pyx_t_1 = NULL;
2441 int __pyx_t_2;
2442 PyObject *__pyx_t_3 = NULL;
2443 PyObject *__pyx_t_4 = NULL;
2444 int __pyx_t_5;
2445 int __pyx_t_6;
2446 int __pyx_t_7;
2447 int __pyx_lineno = 0;
2448 const char *__pyx_filename = NULL;
2449 int __pyx_clineno = 0;
2450 __Pyx_RefNannySetupContext("reformat", 0);
2451
2452 /* "av/video/reformatter.pyx":78
2453 * """
2454 *
2455 * cdef VideoFormat video_format = VideoFormat(format if format is not None else frame.format) # <<<<<<<<<<<<<<
2456 * cdef int c_src_colorspace = (Colorspace[src_colorspace] if src_colorspace is not None else Colorspace.DEFAULT).value
2457 * cdef int c_dst_colorspace = (Colorspace[dst_colorspace] if dst_colorspace is not None else Colorspace.DEFAULT).value
2458 */
2459 __pyx_t_2 = (__pyx_v_format != Py_None);
2460 if ((__pyx_t_2 != 0)) {
2461 __Pyx_INCREF(__pyx_v_format);
2462 __pyx_t_1 = __pyx_v_format;
2463 } else {
2464 __Pyx_INCREF(((PyObject *)__pyx_v_frame->format));
2465 __pyx_t_1 = ((PyObject *)__pyx_v_frame->format);
2466 }
2467 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_2av_5video_6format_VideoFormat), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
2468 __Pyx_GOTREF(__pyx_t_3);
2469 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2470 __pyx_v_video_format = ((struct __pyx_obj_2av_5video_6format_VideoFormat *)__pyx_t_3);
2471 __pyx_t_3 = 0;
2472
2473 /* "av/video/reformatter.pyx":79
2474 *
2475 * cdef VideoFormat video_format = VideoFormat(format if format is not None else frame.format)
2476 * cdef int c_src_colorspace = (Colorspace[src_colorspace] if src_colorspace is not None else Colorspace.DEFAULT).value # <<<<<<<<<<<<<<
2477 * cdef int c_dst_colorspace = (Colorspace[dst_colorspace] if dst_colorspace is not None else Colorspace.DEFAULT).value
2478 * cdef int c_interpolation = (Interpolation[interpolation] if interpolation is not None else Interpolation.BILINEAR).value
2479 */
2480 __pyx_t_2 = (__pyx_v_src_colorspace != Py_None);
2481 if ((__pyx_t_2 != 0)) {
2482 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Colorspace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
2483 __Pyx_GOTREF(__pyx_t_1);
2484 __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_src_colorspace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
2485 __Pyx_GOTREF(__pyx_t_4);
2486 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2487 __pyx_t_3 = __pyx_t_4;
2488 __pyx_t_4 = 0;
2489 } else {
2490 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Colorspace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
2491 __Pyx_GOTREF(__pyx_t_4);
2492 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DEFAULT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
2493 __Pyx_GOTREF(__pyx_t_1);
2494 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2495 __pyx_t_3 = __pyx_t_1;
2496 __pyx_t_1 = 0;
2497 }
2498 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
2499 __Pyx_GOTREF(__pyx_t_1);
2500 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2501 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error)
2502 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2503 __pyx_v_c_src_colorspace = __pyx_t_5;
2504
2505 /* "av/video/reformatter.pyx":80
2506 * cdef VideoFormat video_format = VideoFormat(format if format is not None else frame.format)
2507 * cdef int c_src_colorspace = (Colorspace[src_colorspace] if src_colorspace is not None else Colorspace.DEFAULT).value
2508 * cdef int c_dst_colorspace = (Colorspace[dst_colorspace] if dst_colorspace is not None else Colorspace.DEFAULT).value # <<<<<<<<<<<<<<
2509 * cdef int c_interpolation = (Interpolation[interpolation] if interpolation is not None else Interpolation.BILINEAR).value
2510 *
2511 */
2512 __pyx_t_2 = (__pyx_v_dst_colorspace != Py_None);
2513 if ((__pyx_t_2 != 0)) {
2514 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Colorspace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
2515 __Pyx_GOTREF(__pyx_t_3);
2516 __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_dst_colorspace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
2517 __Pyx_GOTREF(__pyx_t_4);
2518 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2519 __pyx_t_1 = __pyx_t_4;
2520 __pyx_t_4 = 0;
2521 } else {
2522 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Colorspace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
2523 __Pyx_GOTREF(__pyx_t_4);
2524 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DEFAULT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
2525 __Pyx_GOTREF(__pyx_t_3);
2526 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2527 __pyx_t_1 = __pyx_t_3;
2528 __pyx_t_3 = 0;
2529 }
2530 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
2531 __Pyx_GOTREF(__pyx_t_3);
2532 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2533 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L1_error)
2534 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2535 __pyx_v_c_dst_colorspace = __pyx_t_5;
2536
2537 /* "av/video/reformatter.pyx":81
2538 * cdef int c_src_colorspace = (Colorspace[src_colorspace] if src_colorspace is not None else Colorspace.DEFAULT).value
2539 * cdef int c_dst_colorspace = (Colorspace[dst_colorspace] if dst_colorspace is not None else Colorspace.DEFAULT).value
2540 * cdef int c_interpolation = (Interpolation[interpolation] if interpolation is not None else Interpolation.BILINEAR).value # <<<<<<<<<<<<<<
2541 *
2542 * return self._reformat(
2543 */
2544 __pyx_t_2 = (__pyx_v_interpolation != Py_None);
2545 if ((__pyx_t_2 != 0)) {
2546 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Interpolation); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
2547 __Pyx_GOTREF(__pyx_t_1);
2548 __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_interpolation); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 81, __pyx_L1_error)
2549 __Pyx_GOTREF(__pyx_t_4);
2550 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2551 __pyx_t_3 = __pyx_t_4;
2552 __pyx_t_4 = 0;
2553 } else {
2554 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Interpolation); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 81, __pyx_L1_error)
2555 __Pyx_GOTREF(__pyx_t_4);
2556 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_BILINEAR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
2557 __Pyx_GOTREF(__pyx_t_1);
2558 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2559 __pyx_t_3 = __pyx_t_1;
2560 __pyx_t_1 = 0;
2561 }
2562 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
2563 __Pyx_GOTREF(__pyx_t_1);
2564 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2565 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L1_error)
2566 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2567 __pyx_v_c_interpolation = __pyx_t_5;
2568
2569 /* "av/video/reformatter.pyx":83
2570 * cdef int c_interpolation = (Interpolation[interpolation] if interpolation is not None else Interpolation.BILINEAR).value
2571 *
2572 * return self._reformat( # <<<<<<<<<<<<<<
2573 * frame,
2574 * width or frame.ptr.width,
2575 */
2576 __Pyx_XDECREF(__pyx_r);
2577
2578 /* "av/video/reformatter.pyx":85
2579 * return self._reformat(
2580 * frame,
2581 * width or frame.ptr.width, # <<<<<<<<<<<<<<
2582 * height or frame.ptr.height,
2583 * video_format.pix_fmt,
2584 */
2585 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_width); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
2586 if (!__pyx_t_2) {
2587 } else {
2588 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
2589 __pyx_t_5 = __pyx_t_6;
2590 goto __pyx_L3_bool_binop_done;
2591 }
2592 __pyx_t_5 = __pyx_v_frame->__pyx_base.ptr->width;
2593 __pyx_L3_bool_binop_done:;
2594
2595 /* "av/video/reformatter.pyx":86
2596 * frame,
2597 * width or frame.ptr.width,
2598 * height or frame.ptr.height, # <<<<<<<<<<<<<<
2599 * video_format.pix_fmt,
2600 * c_src_colorspace,
2601 */
2602 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_height); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 86, __pyx_L1_error)
2603 if (!__pyx_t_2) {
2604 } else {
2605 __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error)
2606 __pyx_t_6 = __pyx_t_7;
2607 goto __pyx_L5_bool_binop_done;
2608 }
2609 __pyx_t_6 = __pyx_v_frame->__pyx_base.ptr->height;
2610 __pyx_L5_bool_binop_done:;
2611
2612 /* "av/video/reformatter.pyx":83
2613 * cdef int c_interpolation = (Interpolation[interpolation] if interpolation is not None else Interpolation.BILINEAR).value
2614 *
2615 * return self._reformat( # <<<<<<<<<<<<<<
2616 * frame,
2617 * width or frame.ptr.width,
2618 */
2619 __pyx_t_1 = ((struct __pyx_vtabstruct_2av_5video_11reformatter_VideoReformatter *)__pyx_v_self->__pyx_vtab)->_reformat(__pyx_v_self, __pyx_v_frame, __pyx_t_5, __pyx_t_6, __pyx_v_video_format->pix_fmt, __pyx_v_c_src_colorspace, __pyx_v_c_dst_colorspace, __pyx_v_c_interpolation); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2620 __Pyx_GOTREF(__pyx_t_1);
2621 __pyx_r = __pyx_t_1;
2622 __pyx_t_1 = 0;
2623 goto __pyx_L0;
2624
2625 /* "av/video/reformatter.pyx":58
2626 * lib.sws_freeContext(self.ptr)
2627 *
2628 * def reformat(self, VideoFrame frame not None, width=None, height=None, # <<<<<<<<<<<<<<
2629 * format=None, src_colorspace=None, dst_colorspace=None,
2630 * interpolation=None):
2631 */
2632
2633 /* function exit code */
2634 __pyx_L1_error:;
2635 __Pyx_XDECREF(__pyx_t_1);
2636 __Pyx_XDECREF(__pyx_t_3);
2637 __Pyx_XDECREF(__pyx_t_4);
2638 __Pyx_AddTraceback("av.video.reformatter.VideoReformatter.reformat", __pyx_clineno, __pyx_lineno, __pyx_filename);
2639 __pyx_r = NULL;
2640 __pyx_L0:;
2641 __Pyx_XDECREF((PyObject *)__pyx_v_video_format);
2642 __Pyx_XGIVEREF(__pyx_r);
2643 __Pyx_RefNannyFinishContext();
2644 return __pyx_r;
2645 }
2646
2647 /* "av/video/reformatter.pyx":93
2648 * )
2649 *
2650 * cdef _reformat(self, VideoFrame frame, int width, int height, # <<<<<<<<<<<<<<
2651 * lib.AVPixelFormat dst_format, int src_colorspace,
2652 * int dst_colorspace, int interpolation):
2653 */
2654
__pyx_f_2av_5video_11reformatter_16VideoReformatter__reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter * __pyx_v_self,struct __pyx_obj_2av_5video_5frame_VideoFrame * __pyx_v_frame,int __pyx_v_width,int __pyx_v_height,enum AVPixelFormat __pyx_v_dst_format,int __pyx_v_src_colorspace,int __pyx_v_dst_colorspace,int __pyx_v_interpolation)2655 static PyObject *__pyx_f_2av_5video_11reformatter_16VideoReformatter__reformat(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_frame, int __pyx_v_width, int __pyx_v_height, enum AVPixelFormat __pyx_v_dst_format, int __pyx_v_src_colorspace, int __pyx_v_dst_colorspace, int __pyx_v_interpolation) {
2656 enum AVPixelFormat __pyx_v_src_format;
2657 int const *__pyx_v_inv_tbl;
2658 int const *__pyx_v_tbl;
2659 int __pyx_v_src_range;
2660 int __pyx_v_dst_range;
2661 int __pyx_v_brightness;
2662 int __pyx_v_contrast;
2663 int __pyx_v_saturation;
2664 int __pyx_v_ret;
2665 struct __pyx_obj_2av_5video_5frame_VideoFrame *__pyx_v_new_frame = 0;
2666 PyObject *__pyx_r = NULL;
2667 __Pyx_RefNannyDeclarations
2668 int __pyx_t_1;
2669 PyObject *__pyx_t_2 = NULL;
2670 int __pyx_t_3;
2671 int __pyx_t_4;
2672 int __pyx_lineno = 0;
2673 const char *__pyx_filename = NULL;
2674 int __pyx_clineno = 0;
2675 __Pyx_RefNannySetupContext("_reformat", 0);
2676
2677 /* "av/video/reformatter.pyx":97
2678 * int dst_colorspace, int interpolation):
2679 *
2680 * if frame.ptr.format < 0: # <<<<<<<<<<<<<<
2681 * raise ValueError("Frame does not have format set.")
2682 *
2683 */
2684 __pyx_t_1 = ((__pyx_v_frame->__pyx_base.ptr->format < 0) != 0);
2685 if (unlikely(__pyx_t_1)) {
2686
2687 /* "av/video/reformatter.pyx":98
2688 *
2689 * if frame.ptr.format < 0:
2690 * raise ValueError("Frame does not have format set.") # <<<<<<<<<<<<<<
2691 *
2692 * cdef lib.AVPixelFormat src_format = <lib.AVPixelFormat> frame.ptr.format
2693 */
2694 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
2695 __Pyx_GOTREF(__pyx_t_2);
2696 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2697 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2698 __PYX_ERR(0, 98, __pyx_L1_error)
2699
2700 /* "av/video/reformatter.pyx":97
2701 * int dst_colorspace, int interpolation):
2702 *
2703 * if frame.ptr.format < 0: # <<<<<<<<<<<<<<
2704 * raise ValueError("Frame does not have format set.")
2705 *
2706 */
2707 }
2708
2709 /* "av/video/reformatter.pyx":100
2710 * raise ValueError("Frame does not have format set.")
2711 *
2712 * cdef lib.AVPixelFormat src_format = <lib.AVPixelFormat> frame.ptr.format # <<<<<<<<<<<<<<
2713 *
2714 * # Shortcut!
2715 */
2716 __pyx_v_src_format = ((enum AVPixelFormat)__pyx_v_frame->__pyx_base.ptr->format);
2717
2718 /* "av/video/reformatter.pyx":104
2719 * # Shortcut!
2720 * if (
2721 * dst_format == src_format and # <<<<<<<<<<<<<<
2722 * width == frame.ptr.width and
2723 * height == frame.ptr.height and
2724 */
2725 __pyx_t_3 = ((__pyx_v_dst_format == __pyx_v_src_format) != 0);
2726 if (__pyx_t_3) {
2727 } else {
2728 __pyx_t_1 = __pyx_t_3;
2729 goto __pyx_L5_bool_binop_done;
2730 }
2731
2732 /* "av/video/reformatter.pyx":105
2733 * if (
2734 * dst_format == src_format and
2735 * width == frame.ptr.width and # <<<<<<<<<<<<<<
2736 * height == frame.ptr.height and
2737 * dst_colorspace == src_colorspace
2738 */
2739 __pyx_t_3 = ((__pyx_v_width == __pyx_v_frame->__pyx_base.ptr->width) != 0);
2740 if (__pyx_t_3) {
2741 } else {
2742 __pyx_t_1 = __pyx_t_3;
2743 goto __pyx_L5_bool_binop_done;
2744 }
2745
2746 /* "av/video/reformatter.pyx":106
2747 * dst_format == src_format and
2748 * width == frame.ptr.width and
2749 * height == frame.ptr.height and # <<<<<<<<<<<<<<
2750 * dst_colorspace == src_colorspace
2751 * ):
2752 */
2753 __pyx_t_3 = ((__pyx_v_height == __pyx_v_frame->__pyx_base.ptr->height) != 0);
2754 if (__pyx_t_3) {
2755 } else {
2756 __pyx_t_1 = __pyx_t_3;
2757 goto __pyx_L5_bool_binop_done;
2758 }
2759
2760 /* "av/video/reformatter.pyx":107
2761 * width == frame.ptr.width and
2762 * height == frame.ptr.height and
2763 * dst_colorspace == src_colorspace # <<<<<<<<<<<<<<
2764 * ):
2765 * return frame
2766 */
2767 __pyx_t_3 = ((__pyx_v_dst_colorspace == __pyx_v_src_colorspace) != 0);
2768 __pyx_t_1 = __pyx_t_3;
2769 __pyx_L5_bool_binop_done:;
2770
2771 /* "av/video/reformatter.pyx":103
2772 *
2773 * # Shortcut!
2774 * if ( # <<<<<<<<<<<<<<
2775 * dst_format == src_format and
2776 * width == frame.ptr.width and
2777 */
2778 if (__pyx_t_1) {
2779
2780 /* "av/video/reformatter.pyx":109
2781 * dst_colorspace == src_colorspace
2782 * ):
2783 * return frame # <<<<<<<<<<<<<<
2784 *
2785 * # Try and reuse existing SwsContextProxy
2786 */
2787 __Pyx_XDECREF(__pyx_r);
2788 __Pyx_INCREF(((PyObject *)__pyx_v_frame));
2789 __pyx_r = ((PyObject *)__pyx_v_frame);
2790 goto __pyx_L0;
2791
2792 /* "av/video/reformatter.pyx":103
2793 *
2794 * # Shortcut!
2795 * if ( # <<<<<<<<<<<<<<
2796 * dst_format == src_format and
2797 * width == frame.ptr.width and
2798 */
2799 }
2800
2801 /* "av/video/reformatter.pyx":114
2802 * # VideoStream.decode will copy its SwsContextProxy to VideoFrame
2803 * # So all Video frames from the same VideoStream should have the same one
2804 * with nogil: # <<<<<<<<<<<<<<
2805 * self.ptr = lib.sws_getCachedContext(
2806 * self.ptr,
2807 */
2808 {
2809 #ifdef WITH_THREAD
2810 PyThreadState *_save;
2811 Py_UNBLOCK_THREADS
2812 __Pyx_FastGIL_Remember();
2813 #endif
2814 /*try:*/ {
2815
2816 /* "av/video/reformatter.pyx":115
2817 * # So all Video frames from the same VideoStream should have the same one
2818 * with nogil:
2819 * self.ptr = lib.sws_getCachedContext( # <<<<<<<<<<<<<<
2820 * self.ptr,
2821 * frame.ptr.width,
2822 */
2823 __pyx_v_self->ptr = sws_getCachedContext(__pyx_v_self->ptr, __pyx_v_frame->__pyx_base.ptr->width, __pyx_v_frame->__pyx_base.ptr->height, __pyx_v_src_format, __pyx_v_width, __pyx_v_height, __pyx_v_dst_format, __pyx_v_interpolation, NULL, NULL, NULL);
2824 }
2825
2826 /* "av/video/reformatter.pyx":114
2827 * # VideoStream.decode will copy its SwsContextProxy to VideoFrame
2828 * # So all Video frames from the same VideoStream should have the same one
2829 * with nogil: # <<<<<<<<<<<<<<
2830 * self.ptr = lib.sws_getCachedContext(
2831 * self.ptr,
2832 */
2833 /*finally:*/ {
2834 /*normal exit:*/{
2835 #ifdef WITH_THREAD
2836 __Pyx_FastGIL_Forget();
2837 Py_BLOCK_THREADS
2838 #endif
2839 goto __pyx_L11;
2840 }
2841 __pyx_L11:;
2842 }
2843 }
2844
2845 /* "av/video/reformatter.pyx":136
2846 * cdef int src_range, dst_range, brightness, contrast, saturation
2847 * cdef int ret
2848 * if src_colorspace != dst_colorspace: # <<<<<<<<<<<<<<
2849 *
2850 * with nogil:
2851 */
2852 __pyx_t_1 = ((__pyx_v_src_colorspace != __pyx_v_dst_colorspace) != 0);
2853 if (__pyx_t_1) {
2854
2855 /* "av/video/reformatter.pyx":138
2856 * if src_colorspace != dst_colorspace:
2857 *
2858 * with nogil: # <<<<<<<<<<<<<<
2859 *
2860 * # Casts for const-ness, because Cython isn't expressive enough.
2861 */
2862 {
2863 #ifdef WITH_THREAD
2864 PyThreadState *_save;
2865 Py_UNBLOCK_THREADS
2866 __Pyx_FastGIL_Remember();
2867 #endif
2868 /*try:*/ {
2869
2870 /* "av/video/reformatter.pyx":141
2871 *
2872 * # Casts for const-ness, because Cython isn't expressive enough.
2873 * ret = lib.sws_getColorspaceDetails( # <<<<<<<<<<<<<<
2874 * self.ptr,
2875 * <int**>&inv_tbl,
2876 */
2877 __pyx_v_ret = sws_getColorspaceDetails(__pyx_v_self->ptr, ((int **)(&__pyx_v_inv_tbl)), (&__pyx_v_src_range), ((int **)(&__pyx_v_tbl)), (&__pyx_v_dst_range), (&__pyx_v_brightness), (&__pyx_v_contrast), (&__pyx_v_saturation));
2878 }
2879
2880 /* "av/video/reformatter.pyx":138
2881 * if src_colorspace != dst_colorspace:
2882 *
2883 * with nogil: # <<<<<<<<<<<<<<
2884 *
2885 * # Casts for const-ness, because Cython isn't expressive enough.
2886 */
2887 /*finally:*/ {
2888 /*normal exit:*/{
2889 #ifdef WITH_THREAD
2890 __Pyx_FastGIL_Forget();
2891 Py_BLOCK_THREADS
2892 #endif
2893 goto __pyx_L15;
2894 }
2895 __pyx_L15:;
2896 }
2897 }
2898
2899 /* "av/video/reformatter.pyx":152
2900 * )
2901 *
2902 * err_check(ret) # <<<<<<<<<<<<<<
2903 *
2904 * with nogil:
2905 */
2906 __pyx_t_4 = __pyx_f_2av_5error_err_check(__pyx_v_ret, 0, NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 152, __pyx_L1_error)
2907
2908 /* "av/video/reformatter.pyx":154
2909 * err_check(ret)
2910 *
2911 * with nogil: # <<<<<<<<<<<<<<
2912 *
2913 * # Grab the coefficients for the requested transforms.
2914 */
2915 {
2916 #ifdef WITH_THREAD
2917 PyThreadState *_save;
2918 Py_UNBLOCK_THREADS
2919 __Pyx_FastGIL_Remember();
2920 #endif
2921 /*try:*/ {
2922
2923 /* "av/video/reformatter.pyx":158
2924 * # Grab the coefficients for the requested transforms.
2925 * # The inv_table brings us to linear, and `tbl` to the new space.
2926 * if src_colorspace != lib.SWS_CS_DEFAULT: # <<<<<<<<<<<<<<
2927 * inv_tbl = lib.sws_getCoefficients(src_colorspace)
2928 * if dst_colorspace != lib.SWS_CS_DEFAULT:
2929 */
2930 __pyx_t_1 = ((__pyx_v_src_colorspace != SWS_CS_DEFAULT) != 0);
2931 if (__pyx_t_1) {
2932
2933 /* "av/video/reformatter.pyx":159
2934 * # The inv_table brings us to linear, and `tbl` to the new space.
2935 * if src_colorspace != lib.SWS_CS_DEFAULT:
2936 * inv_tbl = lib.sws_getCoefficients(src_colorspace) # <<<<<<<<<<<<<<
2937 * if dst_colorspace != lib.SWS_CS_DEFAULT:
2938 * tbl = lib.sws_getCoefficients(dst_colorspace)
2939 */
2940 __pyx_v_inv_tbl = sws_getCoefficients(__pyx_v_src_colorspace);
2941
2942 /* "av/video/reformatter.pyx":158
2943 * # Grab the coefficients for the requested transforms.
2944 * # The inv_table brings us to linear, and `tbl` to the new space.
2945 * if src_colorspace != lib.SWS_CS_DEFAULT: # <<<<<<<<<<<<<<
2946 * inv_tbl = lib.sws_getCoefficients(src_colorspace)
2947 * if dst_colorspace != lib.SWS_CS_DEFAULT:
2948 */
2949 }
2950
2951 /* "av/video/reformatter.pyx":160
2952 * if src_colorspace != lib.SWS_CS_DEFAULT:
2953 * inv_tbl = lib.sws_getCoefficients(src_colorspace)
2954 * if dst_colorspace != lib.SWS_CS_DEFAULT: # <<<<<<<<<<<<<<
2955 * tbl = lib.sws_getCoefficients(dst_colorspace)
2956 *
2957 */
2958 __pyx_t_1 = ((__pyx_v_dst_colorspace != SWS_CS_DEFAULT) != 0);
2959 if (__pyx_t_1) {
2960
2961 /* "av/video/reformatter.pyx":161
2962 * inv_tbl = lib.sws_getCoefficients(src_colorspace)
2963 * if dst_colorspace != lib.SWS_CS_DEFAULT:
2964 * tbl = lib.sws_getCoefficients(dst_colorspace) # <<<<<<<<<<<<<<
2965 *
2966 * # Apply!
2967 */
2968 __pyx_v_tbl = sws_getCoefficients(__pyx_v_dst_colorspace);
2969
2970 /* "av/video/reformatter.pyx":160
2971 * if src_colorspace != lib.SWS_CS_DEFAULT:
2972 * inv_tbl = lib.sws_getCoefficients(src_colorspace)
2973 * if dst_colorspace != lib.SWS_CS_DEFAULT: # <<<<<<<<<<<<<<
2974 * tbl = lib.sws_getCoefficients(dst_colorspace)
2975 *
2976 */
2977 }
2978
2979 /* "av/video/reformatter.pyx":164
2980 *
2981 * # Apply!
2982 * ret = lib.sws_setColorspaceDetails( # <<<<<<<<<<<<<<
2983 * self.ptr,
2984 * inv_tbl,
2985 */
2986 __pyx_v_ret = sws_setColorspaceDetails(__pyx_v_self->ptr, __pyx_v_inv_tbl, __pyx_v_src_range, __pyx_v_tbl, __pyx_v_dst_range, __pyx_v_brightness, __pyx_v_contrast, __pyx_v_saturation);
2987 }
2988
2989 /* "av/video/reformatter.pyx":154
2990 * err_check(ret)
2991 *
2992 * with nogil: # <<<<<<<<<<<<<<
2993 *
2994 * # Grab the coefficients for the requested transforms.
2995 */
2996 /*finally:*/ {
2997 /*normal exit:*/{
2998 #ifdef WITH_THREAD
2999 __Pyx_FastGIL_Forget();
3000 Py_BLOCK_THREADS
3001 #endif
3002 goto __pyx_L18;
3003 }
3004 __pyx_L18:;
3005 }
3006 }
3007
3008 /* "av/video/reformatter.pyx":175
3009 * )
3010 *
3011 * err_check(ret) # <<<<<<<<<<<<<<
3012 *
3013 * # Create a new VideoFrame.
3014 */
3015 __pyx_t_4 = __pyx_f_2av_5error_err_check(__pyx_v_ret, 0, NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 175, __pyx_L1_error)
3016
3017 /* "av/video/reformatter.pyx":136
3018 * cdef int src_range, dst_range, brightness, contrast, saturation
3019 * cdef int ret
3020 * if src_colorspace != dst_colorspace: # <<<<<<<<<<<<<<
3021 *
3022 * with nogil:
3023 */
3024 }
3025
3026 /* "av/video/reformatter.pyx":178
3027 *
3028 * # Create a new VideoFrame.
3029 * cdef VideoFrame new_frame = alloc_video_frame() # <<<<<<<<<<<<<<
3030 * new_frame._copy_internal_attributes(frame)
3031 * new_frame._init(dst_format, width, height)
3032 */
3033 __pyx_t_2 = ((PyObject *)__pyx_f_2av_5video_5frame_alloc_video_frame()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
3034 __Pyx_GOTREF(__pyx_t_2);
3035 __pyx_v_new_frame = ((struct __pyx_obj_2av_5video_5frame_VideoFrame *)__pyx_t_2);
3036 __pyx_t_2 = 0;
3037
3038 /* "av/video/reformatter.pyx":179
3039 * # Create a new VideoFrame.
3040 * cdef VideoFrame new_frame = alloc_video_frame()
3041 * new_frame._copy_internal_attributes(frame) # <<<<<<<<<<<<<<
3042 * new_frame._init(dst_format, width, height)
3043 *
3044 */
3045 __pyx_t_2 = ((struct __pyx_vtabstruct_2av_5video_5frame_VideoFrame *)__pyx_v_new_frame->__pyx_base.__pyx_vtab)->__pyx_base._copy_internal_attributes(((struct __pyx_obj_2av_5frame_Frame *)__pyx_v_new_frame), ((struct __pyx_obj_2av_5frame_Frame *)__pyx_v_frame), NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
3046 __Pyx_GOTREF(__pyx_t_2);
3047 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3048
3049 /* "av/video/reformatter.pyx":180
3050 * cdef VideoFrame new_frame = alloc_video_frame()
3051 * new_frame._copy_internal_attributes(frame)
3052 * new_frame._init(dst_format, width, height) # <<<<<<<<<<<<<<
3053 *
3054 * # Finally, scale the image.
3055 */
3056 __pyx_t_2 = ((struct __pyx_vtabstruct_2av_5video_5frame_VideoFrame *)__pyx_v_new_frame->__pyx_base.__pyx_vtab)->_init(__pyx_v_new_frame, __pyx_v_dst_format, __pyx_v_width, __pyx_v_height); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
3057 __Pyx_GOTREF(__pyx_t_2);
3058 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3059
3060 /* "av/video/reformatter.pyx":183
3061 *
3062 * # Finally, scale the image.
3063 * with nogil: # <<<<<<<<<<<<<<
3064 * lib.sws_scale(
3065 * self.ptr,
3066 */
3067 {
3068 #ifdef WITH_THREAD
3069 PyThreadState *_save;
3070 Py_UNBLOCK_THREADS
3071 __Pyx_FastGIL_Remember();
3072 #endif
3073 /*try:*/ {
3074
3075 /* "av/video/reformatter.pyx":184
3076 * # Finally, scale the image.
3077 * with nogil:
3078 * lib.sws_scale( # <<<<<<<<<<<<<<
3079 * self.ptr,
3080 * # Cast for const-ness, because Cython isn't expressive enough.
3081 */
3082 (void)(sws_scale(__pyx_v_self->ptr, ((uint8_t const **)__pyx_v_frame->__pyx_base.ptr->data), __pyx_v_frame->__pyx_base.ptr->linesize, 0, __pyx_v_frame->__pyx_base.ptr->height, __pyx_v_new_frame->__pyx_base.ptr->data, __pyx_v_new_frame->__pyx_base.ptr->linesize));
3083 }
3084
3085 /* "av/video/reformatter.pyx":183
3086 *
3087 * # Finally, scale the image.
3088 * with nogil: # <<<<<<<<<<<<<<
3089 * lib.sws_scale(
3090 * self.ptr,
3091 */
3092 /*finally:*/ {
3093 /*normal exit:*/{
3094 #ifdef WITH_THREAD
3095 __Pyx_FastGIL_Forget();
3096 Py_BLOCK_THREADS
3097 #endif
3098 goto __pyx_L23;
3099 }
3100 __pyx_L23:;
3101 }
3102 }
3103
3104 /* "av/video/reformatter.pyx":195
3105 * )
3106 *
3107 * return new_frame # <<<<<<<<<<<<<<
3108 */
3109 __Pyx_XDECREF(__pyx_r);
3110 __Pyx_INCREF(((PyObject *)__pyx_v_new_frame));
3111 __pyx_r = ((PyObject *)__pyx_v_new_frame);
3112 goto __pyx_L0;
3113
3114 /* "av/video/reformatter.pyx":93
3115 * )
3116 *
3117 * cdef _reformat(self, VideoFrame frame, int width, int height, # <<<<<<<<<<<<<<
3118 * lib.AVPixelFormat dst_format, int src_colorspace,
3119 * int dst_colorspace, int interpolation):
3120 */
3121
3122 /* function exit code */
3123 __pyx_L1_error:;
3124 __Pyx_XDECREF(__pyx_t_2);
3125 __Pyx_AddTraceback("av.video.reformatter.VideoReformatter._reformat", __pyx_clineno, __pyx_lineno, __pyx_filename);
3126 __pyx_r = 0;
3127 __pyx_L0:;
3128 __Pyx_XDECREF((PyObject *)__pyx_v_new_frame);
3129 __Pyx_XGIVEREF(__pyx_r);
3130 __Pyx_RefNannyFinishContext();
3131 return __pyx_r;
3132 }
3133
3134 /* "(tree fragment)":1
3135 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3136 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3137 * def __setstate_cython__(self, __pyx_state):
3138 */
3139
3140 /* Python wrapper */
3141 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
3142 static char __pyx_doc_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__[] = "VideoReformatter.__reduce_cython__()";
__pyx_pw_2av_5video_11reformatter_16VideoReformatter_5__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)3143 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3144 PyObject *__pyx_r = 0;
3145 __Pyx_RefNannyDeclarations
3146 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
3147 __pyx_r = __pyx_pf_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__(((struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *)__pyx_v_self));
3148
3149 /* function exit code */
3150 __Pyx_RefNannyFinishContext();
3151 return __pyx_r;
3152 }
3153
__pyx_pf_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter * __pyx_v_self)3154 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self) {
3155 PyObject *__pyx_r = NULL;
3156 __Pyx_RefNannyDeclarations
3157 PyObject *__pyx_t_1 = NULL;
3158 int __pyx_lineno = 0;
3159 const char *__pyx_filename = NULL;
3160 int __pyx_clineno = 0;
3161 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
3162
3163 /* "(tree fragment)":2
3164 * def __reduce_cython__(self):
3165 * raise TypeError("self.ptr cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3166 * def __setstate_cython__(self, __pyx_state):
3167 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3168 */
3169 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
3170 __Pyx_GOTREF(__pyx_t_1);
3171 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3172 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3173 __PYX_ERR(1, 2, __pyx_L1_error)
3174
3175 /* "(tree fragment)":1
3176 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3177 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3178 * def __setstate_cython__(self, __pyx_state):
3179 */
3180
3181 /* function exit code */
3182 __pyx_L1_error:;
3183 __Pyx_XDECREF(__pyx_t_1);
3184 __Pyx_AddTraceback("av.video.reformatter.VideoReformatter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3185 __pyx_r = NULL;
3186 __Pyx_XGIVEREF(__pyx_r);
3187 __Pyx_RefNannyFinishContext();
3188 return __pyx_r;
3189 }
3190
3191 /* "(tree fragment)":3
3192 * def __reduce_cython__(self):
3193 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3194 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3195 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3196 */
3197
3198 /* Python wrapper */
3199 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
3200 static char __pyx_doc_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__[] = "VideoReformatter.__setstate_cython__(__pyx_state)";
__pyx_pw_2av_5video_11reformatter_16VideoReformatter_7__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)3201 static PyObject *__pyx_pw_2av_5video_11reformatter_16VideoReformatter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3202 PyObject *__pyx_r = 0;
3203 __Pyx_RefNannyDeclarations
3204 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
3205 __pyx_r = __pyx_pf_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__(((struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
3206
3207 /* function exit code */
3208 __Pyx_RefNannyFinishContext();
3209 return __pyx_r;
3210 }
3211
__pyx_pf_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)3212 static PyObject *__pyx_pf_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
3213 PyObject *__pyx_r = NULL;
3214 __Pyx_RefNannyDeclarations
3215 PyObject *__pyx_t_1 = NULL;
3216 int __pyx_lineno = 0;
3217 const char *__pyx_filename = NULL;
3218 int __pyx_clineno = 0;
3219 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
3220
3221 /* "(tree fragment)":4
3222 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3223 * def __setstate_cython__(self, __pyx_state):
3224 * raise TypeError("self.ptr cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3225 */
3226 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
3227 __Pyx_GOTREF(__pyx_t_1);
3228 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3229 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3230 __PYX_ERR(1, 4, __pyx_L1_error)
3231
3232 /* "(tree fragment)":3
3233 * def __reduce_cython__(self):
3234 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3235 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3236 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3237 */
3238
3239 /* function exit code */
3240 __pyx_L1_error:;
3241 __Pyx_XDECREF(__pyx_t_1);
3242 __Pyx_AddTraceback("av.video.reformatter.VideoReformatter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3243 __pyx_r = NULL;
3244 __Pyx_XGIVEREF(__pyx_r);
3245 __Pyx_RefNannyFinishContext();
3246 return __pyx_r;
3247 }
3248 static struct __pyx_vtabstruct_2av_5video_11reformatter_VideoReformatter __pyx_vtable_2av_5video_11reformatter_VideoReformatter;
3249
__pyx_tp_new_2av_5video_11reformatter_VideoReformatter(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)3250 static PyObject *__pyx_tp_new_2av_5video_11reformatter_VideoReformatter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
3251 struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *p;
3252 PyObject *o;
3253 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
3254 o = (*t->tp_alloc)(t, 0);
3255 } else {
3256 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
3257 }
3258 if (unlikely(!o)) return 0;
3259 p = ((struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *)o);
3260 p->__pyx_vtab = __pyx_vtabptr_2av_5video_11reformatter_VideoReformatter;
3261 return o;
3262 }
3263
__pyx_tp_dealloc_2av_5video_11reformatter_VideoReformatter(PyObject * o)3264 static void __pyx_tp_dealloc_2av_5video_11reformatter_VideoReformatter(PyObject *o) {
3265 #if CYTHON_USE_TP_FINALIZE
3266 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
3267 if (PyObject_CallFinalizerFromDealloc(o)) return;
3268 }
3269 #endif
3270 {
3271 PyObject *etype, *eval, *etb;
3272 PyErr_Fetch(&etype, &eval, &etb);
3273 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
3274 __pyx_pw_2av_5video_11reformatter_16VideoReformatter_1__dealloc__(o);
3275 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
3276 PyErr_Restore(etype, eval, etb);
3277 }
3278 (*Py_TYPE(o)->tp_free)(o);
3279 }
3280
3281 static PyMethodDef __pyx_methods_2av_5video_11reformatter_VideoReformatter[] = {
3282 {"reformat", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_2av_5video_11reformatter_16VideoReformatter_3reformat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_2av_5video_11reformatter_16VideoReformatter_2reformat},
3283 {"__reduce_cython__", (PyCFunction)__pyx_pw_2av_5video_11reformatter_16VideoReformatter_5__reduce_cython__, METH_NOARGS, __pyx_doc_2av_5video_11reformatter_16VideoReformatter_4__reduce_cython__},
3284 {"__setstate_cython__", (PyCFunction)__pyx_pw_2av_5video_11reformatter_16VideoReformatter_7__setstate_cython__, METH_O, __pyx_doc_2av_5video_11reformatter_16VideoReformatter_6__setstate_cython__},
3285 {0, 0, 0, 0}
3286 };
3287
3288 static PyTypeObject __pyx_type_2av_5video_11reformatter_VideoReformatter = {
3289 PyVarObject_HEAD_INIT(0, 0)
3290 "av.video.reformatter.VideoReformatter", /*tp_name*/
3291 sizeof(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter), /*tp_basicsize*/
3292 0, /*tp_itemsize*/
3293 __pyx_tp_dealloc_2av_5video_11reformatter_VideoReformatter, /*tp_dealloc*/
3294 #if PY_VERSION_HEX < 0x030800b4
3295 0, /*tp_print*/
3296 #endif
3297 #if PY_VERSION_HEX >= 0x030800b4
3298 0, /*tp_vectorcall_offset*/
3299 #endif
3300 0, /*tp_getattr*/
3301 0, /*tp_setattr*/
3302 #if PY_MAJOR_VERSION < 3
3303 0, /*tp_compare*/
3304 #endif
3305 #if PY_MAJOR_VERSION >= 3
3306 0, /*tp_as_async*/
3307 #endif
3308 0, /*tp_repr*/
3309 0, /*tp_as_number*/
3310 0, /*tp_as_sequence*/
3311 0, /*tp_as_mapping*/
3312 0, /*tp_hash*/
3313 0, /*tp_call*/
3314 0, /*tp_str*/
3315 0, /*tp_getattro*/
3316 0, /*tp_setattro*/
3317 0, /*tp_as_buffer*/
3318 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
3319 "An object for reformatting size and pixel format of :class:`.VideoFrame`.\n\n It is most efficient to have a reformatter object for each set of parameters\n you will use as calling :meth:`reformat` will reconfigure the internal object.\n\n ", /*tp_doc*/
3320 0, /*tp_traverse*/
3321 0, /*tp_clear*/
3322 0, /*tp_richcompare*/
3323 0, /*tp_weaklistoffset*/
3324 0, /*tp_iter*/
3325 0, /*tp_iternext*/
3326 __pyx_methods_2av_5video_11reformatter_VideoReformatter, /*tp_methods*/
3327 0, /*tp_members*/
3328 0, /*tp_getset*/
3329 0, /*tp_base*/
3330 0, /*tp_dict*/
3331 0, /*tp_descr_get*/
3332 0, /*tp_descr_set*/
3333 0, /*tp_dictoffset*/
3334 0, /*tp_init*/
3335 0, /*tp_alloc*/
3336 __pyx_tp_new_2av_5video_11reformatter_VideoReformatter, /*tp_new*/
3337 0, /*tp_free*/
3338 0, /*tp_is_gc*/
3339 0, /*tp_bases*/
3340 0, /*tp_mro*/
3341 0, /*tp_cache*/
3342 0, /*tp_subclasses*/
3343 0, /*tp_weaklist*/
3344 0, /*tp_del*/
3345 0, /*tp_version_tag*/
3346 #if PY_VERSION_HEX >= 0x030400a1
3347 0, /*tp_finalize*/
3348 #endif
3349 #if PY_VERSION_HEX >= 0x030800b1
3350 0, /*tp_vectorcall*/
3351 #endif
3352 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
3353 0, /*tp_print*/
3354 #endif
3355 };
3356
3357 static PyMethodDef __pyx_methods[] = {
3358 {0, 0, 0, 0}
3359 };
3360
3361 #if PY_MAJOR_VERSION >= 3
3362 #if CYTHON_PEP489_MULTI_PHASE_INIT
3363 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
3364 static int __pyx_pymod_exec_reformatter(PyObject* module); /*proto*/
3365 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
3366 {Py_mod_create, (void*)__pyx_pymod_create},
3367 {Py_mod_exec, (void*)__pyx_pymod_exec_reformatter},
3368 {0, NULL}
3369 };
3370 #endif
3371
3372 static struct PyModuleDef __pyx_moduledef = {
3373 PyModuleDef_HEAD_INIT,
3374 "reformatter",
3375 0, /* m_doc */
3376 #if CYTHON_PEP489_MULTI_PHASE_INIT
3377 0, /* m_size */
3378 #else
3379 -1, /* m_size */
3380 #endif
3381 __pyx_methods /* m_methods */,
3382 #if CYTHON_PEP489_MULTI_PHASE_INIT
3383 __pyx_moduledef_slots, /* m_slots */
3384 #else
3385 NULL, /* m_reload */
3386 #endif
3387 NULL, /* m_traverse */
3388 NULL, /* m_clear */
3389 NULL /* m_free */
3390 };
3391 #endif
3392 #ifndef CYTHON_SMALL_CODE
3393 #if defined(__clang__)
3394 #define CYTHON_SMALL_CODE
3395 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
3396 #define CYTHON_SMALL_CODE __attribute__((cold))
3397 #else
3398 #define CYTHON_SMALL_CODE
3399 #endif
3400 #endif
3401
3402 static __Pyx_StringTabEntry __pyx_string_tab[] = {
3403 {&__pyx_n_s_AREA, __pyx_k_AREA, sizeof(__pyx_k_AREA), 0, 0, 1, 1},
3404 {&__pyx_kp_s_Area_averaging, __pyx_k_Area_averaging, sizeof(__pyx_k_Area_averaging), 0, 0, 1, 0},
3405 {&__pyx_n_s_BICUBIC, __pyx_k_BICUBIC, sizeof(__pyx_k_BICUBIC), 0, 0, 1, 1},
3406 {&__pyx_n_s_BICUBLIN, __pyx_k_BICUBLIN, sizeof(__pyx_k_BICUBLIN), 0, 0, 1, 1},
3407 {&__pyx_n_s_BILINEAR, __pyx_k_BILINEAR, sizeof(__pyx_k_BILINEAR), 0, 0, 1, 1},
3408 {&__pyx_n_s_Bicubic, __pyx_k_Bicubic, sizeof(__pyx_k_Bicubic), 0, 0, 1, 1},
3409 {&__pyx_kp_s_Bicubic_spline, __pyx_k_Bicubic_spline, sizeof(__pyx_k_Bicubic_spline), 0, 0, 1, 0},
3410 {&__pyx_n_s_Bilinear, __pyx_k_Bilinear, sizeof(__pyx_k_Bilinear), 0, 0, 1, 1},
3411 {&__pyx_n_s_Colorspace, __pyx_k_Colorspace, sizeof(__pyx_k_Colorspace), 0, 0, 1, 1},
3412 {&__pyx_n_s_DEFAULT, __pyx_k_DEFAULT, sizeof(__pyx_k_DEFAULT), 0, 0, 1, 1},
3413 {&__pyx_n_s_Experimental, __pyx_k_Experimental, sizeof(__pyx_k_Experimental), 0, 0, 1, 1},
3414 {&__pyx_n_s_FAST_BILINEAR, __pyx_k_FAST_BILINEAR, sizeof(__pyx_k_FAST_BILINEAR), 0, 0, 1, 1},
3415 {&__pyx_n_s_FCC, __pyx_k_FCC, sizeof(__pyx_k_FCC), 0, 0, 1, 1},
3416 {&__pyx_kp_s_Fast_bilinear, __pyx_k_Fast_bilinear, sizeof(__pyx_k_Fast_bilinear), 0, 0, 1, 0},
3417 {&__pyx_kp_s_Frame_does_not_have_format_set, __pyx_k_Frame_does_not_have_format_set, sizeof(__pyx_k_Frame_does_not_have_format_set), 0, 0, 1, 0},
3418 {&__pyx_n_s_GAUSS, __pyx_k_GAUSS, sizeof(__pyx_k_GAUSS), 0, 0, 1, 1},
3419 {&__pyx_n_s_Gaussian, __pyx_k_Gaussian, sizeof(__pyx_k_Gaussian), 0, 0, 1, 1},
3420 {&__pyx_n_s_ITU601, __pyx_k_ITU601, sizeof(__pyx_k_ITU601), 0, 0, 1, 1},
3421 {&__pyx_n_s_ITU624, __pyx_k_ITU624, sizeof(__pyx_k_ITU624), 0, 0, 1, 1},
3422 {&__pyx_n_s_ITU709, __pyx_k_ITU709, sizeof(__pyx_k_ITU709), 0, 0, 1, 1},
3423 {&__pyx_n_s_Interpolation, __pyx_k_Interpolation, sizeof(__pyx_k_Interpolation), 0, 0, 1, 1},
3424 {&__pyx_n_s_LANCZOS, __pyx_k_LANCZOS, sizeof(__pyx_k_LANCZOS), 0, 0, 1, 1},
3425 {&__pyx_n_s_Lanczos, __pyx_k_Lanczos, sizeof(__pyx_k_Lanczos), 0, 0, 1, 1},
3426 {&__pyx_kp_s_Luma_bicubic_chroma_bilinear, __pyx_k_Luma_bicubic_chroma_bilinear, sizeof(__pyx_k_Luma_bicubic_chroma_bilinear), 0, 0, 1, 0},
3427 {&__pyx_kp_s_Nearest_neighbor_point, __pyx_k_Nearest_neighbor_point, sizeof(__pyx_k_Nearest_neighbor_point), 0, 0, 1, 0},
3428 {&__pyx_n_s_POINT, __pyx_k_POINT, sizeof(__pyx_k_POINT), 0, 0, 1, 1},
3429 {&__pyx_n_s_SINC, __pyx_k_SINC, sizeof(__pyx_k_SINC), 0, 0, 1, 1},
3430 {&__pyx_n_s_SMPTE170M, __pyx_k_SMPTE170M, sizeof(__pyx_k_SMPTE170M), 0, 0, 1, 1},
3431 {&__pyx_n_s_SMPTE240M, __pyx_k_SMPTE240M, sizeof(__pyx_k_SMPTE240M), 0, 0, 1, 1},
3432 {&__pyx_n_s_SPLINE, __pyx_k_SPLINE, sizeof(__pyx_k_SPLINE), 0, 0, 1, 1},
3433 {&__pyx_n_s_Sinc, __pyx_k_Sinc, sizeof(__pyx_k_Sinc), 0, 0, 1, 1},
3434 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
3435 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
3436 {&__pyx_n_s_VideoReformatter, __pyx_k_VideoReformatter, sizeof(__pyx_k_VideoReformatter), 0, 0, 1, 1},
3437 {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
3438 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
3439 {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
3440 {&__pyx_n_s_dst_colorspace, __pyx_k_dst_colorspace, sizeof(__pyx_k_dst_colorspace), 0, 0, 1, 1},
3441 {&__pyx_n_s_fcc, __pyx_k_fcc, sizeof(__pyx_k_fcc), 0, 0, 1, 1},
3442 {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
3443 {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1},
3444 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
3445 {&__pyx_n_s_height, __pyx_k_height, sizeof(__pyx_k_height), 0, 0, 1, 1},
3446 {&__pyx_n_s_interpolation, __pyx_k_interpolation, sizeof(__pyx_k_interpolation), 0, 0, 1, 1},
3447 {&__pyx_n_s_itu601, __pyx_k_itu601, sizeof(__pyx_k_itu601), 0, 0, 1, 1},
3448 {&__pyx_n_s_itu624, __pyx_k_itu624, sizeof(__pyx_k_itu624), 0, 0, 1, 1},
3449 {&__pyx_n_s_itu709, __pyx_k_itu709, sizeof(__pyx_k_itu709), 0, 0, 1, 1},
3450 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
3451 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
3452 {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
3453 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
3454 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
3455 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
3456 {&__pyx_kp_s_self_ptr_cannot_be_converted_to, __pyx_k_self_ptr_cannot_be_converted_to, sizeof(__pyx_k_self_ptr_cannot_be_converted_to), 0, 0, 1, 0},
3457 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
3458 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
3459 {&__pyx_n_s_smpte240, __pyx_k_smpte240, sizeof(__pyx_k_smpte240), 0, 0, 1, 1},
3460 {&__pyx_n_s_src_colorspace, __pyx_k_src_colorspace, sizeof(__pyx_k_src_colorspace), 0, 0, 1, 1},
3461 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
3462 {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
3463 {&__pyx_n_s_width, __pyx_k_width, sizeof(__pyx_k_width), 0, 0, 1, 1},
3464 {0, 0, 0, 0, 0, 0, 0}
3465 };
__Pyx_InitCachedBuiltins(void)3466 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
3467 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 98, __pyx_L1_error)
3468 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
3469 return 0;
3470 __pyx_L1_error:;
3471 return -1;
3472 }
3473
__Pyx_InitCachedConstants(void)3474 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
3475 __Pyx_RefNannyDeclarations
3476 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
3477
3478 /* "av/video/reformatter.pyx":98
3479 *
3480 * if frame.ptr.format < 0:
3481 * raise ValueError("Frame does not have format set.") # <<<<<<<<<<<<<<
3482 *
3483 * cdef lib.AVPixelFormat src_format = <lib.AVPixelFormat> frame.ptr.format
3484 */
3485 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Frame_does_not_have_format_set); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 98, __pyx_L1_error)
3486 __Pyx_GOTREF(__pyx_tuple_);
3487 __Pyx_GIVEREF(__pyx_tuple_);
3488
3489 /* "(tree fragment)":2
3490 * def __reduce_cython__(self):
3491 * raise TypeError("self.ptr cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3492 * def __setstate_cython__(self, __pyx_state):
3493 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3494 */
3495 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error)
3496 __Pyx_GOTREF(__pyx_tuple__2);
3497 __Pyx_GIVEREF(__pyx_tuple__2);
3498
3499 /* "(tree fragment)":4
3500 * raise TypeError("self.ptr cannot be converted to a Python object for pickling")
3501 * def __setstate_cython__(self, __pyx_state):
3502 * raise TypeError("self.ptr cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3503 */
3504 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_self_ptr_cannot_be_converted_to); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
3505 __Pyx_GOTREF(__pyx_tuple__3);
3506 __Pyx_GIVEREF(__pyx_tuple__3);
3507 __Pyx_RefNannyFinishContext();
3508 return 0;
3509 __pyx_L1_error:;
3510 __Pyx_RefNannyFinishContext();
3511 return -1;
3512 }
3513
__Pyx_InitGlobals(void)3514 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
3515 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3516 return 0;
3517 __pyx_L1_error:;
3518 return -1;
3519 }
3520
3521 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
3522 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
3523 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
3524 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
3525 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
3526 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
3527 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
3528
__Pyx_modinit_global_init_code(void)3529 static int __Pyx_modinit_global_init_code(void) {
3530 __Pyx_RefNannyDeclarations
3531 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
3532 /*--- Global init code ---*/
3533 __Pyx_RefNannyFinishContext();
3534 return 0;
3535 }
3536
__Pyx_modinit_variable_export_code(void)3537 static int __Pyx_modinit_variable_export_code(void) {
3538 __Pyx_RefNannyDeclarations
3539 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
3540 /*--- Variable export code ---*/
3541 __Pyx_RefNannyFinishContext();
3542 return 0;
3543 }
3544
__Pyx_modinit_function_export_code(void)3545 static int __Pyx_modinit_function_export_code(void) {
3546 __Pyx_RefNannyDeclarations
3547 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
3548 /*--- Function export code ---*/
3549 __Pyx_RefNannyFinishContext();
3550 return 0;
3551 }
3552
__Pyx_modinit_type_init_code(void)3553 static int __Pyx_modinit_type_init_code(void) {
3554 __Pyx_RefNannyDeclarations
3555 int __pyx_lineno = 0;
3556 const char *__pyx_filename = NULL;
3557 int __pyx_clineno = 0;
3558 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
3559 /*--- Type init code ---*/
3560 __pyx_vtabptr_2av_5video_11reformatter_VideoReformatter = &__pyx_vtable_2av_5video_11reformatter_VideoReformatter;
3561 __pyx_vtable_2av_5video_11reformatter_VideoReformatter._reformat = (PyObject *(*)(struct __pyx_obj_2av_5video_11reformatter_VideoReformatter *, struct __pyx_obj_2av_5video_5frame_VideoFrame *, int, int, enum AVPixelFormat, int, int, int))__pyx_f_2av_5video_11reformatter_16VideoReformatter__reformat;
3562 if (PyType_Ready(&__pyx_type_2av_5video_11reformatter_VideoReformatter) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
3563 #if PY_VERSION_HEX < 0x030800B1
3564 __pyx_type_2av_5video_11reformatter_VideoReformatter.tp_print = 0;
3565 #endif
3566 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_2av_5video_11reformatter_VideoReformatter.tp_dictoffset && __pyx_type_2av_5video_11reformatter_VideoReformatter.tp_getattro == PyObject_GenericGetAttr)) {
3567 __pyx_type_2av_5video_11reformatter_VideoReformatter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
3568 }
3569 if (__Pyx_SetVtable(__pyx_type_2av_5video_11reformatter_VideoReformatter.tp_dict, __pyx_vtabptr_2av_5video_11reformatter_VideoReformatter) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
3570 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_VideoReformatter, (PyObject *)&__pyx_type_2av_5video_11reformatter_VideoReformatter) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
3571 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_2av_5video_11reformatter_VideoReformatter) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
3572 __pyx_ptype_2av_5video_11reformatter_VideoReformatter = &__pyx_type_2av_5video_11reformatter_VideoReformatter;
3573 __Pyx_RefNannyFinishContext();
3574 return 0;
3575 __pyx_L1_error:;
3576 __Pyx_RefNannyFinishContext();
3577 return -1;
3578 }
3579
__Pyx_modinit_type_import_code(void)3580 static int __Pyx_modinit_type_import_code(void) {
3581 __Pyx_RefNannyDeclarations
3582 PyObject *__pyx_t_1 = NULL;
3583 int __pyx_lineno = 0;
3584 const char *__pyx_filename = NULL;
3585 int __pyx_clineno = 0;
3586 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
3587 /*--- Type import code ---*/
3588 __pyx_t_1 = PyImport_ImportModule("av.buffer"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
3589 __Pyx_GOTREF(__pyx_t_1);
3590 __pyx_ptype_2av_6buffer_Buffer = __Pyx_ImportType(__pyx_t_1, "av.buffer", "Buffer", sizeof(struct __pyx_obj_2av_6buffer_Buffer), __Pyx_ImportType_CheckSize_Warn);
3591 if (!__pyx_ptype_2av_6buffer_Buffer) __PYX_ERR(2, 2, __pyx_L1_error)
3592 __pyx_vtabptr_2av_6buffer_Buffer = (struct __pyx_vtabstruct_2av_6buffer_Buffer*)__Pyx_GetVtable(__pyx_ptype_2av_6buffer_Buffer->tp_dict); if (unlikely(!__pyx_vtabptr_2av_6buffer_Buffer)) __PYX_ERR(2, 2, __pyx_L1_error)
3593 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3594 __pyx_t_1 = PyImport_ImportModule("av.bytesource"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
3595 __Pyx_GOTREF(__pyx_t_1);
3596 __pyx_ptype_2av_10bytesource_ByteSource = __Pyx_ImportType(__pyx_t_1, "av.bytesource", "ByteSource", sizeof(struct __pyx_obj_2av_10bytesource_ByteSource), __Pyx_ImportType_CheckSize_Warn);
3597 if (!__pyx_ptype_2av_10bytesource_ByteSource) __PYX_ERR(3, 4, __pyx_L1_error)
3598 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3599 __pyx_t_1 = PyImport_ImportModule("av.codec.codec"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
3600 __Pyx_GOTREF(__pyx_t_1);
3601 __pyx_ptype_2av_5codec_5codec_Codec = __Pyx_ImportType(__pyx_t_1, "av.codec.codec", "Codec", sizeof(struct __pyx_obj_2av_5codec_5codec_Codec), __Pyx_ImportType_CheckSize_Warn);
3602 if (!__pyx_ptype_2av_5codec_5codec_Codec) __PYX_ERR(4, 4, __pyx_L1_error)
3603 __pyx_vtabptr_2av_5codec_5codec_Codec = (struct __pyx_vtabstruct_2av_5codec_5codec_Codec*)__Pyx_GetVtable(__pyx_ptype_2av_5codec_5codec_Codec->tp_dict); if (unlikely(!__pyx_vtabptr_2av_5codec_5codec_Codec)) __PYX_ERR(4, 4, __pyx_L1_error)
3604 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3605 __pyx_t_1 = PyImport_ImportModule("av.codec.context"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 10, __pyx_L1_error)
3606 __Pyx_GOTREF(__pyx_t_1);
3607 __pyx_ptype_2av_5codec_7context_CodecContext = __Pyx_ImportType(__pyx_t_1, "av.codec.context", "CodecContext", sizeof(struct __pyx_obj_2av_5codec_7context_CodecContext), __Pyx_ImportType_CheckSize_Warn);
3608 if (!__pyx_ptype_2av_5codec_7context_CodecContext) __PYX_ERR(5, 10, __pyx_L1_error)
3609 __pyx_vtabptr_2av_5codec_7context_CodecContext = (struct __pyx_vtabstruct_2av_5codec_7context_CodecContext*)__Pyx_GetVtable(__pyx_ptype_2av_5codec_7context_CodecContext->tp_dict); if (unlikely(!__pyx_vtabptr_2av_5codec_7context_CodecContext)) __PYX_ERR(5, 10, __pyx_L1_error)
3610 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3611 __pyx_t_1 = PyImport_ImportModule("av.container.streams"); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 4, __pyx_L1_error)
3612 __Pyx_GOTREF(__pyx_t_1);
3613 __pyx_ptype_2av_9container_7streams_StreamContainer = __Pyx_ImportType(__pyx_t_1, "av.container.streams", "StreamContainer", sizeof(struct __pyx_obj_2av_9container_7streams_StreamContainer), __Pyx_ImportType_CheckSize_Warn);
3614 if (!__pyx_ptype_2av_9container_7streams_StreamContainer) __PYX_ERR(6, 4, __pyx_L1_error)
3615 __pyx_vtabptr_2av_9container_7streams_StreamContainer = (struct __pyx_vtabstruct_2av_9container_7streams_StreamContainer*)__Pyx_GetVtable(__pyx_ptype_2av_9container_7streams_StreamContainer->tp_dict); if (unlikely(!__pyx_vtabptr_2av_9container_7streams_StreamContainer)) __PYX_ERR(6, 4, __pyx_L1_error)
3616 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3617 __pyx_t_1 = PyImport_ImportModule("av.dictionary"); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 4, __pyx_L1_error)
3618 __Pyx_GOTREF(__pyx_t_1);
3619 __pyx_ptype_2av_10dictionary__Dictionary = __Pyx_ImportType(__pyx_t_1, "av.dictionary", "_Dictionary", sizeof(struct __pyx_obj_2av_10dictionary__Dictionary), __Pyx_ImportType_CheckSize_Warn);
3620 if (!__pyx_ptype_2av_10dictionary__Dictionary) __PYX_ERR(7, 4, __pyx_L1_error)
3621 __pyx_vtabptr_2av_10dictionary__Dictionary = (struct __pyx_vtabstruct_2av_10dictionary__Dictionary*)__Pyx_GetVtable(__pyx_ptype_2av_10dictionary__Dictionary->tp_dict); if (unlikely(!__pyx_vtabptr_2av_10dictionary__Dictionary)) __PYX_ERR(7, 4, __pyx_L1_error)
3622 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3623 __pyx_t_1 = PyImport_ImportModule("av.format"); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 4, __pyx_L1_error)
3624 __Pyx_GOTREF(__pyx_t_1);
3625 __pyx_ptype_2av_6format_ContainerFormat = __Pyx_ImportType(__pyx_t_1, "av.format", "ContainerFormat", sizeof(struct __pyx_obj_2av_6format_ContainerFormat), __Pyx_ImportType_CheckSize_Warn);
3626 if (!__pyx_ptype_2av_6format_ContainerFormat) __PYX_ERR(8, 4, __pyx_L1_error)
3627 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3628 __pyx_t_1 = PyImport_ImportModule("av.container.core"); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 15, __pyx_L1_error)
3629 __Pyx_GOTREF(__pyx_t_1);
3630 __pyx_ptype_2av_9container_4core_Container = __Pyx_ImportType(__pyx_t_1, "av.container.core", "Container", sizeof(struct __pyx_obj_2av_9container_4core_Container), __Pyx_ImportType_CheckSize_Warn);
3631 if (!__pyx_ptype_2av_9container_4core_Container) __PYX_ERR(9, 15, __pyx_L1_error)
3632 __pyx_vtabptr_2av_9container_4core_Container = (struct __pyx_vtabstruct_2av_9container_4core_Container*)__Pyx_GetVtable(__pyx_ptype_2av_9container_4core_Container->tp_dict); if (unlikely(!__pyx_vtabptr_2av_9container_4core_Container)) __PYX_ERR(9, 15, __pyx_L1_error)
3633 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3634 __pyx_t_1 = PyImport_ImportModule("av.stream"); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 10, __pyx_L1_error)
3635 __Pyx_GOTREF(__pyx_t_1);
3636 __pyx_ptype_2av_6stream_Stream = __Pyx_ImportType(__pyx_t_1, "av.stream", "Stream", sizeof(struct __pyx_obj_2av_6stream_Stream), __Pyx_ImportType_CheckSize_Warn);
3637 if (!__pyx_ptype_2av_6stream_Stream) __PYX_ERR(10, 10, __pyx_L1_error)
3638 __pyx_vtabptr_2av_6stream_Stream = (struct __pyx_vtabstruct_2av_6stream_Stream*)__Pyx_GetVtable(__pyx_ptype_2av_6stream_Stream->tp_dict); if (unlikely(!__pyx_vtabptr_2av_6stream_Stream)) __PYX_ERR(10, 10, __pyx_L1_error)
3639 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3640 __pyx_t_1 = PyImport_ImportModule("av.packet"); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 8, __pyx_L1_error)
3641 __Pyx_GOTREF(__pyx_t_1);
3642 __pyx_ptype_2av_6packet_Packet = __Pyx_ImportType(__pyx_t_1, "av.packet", "Packet", sizeof(struct __pyx_obj_2av_6packet_Packet), __Pyx_ImportType_CheckSize_Warn);
3643 if (!__pyx_ptype_2av_6packet_Packet) __PYX_ERR(11, 8, __pyx_L1_error)
3644 __pyx_vtabptr_2av_6packet_Packet = (struct __pyx_vtabstruct_2av_6packet_Packet*)__Pyx_GetVtable(__pyx_ptype_2av_6packet_Packet->tp_dict); if (unlikely(!__pyx_vtabptr_2av_6packet_Packet)) __PYX_ERR(11, 8, __pyx_L1_error)
3645 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3646 __pyx_t_1 = PyImport_ImportModule("av.sidedata.sidedata"); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 9, __pyx_L1_error)
3647 __Pyx_GOTREF(__pyx_t_1);
3648 __pyx_ptype_2av_8sidedata_8sidedata_SideData = __Pyx_ImportType(__pyx_t_1, "av.sidedata.sidedata", "SideData", sizeof(struct __pyx_obj_2av_8sidedata_8sidedata_SideData), __Pyx_ImportType_CheckSize_Warn);
3649 if (!__pyx_ptype_2av_8sidedata_8sidedata_SideData) __PYX_ERR(12, 9, __pyx_L1_error)
3650 __pyx_vtabptr_2av_8sidedata_8sidedata_SideData = (struct __pyx_vtabstruct_2av_8sidedata_8sidedata_SideData*)__Pyx_GetVtable(__pyx_ptype_2av_8sidedata_8sidedata_SideData->tp_dict); if (unlikely(!__pyx_vtabptr_2av_8sidedata_8sidedata_SideData)) __PYX_ERR(12, 9, __pyx_L1_error)
3651 __pyx_ptype_2av_8sidedata_8sidedata__SideDataContainer = __Pyx_ImportType(__pyx_t_1, "av.sidedata.sidedata", "_SideDataContainer", sizeof(struct __pyx_obj_2av_8sidedata_8sidedata__SideDataContainer), __Pyx_ImportType_CheckSize_Warn);
3652 if (!__pyx_ptype_2av_8sidedata_8sidedata__SideDataContainer) __PYX_ERR(12, 18, __pyx_L1_error)
3653 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3654 __pyx_t_1 = PyImport_ImportModule("av.frame"); if (unlikely(!__pyx_t_1)) __PYX_ERR(13, 7, __pyx_L1_error)
3655 __Pyx_GOTREF(__pyx_t_1);
3656 __pyx_ptype_2av_5frame_Frame = __Pyx_ImportType(__pyx_t_1, "av.frame", "Frame", sizeof(struct __pyx_obj_2av_5frame_Frame), __Pyx_ImportType_CheckSize_Warn);
3657 if (!__pyx_ptype_2av_5frame_Frame) __PYX_ERR(13, 7, __pyx_L1_error)
3658 __pyx_vtabptr_2av_5frame_Frame = (struct __pyx_vtabstruct_2av_5frame_Frame*)__Pyx_GetVtable(__pyx_ptype_2av_5frame_Frame->tp_dict); if (unlikely(!__pyx_vtabptr_2av_5frame_Frame)) __PYX_ERR(13, 7, __pyx_L1_error)
3659 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3660 __pyx_t_1 = PyImport_ImportModule("av.video.format"); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 4, __pyx_L1_error)
3661 __Pyx_GOTREF(__pyx_t_1);
3662 __pyx_ptype_2av_5video_6format_VideoFormat = __Pyx_ImportType(__pyx_t_1, "av.video.format", "VideoFormat", sizeof(struct __pyx_obj_2av_5video_6format_VideoFormat), __Pyx_ImportType_CheckSize_Warn);
3663 if (!__pyx_ptype_2av_5video_6format_VideoFormat) __PYX_ERR(14, 4, __pyx_L1_error)
3664 __pyx_vtabptr_2av_5video_6format_VideoFormat = (struct __pyx_vtabstruct_2av_5video_6format_VideoFormat*)__Pyx_GetVtable(__pyx_ptype_2av_5video_6format_VideoFormat->tp_dict); if (unlikely(!__pyx_vtabptr_2av_5video_6format_VideoFormat)) __PYX_ERR(14, 4, __pyx_L1_error)
3665 __pyx_ptype_2av_5video_6format_VideoFormatComponent = __Pyx_ImportType(__pyx_t_1, "av.video.format", "VideoFormatComponent", sizeof(struct __pyx_obj_2av_5video_6format_VideoFormatComponent), __Pyx_ImportType_CheckSize_Warn);
3666 if (!__pyx_ptype_2av_5video_6format_VideoFormatComponent) __PYX_ERR(14, 18, __pyx_L1_error)
3667 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3668 __pyx_t_1 = PyImport_ImportModule("av.video.frame"); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 9, __pyx_L1_error)
3669 __Pyx_GOTREF(__pyx_t_1);
3670 __pyx_ptype_2av_5video_5frame_VideoFrame = __Pyx_ImportType(__pyx_t_1, "av.video.frame", "VideoFrame", sizeof(struct __pyx_obj_2av_5video_5frame_VideoFrame), __Pyx_ImportType_CheckSize_Warn);
3671 if (!__pyx_ptype_2av_5video_5frame_VideoFrame) __PYX_ERR(15, 9, __pyx_L1_error)
3672 __pyx_vtabptr_2av_5video_5frame_VideoFrame = (struct __pyx_vtabstruct_2av_5video_5frame_VideoFrame*)__Pyx_GetVtable(__pyx_ptype_2av_5video_5frame_VideoFrame->tp_dict); if (unlikely(!__pyx_vtabptr_2av_5video_5frame_VideoFrame)) __PYX_ERR(15, 9, __pyx_L1_error)
3673 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3674 __Pyx_RefNannyFinishContext();
3675 return 0;
3676 __pyx_L1_error:;
3677 __Pyx_XDECREF(__pyx_t_1);
3678 __Pyx_RefNannyFinishContext();
3679 return -1;
3680 }
3681
__Pyx_modinit_variable_import_code(void)3682 static int __Pyx_modinit_variable_import_code(void) {
3683 __Pyx_RefNannyDeclarations
3684 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
3685 /*--- Variable import code ---*/
3686 __Pyx_RefNannyFinishContext();
3687 return 0;
3688 }
3689
__Pyx_modinit_function_import_code(void)3690 static int __Pyx_modinit_function_import_code(void) {
3691 __Pyx_RefNannyDeclarations
3692 PyObject *__pyx_t_1 = NULL;
3693 int __pyx_lineno = 0;
3694 const char *__pyx_filename = NULL;
3695 int __pyx_clineno = 0;
3696 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
3697 /*--- Function import code ---*/
3698 __pyx_t_1 = PyImport_ImportModule("av.dictionary"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
3699 __Pyx_GOTREF(__pyx_t_1);
3700 if (__Pyx_ImportFunction(__pyx_t_1, "wrap_dictionary", (void (**)(void))&__pyx_f_2av_10dictionary_wrap_dictionary, "struct __pyx_obj_2av_10dictionary__Dictionary *(AVDictionary *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3701 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3702 __pyx_t_1 = PyImport_ImportModule("av.video.frame"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
3703 __Pyx_GOTREF(__pyx_t_1);
3704 if (__Pyx_ImportFunction(__pyx_t_1, "alloc_video_frame", (void (**)(void))&__pyx_f_2av_5video_5frame_alloc_video_frame, "struct __pyx_obj_2av_5video_5frame_VideoFrame *(void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3705 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3706 __pyx_t_1 = PyImport_ImportModule("av.enum"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
3707 __Pyx_GOTREF(__pyx_t_1);
3708 if (__Pyx_ImportFunction(__pyx_t_1, "define_enum", (void (**)(void))&__pyx_f_2av_4enum_define_enum, "PyObject *(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_4enum_define_enum *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3709 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3710 __pyx_t_1 = PyImport_ImportModule("av.error"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
3711 __Pyx_GOTREF(__pyx_t_1);
3712 if (__Pyx_ImportFunction(__pyx_t_1, "err_check", (void (**)(void))&__pyx_f_2av_5error_err_check, "int (int, int __pyx_skip_dispatch, struct __pyx_opt_args_2av_5error_err_check *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3713 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3714 __Pyx_RefNannyFinishContext();
3715 return 0;
3716 __pyx_L1_error:;
3717 __Pyx_XDECREF(__pyx_t_1);
3718 __Pyx_RefNannyFinishContext();
3719 return -1;
3720 }
3721
3722
3723 #ifndef CYTHON_NO_PYINIT_EXPORT
3724 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
3725 #elif PY_MAJOR_VERSION < 3
3726 #ifdef __cplusplus
3727 #define __Pyx_PyMODINIT_FUNC extern "C" void
3728 #else
3729 #define __Pyx_PyMODINIT_FUNC void
3730 #endif
3731 #else
3732 #ifdef __cplusplus
3733 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3734 #else
3735 #define __Pyx_PyMODINIT_FUNC PyObject *
3736 #endif
3737 #endif
3738
3739
3740 #if PY_MAJOR_VERSION < 3
3741 __Pyx_PyMODINIT_FUNC initreformatter(void) CYTHON_SMALL_CODE; /*proto*/
initreformatter(void)3742 __Pyx_PyMODINIT_FUNC initreformatter(void)
3743 #else
3744 __Pyx_PyMODINIT_FUNC PyInit_reformatter(void) CYTHON_SMALL_CODE; /*proto*/
3745 __Pyx_PyMODINIT_FUNC PyInit_reformatter(void)
3746 #if CYTHON_PEP489_MULTI_PHASE_INIT
3747 {
3748 return PyModuleDef_Init(&__pyx_moduledef);
3749 }
3750 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3751 #if PY_VERSION_HEX >= 0x030700A1
3752 static PY_INT64_T main_interpreter_id = -1;
3753 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3754 if (main_interpreter_id == -1) {
3755 main_interpreter_id = current_id;
3756 return (unlikely(current_id == -1)) ? -1 : 0;
3757 } else if (unlikely(main_interpreter_id != current_id))
3758 #else
3759 static PyInterpreterState *main_interpreter = NULL;
3760 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
3761 if (!main_interpreter) {
3762 main_interpreter = current_interpreter;
3763 } else if (unlikely(main_interpreter != current_interpreter))
3764 #endif
3765 {
3766 PyErr_SetString(
3767 PyExc_ImportError,
3768 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
3769 return -1;
3770 }
3771 return 0;
3772 }
3773 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
3774 PyObject *value = PyObject_GetAttrString(spec, from_name);
3775 int result = 0;
3776 if (likely(value)) {
3777 if (allow_none || value != Py_None) {
3778 result = PyDict_SetItemString(moddict, to_name, value);
3779 }
3780 Py_DECREF(value);
3781 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3782 PyErr_Clear();
3783 } else {
3784 result = -1;
3785 }
3786 return result;
3787 }
3788 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
3789 PyObject *module = NULL, *moddict, *modname;
3790 if (__Pyx_check_single_interpreter())
3791 return NULL;
3792 if (__pyx_m)
3793 return __Pyx_NewRef(__pyx_m);
3794 modname = PyObject_GetAttrString(spec, "name");
3795 if (unlikely(!modname)) goto bad;
3796 module = PyModule_NewObject(modname);
3797 Py_DECREF(modname);
3798 if (unlikely(!module)) goto bad;
3799 moddict = PyModule_GetDict(module);
3800 if (unlikely(!moddict)) goto bad;
3801 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
3802 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
3803 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
3804 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
3805 return module;
3806 bad:
3807 Py_XDECREF(module);
3808 return NULL;
3809 }
3810
3811
3812 static CYTHON_SMALL_CODE int __pyx_pymod_exec_reformatter(PyObject *__pyx_pyinit_module)
3813 #endif
3814 #endif
3815 {
3816 PyObject *__pyx_t_1 = NULL;
3817 PyObject *__pyx_t_2 = NULL;
3818 PyObject *__pyx_t_3 = NULL;
3819 PyObject *__pyx_t_4 = NULL;
3820 PyObject *__pyx_t_5 = NULL;
3821 PyObject *__pyx_t_6 = NULL;
3822 PyObject *__pyx_t_7 = NULL;
3823 PyObject *__pyx_t_8 = NULL;
3824 PyObject *__pyx_t_9 = NULL;
3825 PyObject *__pyx_t_10 = NULL;
3826 PyObject *__pyx_t_11 = NULL;
3827 PyObject *__pyx_t_12 = NULL;
3828 PyObject *__pyx_t_13 = NULL;
3829 PyObject *__pyx_t_14 = NULL;
3830 PyObject *__pyx_t_15 = NULL;
3831 int __pyx_lineno = 0;
3832 const char *__pyx_filename = NULL;
3833 int __pyx_clineno = 0;
3834 __Pyx_RefNannyDeclarations
3835 #if CYTHON_PEP489_MULTI_PHASE_INIT
3836 if (__pyx_m) {
3837 if (__pyx_m == __pyx_pyinit_module) return 0;
3838 PyErr_SetString(PyExc_RuntimeError, "Module 'reformatter' has already been imported. Re-initialisation is not supported.");
3839 return -1;
3840 }
3841 #elif PY_MAJOR_VERSION >= 3
3842 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
3843 #endif
3844 #if CYTHON_REFNANNY
3845 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3846 if (!__Pyx_RefNanny) {
3847 PyErr_Clear();
3848 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3849 if (!__Pyx_RefNanny)
3850 Py_FatalError("failed to import 'refnanny' module");
3851 }
3852 #endif
3853 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_reformatter(void)", 0);
3854 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3855 #ifdef __Pxy_PyFrame_Initialize_Offsets
3856 __Pxy_PyFrame_Initialize_Offsets();
3857 #endif
3858 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
3859 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
3860 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
3861 #ifdef __Pyx_CyFunction_USED
3862 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3863 #endif
3864 #ifdef __Pyx_FusedFunction_USED
3865 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3866 #endif
3867 #ifdef __Pyx_Coroutine_USED
3868 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3869 #endif
3870 #ifdef __Pyx_Generator_USED
3871 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3872 #endif
3873 #ifdef __Pyx_AsyncGen_USED
3874 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3875 #endif
3876 #ifdef __Pyx_StopAsyncIteration_USED
3877 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3878 #endif
3879 /*--- Library function declarations ---*/
3880 /*--- Threads initialization code ---*/
3881 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3882 #ifdef WITH_THREAD /* Python build with threading support? */
3883 PyEval_InitThreads();
3884 #endif
3885 #endif
3886 /*--- Module creation code ---*/
3887 #if CYTHON_PEP489_MULTI_PHASE_INIT
3888 __pyx_m = __pyx_pyinit_module;
3889 Py_INCREF(__pyx_m);
3890 #else
3891 #if PY_MAJOR_VERSION < 3
3892 __pyx_m = Py_InitModule4("reformatter", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3893 #else
3894 __pyx_m = PyModule_Create(&__pyx_moduledef);
3895 #endif
3896 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3897 #endif
3898 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3899 Py_INCREF(__pyx_d);
3900 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3901 Py_INCREF(__pyx_b);
3902 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3903 Py_INCREF(__pyx_cython_runtime);
3904 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3905 /*--- Initialize various global constants etc. ---*/
3906 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3907 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3908 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3909 #endif
3910 if (__pyx_module_is_main_av__video__reformatter) {
3911 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3912 }
3913 #if PY_MAJOR_VERSION >= 3
3914 {
3915 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3916 if (!PyDict_GetItemString(modules, "av.video.reformatter")) {
3917 if (unlikely(PyDict_SetItemString(modules, "av.video.reformatter", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3918 }
3919 }
3920 #endif
3921 /*--- Builtin init code ---*/
3922 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3923 /*--- Constants init code ---*/
3924 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3925 /*--- Global type/function init code ---*/
3926 (void)__Pyx_modinit_global_init_code();
3927 (void)__Pyx_modinit_variable_export_code();
3928 (void)__Pyx_modinit_function_export_code();
3929 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3930 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3931 (void)__Pyx_modinit_variable_import_code();
3932 if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3933 /*--- Execution code ---*/
3934 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3935 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3936 #endif
3937
3938 /* "av/video/reformatter.pyx":10
3939 *
3940 *
3941 * Interpolation = define_enum('Interpolation', __name__, ( # <<<<<<<<<<<<<<
3942 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"),
3943 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
3944 */
3945 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
3946 __Pyx_GOTREF(__pyx_t_1);
3947
3948 /* "av/video/reformatter.pyx":11
3949 *
3950 * Interpolation = define_enum('Interpolation', __name__, (
3951 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"), # <<<<<<<<<<<<<<
3952 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
3953 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"),
3954 */
3955 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_FAST_BILINEAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
3956 __Pyx_GOTREF(__pyx_t_2);
3957 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)
3958 __Pyx_GOTREF(__pyx_t_3);
3959 __Pyx_INCREF(__pyx_n_s_FAST_BILINEAR);
3960 __Pyx_GIVEREF(__pyx_n_s_FAST_BILINEAR);
3961 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_FAST_BILINEAR);
3962 __Pyx_GIVEREF(__pyx_t_2);
3963 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
3964 __Pyx_INCREF(__pyx_kp_s_Fast_bilinear);
3965 __Pyx_GIVEREF(__pyx_kp_s_Fast_bilinear);
3966 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_Fast_bilinear);
3967 __pyx_t_2 = 0;
3968
3969 /* "av/video/reformatter.pyx":12
3970 * Interpolation = define_enum('Interpolation', __name__, (
3971 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"),
3972 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"), # <<<<<<<<<<<<<<
3973 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"),
3974 * ('X', lib.SWS_X, "Experimental"),
3975 */
3976 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_BILINEAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
3977 __Pyx_GOTREF(__pyx_t_2);
3978 __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 12, __pyx_L1_error)
3979 __Pyx_GOTREF(__pyx_t_4);
3980 __Pyx_INCREF(__pyx_n_s_BILINEAR);
3981 __Pyx_GIVEREF(__pyx_n_s_BILINEAR);
3982 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_BILINEAR);
3983 __Pyx_GIVEREF(__pyx_t_2);
3984 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
3985 __Pyx_INCREF(__pyx_n_s_Bilinear);
3986 __Pyx_GIVEREF(__pyx_n_s_Bilinear);
3987 PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_Bilinear);
3988 __pyx_t_2 = 0;
3989
3990 /* "av/video/reformatter.pyx":13
3991 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"),
3992 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
3993 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"), # <<<<<<<<<<<<<<
3994 * ('X', lib.SWS_X, "Experimental"),
3995 * ('POINT', lib.SWS_POINT, "Nearest neighbor / point"),
3996 */
3997 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_BICUBIC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
3998 __Pyx_GOTREF(__pyx_t_2);
3999 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 13, __pyx_L1_error)
4000 __Pyx_GOTREF(__pyx_t_5);
4001 __Pyx_INCREF(__pyx_n_s_BICUBIC);
4002 __Pyx_GIVEREF(__pyx_n_s_BICUBIC);
4003 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_BICUBIC);
4004 __Pyx_GIVEREF(__pyx_t_2);
4005 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
4006 __Pyx_INCREF(__pyx_n_s_Bicubic);
4007 __Pyx_GIVEREF(__pyx_n_s_Bicubic);
4008 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_n_s_Bicubic);
4009 __pyx_t_2 = 0;
4010
4011 /* "av/video/reformatter.pyx":14
4012 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
4013 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"),
4014 * ('X', lib.SWS_X, "Experimental"), # <<<<<<<<<<<<<<
4015 * ('POINT', lib.SWS_POINT, "Nearest neighbor / point"),
4016 * ('AREA', lib.SWS_AREA, "Area averaging"),
4017 */
4018 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_X); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
4019 __Pyx_GOTREF(__pyx_t_2);
4020 __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
4021 __Pyx_GOTREF(__pyx_t_6);
4022 __Pyx_INCREF(__pyx_n_s_X);
4023 __Pyx_GIVEREF(__pyx_n_s_X);
4024 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_X);
4025 __Pyx_GIVEREF(__pyx_t_2);
4026 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
4027 __Pyx_INCREF(__pyx_n_s_Experimental);
4028 __Pyx_GIVEREF(__pyx_n_s_Experimental);
4029 PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_n_s_Experimental);
4030 __pyx_t_2 = 0;
4031
4032 /* "av/video/reformatter.pyx":15
4033 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"),
4034 * ('X', lib.SWS_X, "Experimental"),
4035 * ('POINT', lib.SWS_POINT, "Nearest neighbor / point"), # <<<<<<<<<<<<<<
4036 * ('AREA', lib.SWS_AREA, "Area averaging"),
4037 * ('BICUBLIN', lib.SWS_BICUBLIN, "Luma bicubic / chroma bilinear"),
4038 */
4039 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_POINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
4040 __Pyx_GOTREF(__pyx_t_2);
4041 __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 15, __pyx_L1_error)
4042 __Pyx_GOTREF(__pyx_t_7);
4043 __Pyx_INCREF(__pyx_n_s_POINT);
4044 __Pyx_GIVEREF(__pyx_n_s_POINT);
4045 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_POINT);
4046 __Pyx_GIVEREF(__pyx_t_2);
4047 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
4048 __Pyx_INCREF(__pyx_kp_s_Nearest_neighbor_point);
4049 __Pyx_GIVEREF(__pyx_kp_s_Nearest_neighbor_point);
4050 PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_s_Nearest_neighbor_point);
4051 __pyx_t_2 = 0;
4052
4053 /* "av/video/reformatter.pyx":16
4054 * ('X', lib.SWS_X, "Experimental"),
4055 * ('POINT', lib.SWS_POINT, "Nearest neighbor / point"),
4056 * ('AREA', lib.SWS_AREA, "Area averaging"), # <<<<<<<<<<<<<<
4057 * ('BICUBLIN', lib.SWS_BICUBLIN, "Luma bicubic / chroma bilinear"),
4058 * ('GAUSS', lib.SWS_GAUSS, "Gaussian"),
4059 */
4060 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_AREA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
4061 __Pyx_GOTREF(__pyx_t_2);
4062 __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 16, __pyx_L1_error)
4063 __Pyx_GOTREF(__pyx_t_8);
4064 __Pyx_INCREF(__pyx_n_s_AREA);
4065 __Pyx_GIVEREF(__pyx_n_s_AREA);
4066 PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_AREA);
4067 __Pyx_GIVEREF(__pyx_t_2);
4068 PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
4069 __Pyx_INCREF(__pyx_kp_s_Area_averaging);
4070 __Pyx_GIVEREF(__pyx_kp_s_Area_averaging);
4071 PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_s_Area_averaging);
4072 __pyx_t_2 = 0;
4073
4074 /* "av/video/reformatter.pyx":17
4075 * ('POINT', lib.SWS_POINT, "Nearest neighbor / point"),
4076 * ('AREA', lib.SWS_AREA, "Area averaging"),
4077 * ('BICUBLIN', lib.SWS_BICUBLIN, "Luma bicubic / chroma bilinear"), # <<<<<<<<<<<<<<
4078 * ('GAUSS', lib.SWS_GAUSS, "Gaussian"),
4079 * ('SINC', lib.SWS_SINC, "Sinc"),
4080 */
4081 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_BICUBLIN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
4082 __Pyx_GOTREF(__pyx_t_2);
4083 __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 17, __pyx_L1_error)
4084 __Pyx_GOTREF(__pyx_t_9);
4085 __Pyx_INCREF(__pyx_n_s_BICUBLIN);
4086 __Pyx_GIVEREF(__pyx_n_s_BICUBLIN);
4087 PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_BICUBLIN);
4088 __Pyx_GIVEREF(__pyx_t_2);
4089 PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
4090 __Pyx_INCREF(__pyx_kp_s_Luma_bicubic_chroma_bilinear);
4091 __Pyx_GIVEREF(__pyx_kp_s_Luma_bicubic_chroma_bilinear);
4092 PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_s_Luma_bicubic_chroma_bilinear);
4093 __pyx_t_2 = 0;
4094
4095 /* "av/video/reformatter.pyx":18
4096 * ('AREA', lib.SWS_AREA, "Area averaging"),
4097 * ('BICUBLIN', lib.SWS_BICUBLIN, "Luma bicubic / chroma bilinear"),
4098 * ('GAUSS', lib.SWS_GAUSS, "Gaussian"), # <<<<<<<<<<<<<<
4099 * ('SINC', lib.SWS_SINC, "Sinc"),
4100 * ('LANCZOS', lib.SWS_LANCZOS, "Lanczos"),
4101 */
4102 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_GAUSS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
4103 __Pyx_GOTREF(__pyx_t_2);
4104 __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 18, __pyx_L1_error)
4105 __Pyx_GOTREF(__pyx_t_10);
4106 __Pyx_INCREF(__pyx_n_s_GAUSS);
4107 __Pyx_GIVEREF(__pyx_n_s_GAUSS);
4108 PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_n_s_GAUSS);
4109 __Pyx_GIVEREF(__pyx_t_2);
4110 PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
4111 __Pyx_INCREF(__pyx_n_s_Gaussian);
4112 __Pyx_GIVEREF(__pyx_n_s_Gaussian);
4113 PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_n_s_Gaussian);
4114 __pyx_t_2 = 0;
4115
4116 /* "av/video/reformatter.pyx":19
4117 * ('BICUBLIN', lib.SWS_BICUBLIN, "Luma bicubic / chroma bilinear"),
4118 * ('GAUSS', lib.SWS_GAUSS, "Gaussian"),
4119 * ('SINC', lib.SWS_SINC, "Sinc"), # <<<<<<<<<<<<<<
4120 * ('LANCZOS', lib.SWS_LANCZOS, "Lanczos"),
4121 * ('SPLINE', lib.SWS_SPLINE, "Bicubic spline"),
4122 */
4123 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_SINC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
4124 __Pyx_GOTREF(__pyx_t_2);
4125 __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 19, __pyx_L1_error)
4126 __Pyx_GOTREF(__pyx_t_11);
4127 __Pyx_INCREF(__pyx_n_s_SINC);
4128 __Pyx_GIVEREF(__pyx_n_s_SINC);
4129 PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_n_s_SINC);
4130 __Pyx_GIVEREF(__pyx_t_2);
4131 PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_2);
4132 __Pyx_INCREF(__pyx_n_s_Sinc);
4133 __Pyx_GIVEREF(__pyx_n_s_Sinc);
4134 PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_n_s_Sinc);
4135 __pyx_t_2 = 0;
4136
4137 /* "av/video/reformatter.pyx":20
4138 * ('GAUSS', lib.SWS_GAUSS, "Gaussian"),
4139 * ('SINC', lib.SWS_SINC, "Sinc"),
4140 * ('LANCZOS', lib.SWS_LANCZOS, "Lanczos"), # <<<<<<<<<<<<<<
4141 * ('SPLINE', lib.SWS_SPLINE, "Bicubic spline"),
4142 * ))
4143 */
4144 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_LANCZOS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
4145 __Pyx_GOTREF(__pyx_t_2);
4146 __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 20, __pyx_L1_error)
4147 __Pyx_GOTREF(__pyx_t_12);
4148 __Pyx_INCREF(__pyx_n_s_LANCZOS);
4149 __Pyx_GIVEREF(__pyx_n_s_LANCZOS);
4150 PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_n_s_LANCZOS);
4151 __Pyx_GIVEREF(__pyx_t_2);
4152 PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
4153 __Pyx_INCREF(__pyx_n_s_Lanczos);
4154 __Pyx_GIVEREF(__pyx_n_s_Lanczos);
4155 PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_n_s_Lanczos);
4156 __pyx_t_2 = 0;
4157
4158 /* "av/video/reformatter.pyx":21
4159 * ('SINC', lib.SWS_SINC, "Sinc"),
4160 * ('LANCZOS', lib.SWS_LANCZOS, "Lanczos"),
4161 * ('SPLINE', lib.SWS_SPLINE, "Bicubic spline"), # <<<<<<<<<<<<<<
4162 * ))
4163 *
4164 */
4165 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_SPLINE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
4166 __Pyx_GOTREF(__pyx_t_2);
4167 __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 21, __pyx_L1_error)
4168 __Pyx_GOTREF(__pyx_t_13);
4169 __Pyx_INCREF(__pyx_n_s_SPLINE);
4170 __Pyx_GIVEREF(__pyx_n_s_SPLINE);
4171 PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_n_s_SPLINE);
4172 __Pyx_GIVEREF(__pyx_t_2);
4173 PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_2);
4174 __Pyx_INCREF(__pyx_kp_s_Bicubic_spline);
4175 __Pyx_GIVEREF(__pyx_kp_s_Bicubic_spline);
4176 PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_s_Bicubic_spline);
4177 __pyx_t_2 = 0;
4178
4179 /* "av/video/reformatter.pyx":11
4180 *
4181 * Interpolation = define_enum('Interpolation', __name__, (
4182 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"), # <<<<<<<<<<<<<<
4183 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
4184 * ('BICUBIC', lib.SWS_BICUBIC, "Bicubic"),
4185 */
4186 __pyx_t_2 = PyTuple_New(11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
4187 __Pyx_GOTREF(__pyx_t_2);
4188 __Pyx_GIVEREF(__pyx_t_3);
4189 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
4190 __Pyx_GIVEREF(__pyx_t_4);
4191 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
4192 __Pyx_GIVEREF(__pyx_t_5);
4193 PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
4194 __Pyx_GIVEREF(__pyx_t_6);
4195 PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
4196 __Pyx_GIVEREF(__pyx_t_7);
4197 PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
4198 __Pyx_GIVEREF(__pyx_t_8);
4199 PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_8);
4200 __Pyx_GIVEREF(__pyx_t_9);
4201 PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_9);
4202 __Pyx_GIVEREF(__pyx_t_10);
4203 PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_t_10);
4204 __Pyx_GIVEREF(__pyx_t_11);
4205 PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_t_11);
4206 __Pyx_GIVEREF(__pyx_t_12);
4207 PyTuple_SET_ITEM(__pyx_t_2, 9, __pyx_t_12);
4208 __Pyx_GIVEREF(__pyx_t_13);
4209 PyTuple_SET_ITEM(__pyx_t_2, 10, __pyx_t_13);
4210 __pyx_t_3 = 0;
4211 __pyx_t_4 = 0;
4212 __pyx_t_5 = 0;
4213 __pyx_t_6 = 0;
4214 __pyx_t_7 = 0;
4215 __pyx_t_8 = 0;
4216 __pyx_t_9 = 0;
4217 __pyx_t_10 = 0;
4218 __pyx_t_11 = 0;
4219 __pyx_t_12 = 0;
4220 __pyx_t_13 = 0;
4221
4222 /* "av/video/reformatter.pyx":10
4223 *
4224 *
4225 * Interpolation = define_enum('Interpolation', __name__, ( # <<<<<<<<<<<<<<
4226 * ('FAST_BILINEAR', lib.SWS_FAST_BILINEAR, "Fast bilinear"),
4227 * ('BILINEAR', lib.SWS_BILINEAR, "Bilinear"),
4228 */
4229 __pyx_t_13 = __pyx_f_2av_4enum_define_enum(__pyx_n_s_Interpolation, __pyx_t_1, __pyx_t_2, 0, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 10, __pyx_L1_error)
4230 __Pyx_GOTREF(__pyx_t_13);
4231 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4232 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4233 if (PyDict_SetItem(__pyx_d, __pyx_n_s_Interpolation, __pyx_t_13) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
4234 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4235
4236 /* "av/video/reformatter.pyx":24
4237 * ))
4238 *
4239 * Colorspace = define_enum('Colorspace', __name__, ( # <<<<<<<<<<<<<<
4240 *
4241 * ('ITU709', lib.SWS_CS_ITU709),
4242 */
4243 __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 24, __pyx_L1_error)
4244 __Pyx_GOTREF(__pyx_t_13);
4245
4246 /* "av/video/reformatter.pyx":26
4247 * Colorspace = define_enum('Colorspace', __name__, (
4248 *
4249 * ('ITU709', lib.SWS_CS_ITU709), # <<<<<<<<<<<<<<
4250 * ('FCC', lib.SWS_CS_FCC),
4251 * ('ITU601', lib.SWS_CS_ITU601),
4252 */
4253 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_ITU709); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
4254 __Pyx_GOTREF(__pyx_t_2);
4255 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
4256 __Pyx_GOTREF(__pyx_t_1);
4257 __Pyx_INCREF(__pyx_n_s_ITU709);
4258 __Pyx_GIVEREF(__pyx_n_s_ITU709);
4259 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ITU709);
4260 __Pyx_GIVEREF(__pyx_t_2);
4261 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
4262 __pyx_t_2 = 0;
4263
4264 /* "av/video/reformatter.pyx":27
4265 *
4266 * ('ITU709', lib.SWS_CS_ITU709),
4267 * ('FCC', lib.SWS_CS_FCC), # <<<<<<<<<<<<<<
4268 * ('ITU601', lib.SWS_CS_ITU601),
4269 * ('ITU624', lib.SWS_CS_ITU624),
4270 */
4271 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_FCC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
4272 __Pyx_GOTREF(__pyx_t_2);
4273 __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 27, __pyx_L1_error)
4274 __Pyx_GOTREF(__pyx_t_12);
4275 __Pyx_INCREF(__pyx_n_s_FCC);
4276 __Pyx_GIVEREF(__pyx_n_s_FCC);
4277 PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_n_s_FCC);
4278 __Pyx_GIVEREF(__pyx_t_2);
4279 PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
4280 __pyx_t_2 = 0;
4281
4282 /* "av/video/reformatter.pyx":28
4283 * ('ITU709', lib.SWS_CS_ITU709),
4284 * ('FCC', lib.SWS_CS_FCC),
4285 * ('ITU601', lib.SWS_CS_ITU601), # <<<<<<<<<<<<<<
4286 * ('ITU624', lib.SWS_CS_ITU624),
4287 * ('SMPTE170M', lib.SWS_CS_SMPTE170M),
4288 */
4289 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_ITU601); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
4290 __Pyx_GOTREF(__pyx_t_2);
4291 __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 28, __pyx_L1_error)
4292 __Pyx_GOTREF(__pyx_t_11);
4293 __Pyx_INCREF(__pyx_n_s_ITU601);
4294 __Pyx_GIVEREF(__pyx_n_s_ITU601);
4295 PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_n_s_ITU601);
4296 __Pyx_GIVEREF(__pyx_t_2);
4297 PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_2);
4298 __pyx_t_2 = 0;
4299
4300 /* "av/video/reformatter.pyx":29
4301 * ('FCC', lib.SWS_CS_FCC),
4302 * ('ITU601', lib.SWS_CS_ITU601),
4303 * ('ITU624', lib.SWS_CS_ITU624), # <<<<<<<<<<<<<<
4304 * ('SMPTE170M', lib.SWS_CS_SMPTE170M),
4305 * ('SMPTE240M', lib.SWS_CS_SMPTE240M),
4306 */
4307 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_ITU624); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
4308 __Pyx_GOTREF(__pyx_t_2);
4309 __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 29, __pyx_L1_error)
4310 __Pyx_GOTREF(__pyx_t_10);
4311 __Pyx_INCREF(__pyx_n_s_ITU624);
4312 __Pyx_GIVEREF(__pyx_n_s_ITU624);
4313 PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_n_s_ITU624);
4314 __Pyx_GIVEREF(__pyx_t_2);
4315 PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
4316 __pyx_t_2 = 0;
4317
4318 /* "av/video/reformatter.pyx":30
4319 * ('ITU601', lib.SWS_CS_ITU601),
4320 * ('ITU624', lib.SWS_CS_ITU624),
4321 * ('SMPTE170M', lib.SWS_CS_SMPTE170M), # <<<<<<<<<<<<<<
4322 * ('SMPTE240M', lib.SWS_CS_SMPTE240M),
4323 * ('DEFAULT', lib.SWS_CS_DEFAULT),
4324 */
4325 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_SMPTE170M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
4326 __Pyx_GOTREF(__pyx_t_2);
4327 __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 30, __pyx_L1_error)
4328 __Pyx_GOTREF(__pyx_t_9);
4329 __Pyx_INCREF(__pyx_n_s_SMPTE170M);
4330 __Pyx_GIVEREF(__pyx_n_s_SMPTE170M);
4331 PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_SMPTE170M);
4332 __Pyx_GIVEREF(__pyx_t_2);
4333 PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
4334 __pyx_t_2 = 0;
4335
4336 /* "av/video/reformatter.pyx":31
4337 * ('ITU624', lib.SWS_CS_ITU624),
4338 * ('SMPTE170M', lib.SWS_CS_SMPTE170M),
4339 * ('SMPTE240M', lib.SWS_CS_SMPTE240M), # <<<<<<<<<<<<<<
4340 * ('DEFAULT', lib.SWS_CS_DEFAULT),
4341 *
4342 */
4343 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_SMPTE240M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
4344 __Pyx_GOTREF(__pyx_t_2);
4345 __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 31, __pyx_L1_error)
4346 __Pyx_GOTREF(__pyx_t_8);
4347 __Pyx_INCREF(__pyx_n_s_SMPTE240M);
4348 __Pyx_GIVEREF(__pyx_n_s_SMPTE240M);
4349 PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_SMPTE240M);
4350 __Pyx_GIVEREF(__pyx_t_2);
4351 PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
4352 __pyx_t_2 = 0;
4353
4354 /* "av/video/reformatter.pyx":32
4355 * ('SMPTE170M', lib.SWS_CS_SMPTE170M),
4356 * ('SMPTE240M', lib.SWS_CS_SMPTE240M),
4357 * ('DEFAULT', lib.SWS_CS_DEFAULT), # <<<<<<<<<<<<<<
4358 *
4359 * # Lowercase for b/c.
4360 */
4361 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_DEFAULT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
4362 __Pyx_GOTREF(__pyx_t_2);
4363 __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error)
4364 __Pyx_GOTREF(__pyx_t_7);
4365 __Pyx_INCREF(__pyx_n_s_DEFAULT);
4366 __Pyx_GIVEREF(__pyx_n_s_DEFAULT);
4367 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_DEFAULT);
4368 __Pyx_GIVEREF(__pyx_t_2);
4369 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
4370 __pyx_t_2 = 0;
4371
4372 /* "av/video/reformatter.pyx":35
4373 *
4374 * # Lowercase for b/c.
4375 * ('itu709', lib.SWS_CS_ITU709), # <<<<<<<<<<<<<<
4376 * ('fcc', lib.SWS_CS_FCC),
4377 * ('itu601', lib.SWS_CS_ITU601),
4378 */
4379 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_ITU709); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
4380 __Pyx_GOTREF(__pyx_t_2);
4381 __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 35, __pyx_L1_error)
4382 __Pyx_GOTREF(__pyx_t_6);
4383 __Pyx_INCREF(__pyx_n_s_itu709);
4384 __Pyx_GIVEREF(__pyx_n_s_itu709);
4385 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_itu709);
4386 __Pyx_GIVEREF(__pyx_t_2);
4387 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
4388 __pyx_t_2 = 0;
4389
4390 /* "av/video/reformatter.pyx":36
4391 * # Lowercase for b/c.
4392 * ('itu709', lib.SWS_CS_ITU709),
4393 * ('fcc', lib.SWS_CS_FCC), # <<<<<<<<<<<<<<
4394 * ('itu601', lib.SWS_CS_ITU601),
4395 * ('itu624', lib.SWS_CS_SMPTE170M),
4396 */
4397 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_FCC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
4398 __Pyx_GOTREF(__pyx_t_2);
4399 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error)
4400 __Pyx_GOTREF(__pyx_t_5);
4401 __Pyx_INCREF(__pyx_n_s_fcc);
4402 __Pyx_GIVEREF(__pyx_n_s_fcc);
4403 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_fcc);
4404 __Pyx_GIVEREF(__pyx_t_2);
4405 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
4406 __pyx_t_2 = 0;
4407
4408 /* "av/video/reformatter.pyx":37
4409 * ('itu709', lib.SWS_CS_ITU709),
4410 * ('fcc', lib.SWS_CS_FCC),
4411 * ('itu601', lib.SWS_CS_ITU601), # <<<<<<<<<<<<<<
4412 * ('itu624', lib.SWS_CS_SMPTE170M),
4413 * ('smpte240', lib.SWS_CS_SMPTE240M),
4414 */
4415 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_ITU601); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
4416 __Pyx_GOTREF(__pyx_t_2);
4417 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error)
4418 __Pyx_GOTREF(__pyx_t_4);
4419 __Pyx_INCREF(__pyx_n_s_itu601);
4420 __Pyx_GIVEREF(__pyx_n_s_itu601);
4421 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_itu601);
4422 __Pyx_GIVEREF(__pyx_t_2);
4423 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
4424 __pyx_t_2 = 0;
4425
4426 /* "av/video/reformatter.pyx":38
4427 * ('fcc', lib.SWS_CS_FCC),
4428 * ('itu601', lib.SWS_CS_ITU601),
4429 * ('itu624', lib.SWS_CS_SMPTE170M), # <<<<<<<<<<<<<<
4430 * ('smpte240', lib.SWS_CS_SMPTE240M),
4431 * ('default', lib.SWS_CS_DEFAULT),
4432 */
4433 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_SMPTE170M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
4434 __Pyx_GOTREF(__pyx_t_2);
4435 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
4436 __Pyx_GOTREF(__pyx_t_3);
4437 __Pyx_INCREF(__pyx_n_s_itu624);
4438 __Pyx_GIVEREF(__pyx_n_s_itu624);
4439 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_itu624);
4440 __Pyx_GIVEREF(__pyx_t_2);
4441 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
4442 __pyx_t_2 = 0;
4443
4444 /* "av/video/reformatter.pyx":39
4445 * ('itu601', lib.SWS_CS_ITU601),
4446 * ('itu624', lib.SWS_CS_SMPTE170M),
4447 * ('smpte240', lib.SWS_CS_SMPTE240M), # <<<<<<<<<<<<<<
4448 * ('default', lib.SWS_CS_DEFAULT),
4449 *
4450 */
4451 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_SMPTE240M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
4452 __Pyx_GOTREF(__pyx_t_2);
4453 __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 39, __pyx_L1_error)
4454 __Pyx_GOTREF(__pyx_t_14);
4455 __Pyx_INCREF(__pyx_n_s_smpte240);
4456 __Pyx_GIVEREF(__pyx_n_s_smpte240);
4457 PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_n_s_smpte240);
4458 __Pyx_GIVEREF(__pyx_t_2);
4459 PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2);
4460 __pyx_t_2 = 0;
4461
4462 /* "av/video/reformatter.pyx":40
4463 * ('itu624', lib.SWS_CS_SMPTE170M),
4464 * ('smpte240', lib.SWS_CS_SMPTE240M),
4465 * ('default', lib.SWS_CS_DEFAULT), # <<<<<<<<<<<<<<
4466 *
4467 * ))
4468 */
4469 __pyx_t_2 = __Pyx_PyInt_From_int(SWS_CS_DEFAULT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
4470 __Pyx_GOTREF(__pyx_t_2);
4471 __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 40, __pyx_L1_error)
4472 __Pyx_GOTREF(__pyx_t_15);
4473 __Pyx_INCREF(__pyx_n_s_default);
4474 __Pyx_GIVEREF(__pyx_n_s_default);
4475 PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_n_s_default);
4476 __Pyx_GIVEREF(__pyx_t_2);
4477 PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2);
4478 __pyx_t_2 = 0;
4479
4480 /* "av/video/reformatter.pyx":26
4481 * Colorspace = define_enum('Colorspace', __name__, (
4482 *
4483 * ('ITU709', lib.SWS_CS_ITU709), # <<<<<<<<<<<<<<
4484 * ('FCC', lib.SWS_CS_FCC),
4485 * ('ITU601', lib.SWS_CS_ITU601),
4486 */
4487 __pyx_t_2 = PyTuple_New(13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
4488 __Pyx_GOTREF(__pyx_t_2);
4489 __Pyx_GIVEREF(__pyx_t_1);
4490 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4491 __Pyx_GIVEREF(__pyx_t_12);
4492 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_12);
4493 __Pyx_GIVEREF(__pyx_t_11);
4494 PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_11);
4495 __Pyx_GIVEREF(__pyx_t_10);
4496 PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_10);
4497 __Pyx_GIVEREF(__pyx_t_9);
4498 PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_9);
4499 __Pyx_GIVEREF(__pyx_t_8);
4500 PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_8);
4501 __Pyx_GIVEREF(__pyx_t_7);
4502 PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_7);
4503 __Pyx_GIVEREF(__pyx_t_6);
4504 PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_t_6);
4505 __Pyx_GIVEREF(__pyx_t_5);
4506 PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_t_5);
4507 __Pyx_GIVEREF(__pyx_t_4);
4508 PyTuple_SET_ITEM(__pyx_t_2, 9, __pyx_t_4);
4509 __Pyx_GIVEREF(__pyx_t_3);
4510 PyTuple_SET_ITEM(__pyx_t_2, 10, __pyx_t_3);
4511 __Pyx_GIVEREF(__pyx_t_14);
4512 PyTuple_SET_ITEM(__pyx_t_2, 11, __pyx_t_14);
4513 __Pyx_GIVEREF(__pyx_t_15);
4514 PyTuple_SET_ITEM(__pyx_t_2, 12, __pyx_t_15);
4515 __pyx_t_1 = 0;
4516 __pyx_t_12 = 0;
4517 __pyx_t_11 = 0;
4518 __pyx_t_10 = 0;
4519 __pyx_t_9 = 0;
4520 __pyx_t_8 = 0;
4521 __pyx_t_7 = 0;
4522 __pyx_t_6 = 0;
4523 __pyx_t_5 = 0;
4524 __pyx_t_4 = 0;
4525 __pyx_t_3 = 0;
4526 __pyx_t_14 = 0;
4527 __pyx_t_15 = 0;
4528
4529 /* "av/video/reformatter.pyx":24
4530 * ))
4531 *
4532 * Colorspace = define_enum('Colorspace', __name__, ( # <<<<<<<<<<<<<<
4533 *
4534 * ('ITU709', lib.SWS_CS_ITU709),
4535 */
4536 __pyx_t_15 = __pyx_f_2av_4enum_define_enum(__pyx_n_s_Colorspace, __pyx_t_13, __pyx_t_2, 0, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 24, __pyx_L1_error)
4537 __Pyx_GOTREF(__pyx_t_15);
4538 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4539 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4540 if (PyDict_SetItem(__pyx_d, __pyx_n_s_Colorspace, __pyx_t_15) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
4541 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
4542
4543 /* "av/video/reformatter.pyx":1
4544 * from libc.stdint cimport uint8_t # <<<<<<<<<<<<<<
4545 * cimport libav as lib
4546 *
4547 */
4548 __pyx_t_15 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1, __pyx_L1_error)
4549 __Pyx_GOTREF(__pyx_t_15);
4550 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_15) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4551 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
4552
4553 /*--- Wrapped vars code ---*/
4554
4555 goto __pyx_L0;
4556 __pyx_L1_error:;
4557 __Pyx_XDECREF(__pyx_t_1);
4558 __Pyx_XDECREF(__pyx_t_2);
4559 __Pyx_XDECREF(__pyx_t_3);
4560 __Pyx_XDECREF(__pyx_t_4);
4561 __Pyx_XDECREF(__pyx_t_5);
4562 __Pyx_XDECREF(__pyx_t_6);
4563 __Pyx_XDECREF(__pyx_t_7);
4564 __Pyx_XDECREF(__pyx_t_8);
4565 __Pyx_XDECREF(__pyx_t_9);
4566 __Pyx_XDECREF(__pyx_t_10);
4567 __Pyx_XDECREF(__pyx_t_11);
4568 __Pyx_XDECREF(__pyx_t_12);
4569 __Pyx_XDECREF(__pyx_t_13);
4570 __Pyx_XDECREF(__pyx_t_14);
4571 __Pyx_XDECREF(__pyx_t_15);
4572 if (__pyx_m) {
4573 if (__pyx_d) {
4574 __Pyx_AddTraceback("init av.video.reformatter", __pyx_clineno, __pyx_lineno, __pyx_filename);
4575 }
4576 Py_CLEAR(__pyx_m);
4577 } else if (!PyErr_Occurred()) {
4578 PyErr_SetString(PyExc_ImportError, "init av.video.reformatter");
4579 }
4580 __pyx_L0:;
4581 __Pyx_RefNannyFinishContext();
4582 #if CYTHON_PEP489_MULTI_PHASE_INIT
4583 return (__pyx_m != NULL) ? 0 : -1;
4584 #elif PY_MAJOR_VERSION >= 3
4585 return __pyx_m;
4586 #else
4587 return;
4588 #endif
4589 }
4590
4591 /* --- Runtime support code --- */
4592 /* Refnanny */
4593 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)4594 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
4595 PyObject *m = NULL, *p = NULL;
4596 void *r = NULL;
4597 m = PyImport_ImportModule(modname);
4598 if (!m) goto end;
4599 p = PyObject_GetAttrString(m, "RefNannyAPI");
4600 if (!p) goto end;
4601 r = PyLong_AsVoidPtr(p);
4602 end:
4603 Py_XDECREF(p);
4604 Py_XDECREF(m);
4605 return (__Pyx_RefNannyAPIStruct *)r;
4606 }
4607 #endif
4608
4609 /* PyObjectGetAttrStr */
4610 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)4611 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
4612 PyTypeObject* tp = Py_TYPE(obj);
4613 if (likely(tp->tp_getattro))
4614 return tp->tp_getattro(obj, attr_name);
4615 #if PY_MAJOR_VERSION < 3
4616 if (likely(tp->tp_getattr))
4617 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
4618 #endif
4619 return PyObject_GetAttr(obj, attr_name);
4620 }
4621 #endif
4622
4623 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)4624 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
4625 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
4626 if (unlikely(!result)) {
4627 PyErr_Format(PyExc_NameError,
4628 #if PY_MAJOR_VERSION >= 3
4629 "name '%U' is not defined", name);
4630 #else
4631 "name '%.200s' is not defined", PyString_AS_STRING(name));
4632 #endif
4633 }
4634 return result;
4635 }
4636
4637 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)4638 static void __Pyx_RaiseDoubleKeywordsError(
4639 const char* func_name,
4640 PyObject* kw_name)
4641 {
4642 PyErr_Format(PyExc_TypeError,
4643 #if PY_MAJOR_VERSION >= 3
4644 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
4645 #else
4646 "%s() got multiple values for keyword argument '%s'", func_name,
4647 PyString_AsString(kw_name));
4648 #endif
4649 }
4650
4651 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)4652 static int __Pyx_ParseOptionalKeywords(
4653 PyObject *kwds,
4654 PyObject **argnames[],
4655 PyObject *kwds2,
4656 PyObject *values[],
4657 Py_ssize_t num_pos_args,
4658 const char* function_name)
4659 {
4660 PyObject *key = 0, *value = 0;
4661 Py_ssize_t pos = 0;
4662 PyObject*** name;
4663 PyObject*** first_kw_arg = argnames + num_pos_args;
4664 while (PyDict_Next(kwds, &pos, &key, &value)) {
4665 name = first_kw_arg;
4666 while (*name && (**name != key)) name++;
4667 if (*name) {
4668 values[name-argnames] = value;
4669 continue;
4670 }
4671 name = first_kw_arg;
4672 #if PY_MAJOR_VERSION < 3
4673 if (likely(PyString_Check(key))) {
4674 while (*name) {
4675 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
4676 && _PyString_Eq(**name, key)) {
4677 values[name-argnames] = value;
4678 break;
4679 }
4680 name++;
4681 }
4682 if (*name) continue;
4683 else {
4684 PyObject*** argname = argnames;
4685 while (argname != first_kw_arg) {
4686 if ((**argname == key) || (
4687 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
4688 && _PyString_Eq(**argname, key))) {
4689 goto arg_passed_twice;
4690 }
4691 argname++;
4692 }
4693 }
4694 } else
4695 #endif
4696 if (likely(PyUnicode_Check(key))) {
4697 while (*name) {
4698 int cmp = (**name == key) ? 0 :
4699 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
4700 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
4701 #endif
4702 PyUnicode_Compare(**name, key);
4703 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
4704 if (cmp == 0) {
4705 values[name-argnames] = value;
4706 break;
4707 }
4708 name++;
4709 }
4710 if (*name) continue;
4711 else {
4712 PyObject*** argname = argnames;
4713 while (argname != first_kw_arg) {
4714 int cmp = (**argname == key) ? 0 :
4715 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
4716 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
4717 #endif
4718 PyUnicode_Compare(**argname, key);
4719 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
4720 if (cmp == 0) goto arg_passed_twice;
4721 argname++;
4722 }
4723 }
4724 } else
4725 goto invalid_keyword_type;
4726 if (kwds2) {
4727 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
4728 } else {
4729 goto invalid_keyword;
4730 }
4731 }
4732 return 0;
4733 arg_passed_twice:
4734 __Pyx_RaiseDoubleKeywordsError(function_name, key);
4735 goto bad;
4736 invalid_keyword_type:
4737 PyErr_Format(PyExc_TypeError,
4738 "%.200s() keywords must be strings", function_name);
4739 goto bad;
4740 invalid_keyword:
4741 PyErr_Format(PyExc_TypeError,
4742 #if PY_MAJOR_VERSION < 3
4743 "%.200s() got an unexpected keyword argument '%.200s'",
4744 function_name, PyString_AsString(key));
4745 #else
4746 "%s() got an unexpected keyword argument '%U'",
4747 function_name, key);
4748 #endif
4749 bad:
4750 return -1;
4751 }
4752
4753 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)4754 static void __Pyx_RaiseArgtupleInvalid(
4755 const char* func_name,
4756 int exact,
4757 Py_ssize_t num_min,
4758 Py_ssize_t num_max,
4759 Py_ssize_t num_found)
4760 {
4761 Py_ssize_t num_expected;
4762 const char *more_or_less;
4763 if (num_found < num_min) {
4764 num_expected = num_min;
4765 more_or_less = "at least";
4766 } else {
4767 num_expected = num_max;
4768 more_or_less = "at most";
4769 }
4770 if (exact) {
4771 more_or_less = "exactly";
4772 }
4773 PyErr_Format(PyExc_TypeError,
4774 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
4775 func_name, more_or_less, num_expected,
4776 (num_expected == 1) ? "" : "s", num_found);
4777 }
4778
4779 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)4780 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
4781 {
4782 if (unlikely(!type)) {
4783 PyErr_SetString(PyExc_SystemError, "Missing type object");
4784 return 0;
4785 }
4786 else if (exact) {
4787 #if PY_MAJOR_VERSION == 2
4788 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
4789 #endif
4790 }
4791 else {
4792 if (likely(__Pyx_TypeCheck(obj, type))) return 1;
4793 }
4794 PyErr_Format(PyExc_TypeError,
4795 "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
4796 name, type->tp_name, Py_TYPE(obj)->tp_name);
4797 return 0;
4798 }
4799
4800 /* PyCFunctionFastCall */
4801 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)4802 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
4803 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
4804 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
4805 PyObject *self = PyCFunction_GET_SELF(func);
4806 int flags = PyCFunction_GET_FLAGS(func);
4807 assert(PyCFunction_Check(func));
4808 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
4809 assert(nargs >= 0);
4810 assert(nargs == 0 || args != NULL);
4811 /* _PyCFunction_FastCallDict() must not be called with an exception set,
4812 because it may clear it (directly or indirectly) and so the
4813 caller loses its exception */
4814 assert(!PyErr_Occurred());
4815 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
4816 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
4817 } else {
4818 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
4819 }
4820 }
4821 #endif
4822
4823 /* PyFunctionFastCall */
4824 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)4825 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
4826 PyObject *globals) {
4827 PyFrameObject *f;
4828 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4829 PyObject **fastlocals;
4830 Py_ssize_t i;
4831 PyObject *result;
4832 assert(globals != NULL);
4833 /* XXX Perhaps we should create a specialized
4834 PyFrame_New() that doesn't take locals, but does
4835 take builtins without sanity checking them.
4836 */
4837 assert(tstate != NULL);
4838 f = PyFrame_New(tstate, co, globals, NULL);
4839 if (f == NULL) {
4840 return NULL;
4841 }
4842 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
4843 for (i = 0; i < na; i++) {
4844 Py_INCREF(*args);
4845 fastlocals[i] = *args++;
4846 }
4847 result = PyEval_EvalFrameEx(f,0);
4848 ++tstate->recursion_depth;
4849 Py_DECREF(f);
4850 --tstate->recursion_depth;
4851 return result;
4852 }
4853 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)4854 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
4855 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
4856 PyObject *globals = PyFunction_GET_GLOBALS(func);
4857 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
4858 PyObject *closure;
4859 #if PY_MAJOR_VERSION >= 3
4860 PyObject *kwdefs;
4861 #endif
4862 PyObject *kwtuple, **k;
4863 PyObject **d;
4864 Py_ssize_t nd;
4865 Py_ssize_t nk;
4866 PyObject *result;
4867 assert(kwargs == NULL || PyDict_Check(kwargs));
4868 nk = kwargs ? PyDict_Size(kwargs) : 0;
4869 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
4870 return NULL;
4871 }
4872 if (
4873 #if PY_MAJOR_VERSION >= 3
4874 co->co_kwonlyargcount == 0 &&
4875 #endif
4876 likely(kwargs == NULL || nk == 0) &&
4877 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
4878 if (argdefs == NULL && co->co_argcount == nargs) {
4879 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
4880 goto done;
4881 }
4882 else if (nargs == 0 && argdefs != NULL
4883 && co->co_argcount == Py_SIZE(argdefs)) {
4884 /* function called with no arguments, but all parameters have
4885 a default value: use default values as arguments .*/
4886 args = &PyTuple_GET_ITEM(argdefs, 0);
4887 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
4888 goto done;
4889 }
4890 }
4891 if (kwargs != NULL) {
4892 Py_ssize_t pos, i;
4893 kwtuple = PyTuple_New(2 * nk);
4894 if (kwtuple == NULL) {
4895 result = NULL;
4896 goto done;
4897 }
4898 k = &PyTuple_GET_ITEM(kwtuple, 0);
4899 pos = i = 0;
4900 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
4901 Py_INCREF(k[i]);
4902 Py_INCREF(k[i+1]);
4903 i += 2;
4904 }
4905 nk = i / 2;
4906 }
4907 else {
4908 kwtuple = NULL;
4909 k = NULL;
4910 }
4911 closure = PyFunction_GET_CLOSURE(func);
4912 #if PY_MAJOR_VERSION >= 3
4913 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
4914 #endif
4915 if (argdefs != NULL) {
4916 d = &PyTuple_GET_ITEM(argdefs, 0);
4917 nd = Py_SIZE(argdefs);
4918 }
4919 else {
4920 d = NULL;
4921 nd = 0;
4922 }
4923 #if PY_MAJOR_VERSION >= 3
4924 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
4925 args, (int)nargs,
4926 k, (int)nk,
4927 d, (int)nd, kwdefs, closure);
4928 #else
4929 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
4930 args, (int)nargs,
4931 k, (int)nk,
4932 d, (int)nd, closure);
4933 #endif
4934 Py_XDECREF(kwtuple);
4935 done:
4936 Py_LeaveRecursiveCall();
4937 return result;
4938 }
4939 #endif
4940 #endif
4941
4942 /* PyObjectCall */
4943 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)4944 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
4945 PyObject *result;
4946 ternaryfunc call = func->ob_type->tp_call;
4947 if (unlikely(!call))
4948 return PyObject_Call(func, arg, kw);
4949 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4950 return NULL;
4951 result = (*call)(func, arg, kw);
4952 Py_LeaveRecursiveCall();
4953 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4954 PyErr_SetString(
4955 PyExc_SystemError,
4956 "NULL result without error in PyObject_Call");
4957 }
4958 return result;
4959 }
4960 #endif
4961
4962 /* PyObjectCallMethO */
4963 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)4964 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
4965 PyObject *self, *result;
4966 PyCFunction cfunc;
4967 cfunc = PyCFunction_GET_FUNCTION(func);
4968 self = PyCFunction_GET_SELF(func);
4969 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4970 return NULL;
4971 result = cfunc(self, arg);
4972 Py_LeaveRecursiveCall();
4973 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4974 PyErr_SetString(
4975 PyExc_SystemError,
4976 "NULL result without error in PyObject_Call");
4977 }
4978 return result;
4979 }
4980 #endif
4981
4982 /* PyObjectCallOneArg */
4983 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)4984 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4985 PyObject *result;
4986 PyObject *args = PyTuple_New(1);
4987 if (unlikely(!args)) return NULL;
4988 Py_INCREF(arg);
4989 PyTuple_SET_ITEM(args, 0, arg);
4990 result = __Pyx_PyObject_Call(func, args, NULL);
4991 Py_DECREF(args);
4992 return result;
4993 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)4994 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4995 #if CYTHON_FAST_PYCALL
4996 if (PyFunction_Check(func)) {
4997 return __Pyx_PyFunction_FastCall(func, &arg, 1);
4998 }
4999 #endif
5000 if (likely(PyCFunction_Check(func))) {
5001 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
5002 return __Pyx_PyObject_CallMethO(func, arg);
5003 #if CYTHON_FAST_PYCCALL
5004 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
5005 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
5006 #endif
5007 }
5008 }
5009 return __Pyx__PyObject_CallOneArg(func, arg);
5010 }
5011 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)5012 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5013 PyObject *result;
5014 PyObject *args = PyTuple_Pack(1, arg);
5015 if (unlikely(!args)) return NULL;
5016 result = __Pyx_PyObject_Call(func, args, NULL);
5017 Py_DECREF(args);
5018 return result;
5019 }
5020 #endif
5021
5022 /* PyDictVersioning */
5023 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)5024 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
5025 PyObject *dict = Py_TYPE(obj)->tp_dict;
5026 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
5027 }
__Pyx_get_object_dict_version(PyObject * obj)5028 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
5029 PyObject **dictptr = NULL;
5030 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
5031 if (offset) {
5032 #if CYTHON_COMPILING_IN_CPYTHON
5033 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
5034 #else
5035 dictptr = _PyObject_GetDictPtr(obj);
5036 #endif
5037 }
5038 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
5039 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)5040 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
5041 PyObject *dict = Py_TYPE(obj)->tp_dict;
5042 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
5043 return 0;
5044 return obj_dict_version == __Pyx_get_object_dict_version(obj);
5045 }
5046 #endif
5047
5048 /* GetModuleGlobalName */
5049 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)5050 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
5051 #else
5052 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
5053 #endif
5054 {
5055 PyObject *result;
5056 #if !CYTHON_AVOID_BORROWED_REFS
5057 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
5058 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
5059 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5060 if (likely(result)) {
5061 return __Pyx_NewRef(result);
5062 } else if (unlikely(PyErr_Occurred())) {
5063 return NULL;
5064 }
5065 #else
5066 result = PyDict_GetItem(__pyx_d, name);
5067 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5068 if (likely(result)) {
5069 return __Pyx_NewRef(result);
5070 }
5071 #endif
5072 #else
5073 result = PyObject_GetItem(__pyx_d, name);
5074 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5075 if (likely(result)) {
5076 return __Pyx_NewRef(result);
5077 }
5078 PyErr_Clear();
5079 #endif
5080 return __Pyx_GetBuiltinName(name);
5081 }
5082
5083 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)5084 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
5085 PyObject *r;
5086 if (!j) return NULL;
5087 r = PyObject_GetItem(o, j);
5088 Py_DECREF(j);
5089 return r;
5090 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5091 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
5092 CYTHON_NCP_UNUSED int wraparound,
5093 CYTHON_NCP_UNUSED int boundscheck) {
5094 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5095 Py_ssize_t wrapped_i = i;
5096 if (wraparound & unlikely(i < 0)) {
5097 wrapped_i += PyList_GET_SIZE(o);
5098 }
5099 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
5100 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
5101 Py_INCREF(r);
5102 return r;
5103 }
5104 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5105 #else
5106 return PySequence_GetItem(o, i);
5107 #endif
5108 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5109 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
5110 CYTHON_NCP_UNUSED int wraparound,
5111 CYTHON_NCP_UNUSED int boundscheck) {
5112 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5113 Py_ssize_t wrapped_i = i;
5114 if (wraparound & unlikely(i < 0)) {
5115 wrapped_i += PyTuple_GET_SIZE(o);
5116 }
5117 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
5118 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
5119 Py_INCREF(r);
5120 return r;
5121 }
5122 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5123 #else
5124 return PySequence_GetItem(o, i);
5125 #endif
5126 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5127 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
5128 CYTHON_NCP_UNUSED int wraparound,
5129 CYTHON_NCP_UNUSED int boundscheck) {
5130 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
5131 if (is_list || PyList_CheckExact(o)) {
5132 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
5133 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
5134 PyObject *r = PyList_GET_ITEM(o, n);
5135 Py_INCREF(r);
5136 return r;
5137 }
5138 }
5139 else if (PyTuple_CheckExact(o)) {
5140 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
5141 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
5142 PyObject *r = PyTuple_GET_ITEM(o, n);
5143 Py_INCREF(r);
5144 return r;
5145 }
5146 } else {
5147 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
5148 if (likely(m && m->sq_item)) {
5149 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
5150 Py_ssize_t l = m->sq_length(o);
5151 if (likely(l >= 0)) {
5152 i += l;
5153 } else {
5154 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
5155 return NULL;
5156 PyErr_Clear();
5157 }
5158 }
5159 return m->sq_item(o, i);
5160 }
5161 }
5162 #else
5163 if (is_list || PySequence_Check(o)) {
5164 return PySequence_GetItem(o, i);
5165 }
5166 #endif
5167 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5168 }
5169
5170 /* ObjectGetItem */
5171 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)5172 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
5173 PyObject *runerr;
5174 Py_ssize_t key_value;
5175 PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
5176 if (unlikely(!(m && m->sq_item))) {
5177 PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
5178 return NULL;
5179 }
5180 key_value = __Pyx_PyIndex_AsSsize_t(index);
5181 if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
5182 return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
5183 }
5184 if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
5185 PyErr_Clear();
5186 PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
5187 }
5188 return NULL;
5189 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)5190 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
5191 PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
5192 if (likely(m && m->mp_subscript)) {
5193 return m->mp_subscript(obj, key);
5194 }
5195 return __Pyx_PyObject_GetIndex(obj, key);
5196 }
5197 #endif
5198
5199 /* PyErrFetchRestore */
5200 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)5201 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5202 PyObject *tmp_type, *tmp_value, *tmp_tb;
5203 tmp_type = tstate->curexc_type;
5204 tmp_value = tstate->curexc_value;
5205 tmp_tb = tstate->curexc_traceback;
5206 tstate->curexc_type = type;
5207 tstate->curexc_value = value;
5208 tstate->curexc_traceback = tb;
5209 Py_XDECREF(tmp_type);
5210 Py_XDECREF(tmp_value);
5211 Py_XDECREF(tmp_tb);
5212 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5213 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5214 *type = tstate->curexc_type;
5215 *value = tstate->curexc_value;
5216 *tb = tstate->curexc_traceback;
5217 tstate->curexc_type = 0;
5218 tstate->curexc_value = 0;
5219 tstate->curexc_traceback = 0;
5220 }
5221 #endif
5222
5223 /* RaiseException */
5224 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)5225 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
5226 CYTHON_UNUSED PyObject *cause) {
5227 __Pyx_PyThreadState_declare
5228 Py_XINCREF(type);
5229 if (!value || value == Py_None)
5230 value = NULL;
5231 else
5232 Py_INCREF(value);
5233 if (!tb || tb == Py_None)
5234 tb = NULL;
5235 else {
5236 Py_INCREF(tb);
5237 if (!PyTraceBack_Check(tb)) {
5238 PyErr_SetString(PyExc_TypeError,
5239 "raise: arg 3 must be a traceback or None");
5240 goto raise_error;
5241 }
5242 }
5243 if (PyType_Check(type)) {
5244 #if CYTHON_COMPILING_IN_PYPY
5245 if (!value) {
5246 Py_INCREF(Py_None);
5247 value = Py_None;
5248 }
5249 #endif
5250 PyErr_NormalizeException(&type, &value, &tb);
5251 } else {
5252 if (value) {
5253 PyErr_SetString(PyExc_TypeError,
5254 "instance exception may not have a separate value");
5255 goto raise_error;
5256 }
5257 value = type;
5258 type = (PyObject*) Py_TYPE(type);
5259 Py_INCREF(type);
5260 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
5261 PyErr_SetString(PyExc_TypeError,
5262 "raise: exception class must be a subclass of BaseException");
5263 goto raise_error;
5264 }
5265 }
5266 __Pyx_PyThreadState_assign
5267 __Pyx_ErrRestore(type, value, tb);
5268 return;
5269 raise_error:
5270 Py_XDECREF(value);
5271 Py_XDECREF(type);
5272 Py_XDECREF(tb);
5273 return;
5274 }
5275 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)5276 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
5277 PyObject* owned_instance = NULL;
5278 if (tb == Py_None) {
5279 tb = 0;
5280 } else if (tb && !PyTraceBack_Check(tb)) {
5281 PyErr_SetString(PyExc_TypeError,
5282 "raise: arg 3 must be a traceback or None");
5283 goto bad;
5284 }
5285 if (value == Py_None)
5286 value = 0;
5287 if (PyExceptionInstance_Check(type)) {
5288 if (value) {
5289 PyErr_SetString(PyExc_TypeError,
5290 "instance exception may not have a separate value");
5291 goto bad;
5292 }
5293 value = type;
5294 type = (PyObject*) Py_TYPE(value);
5295 } else if (PyExceptionClass_Check(type)) {
5296 PyObject *instance_class = NULL;
5297 if (value && PyExceptionInstance_Check(value)) {
5298 instance_class = (PyObject*) Py_TYPE(value);
5299 if (instance_class != type) {
5300 int is_subclass = PyObject_IsSubclass(instance_class, type);
5301 if (!is_subclass) {
5302 instance_class = NULL;
5303 } else if (unlikely(is_subclass == -1)) {
5304 goto bad;
5305 } else {
5306 type = instance_class;
5307 }
5308 }
5309 }
5310 if (!instance_class) {
5311 PyObject *args;
5312 if (!value)
5313 args = PyTuple_New(0);
5314 else if (PyTuple_Check(value)) {
5315 Py_INCREF(value);
5316 args = value;
5317 } else
5318 args = PyTuple_Pack(1, value);
5319 if (!args)
5320 goto bad;
5321 owned_instance = PyObject_Call(type, args, NULL);
5322 Py_DECREF(args);
5323 if (!owned_instance)
5324 goto bad;
5325 value = owned_instance;
5326 if (!PyExceptionInstance_Check(value)) {
5327 PyErr_Format(PyExc_TypeError,
5328 "calling %R should have returned an instance of "
5329 "BaseException, not %R",
5330 type, Py_TYPE(value));
5331 goto bad;
5332 }
5333 }
5334 } else {
5335 PyErr_SetString(PyExc_TypeError,
5336 "raise: exception class must be a subclass of BaseException");
5337 goto bad;
5338 }
5339 if (cause) {
5340 PyObject *fixed_cause;
5341 if (cause == Py_None) {
5342 fixed_cause = NULL;
5343 } else if (PyExceptionClass_Check(cause)) {
5344 fixed_cause = PyObject_CallObject(cause, NULL);
5345 if (fixed_cause == NULL)
5346 goto bad;
5347 } else if (PyExceptionInstance_Check(cause)) {
5348 fixed_cause = cause;
5349 Py_INCREF(fixed_cause);
5350 } else {
5351 PyErr_SetString(PyExc_TypeError,
5352 "exception causes must derive from "
5353 "BaseException");
5354 goto bad;
5355 }
5356 PyException_SetCause(value, fixed_cause);
5357 }
5358 PyErr_SetObject(type, value);
5359 if (tb) {
5360 #if CYTHON_COMPILING_IN_PYPY
5361 PyObject *tmp_type, *tmp_value, *tmp_tb;
5362 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
5363 Py_INCREF(tb);
5364 PyErr_Restore(tmp_type, tmp_value, tb);
5365 Py_XDECREF(tmp_tb);
5366 #else
5367 PyThreadState *tstate = __Pyx_PyThreadState_Current;
5368 PyObject* tmp_tb = tstate->curexc_traceback;
5369 if (tb != tmp_tb) {
5370 Py_INCREF(tb);
5371 tstate->curexc_traceback = tb;
5372 Py_XDECREF(tmp_tb);
5373 }
5374 #endif
5375 }
5376 bad:
5377 Py_XDECREF(owned_instance);
5378 return;
5379 }
5380 #endif
5381
5382 /* PyObject_GenericGetAttrNoDict */
5383 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)5384 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
5385 PyErr_Format(PyExc_AttributeError,
5386 #if PY_MAJOR_VERSION >= 3
5387 "'%.50s' object has no attribute '%U'",
5388 tp->tp_name, attr_name);
5389 #else
5390 "'%.50s' object has no attribute '%.400s'",
5391 tp->tp_name, PyString_AS_STRING(attr_name));
5392 #endif
5393 return NULL;
5394 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)5395 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
5396 PyObject *descr;
5397 PyTypeObject *tp = Py_TYPE(obj);
5398 if (unlikely(!PyString_Check(attr_name))) {
5399 return PyObject_GenericGetAttr(obj, attr_name);
5400 }
5401 assert(!tp->tp_dictoffset);
5402 descr = _PyType_Lookup(tp, attr_name);
5403 if (unlikely(!descr)) {
5404 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
5405 }
5406 Py_INCREF(descr);
5407 #if PY_MAJOR_VERSION < 3
5408 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
5409 #endif
5410 {
5411 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
5412 if (unlikely(f)) {
5413 PyObject *res = f(descr, obj, (PyObject *)tp);
5414 Py_DECREF(descr);
5415 return res;
5416 }
5417 }
5418 return descr;
5419 }
5420 #endif
5421
5422 /* PyObject_GenericGetAttr */
5423 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)5424 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
5425 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
5426 return PyObject_GenericGetAttr(obj, attr_name);
5427 }
5428 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
5429 }
5430 #endif
5431
5432 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)5433 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
5434 #if PY_VERSION_HEX >= 0x02070000
5435 PyObject *ob = PyCapsule_New(vtable, 0, 0);
5436 #else
5437 PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
5438 #endif
5439 if (!ob)
5440 goto bad;
5441 if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
5442 goto bad;
5443 Py_DECREF(ob);
5444 return 0;
5445 bad:
5446 Py_XDECREF(ob);
5447 return -1;
5448 }
5449
5450 /* PyErrExceptionMatches */
5451 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)5452 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5453 Py_ssize_t i, n;
5454 n = PyTuple_GET_SIZE(tuple);
5455 #if PY_MAJOR_VERSION >= 3
5456 for (i=0; i<n; i++) {
5457 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5458 }
5459 #endif
5460 for (i=0; i<n; i++) {
5461 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
5462 }
5463 return 0;
5464 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)5465 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
5466 PyObject *exc_type = tstate->curexc_type;
5467 if (exc_type == err) return 1;
5468 if (unlikely(!exc_type)) return 0;
5469 if (unlikely(PyTuple_Check(err)))
5470 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
5471 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
5472 }
5473 #endif
5474
5475 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)5476 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
5477 __Pyx_PyThreadState_declare
5478 __Pyx_PyThreadState_assign
5479 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
5480 __Pyx_PyErr_Clear();
5481 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)5482 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
5483 PyObject *result;
5484 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
5485 PyTypeObject* tp = Py_TYPE(obj);
5486 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
5487 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
5488 }
5489 #endif
5490 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
5491 if (unlikely(!result)) {
5492 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
5493 }
5494 return result;
5495 }
5496
5497 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)5498 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
5499 int ret;
5500 PyObject *name_attr;
5501 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
5502 if (likely(name_attr)) {
5503 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
5504 } else {
5505 ret = -1;
5506 }
5507 if (unlikely(ret < 0)) {
5508 PyErr_Clear();
5509 ret = 0;
5510 }
5511 Py_XDECREF(name_attr);
5512 return ret;
5513 }
__Pyx_setup_reduce(PyObject * type_obj)5514 static int __Pyx_setup_reduce(PyObject* type_obj) {
5515 int ret = 0;
5516 PyObject *object_reduce = NULL;
5517 PyObject *object_reduce_ex = NULL;
5518 PyObject *reduce = NULL;
5519 PyObject *reduce_ex = NULL;
5520 PyObject *reduce_cython = NULL;
5521 PyObject *setstate = NULL;
5522 PyObject *setstate_cython = NULL;
5523 #if CYTHON_USE_PYTYPE_LOOKUP
5524 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
5525 #else
5526 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
5527 #endif
5528 #if CYTHON_USE_PYTYPE_LOOKUP
5529 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
5530 #else
5531 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
5532 #endif
5533 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
5534 if (reduce_ex == object_reduce_ex) {
5535 #if CYTHON_USE_PYTYPE_LOOKUP
5536 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
5537 #else
5538 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
5539 #endif
5540 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
5541 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
5542 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
5543 if (likely(reduce_cython)) {
5544 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5545 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5546 } else if (reduce == object_reduce || PyErr_Occurred()) {
5547 goto __PYX_BAD;
5548 }
5549 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
5550 if (!setstate) PyErr_Clear();
5551 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
5552 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
5553 if (likely(setstate_cython)) {
5554 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5555 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5556 } else if (!setstate || PyErr_Occurred()) {
5557 goto __PYX_BAD;
5558 }
5559 }
5560 PyType_Modified((PyTypeObject*)type_obj);
5561 }
5562 }
5563 goto __PYX_GOOD;
5564 __PYX_BAD:
5565 if (!PyErr_Occurred())
5566 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
5567 ret = -1;
5568 __PYX_GOOD:
5569 #if !CYTHON_USE_PYTYPE_LOOKUP
5570 Py_XDECREF(object_reduce);
5571 Py_XDECREF(object_reduce_ex);
5572 #endif
5573 Py_XDECREF(reduce);
5574 Py_XDECREF(reduce_ex);
5575 Py_XDECREF(reduce_cython);
5576 Py_XDECREF(setstate);
5577 Py_XDECREF(setstate_cython);
5578 return ret;
5579 }
5580
5581 /* TypeImport */
5582 #ifndef __PYX_HAVE_RT_ImportType
5583 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)5584 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
5585 size_t size, enum __Pyx_ImportType_CheckSize check_size)
5586 {
5587 PyObject *result = 0;
5588 char warning[200];
5589 Py_ssize_t basicsize;
5590 #ifdef Py_LIMITED_API
5591 PyObject *py_basicsize;
5592 #endif
5593 result = PyObject_GetAttrString(module, class_name);
5594 if (!result)
5595 goto bad;
5596 if (!PyType_Check(result)) {
5597 PyErr_Format(PyExc_TypeError,
5598 "%.200s.%.200s is not a type object",
5599 module_name, class_name);
5600 goto bad;
5601 }
5602 #ifndef Py_LIMITED_API
5603 basicsize = ((PyTypeObject *)result)->tp_basicsize;
5604 #else
5605 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
5606 if (!py_basicsize)
5607 goto bad;
5608 basicsize = PyLong_AsSsize_t(py_basicsize);
5609 Py_DECREF(py_basicsize);
5610 py_basicsize = 0;
5611 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
5612 goto bad;
5613 #endif
5614 if ((size_t)basicsize < size) {
5615 PyErr_Format(PyExc_ValueError,
5616 "%.200s.%.200s size changed, may indicate binary incompatibility. "
5617 "Expected %zd from C header, got %zd from PyObject",
5618 module_name, class_name, size, basicsize);
5619 goto bad;
5620 }
5621 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
5622 PyErr_Format(PyExc_ValueError,
5623 "%.200s.%.200s size changed, may indicate binary incompatibility. "
5624 "Expected %zd from C header, got %zd from PyObject",
5625 module_name, class_name, size, basicsize);
5626 goto bad;
5627 }
5628 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
5629 PyOS_snprintf(warning, sizeof(warning),
5630 "%s.%s size changed, may indicate binary incompatibility. "
5631 "Expected %zd from C header, got %zd from PyObject",
5632 module_name, class_name, size, basicsize);
5633 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
5634 }
5635 return (PyTypeObject *)result;
5636 bad:
5637 Py_XDECREF(result);
5638 return NULL;
5639 }
5640 #endif
5641
5642 /* GetVTable */
__Pyx_GetVtable(PyObject * dict)5643 static void* __Pyx_GetVtable(PyObject *dict) {
5644 void* ptr;
5645 PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
5646 if (!ob)
5647 goto bad;
5648 #if PY_VERSION_HEX >= 0x02070000
5649 ptr = PyCapsule_GetPointer(ob, 0);
5650 #else
5651 ptr = PyCObject_AsVoidPtr(ob);
5652 #endif
5653 if (!ptr && !PyErr_Occurred())
5654 PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
5655 Py_DECREF(ob);
5656 return ptr;
5657 bad:
5658 Py_XDECREF(ob);
5659 return NULL;
5660 }
5661
5662 /* CLineInTraceback */
5663 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)5664 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
5665 PyObject *use_cline;
5666 PyObject *ptype, *pvalue, *ptraceback;
5667 #if CYTHON_COMPILING_IN_CPYTHON
5668 PyObject **cython_runtime_dict;
5669 #endif
5670 if (unlikely(!__pyx_cython_runtime)) {
5671 return c_line;
5672 }
5673 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
5674 #if CYTHON_COMPILING_IN_CPYTHON
5675 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
5676 if (likely(cython_runtime_dict)) {
5677 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
5678 use_cline, *cython_runtime_dict,
5679 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
5680 } else
5681 #endif
5682 {
5683 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
5684 if (use_cline_obj) {
5685 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
5686 Py_DECREF(use_cline_obj);
5687 } else {
5688 PyErr_Clear();
5689 use_cline = NULL;
5690 }
5691 }
5692 if (!use_cline) {
5693 c_line = 0;
5694 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
5695 }
5696 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
5697 c_line = 0;
5698 }
5699 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
5700 return c_line;
5701 }
5702 #endif
5703
5704 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)5705 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
5706 int start = 0, mid = 0, end = count - 1;
5707 if (end >= 0 && code_line > entries[end].code_line) {
5708 return count;
5709 }
5710 while (start < end) {
5711 mid = start + (end - start) / 2;
5712 if (code_line < entries[mid].code_line) {
5713 end = mid;
5714 } else if (code_line > entries[mid].code_line) {
5715 start = mid + 1;
5716 } else {
5717 return mid;
5718 }
5719 }
5720 if (code_line <= entries[mid].code_line) {
5721 return mid;
5722 } else {
5723 return mid + 1;
5724 }
5725 }
__pyx_find_code_object(int code_line)5726 static PyCodeObject *__pyx_find_code_object(int code_line) {
5727 PyCodeObject* code_object;
5728 int pos;
5729 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
5730 return NULL;
5731 }
5732 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5733 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
5734 return NULL;
5735 }
5736 code_object = __pyx_code_cache.entries[pos].code_object;
5737 Py_INCREF(code_object);
5738 return code_object;
5739 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)5740 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
5741 int pos, i;
5742 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
5743 if (unlikely(!code_line)) {
5744 return;
5745 }
5746 if (unlikely(!entries)) {
5747 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
5748 if (likely(entries)) {
5749 __pyx_code_cache.entries = entries;
5750 __pyx_code_cache.max_count = 64;
5751 __pyx_code_cache.count = 1;
5752 entries[0].code_line = code_line;
5753 entries[0].code_object = code_object;
5754 Py_INCREF(code_object);
5755 }
5756 return;
5757 }
5758 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5759 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
5760 PyCodeObject* tmp = entries[pos].code_object;
5761 entries[pos].code_object = code_object;
5762 Py_DECREF(tmp);
5763 return;
5764 }
5765 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
5766 int new_max = __pyx_code_cache.max_count + 64;
5767 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
5768 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
5769 if (unlikely(!entries)) {
5770 return;
5771 }
5772 __pyx_code_cache.entries = entries;
5773 __pyx_code_cache.max_count = new_max;
5774 }
5775 for (i=__pyx_code_cache.count; i>pos; i--) {
5776 entries[i] = entries[i-1];
5777 }
5778 entries[pos].code_line = code_line;
5779 entries[pos].code_object = code_object;
5780 __pyx_code_cache.count++;
5781 Py_INCREF(code_object);
5782 }
5783
5784 /* AddTraceback */
5785 #include "compile.h"
5786 #include "frameobject.h"
5787 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)5788 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
5789 const char *funcname, int c_line,
5790 int py_line, const char *filename) {
5791 PyCodeObject *py_code = 0;
5792 PyObject *py_srcfile = 0;
5793 PyObject *py_funcname = 0;
5794 #if PY_MAJOR_VERSION < 3
5795 py_srcfile = PyString_FromString(filename);
5796 #else
5797 py_srcfile = PyUnicode_FromString(filename);
5798 #endif
5799 if (!py_srcfile) goto bad;
5800 if (c_line) {
5801 #if PY_MAJOR_VERSION < 3
5802 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5803 #else
5804 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5805 #endif
5806 }
5807 else {
5808 #if PY_MAJOR_VERSION < 3
5809 py_funcname = PyString_FromString(funcname);
5810 #else
5811 py_funcname = PyUnicode_FromString(funcname);
5812 #endif
5813 }
5814 if (!py_funcname) goto bad;
5815 py_code = __Pyx_PyCode_New(
5816 0,
5817 0,
5818 0,
5819 0,
5820 0,
5821 __pyx_empty_bytes, /*PyObject *code,*/
5822 __pyx_empty_tuple, /*PyObject *consts,*/
5823 __pyx_empty_tuple, /*PyObject *names,*/
5824 __pyx_empty_tuple, /*PyObject *varnames,*/
5825 __pyx_empty_tuple, /*PyObject *freevars,*/
5826 __pyx_empty_tuple, /*PyObject *cellvars,*/
5827 py_srcfile, /*PyObject *filename,*/
5828 py_funcname, /*PyObject *name,*/
5829 py_line,
5830 __pyx_empty_bytes /*PyObject *lnotab*/
5831 );
5832 Py_DECREF(py_srcfile);
5833 Py_DECREF(py_funcname);
5834 return py_code;
5835 bad:
5836 Py_XDECREF(py_srcfile);
5837 Py_XDECREF(py_funcname);
5838 return NULL;
5839 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)5840 static void __Pyx_AddTraceback(const char *funcname, int c_line,
5841 int py_line, const char *filename) {
5842 PyCodeObject *py_code = 0;
5843 PyFrameObject *py_frame = 0;
5844 PyThreadState *tstate = __Pyx_PyThreadState_Current;
5845 if (c_line) {
5846 c_line = __Pyx_CLineForTraceback(tstate, c_line);
5847 }
5848 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
5849 if (!py_code) {
5850 py_code = __Pyx_CreateCodeObjectForTraceback(
5851 funcname, c_line, py_line, filename);
5852 if (!py_code) goto bad;
5853 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
5854 }
5855 py_frame = PyFrame_New(
5856 tstate, /*PyThreadState *tstate,*/
5857 py_code, /*PyCodeObject *code,*/
5858 __pyx_d, /*PyObject *globals,*/
5859 0 /*PyObject *locals*/
5860 );
5861 if (!py_frame) goto bad;
5862 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
5863 PyTraceBack_Here(py_frame);
5864 bad:
5865 Py_XDECREF(py_code);
5866 Py_XDECREF(py_frame);
5867 }
5868
5869 /* CIntToPy */
__Pyx_PyInt_From_int(int value)5870 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
5871 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
5872 const int is_unsigned = neg_one > const_zero;
5873 if (is_unsigned) {
5874 if (sizeof(int) < sizeof(long)) {
5875 return PyInt_FromLong((long) value);
5876 } else if (sizeof(int) <= sizeof(unsigned long)) {
5877 return PyLong_FromUnsignedLong((unsigned long) value);
5878 #ifdef HAVE_LONG_LONG
5879 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5880 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5881 #endif
5882 }
5883 } else {
5884 if (sizeof(int) <= sizeof(long)) {
5885 return PyInt_FromLong((long) value);
5886 #ifdef HAVE_LONG_LONG
5887 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5888 return PyLong_FromLongLong((PY_LONG_LONG) value);
5889 #endif
5890 }
5891 }
5892 {
5893 int one = 1; int little = (int)*(unsigned char *)&one;
5894 unsigned char *bytes = (unsigned char *)&value;
5895 return _PyLong_FromByteArray(bytes, sizeof(int),
5896 little, !is_unsigned);
5897 }
5898 }
5899
5900 /* CIntFromPyVerify */
5901 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
5902 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
5903 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
5904 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
5905 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
5906 {\
5907 func_type value = func_value;\
5908 if (sizeof(target_type) < sizeof(func_type)) {\
5909 if (unlikely(value != (func_type) (target_type) value)) {\
5910 func_type zero = 0;\
5911 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
5912 return (target_type) -1;\
5913 if (is_unsigned && unlikely(value < zero))\
5914 goto raise_neg_overflow;\
5915 else\
5916 goto raise_overflow;\
5917 }\
5918 }\
5919 return (target_type) value;\
5920 }
5921
5922 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)5923 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
5924 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
5925 const int is_unsigned = neg_one > const_zero;
5926 #if PY_MAJOR_VERSION < 3
5927 if (likely(PyInt_Check(x))) {
5928 if (sizeof(int) < sizeof(long)) {
5929 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
5930 } else {
5931 long val = PyInt_AS_LONG(x);
5932 if (is_unsigned && unlikely(val < 0)) {
5933 goto raise_neg_overflow;
5934 }
5935 return (int) val;
5936 }
5937 } else
5938 #endif
5939 if (likely(PyLong_Check(x))) {
5940 if (is_unsigned) {
5941 #if CYTHON_USE_PYLONG_INTERNALS
5942 const digit* digits = ((PyLongObject*)x)->ob_digit;
5943 switch (Py_SIZE(x)) {
5944 case 0: return (int) 0;
5945 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
5946 case 2:
5947 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
5948 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5949 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5950 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
5951 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5952 }
5953 }
5954 break;
5955 case 3:
5956 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
5957 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5958 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5959 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
5960 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5961 }
5962 }
5963 break;
5964 case 4:
5965 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
5966 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5967 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5968 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
5969 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5970 }
5971 }
5972 break;
5973 }
5974 #endif
5975 #if CYTHON_COMPILING_IN_CPYTHON
5976 if (unlikely(Py_SIZE(x) < 0)) {
5977 goto raise_neg_overflow;
5978 }
5979 #else
5980 {
5981 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5982 if (unlikely(result < 0))
5983 return (int) -1;
5984 if (unlikely(result == 1))
5985 goto raise_neg_overflow;
5986 }
5987 #endif
5988 if (sizeof(int) <= sizeof(unsigned long)) {
5989 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
5990 #ifdef HAVE_LONG_LONG
5991 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5992 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5993 #endif
5994 }
5995 } else {
5996 #if CYTHON_USE_PYLONG_INTERNALS
5997 const digit* digits = ((PyLongObject*)x)->ob_digit;
5998 switch (Py_SIZE(x)) {
5999 case 0: return (int) 0;
6000 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
6001 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
6002 case -2:
6003 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
6004 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6005 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6006 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6007 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6008 }
6009 }
6010 break;
6011 case 2:
6012 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
6013 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6014 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6015 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6016 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6017 }
6018 }
6019 break;
6020 case -3:
6021 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6022 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6023 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6024 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6025 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6026 }
6027 }
6028 break;
6029 case 3:
6030 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
6031 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6032 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6033 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6034 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6035 }
6036 }
6037 break;
6038 case -4:
6039 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6040 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6041 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6042 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
6043 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6044 }
6045 }
6046 break;
6047 case 4:
6048 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
6049 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6050 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6051 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
6052 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6053 }
6054 }
6055 break;
6056 }
6057 #endif
6058 if (sizeof(int) <= sizeof(long)) {
6059 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
6060 #ifdef HAVE_LONG_LONG
6061 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
6062 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
6063 #endif
6064 }
6065 }
6066 {
6067 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6068 PyErr_SetString(PyExc_RuntimeError,
6069 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6070 #else
6071 int val;
6072 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6073 #if PY_MAJOR_VERSION < 3
6074 if (likely(v) && !PyLong_Check(v)) {
6075 PyObject *tmp = v;
6076 v = PyNumber_Long(tmp);
6077 Py_DECREF(tmp);
6078 }
6079 #endif
6080 if (likely(v)) {
6081 int one = 1; int is_little = (int)*(unsigned char *)&one;
6082 unsigned char *bytes = (unsigned char *)&val;
6083 int ret = _PyLong_AsByteArray((PyLongObject *)v,
6084 bytes, sizeof(val),
6085 is_little, !is_unsigned);
6086 Py_DECREF(v);
6087 if (likely(!ret))
6088 return val;
6089 }
6090 #endif
6091 return (int) -1;
6092 }
6093 } else {
6094 int val;
6095 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6096 if (!tmp) return (int) -1;
6097 val = __Pyx_PyInt_As_int(tmp);
6098 Py_DECREF(tmp);
6099 return val;
6100 }
6101 raise_overflow:
6102 PyErr_SetString(PyExc_OverflowError,
6103 "value too large to convert to int");
6104 return (int) -1;
6105 raise_neg_overflow:
6106 PyErr_SetString(PyExc_OverflowError,
6107 "can't convert negative value to int");
6108 return (int) -1;
6109 }
6110
6111 /* CIntToPy */
__Pyx_PyInt_From_long(long value)6112 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
6113 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
6114 const int is_unsigned = neg_one > const_zero;
6115 if (is_unsigned) {
6116 if (sizeof(long) < sizeof(long)) {
6117 return PyInt_FromLong((long) value);
6118 } else if (sizeof(long) <= sizeof(unsigned long)) {
6119 return PyLong_FromUnsignedLong((unsigned long) value);
6120 #ifdef HAVE_LONG_LONG
6121 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6122 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
6123 #endif
6124 }
6125 } else {
6126 if (sizeof(long) <= sizeof(long)) {
6127 return PyInt_FromLong((long) value);
6128 #ifdef HAVE_LONG_LONG
6129 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6130 return PyLong_FromLongLong((PY_LONG_LONG) value);
6131 #endif
6132 }
6133 }
6134 {
6135 int one = 1; int little = (int)*(unsigned char *)&one;
6136 unsigned char *bytes = (unsigned char *)&value;
6137 return _PyLong_FromByteArray(bytes, sizeof(long),
6138 little, !is_unsigned);
6139 }
6140 }
6141
6142 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)6143 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
6144 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
6145 const int is_unsigned = neg_one > const_zero;
6146 #if PY_MAJOR_VERSION < 3
6147 if (likely(PyInt_Check(x))) {
6148 if (sizeof(long) < sizeof(long)) {
6149 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
6150 } else {
6151 long val = PyInt_AS_LONG(x);
6152 if (is_unsigned && unlikely(val < 0)) {
6153 goto raise_neg_overflow;
6154 }
6155 return (long) val;
6156 }
6157 } else
6158 #endif
6159 if (likely(PyLong_Check(x))) {
6160 if (is_unsigned) {
6161 #if CYTHON_USE_PYLONG_INTERNALS
6162 const digit* digits = ((PyLongObject*)x)->ob_digit;
6163 switch (Py_SIZE(x)) {
6164 case 0: return (long) 0;
6165 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
6166 case 2:
6167 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6168 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6169 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6170 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
6171 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6172 }
6173 }
6174 break;
6175 case 3:
6176 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6177 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6178 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6179 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
6180 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6181 }
6182 }
6183 break;
6184 case 4:
6185 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6186 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6187 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6188 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
6189 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
6190 }
6191 }
6192 break;
6193 }
6194 #endif
6195 #if CYTHON_COMPILING_IN_CPYTHON
6196 if (unlikely(Py_SIZE(x) < 0)) {
6197 goto raise_neg_overflow;
6198 }
6199 #else
6200 {
6201 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
6202 if (unlikely(result < 0))
6203 return (long) -1;
6204 if (unlikely(result == 1))
6205 goto raise_neg_overflow;
6206 }
6207 #endif
6208 if (sizeof(long) <= sizeof(unsigned long)) {
6209 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
6210 #ifdef HAVE_LONG_LONG
6211 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6212 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
6213 #endif
6214 }
6215 } else {
6216 #if CYTHON_USE_PYLONG_INTERNALS
6217 const digit* digits = ((PyLongObject*)x)->ob_digit;
6218 switch (Py_SIZE(x)) {
6219 case 0: return (long) 0;
6220 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
6221 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
6222 case -2:
6223 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
6224 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6225 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6226 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6227 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6228 }
6229 }
6230 break;
6231 case 2:
6232 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6233 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6234 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6235 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6236 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6237 }
6238 }
6239 break;
6240 case -3:
6241 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6242 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6243 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6244 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6245 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6246 }
6247 }
6248 break;
6249 case 3:
6250 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6251 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6252 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6253 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6254 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6255 }
6256 }
6257 break;
6258 case -4:
6259 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6260 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6261 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6262 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6263 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6264 }
6265 }
6266 break;
6267 case 4:
6268 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6269 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6270 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6271 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6272 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6273 }
6274 }
6275 break;
6276 }
6277 #endif
6278 if (sizeof(long) <= sizeof(long)) {
6279 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
6280 #ifdef HAVE_LONG_LONG
6281 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6282 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
6283 #endif
6284 }
6285 }
6286 {
6287 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6288 PyErr_SetString(PyExc_RuntimeError,
6289 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6290 #else
6291 long val;
6292 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6293 #if PY_MAJOR_VERSION < 3
6294 if (likely(v) && !PyLong_Check(v)) {
6295 PyObject *tmp = v;
6296 v = PyNumber_Long(tmp);
6297 Py_DECREF(tmp);
6298 }
6299 #endif
6300 if (likely(v)) {
6301 int one = 1; int is_little = (int)*(unsigned char *)&one;
6302 unsigned char *bytes = (unsigned char *)&val;
6303 int ret = _PyLong_AsByteArray((PyLongObject *)v,
6304 bytes, sizeof(val),
6305 is_little, !is_unsigned);
6306 Py_DECREF(v);
6307 if (likely(!ret))
6308 return val;
6309 }
6310 #endif
6311 return (long) -1;
6312 }
6313 } else {
6314 long val;
6315 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6316 if (!tmp) return (long) -1;
6317 val = __Pyx_PyInt_As_long(tmp);
6318 Py_DECREF(tmp);
6319 return val;
6320 }
6321 raise_overflow:
6322 PyErr_SetString(PyExc_OverflowError,
6323 "value too large to convert to long");
6324 return (long) -1;
6325 raise_neg_overflow:
6326 PyErr_SetString(PyExc_OverflowError,
6327 "can't convert negative value to long");
6328 return (long) -1;
6329 }
6330
6331 /* FastTypeChecks */
6332 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)6333 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
6334 while (a) {
6335 a = a->tp_base;
6336 if (a == b)
6337 return 1;
6338 }
6339 return b == &PyBaseObject_Type;
6340 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)6341 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
6342 PyObject *mro;
6343 if (a == b) return 1;
6344 mro = a->tp_mro;
6345 if (likely(mro)) {
6346 Py_ssize_t i, n;
6347 n = PyTuple_GET_SIZE(mro);
6348 for (i = 0; i < n; i++) {
6349 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
6350 return 1;
6351 }
6352 return 0;
6353 }
6354 return __Pyx_InBases(a, b);
6355 }
6356 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6357 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
6358 PyObject *exception, *value, *tb;
6359 int res;
6360 __Pyx_PyThreadState_declare
6361 __Pyx_PyThreadState_assign
6362 __Pyx_ErrFetch(&exception, &value, &tb);
6363 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
6364 if (unlikely(res == -1)) {
6365 PyErr_WriteUnraisable(err);
6366 res = 0;
6367 }
6368 if (!res) {
6369 res = PyObject_IsSubclass(err, exc_type2);
6370 if (unlikely(res == -1)) {
6371 PyErr_WriteUnraisable(err);
6372 res = 0;
6373 }
6374 }
6375 __Pyx_ErrRestore(exception, value, tb);
6376 return res;
6377 }
6378 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6379 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
6380 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
6381 if (!res) {
6382 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
6383 }
6384 return res;
6385 }
6386 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)6387 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
6388 Py_ssize_t i, n;
6389 assert(PyExceptionClass_Check(exc_type));
6390 n = PyTuple_GET_SIZE(tuple);
6391 #if PY_MAJOR_VERSION >= 3
6392 for (i=0; i<n; i++) {
6393 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
6394 }
6395 #endif
6396 for (i=0; i<n; i++) {
6397 PyObject *t = PyTuple_GET_ITEM(tuple, i);
6398 #if PY_MAJOR_VERSION < 3
6399 if (likely(exc_type == t)) return 1;
6400 #endif
6401 if (likely(PyExceptionClass_Check(t))) {
6402 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
6403 } else {
6404 }
6405 }
6406 return 0;
6407 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)6408 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
6409 if (likely(err == exc_type)) return 1;
6410 if (likely(PyExceptionClass_Check(err))) {
6411 if (likely(PyExceptionClass_Check(exc_type))) {
6412 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
6413 } else if (likely(PyTuple_Check(exc_type))) {
6414 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
6415 } else {
6416 }
6417 }
6418 return PyErr_GivenExceptionMatches(err, exc_type);
6419 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6420 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
6421 assert(PyExceptionClass_Check(exc_type1));
6422 assert(PyExceptionClass_Check(exc_type2));
6423 if (likely(err == exc_type1 || err == exc_type2)) return 1;
6424 if (likely(PyExceptionClass_Check(err))) {
6425 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
6426 }
6427 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
6428 }
6429 #endif
6430
6431 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)6432 static int __Pyx_check_binary_version(void) {
6433 char ctversion[4], rtversion[4];
6434 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
6435 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
6436 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
6437 char message[200];
6438 PyOS_snprintf(message, sizeof(message),
6439 "compiletime version %s of module '%.100s' "
6440 "does not match runtime version %s",
6441 ctversion, __Pyx_MODULE_NAME, rtversion);
6442 return PyErr_WarnEx(NULL, message, 1);
6443 }
6444 return 0;
6445 }
6446
6447 /* FunctionImport */
6448 #ifndef __PYX_HAVE_RT_ImportFunction
6449 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)6450 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
6451 PyObject *d = 0;
6452 PyObject *cobj = 0;
6453 union {
6454 void (*fp)(void);
6455 void *p;
6456 } tmp;
6457 d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
6458 if (!d)
6459 goto bad;
6460 cobj = PyDict_GetItemString(d, funcname);
6461 if (!cobj) {
6462 PyErr_Format(PyExc_ImportError,
6463 "%.200s does not export expected C function %.200s",
6464 PyModule_GetName(module), funcname);
6465 goto bad;
6466 }
6467 #if PY_VERSION_HEX >= 0x02070000
6468 if (!PyCapsule_IsValid(cobj, sig)) {
6469 PyErr_Format(PyExc_TypeError,
6470 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
6471 PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
6472 goto bad;
6473 }
6474 tmp.p = PyCapsule_GetPointer(cobj, sig);
6475 #else
6476 {const char *desc, *s1, *s2;
6477 desc = (const char *)PyCObject_GetDesc(cobj);
6478 if (!desc)
6479 goto bad;
6480 s1 = desc; s2 = sig;
6481 while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
6482 if (*s1 != *s2) {
6483 PyErr_Format(PyExc_TypeError,
6484 "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
6485 PyModule_GetName(module), funcname, sig, desc);
6486 goto bad;
6487 }
6488 tmp.p = PyCObject_AsVoidPtr(cobj);}
6489 #endif
6490 *f = tmp.fp;
6491 if (!(*f))
6492 goto bad;
6493 Py_DECREF(d);
6494 return 0;
6495 bad:
6496 Py_XDECREF(d);
6497 return -1;
6498 }
6499 #endif
6500
6501 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)6502 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
6503 while (t->p) {
6504 #if PY_MAJOR_VERSION < 3
6505 if (t->is_unicode) {
6506 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
6507 } else if (t->intern) {
6508 *t->p = PyString_InternFromString(t->s);
6509 } else {
6510 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
6511 }
6512 #else
6513 if (t->is_unicode | t->is_str) {
6514 if (t->intern) {
6515 *t->p = PyUnicode_InternFromString(t->s);
6516 } else if (t->encoding) {
6517 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
6518 } else {
6519 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
6520 }
6521 } else {
6522 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
6523 }
6524 #endif
6525 if (!*t->p)
6526 return -1;
6527 if (PyObject_Hash(*t->p) == -1)
6528 return -1;
6529 ++t;
6530 }
6531 return 0;
6532 }
6533
__Pyx_PyUnicode_FromString(const char * c_str)6534 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
6535 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
6536 }
__Pyx_PyObject_AsString(PyObject * o)6537 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
6538 Py_ssize_t ignore;
6539 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
6540 }
6541 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6542 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6543 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6544 char* defenc_c;
6545 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
6546 if (!defenc) return NULL;
6547 defenc_c = PyBytes_AS_STRING(defenc);
6548 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6549 {
6550 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
6551 char* c;
6552 for (c = defenc_c; c < end; c++) {
6553 if ((unsigned char) (*c) >= 128) {
6554 PyUnicode_AsASCIIString(o);
6555 return NULL;
6556 }
6557 }
6558 }
6559 #endif
6560 *length = PyBytes_GET_SIZE(defenc);
6561 return defenc_c;
6562 }
6563 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6564 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6565 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
6566 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6567 if (likely(PyUnicode_IS_ASCII(o))) {
6568 *length = PyUnicode_GET_LENGTH(o);
6569 return PyUnicode_AsUTF8(o);
6570 } else {
6571 PyUnicode_AsASCIIString(o);
6572 return NULL;
6573 }
6574 #else
6575 return PyUnicode_AsUTF8AndSize(o, length);
6576 #endif
6577 }
6578 #endif
6579 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)6580 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6581 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6582 if (
6583 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6584 __Pyx_sys_getdefaultencoding_not_ascii &&
6585 #endif
6586 PyUnicode_Check(o)) {
6587 return __Pyx_PyUnicode_AsStringAndSize(o, length);
6588 } else
6589 #endif
6590 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
6591 if (PyByteArray_Check(o)) {
6592 *length = PyByteArray_GET_SIZE(o);
6593 return PyByteArray_AS_STRING(o);
6594 } else
6595 #endif
6596 {
6597 char* result;
6598 int r = PyBytes_AsStringAndSize(o, &result, length);
6599 if (unlikely(r < 0)) {
6600 return NULL;
6601 } else {
6602 return result;
6603 }
6604 }
6605 }
__Pyx_PyObject_IsTrue(PyObject * x)6606 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
6607 int is_true = x == Py_True;
6608 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
6609 else return PyObject_IsTrue(x);
6610 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)6611 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
6612 int retval;
6613 if (unlikely(!x)) return -1;
6614 retval = __Pyx_PyObject_IsTrue(x);
6615 Py_DECREF(x);
6616 return retval;
6617 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)6618 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
6619 #if PY_MAJOR_VERSION >= 3
6620 if (PyLong_Check(result)) {
6621 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
6622 "__int__ returned non-int (type %.200s). "
6623 "The ability to return an instance of a strict subclass of int "
6624 "is deprecated, and may be removed in a future version of Python.",
6625 Py_TYPE(result)->tp_name)) {
6626 Py_DECREF(result);
6627 return NULL;
6628 }
6629 return result;
6630 }
6631 #endif
6632 PyErr_Format(PyExc_TypeError,
6633 "__%.4s__ returned non-%.4s (type %.200s)",
6634 type_name, type_name, Py_TYPE(result)->tp_name);
6635 Py_DECREF(result);
6636 return NULL;
6637 }
__Pyx_PyNumber_IntOrLong(PyObject * x)6638 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
6639 #if CYTHON_USE_TYPE_SLOTS
6640 PyNumberMethods *m;
6641 #endif
6642 const char *name = NULL;
6643 PyObject *res = NULL;
6644 #if PY_MAJOR_VERSION < 3
6645 if (likely(PyInt_Check(x) || PyLong_Check(x)))
6646 #else
6647 if (likely(PyLong_Check(x)))
6648 #endif
6649 return __Pyx_NewRef(x);
6650 #if CYTHON_USE_TYPE_SLOTS
6651 m = Py_TYPE(x)->tp_as_number;
6652 #if PY_MAJOR_VERSION < 3
6653 if (m && m->nb_int) {
6654 name = "int";
6655 res = m->nb_int(x);
6656 }
6657 else if (m && m->nb_long) {
6658 name = "long";
6659 res = m->nb_long(x);
6660 }
6661 #else
6662 if (likely(m && m->nb_int)) {
6663 name = "int";
6664 res = m->nb_int(x);
6665 }
6666 #endif
6667 #else
6668 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
6669 res = PyNumber_Int(x);
6670 }
6671 #endif
6672 if (likely(res)) {
6673 #if PY_MAJOR_VERSION < 3
6674 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
6675 #else
6676 if (unlikely(!PyLong_CheckExact(res))) {
6677 #endif
6678 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
6679 }
6680 }
6681 else if (!PyErr_Occurred()) {
6682 PyErr_SetString(PyExc_TypeError,
6683 "an integer is required");
6684 }
6685 return res;
6686 }
6687 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
6688 Py_ssize_t ival;
6689 PyObject *x;
6690 #if PY_MAJOR_VERSION < 3
6691 if (likely(PyInt_CheckExact(b))) {
6692 if (sizeof(Py_ssize_t) >= sizeof(long))
6693 return PyInt_AS_LONG(b);
6694 else
6695 return PyInt_AsSsize_t(b);
6696 }
6697 #endif
6698 if (likely(PyLong_CheckExact(b))) {
6699 #if CYTHON_USE_PYLONG_INTERNALS
6700 const digit* digits = ((PyLongObject*)b)->ob_digit;
6701 const Py_ssize_t size = Py_SIZE(b);
6702 if (likely(__Pyx_sst_abs(size) <= 1)) {
6703 ival = likely(size) ? digits[0] : 0;
6704 if (size == -1) ival = -ival;
6705 return ival;
6706 } else {
6707 switch (size) {
6708 case 2:
6709 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6710 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6711 }
6712 break;
6713 case -2:
6714 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6715 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6716 }
6717 break;
6718 case 3:
6719 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6720 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6721 }
6722 break;
6723 case -3:
6724 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6725 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6726 }
6727 break;
6728 case 4:
6729 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6730 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6731 }
6732 break;
6733 case -4:
6734 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6735 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6736 }
6737 break;
6738 }
6739 }
6740 #endif
6741 return PyLong_AsSsize_t(b);
6742 }
6743 x = PyNumber_Index(b);
6744 if (!x) return -1;
6745 ival = PyInt_AsSsize_t(x);
6746 Py_DECREF(x);
6747 return ival;
6748 }
6749 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
6750 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
6751 }
6752 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
6753 return PyInt_FromSize_t(ival);
6754 }
6755
6756
6757 #endif /* Py_PYTHON_H */
6758