From da882d498018d25579ae7955d70c79f684bd29ce Mon Sep 17 00:00:00 2001 From: synodriver Date: Wed, 6 Jul 2022 14:45:36 +0000 Subject: [PATCH] release gil --- pysilk/backends/cython/_silk_cy.c | 946 ++++++++++++++++------------ pysilk/backends/cython/_silk_cy.pyx | 38 +- 2 files changed, 556 insertions(+), 428 deletions(-) diff --git a/pysilk/backends/cython/_silk_cy.c b/pysilk/backends/cython/_silk_cy.c index a8fbf21..98c1af2 100644 --- a/pysilk/backends/cython/_silk_cy.c +++ b/pysilk/backends/cython/_silk_cy.c @@ -1,128 +1,15 @@ -/* Generated by Cython 0.29.23 */ +/* Generated by Cython 0.29.30 */ /* BEGIN: Cython Metadata { "distutils": { - "depends": [ - "silk-v3-decoder\\silk\\interface\\SKP_Silk_SDK_API.h", - "silk-v3-decoder\\silk\\interface\\SKP_Silk_control.h" - ], + "depends": [], "include_dirs": [ "./silk-v3-decoder/silk/interface" ], "name": "pysilk.backends.cython._silk_cy", "sources": [ - "pysilk/backends/cython/_silk_cy.pyx", - "./silk-v3-decoder/silk/src\\SKP_Silk_A2NLSF.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_ana_filt_bank_1.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_apply_sine_window.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_array_maxabs.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_autocorr.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_biquad.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_biquad_alt.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_burg_modified.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_bwexpander.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_bwexpander_32.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_CNG.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_code_signs.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_control_audio_bandwidth.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_control_codec_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_corrMatrix_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_create_init_destroy.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decoder_set_fs.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decode_core.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decode_frame.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decode_parameters.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decode_pitch.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_decode_pulses.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_dec_API.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_detect_SWB_input.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_div_oabi.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_encode_frame_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_encode_parameters.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_encode_pulses.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_enc_API.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_find_LPC_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_find_LTP_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_find_pitch_lags_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_find_pred_coefs_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_gain_quant.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_HP_variable_cutoff_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_init_encoder_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_inner_prod_aligned.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_interpolate.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_k2a.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_k2a_Q16.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LBRR_reset.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_lin2log.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_log2lin.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LPC_inv_pred_gain.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LPC_synthesis_filter.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LPC_synthesis_order16.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LP_variable_cutoff.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LSF_cos_table.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LTP_analysis_filter_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_LTP_scale_ctrl_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_MA.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF2A.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF2A_stable.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_MSVQ_decode.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_MSVQ_encode_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_stabilize.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_VQ_rate_distortion_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_VQ_sum_error_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NLSF_VQ_weights_laroia.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_noise_shape_analysis_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NSQ.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_NSQ_del_dec.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_pitch_analysis_core.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_pitch_est_tables.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_PLC.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_prefilter_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_process_gains_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_process_NLSFs_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_quant_LTP_gains_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_range_coder.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_regularize_correlations_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_down2.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_down2_3.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_down3.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_AR2.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_ARMA4.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_copy.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_down4.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_down_FIR.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_IIR_FIR.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_up2_HQ.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_private_up4.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_rom.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_resampler_up2.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_residual_energy16_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_residual_energy_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_scale_copy_vector16.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_scale_vector.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_schur.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_schur64.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_shell_coder.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_sigm_Q15.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_solve_LS_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_sort.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_sum_sqr_shift.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_gain.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_LTP.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_NLSF_CB0_10.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_NLSF_CB0_16.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_NLSF_CB1_10.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_NLSF_CB1_16.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_other.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_pitch_lag.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_pulses_per_block.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_sign.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_tables_type_offset.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_VAD.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_VQ_nearest_neighbor_FIX.c", - "./silk-v3-decoder/silk/src\\SKP_Silk_warped_autocorrelation_FIX.c" + "pysilk/backends/cython/_silk_cy.pyx" ] }, "module_name": "pysilk.backends.cython._silk_cy" @@ -138,8 +25,8 @@ END: Cython Metadata */ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_29_23" -#define CYTHON_HEX_VERSION 0x001D17F0 +#define CYTHON_ABI "0_29_30" +#define CYTHON_HEX_VERSION 0x001D1EF0 #define CYTHON_FUTURE_DIVISION 1 #include #ifndef offsetof @@ -214,6 +101,9 @@ END: Cython Metadata */ #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) + #endif #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -255,6 +145,9 @@ END: Cython Metadata */ #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -286,7 +179,7 @@ END: Cython Metadata */ #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif - #if PY_VERSION_HEX < 0x030300F0 + #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) @@ -301,11 +194,14 @@ END: Cython Metadata */ #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif - #ifndef CYTHON_FAST_THREAD_STATE + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #elif !defined(CYTHON_FAST_THREAD_STATE) #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 + #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) @@ -316,15 +212,23 @@ END: Cython Metadata */ #ifndef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) #endif - #ifndef CYTHON_USE_EXC_INFO_STACK + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) #endif + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif #undef SHIFT #undef BASE #undef MASK @@ -441,9 +345,68 @@ END: Cython Metadata */ #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#if PY_VERSION_HEX >= 0x030B00A1 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; + PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; + const char *fn_cstr=NULL; + const char *name_cstr=NULL; + PyCodeObject* co=NULL; + PyObject *type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); + if (!(kwds=PyDict_New())) goto end; + if (!(argcount=PyLong_FromLong(a))) goto end; + if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; + if (!(posonlyargcount=PyLong_FromLong(0))) goto end; + if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; + if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; + if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; + if (!(nlocals=PyLong_FromLong(l))) goto end; + if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; + if (!(stacksize=PyLong_FromLong(s))) goto end; + if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; + if (!(flags=PyLong_FromLong(f))) goto end; + if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; + if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; + if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; + if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; + if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; + if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here + if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; + Py_XDECREF((PyObject*)co); + co = (PyCodeObject*)call_result; + call_result = NULL; + if (0) { + cleanup_code_too: + Py_XDECREF((PyObject*)co); + co = NULL; + } + end: + Py_XDECREF(kwds); + Py_XDECREF(argcount); + Py_XDECREF(posonlyargcount); + Py_XDECREF(kwonlyargcount); + Py_XDECREF(nlocals); + Py_XDECREF(stacksize); + Py_XDECREF(replace); + Py_XDECREF(call_result); + Py_XDECREF(empty); + if (type) { + PyErr_Restore(type, value, traceback); + } + return co; + } #else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) @@ -557,8 +520,12 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 + #if defined(PyUnicode_IS_READY) #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) + #else + #define __Pyx_PyUnicode_READY(op) (0) + #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) @@ -567,7 +534,11 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #endif @@ -673,10 +644,10 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) @@ -701,8 +672,10 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { } __Pyx_PyAsyncMethodsStruct; #endif -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES +#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) + #if !defined(_USE_MATH_DEFINES) + #define _USE_MATH_DEFINES + #endif #endif #include #ifdef NAN @@ -863,6 +836,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else @@ -975,14 +949,9 @@ static const char *__pyx_filename; static const char *__pyx_f[] = { - "pysilk\\backends\\cython\\_silk_cy.pyx", + "pysilk/backends/cython/_silk_cy.pyx", "type.pxd", }; -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* NoFastGil.proto */ #define __Pyx_PyGILState_Ensure PyGILState_Ensure #define __Pyx_PyGILState_Release PyGILState_Release @@ -990,6 +959,11 @@ static const char *__pyx_f[] = { #define __Pyx_FastGIL_Forget() #define __Pyx_FastGilFuncInit() +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_opt_args_6pysilk_8backends_6cython_8_silk_cy_encode; @@ -1012,7 +986,7 @@ struct __pyx_opt_args_6pysilk_8backends_6cython_8_silk_cy_encode { int tencent; }; -/* "pysilk/backends/cython/_silk_cy.pyx":182 +/* "pysilk/backends/cython/_silk_cy.pyx":187 * PyMem_Free(enc) * * cpdef inline void decode(object input, # <<<<<<<<<<<<<< @@ -1147,13 +1121,21 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif +#if CYTHON_FAST_PYCALL static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif // CYTHON_FAST_PYCALL #endif /* PyObjectCall.proto */ @@ -1573,7 +1555,7 @@ static const char __pyx_k_input_except_a_file_like_object[] = "input except a fi static const char __pyx_k_pysilk_backends_cython__silk_cy[] = "pysilk.backends.cython._silk_cy"; static const char __pyx_k_input_must_be_a_file_like_rb_obj[] = "input must be a file-like rb object, got "; static const char __pyx_k_output_except_a_file_like_object[] = "output except a file-like object, got %s"; -static const char __pyx_k_pysilk_backends_cython__silk_cy_2[] = "pysilk\\backends\\cython\\_silk_cy.pyx"; +static const char __pyx_k_pysilk_backends_cython__silk_cy_2[] = "pysilk/backends/cython/_silk_cy.pyx"; static PyObject *__pyx_kp_b_3; static PyObject *__pyx_n_u_DEC_INVALID_SAMPLING_FREQUENCY; static PyObject *__pyx_n_u_DEC_PAYLOAD_ERROR; @@ -2854,7 +2836,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO * int32_t complexity = 2, * bint use_inband_fec = False, # <<<<<<<<<<<<<< * bint use_dtx = False, - * bint tencent = True) with gil: + * bint tencent = True): */ int __pyx_v_use_inband_fec = ((int)0); @@ -2862,7 +2844,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO * int32_t complexity = 2, * bint use_inband_fec = False, * bint use_dtx = False, # <<<<<<<<<<<<<< - * bint tencent = True) with gil: + * bint tencent = True): * """encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> bytes */ int __pyx_v_use_dtx = ((int)0); @@ -2870,7 +2852,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO /* "pysilk/backends/cython/_silk_cy.pyx":100 * bint use_inband_fec = False, * bint use_dtx = False, - * bint tencent = True) with gil: # <<<<<<<<<<<<<< + * bint tencent = True): # <<<<<<<<<<<<<< * """encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> bytes * */ @@ -2883,6 +2865,8 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO int32_t __pyx_v_frame_size; int16_t __pyx_v_n_bytes; uint8_t __pyx_v_payload[0x4E2]; + int16_t *__pyx_v_chunk_ptr; + int32_t __pyx_v_chunk_size; PyObject *__pyx_v_chunk = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -2894,9 +2878,6 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif __Pyx_RefNannySetupContext("encode", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { @@ -2918,8 +2899,6 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO } } } - __Pyx_INCREF(__pyx_v_input); - __Pyx_INCREF(__pyx_v_output); /* "pysilk/backends/cython/_silk_cy.pyx":116 * :return: None @@ -3403,29 +3382,29 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO * output.write(b"#!SILK_V3") * cdef int16_t n_bytes = 1250 # <<<<<<<<<<<<<< * cdef uint8_t payload[1250] - * while True: + * cdef int16_t* chunk_ptr */ __pyx_v_n_bytes = 0x4E2; - /* "pysilk/backends/cython/_silk_cy.pyx":159 - * cdef int16_t n_bytes = 1250 - * cdef uint8_t payload[1250] + /* "pysilk/backends/cython/_silk_cy.pyx":161 + * cdef int16_t* chunk_ptr + * cdef int32_t chunk_size * while True: # <<<<<<<<<<<<<< * chunk = input.read(frame_size) # type: bytes * if not PyBytes_Check(chunk): */ while (1) { - /* "pysilk/backends/cython/_silk_cy.pyx":160 - * cdef uint8_t payload[1250] + /* "pysilk/backends/cython/_silk_cy.pyx":162 + * cdef int32_t chunk_size * while True: * chunk = input.read(frame_size) # type: bytes # <<<<<<<<<<<<<< * if not PyBytes_Check(chunk): * PyMem_Free(enc) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_frame_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_frame_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { @@ -3440,13 +3419,13 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_chunk, __pyx_t_2); __pyx_t_2 = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":161 + /* "pysilk/backends/cython/_silk_cy.pyx":163 * while True: * chunk = input.read(frame_size) # type: bytes * if not PyBytes_Check(chunk): # <<<<<<<<<<<<<< @@ -3456,7 +3435,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __pyx_t_1 = ((!(PyBytes_Check(__pyx_v_chunk) != 0)) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":162 + /* "pysilk/backends/cython/_silk_cy.pyx":164 * chunk = input.read(frame_size) # type: bytes * if not PyBytes_Check(chunk): * PyMem_Free(enc) # <<<<<<<<<<<<<< @@ -3465,29 +3444,29 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO */ PyMem_Free(__pyx_v_enc); - /* "pysilk/backends/cython/_silk_cy.pyx":163 + /* "pysilk/backends/cython/_silk_cy.pyx":165 * if not PyBytes_Check(chunk): * PyMem_Free(enc) * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") # <<<<<<<<<<<<<< * * n_bytes = 1250 */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_input_must_be_a_file_like_rb_obj, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_input_must_be_a_file_like_rb_obj, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 163, __pyx_L1_error) + __PYX_ERR(0, 165, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":161 + /* "pysilk/backends/cython/_silk_cy.pyx":163 * while True: * chunk = input.read(frame_size) # type: bytes * if not PyBytes_Check(chunk): # <<<<<<<<<<<<<< @@ -3496,7 +3475,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":165 + /* "pysilk/backends/cython/_silk_cy.pyx":167 * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") * * n_bytes = 1250 # <<<<<<<<<<<<<< @@ -3505,56 +3484,101 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO */ __pyx_v_n_bytes = 0x4E2; - /* "pysilk/backends/cython/_silk_cy.pyx":166 + /* "pysilk/backends/cython/_silk_cy.pyx":168 * * n_bytes = 1250 * if PyBytes_Size(chunk) < frame_size: # <<<<<<<<<<<<<< * break - * code = SKP_Silk_SDK_Encode(enc, + * chunk_ptr = PyBytes_AS_STRING(chunk) */ - __pyx_t_6 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_6 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 168, __pyx_L1_error) __pyx_t_1 = ((((int32_t)__pyx_t_6) < __pyx_v_frame_size) != 0); if (__pyx_t_1) { - /* "pysilk/backends/cython/_silk_cy.pyx":167 + /* "pysilk/backends/cython/_silk_cy.pyx":169 * n_bytes = 1250 * if PyBytes_Size(chunk) < frame_size: * break # <<<<<<<<<<<<<< - * code = SKP_Silk_SDK_Encode(enc, - * &enc_control, + * chunk_ptr = PyBytes_AS_STRING(chunk) + * chunk_size = (PyBytes_Size(chunk) / 2) */ goto __pyx_L10_break; - /* "pysilk/backends/cython/_silk_cy.pyx":166 + /* "pysilk/backends/cython/_silk_cy.pyx":168 * * n_bytes = 1250 * if PyBytes_Size(chunk) < frame_size: # <<<<<<<<<<<<<< * break - * code = SKP_Silk_SDK_Encode(enc, + * chunk_ptr = PyBytes_AS_STRING(chunk) */ } + /* "pysilk/backends/cython/_silk_cy.pyx":170 + * if PyBytes_Size(chunk) < frame_size: + * break + * chunk_ptr = PyBytes_AS_STRING(chunk) # <<<<<<<<<<<<<< + * chunk_size = (PyBytes_Size(chunk) / 2) + * with nogil: + */ + __pyx_v_chunk_ptr = ((int16_t *)PyBytes_AS_STRING(__pyx_v_chunk)); + /* "pysilk/backends/cython/_silk_cy.pyx":171 - * &enc_control, - * PyBytes_AS_STRING(chunk), - * (PyBytes_Size(chunk) / 2), # <<<<<<<<<<<<<< - * payload, - * &n_bytes) + * break + * chunk_ptr = PyBytes_AS_STRING(chunk) + * chunk_size = (PyBytes_Size(chunk) / 2) # <<<<<<<<<<<<<< + * with nogil: + * code = SKP_Silk_SDK_Encode(enc, */ __pyx_t_6 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 171, __pyx_L1_error) + __pyx_v_chunk_size = ((int32_t)(__pyx_t_6 / 2)); - /* "pysilk/backends/cython/_silk_cy.pyx":168 - * if PyBytes_Size(chunk) < frame_size: - * break - * code = SKP_Silk_SDK_Encode(enc, # <<<<<<<<<<<<<< - * &enc_control, - * PyBytes_AS_STRING(chunk), + /* "pysilk/backends/cython/_silk_cy.pyx":172 + * chunk_ptr = PyBytes_AS_STRING(chunk) + * chunk_size = (PyBytes_Size(chunk) / 2) + * with nogil: # <<<<<<<<<<<<<< + * code = SKP_Silk_SDK_Encode(enc, + * &enc_control, */ - __pyx_v_code = SKP_Silk_SDK_Encode(__pyx_v_enc, (&__pyx_v_enc_control), ((int16_t *)PyBytes_AS_STRING(__pyx_v_chunk)), ((int32_t)(__pyx_t_6 / 2)), __pyx_v_payload, (&__pyx_v_n_bytes)); + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { - /* "pysilk/backends/cython/_silk_cy.pyx":174 - * payload, - * &n_bytes) + /* "pysilk/backends/cython/_silk_cy.pyx":173 + * chunk_size = (PyBytes_Size(chunk) / 2) + * with nogil: + * code = SKP_Silk_SDK_Encode(enc, # <<<<<<<<<<<<<< + * &enc_control, + * chunk_ptr, + */ + __pyx_v_code = SKP_Silk_SDK_Encode(__pyx_v_enc, (&__pyx_v_enc_control), __pyx_v_chunk_ptr, __pyx_v_chunk_size, __pyx_v_payload, (&__pyx_v_n_bytes)); + } + + /* "pysilk/backends/cython/_silk_cy.pyx":172 + * chunk_ptr = PyBytes_AS_STRING(chunk) + * chunk_size = (PyBytes_Size(chunk) / 2) + * with nogil: # <<<<<<<<<<<<<< + * code = SKP_Silk_SDK_Encode(enc, + * &enc_control, + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L17; + } + __pyx_L17:; + } + } + + /* "pysilk/backends/cython/_silk_cy.pyx":179 + * payload, + * &n_bytes) * if code != 0: # <<<<<<<<<<<<<< * PyMem_Free(enc) * raise SilkError(code) @@ -3562,8 +3586,8 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __pyx_t_1 = ((__pyx_v_code != 0) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":175 - * &n_bytes) + /* "pysilk/backends/cython/_silk_cy.pyx":180 + * &n_bytes) * if code != 0: * PyMem_Free(enc) # <<<<<<<<<<<<<< * raise SilkError(code) @@ -3571,16 +3595,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO */ PyMem_Free(__pyx_v_enc); - /* "pysilk/backends/cython/_silk_cy.pyx":176 + /* "pysilk/backends/cython/_silk_cy.pyx":181 * if code != 0: * PyMem_Free(enc) * raise SilkError(code) # <<<<<<<<<<<<<< * * write_i16_le(output, n_bytes) */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -3595,23 +3619,23 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 176, __pyx_L1_error) + __PYX_ERR(0, 181, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":174 - * payload, - * &n_bytes) + /* "pysilk/backends/cython/_silk_cy.pyx":179 + * payload, + * &n_bytes) * if code != 0: # <<<<<<<<<<<<<< * PyMem_Free(enc) * raise SilkError(code) */ } - /* "pysilk/backends/cython/_silk_cy.pyx":178 + /* "pysilk/backends/cython/_silk_cy.pyx":183 * raise SilkError(code) * * write_i16_le(output, n_bytes) # <<<<<<<<<<<<<< @@ -3620,16 +3644,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO */ __pyx_f_6pysilk_8backends_6cython_8_silk_cy_write_i16_le(__pyx_v_output, __pyx_v_n_bytes); - /* "pysilk/backends/cython/_silk_cy.pyx":179 + /* "pysilk/backends/cython/_silk_cy.pyx":184 * * write_i16_le(output, n_bytes) * output.write( payload[0:n_bytes]) # <<<<<<<<<<<<<< * PyMem_Free(enc) * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_output, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_output, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_payload) + 0, __pyx_v_n_bytes - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_payload) + 0, __pyx_v_n_bytes - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -3644,14 +3668,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L10_break:; - /* "pysilk/backends/cython/_silk_cy.pyx":180 + /* "pysilk/backends/cython/_silk_cy.pyx":185 * write_i16_le(output, n_bytes) * output.write( payload[0:n_bytes]) * PyMem_Free(enc) # <<<<<<<<<<<<<< @@ -3678,12 +3702,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_encode(PyO __Pyx_WriteUnraisable("pysilk.backends.cython._silk_cy.encode", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_chunk); - __Pyx_XDECREF(__pyx_v_input); - __Pyx_XDECREF(__pyx_v_output); __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif } /* Python wrapper */ @@ -3849,7 +3868,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_1encode(PyObject * * int32_t complexity = 2, * bint use_inband_fec = False, # <<<<<<<<<<<<<< * bint use_dtx = False, - * bint tencent = True) with gil: + * bint tencent = True): */ __pyx_v_use_inband_fec = ((int)0); } @@ -3861,7 +3880,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_1encode(PyObject * * int32_t complexity = 2, * bint use_inband_fec = False, * bint use_dtx = False, # <<<<<<<<<<<<<< - * bint tencent = True) with gil: + * bint tencent = True): * """encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> bytes */ __pyx_v_use_dtx = ((int)0); @@ -3873,7 +3892,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_1encode(PyObject * /* "pysilk/backends/cython/_silk_cy.pyx":100 * bint use_inband_fec = False, * bint use_dtx = False, - * bint tencent = True) with gil: # <<<<<<<<<<<<<< + * bint tencent = True): # <<<<<<<<<<<<<< * """encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> bytes * */ @@ -3938,7 +3957,7 @@ static PyObject *__pyx_pf_6pysilk_8backends_6cython_8_silk_cy_encode(CYTHON_UNUS return __pyx_r; } -/* "pysilk/backends/cython/_silk_cy.pyx":182 +/* "pysilk/backends/cython/_silk_cy.pyx":187 * PyMem_Free(enc) * * cpdef inline void decode(object input, # <<<<<<<<<<<<<< @@ -3951,20 +3970,20 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO int32_t __pyx_v_frame_size = ((int32_t)0); int32_t __pyx_v_frames_per_packet = ((int32_t)1); - /* "pysilk/backends/cython/_silk_cy.pyx":187 + /* "pysilk/backends/cython/_silk_cy.pyx":192 * int32_t frame_size=0, * int32_t frames_per_packet=1, * bint more_internal_decoder_frames=False, # <<<<<<<<<<<<<< * int32_t in_band_fec_offset=0, - * bint loss=False) with gil: + * bint loss=False): */ int __pyx_v_more_internal_decoder_frames = ((int)0); int32_t __pyx_v_in_band_fec_offset = ((int32_t)0); - /* "pysilk/backends/cython/_silk_cy.pyx":189 + /* "pysilk/backends/cython/_silk_cy.pyx":194 * bint more_internal_decoder_frames=False, * int32_t in_band_fec_offset=0, - * bint loss=False) with gil: # <<<<<<<<<<<<<< + * bint loss=False): # <<<<<<<<<<<<<< * """decode(input: BinaryIO, output: BinaryIO, sample_rate: int, frame_size: int = 0, frames_per_packet: int = 1, more_internal_decoder_frames: bool = False, in_band_fec_offset: int = 0, loss: bool = False) -> bytes * */ @@ -3976,6 +3995,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO void *__pyx_v_dec; uint8_t *__pyx_v_buf; int16_t __pyx_v_n_bytes; + uint8_t const *__pyx_v_chunk_ptr; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; @@ -3987,9 +4007,6 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif __Pyx_RefNannySetupContext("decode", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { @@ -4008,10 +4025,8 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } } } - __Pyx_INCREF(__pyx_v_input); - __Pyx_INCREF(__pyx_v_output); - /* "pysilk/backends/cython/_silk_cy.pyx":203 + /* "pysilk/backends/cython/_silk_cy.pyx":208 * :return: * """ * if not PyFile_Check(input): # <<<<<<<<<<<<<< @@ -4021,26 +4036,26 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((!(__pyx_f_6pysilk_8backends_6cython_8_silk_cy_PyFile_Check(__pyx_v_input) != 0)) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":204 + /* "pysilk/backends/cython/_silk_cy.pyx":209 * """ * if not PyFile_Check(input): * raise TypeError("input except a file-like object, got %s" % type(input).__name__) # <<<<<<<<<<<<<< * if not PyFile_Check(output): * raise TypeError("output except a file-like object, got %s" % type(output).__name__) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_input_except_a_file_like_object, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_input_except_a_file_like_object, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 204, __pyx_L1_error) + __PYX_ERR(0, 209, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":203 + /* "pysilk/backends/cython/_silk_cy.pyx":208 * :return: * """ * if not PyFile_Check(input): # <<<<<<<<<<<<<< @@ -4049,7 +4064,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":205 + /* "pysilk/backends/cython/_silk_cy.pyx":210 * if not PyFile_Check(input): * raise TypeError("input except a file-like object, got %s" % type(input).__name__) * if not PyFile_Check(output): # <<<<<<<<<<<<<< @@ -4059,26 +4074,26 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((!(__pyx_f_6pysilk_8backends_6cython_8_silk_cy_PyFile_Check(__pyx_v_output) != 0)) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":206 + /* "pysilk/backends/cython/_silk_cy.pyx":211 * raise TypeError("input except a file-like object, got %s" % type(input).__name__) * if not PyFile_Check(output): * raise TypeError("output except a file-like object, got %s" % type(output).__name__) # <<<<<<<<<<<<<< * * chunk = input.read(9) # type: bytes */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_output)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_output)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_output_except_a_file_like_object, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_output_except_a_file_like_object, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 206, __pyx_L1_error) + __PYX_ERR(0, 211, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":205 + /* "pysilk/backends/cython/_silk_cy.pyx":210 * if not PyFile_Check(input): * raise TypeError("input except a file-like object, got %s" % type(input).__name__) * if not PyFile_Check(output): # <<<<<<<<<<<<<< @@ -4087,14 +4102,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":208 + /* "pysilk/backends/cython/_silk_cy.pyx":213 * raise TypeError("output except a file-like object, got %s" % type(output).__name__) * * chunk = input.read(9) # type: bytes # <<<<<<<<<<<<<< * if not PyBytes_Check(chunk): * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { @@ -4108,13 +4123,13 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_int_9) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_9); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_chunk = __pyx_t_2; __pyx_t_2 = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":209 + /* "pysilk/backends/cython/_silk_cy.pyx":214 * * chunk = input.read(9) # type: bytes * if not PyBytes_Check(chunk): # <<<<<<<<<<<<<< @@ -4124,29 +4139,29 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((!(PyBytes_Check(__pyx_v_chunk) != 0)) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":210 + /* "pysilk/backends/cython/_silk_cy.pyx":215 * chunk = input.read(9) # type: bytes * if not PyBytes_Check(chunk): * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") # <<<<<<<<<<<<<< * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": * raise SilkError("INVALID") */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_input)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_input_must_be_a_file_like_rb_obj, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_input_must_be_a_file_like_rb_obj, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 210, __pyx_L1_error) + __PYX_ERR(0, 215, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":209 + /* "pysilk/backends/cython/_silk_cy.pyx":214 * * chunk = input.read(9) # type: bytes * if not PyBytes_Check(chunk): # <<<<<<<<<<<<<< @@ -4155,32 +4170,32 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":211 + /* "pysilk/backends/cython/_silk_cy.pyx":216 * if not PyBytes_Check(chunk): * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": # <<<<<<<<<<<<<< * raise SilkError("INVALID") * elif chunk == b"\x02#!SILK_V": */ - __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V3_2, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V3_2, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 216, __pyx_L1_error) if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L7_bool_binop_done; } - __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 216, __pyx_L1_error) __pyx_t_1 = __pyx_t_5; __pyx_L7_bool_binop_done:; if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":212 + /* "pysilk/backends/cython/_silk_cy.pyx":217 * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": * raise SilkError("INVALID") # <<<<<<<<<<<<<< * elif chunk == b"\x02#!SILK_V": * chunk = input.read(1) */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4194,14 +4209,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_INVALID) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_INVALID); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 212, __pyx_L1_error) + __PYX_ERR(0, 217, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":211 + /* "pysilk/backends/cython/_silk_cy.pyx":216 * if not PyBytes_Check(chunk): * raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}") * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": # <<<<<<<<<<<<<< @@ -4210,24 +4225,24 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":213 + /* "pysilk/backends/cython/_silk_cy.pyx":218 * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": * raise SilkError("INVALID") * elif chunk == b"\x02#!SILK_V": # <<<<<<<<<<<<<< * chunk = input.read(1) * if chunk != b"3": */ - __pyx_t_1 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_SILK_V, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 218, __pyx_L1_error) if (__pyx_t_1) { - /* "pysilk/backends/cython/_silk_cy.pyx":214 + /* "pysilk/backends/cython/_silk_cy.pyx":219 * raise SilkError("INVALID") * elif chunk == b"\x02#!SILK_V": * chunk = input.read(1) # <<<<<<<<<<<<<< * if chunk != b"3": * raise SilkError("INVALID") */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4241,30 +4256,30 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_chunk, __pyx_t_3); __pyx_t_3 = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":215 + /* "pysilk/backends/cython/_silk_cy.pyx":220 * elif chunk == b"\x02#!SILK_V": * chunk = input.read(1) * if chunk != b"3": # <<<<<<<<<<<<<< * raise SilkError("INVALID") * */ - __pyx_t_1 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_3, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 215, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyBytes_Equals(__pyx_v_chunk, __pyx_kp_b_3, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 220, __pyx_L1_error) if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":216 + /* "pysilk/backends/cython/_silk_cy.pyx":221 * chunk = input.read(1) * if chunk != b"3": * raise SilkError("INVALID") # <<<<<<<<<<<<<< * * cdef SKP_SILK_SDK_DecControlStruct dec_control */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4278,14 +4293,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_INVALID) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_INVALID); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 216, __pyx_L1_error) + __PYX_ERR(0, 221, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":215 + /* "pysilk/backends/cython/_silk_cy.pyx":220 * elif chunk == b"\x02#!SILK_V": * chunk = input.read(1) * if chunk != b"3": # <<<<<<<<<<<<<< @@ -4294,7 +4309,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":213 + /* "pysilk/backends/cython/_silk_cy.pyx":218 * if chunk != b"#!SILK_V3" and chunk != b"\x02#!SILK_V": * raise SilkError("INVALID") * elif chunk == b"\x02#!SILK_V": # <<<<<<<<<<<<<< @@ -4303,7 +4318,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":219 + /* "pysilk/backends/cython/_silk_cy.pyx":224 * * cdef SKP_SILK_SDK_DecControlStruct dec_control * dec_control.API_sampleRate = sample_rate # <<<<<<<<<<<<<< @@ -4312,7 +4327,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_control.API_sampleRate = __pyx_v_sample_rate; - /* "pysilk/backends/cython/_silk_cy.pyx":220 + /* "pysilk/backends/cython/_silk_cy.pyx":225 * cdef SKP_SILK_SDK_DecControlStruct dec_control * dec_control.API_sampleRate = sample_rate * dec_control.frameSize = frame_size # <<<<<<<<<<<<<< @@ -4321,7 +4336,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_control.frameSize = __pyx_v_frame_size; - /* "pysilk/backends/cython/_silk_cy.pyx":221 + /* "pysilk/backends/cython/_silk_cy.pyx":226 * dec_control.API_sampleRate = sample_rate * dec_control.frameSize = frame_size * dec_control.framesPerPacket = frames_per_packet # <<<<<<<<<<<<<< @@ -4330,7 +4345,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_control.framesPerPacket = __pyx_v_frames_per_packet; - /* "pysilk/backends/cython/_silk_cy.pyx":222 + /* "pysilk/backends/cython/_silk_cy.pyx":227 * dec_control.frameSize = frame_size * dec_control.framesPerPacket = frames_per_packet * dec_control.moreInternalDecoderFrames = more_internal_decoder_frames # <<<<<<<<<<<<<< @@ -4339,7 +4354,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_control.moreInternalDecoderFrames = __pyx_v_more_internal_decoder_frames; - /* "pysilk/backends/cython/_silk_cy.pyx":223 + /* "pysilk/backends/cython/_silk_cy.pyx":228 * dec_control.framesPerPacket = frames_per_packet * dec_control.moreInternalDecoderFrames = more_internal_decoder_frames * dec_control.inBandFECOffset = in_band_fec_offset # <<<<<<<<<<<<<< @@ -4348,7 +4363,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_control.inBandFECOffset = __pyx_v_in_band_fec_offset; - /* "pysilk/backends/cython/_silk_cy.pyx":224 + /* "pysilk/backends/cython/_silk_cy.pyx":229 * dec_control.moreInternalDecoderFrames = more_internal_decoder_frames * dec_control.inBandFECOffset = in_band_fec_offset * cdef int32_t dec_size = 0 # <<<<<<<<<<<<<< @@ -4357,7 +4372,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec_size = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":225 + /* "pysilk/backends/cython/_silk_cy.pyx":230 * dec_control.inBandFECOffset = in_band_fec_offset * cdef int32_t dec_size = 0 * cdef int32_t code = SKP_Silk_SDK_Get_Decoder_Size(&dec_size) # <<<<<<<<<<<<<< @@ -4366,7 +4381,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_code = SKP_Silk_SDK_Get_Decoder_Size((&__pyx_v_dec_size)); - /* "pysilk/backends/cython/_silk_cy.pyx":226 + /* "pysilk/backends/cython/_silk_cy.pyx":231 * cdef int32_t dec_size = 0 * cdef int32_t code = SKP_Silk_SDK_Get_Decoder_Size(&dec_size) * if code != 0: # <<<<<<<<<<<<<< @@ -4376,16 +4391,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_code != 0) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":227 + /* "pysilk/backends/cython/_silk_cy.pyx":232 * cdef int32_t code = SKP_Silk_SDK_Get_Decoder_Size(&dec_size) * if code != 0: * raise SilkError(code) # <<<<<<<<<<<<<< * cdef void *dec = PyMem_Malloc(dec_size) * if dec == NULL: */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4400,14 +4415,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 227, __pyx_L1_error) + __PYX_ERR(0, 232, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":226 + /* "pysilk/backends/cython/_silk_cy.pyx":231 * cdef int32_t dec_size = 0 * cdef int32_t code = SKP_Silk_SDK_Get_Decoder_Size(&dec_size) * if code != 0: # <<<<<<<<<<<<<< @@ -4416,7 +4431,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":228 + /* "pysilk/backends/cython/_silk_cy.pyx":233 * if code != 0: * raise SilkError(code) * cdef void *dec = PyMem_Malloc(dec_size) # <<<<<<<<<<<<<< @@ -4425,7 +4440,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_dec = PyMem_Malloc(__pyx_v_dec_size); - /* "pysilk/backends/cython/_silk_cy.pyx":229 + /* "pysilk/backends/cython/_silk_cy.pyx":234 * raise SilkError(code) * cdef void *dec = PyMem_Malloc(dec_size) * if dec == NULL: # <<<<<<<<<<<<<< @@ -4435,16 +4450,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_dec == NULL) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":230 + /* "pysilk/backends/cython/_silk_cy.pyx":235 * cdef void *dec = PyMem_Malloc(dec_size) * if dec == NULL: * raise MemoryError # <<<<<<<<<<<<<< * code = SKP_Silk_SDK_InitDecoder(dec) * if code != 0: */ - PyErr_NoMemory(); __PYX_ERR(0, 230, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 235, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":229 + /* "pysilk/backends/cython/_silk_cy.pyx":234 * raise SilkError(code) * cdef void *dec = PyMem_Malloc(dec_size) * if dec == NULL: # <<<<<<<<<<<<<< @@ -4453,7 +4468,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":231 + /* "pysilk/backends/cython/_silk_cy.pyx":236 * if dec == NULL: * raise MemoryError * code = SKP_Silk_SDK_InitDecoder(dec) # <<<<<<<<<<<<<< @@ -4462,7 +4477,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_code = SKP_Silk_SDK_InitDecoder(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":232 + /* "pysilk/backends/cython/_silk_cy.pyx":237 * raise MemoryError * code = SKP_Silk_SDK_InitDecoder(dec) * if code != 0: # <<<<<<<<<<<<<< @@ -4472,7 +4487,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_code != 0) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":233 + /* "pysilk/backends/cython/_silk_cy.pyx":238 * code = SKP_Silk_SDK_InitDecoder(dec) * if code != 0: * PyMem_Free(dec) # <<<<<<<<<<<<<< @@ -4481,16 +4496,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":234 + /* "pysilk/backends/cython/_silk_cy.pyx":239 * if code != 0: * PyMem_Free(dec) * raise SilkError(code) # <<<<<<<<<<<<<< * frame_size = sample_rate / 1000 * 40 * # cdef uint8_t buf[frame_size] # otherwise need malloc */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4505,14 +4520,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 234, __pyx_L1_error) + __PYX_ERR(0, 239, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":232 + /* "pysilk/backends/cython/_silk_cy.pyx":237 * raise MemoryError * code = SKP_Silk_SDK_InitDecoder(dec) * if code != 0: # <<<<<<<<<<<<<< @@ -4521,7 +4536,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":235 + /* "pysilk/backends/cython/_silk_cy.pyx":240 * PyMem_Free(dec) * raise SilkError(code) * frame_size = sample_rate / 1000 * 40 # <<<<<<<<<<<<<< @@ -4530,7 +4545,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_frame_size = ((((long)__pyx_v_sample_rate) / 0x3E8) * 40); - /* "pysilk/backends/cython/_silk_cy.pyx":237 + /* "pysilk/backends/cython/_silk_cy.pyx":242 * frame_size = sample_rate / 1000 * 40 * # cdef uint8_t buf[frame_size] # otherwise need malloc * cdef uint8_t *buf = PyMem_Malloc(frame_size) # <<<<<<<<<<<<<< @@ -4539,7 +4554,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_buf = ((uint8_t *)PyMem_Malloc(__pyx_v_frame_size)); - /* "pysilk/backends/cython/_silk_cy.pyx":238 + /* "pysilk/backends/cython/_silk_cy.pyx":243 * # cdef uint8_t buf[frame_size] # otherwise need malloc * cdef uint8_t *buf = PyMem_Malloc(frame_size) * if buf == NULL: # <<<<<<<<<<<<<< @@ -4549,7 +4564,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":239 + /* "pysilk/backends/cython/_silk_cy.pyx":244 * cdef uint8_t *buf = PyMem_Malloc(frame_size) * if buf == NULL: * PyMem_Free(dec) # <<<<<<<<<<<<<< @@ -4558,16 +4573,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":240 + /* "pysilk/backends/cython/_silk_cy.pyx":245 * if buf == NULL: * PyMem_Free(dec) * raise MemoryError # <<<<<<<<<<<<<< * cdef int16_t n_bytes - * while True: + * cdef const uint8_t *chunk_ptr */ - PyErr_NoMemory(); __PYX_ERR(0, 240, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 245, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":238 + /* "pysilk/backends/cython/_silk_cy.pyx":243 * # cdef uint8_t buf[frame_size] # otherwise need malloc * cdef uint8_t *buf = PyMem_Malloc(frame_size) * if buf == NULL: # <<<<<<<<<<<<<< @@ -4576,23 +4591,23 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":242 - * raise MemoryError + /* "pysilk/backends/cython/_silk_cy.pyx":248 * cdef int16_t n_bytes + * cdef const uint8_t *chunk_ptr * while True: # <<<<<<<<<<<<<< * chunk = input.read(2) * if PyBytes_Size(chunk) < 2: */ while (1) { - /* "pysilk/backends/cython/_silk_cy.pyx":243 - * cdef int16_t n_bytes + /* "pysilk/backends/cython/_silk_cy.pyx":249 + * cdef const uint8_t *chunk_ptr * while True: * chunk = input.read(2) # <<<<<<<<<<<<<< * if PyBytes_Size(chunk) < 2: * break */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4606,24 +4621,24 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_int_2) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_chunk, __pyx_t_3); __pyx_t_3 = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":244 + /* "pysilk/backends/cython/_silk_cy.pyx":250 * while True: * chunk = input.read(2) * if PyBytes_Size(chunk) < 2: # <<<<<<<<<<<<<< * break * n_bytes = bytes_to_i16(chunk) */ - __pyx_t_7 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_7 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 250, __pyx_L1_error) __pyx_t_1 = ((__pyx_t_7 < 2) != 0); if (__pyx_t_1) { - /* "pysilk/backends/cython/_silk_cy.pyx":245 + /* "pysilk/backends/cython/_silk_cy.pyx":251 * chunk = input.read(2) * if PyBytes_Size(chunk) < 2: * break # <<<<<<<<<<<<<< @@ -4632,7 +4647,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ goto __pyx_L15_break; - /* "pysilk/backends/cython/_silk_cy.pyx":244 + /* "pysilk/backends/cython/_silk_cy.pyx":250 * while True: * chunk = input.read(2) * if PyBytes_Size(chunk) < 2: # <<<<<<<<<<<<<< @@ -4641,17 +4656,17 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":246 + /* "pysilk/backends/cython/_silk_cy.pyx":252 * if PyBytes_Size(chunk) < 2: * break * n_bytes = bytes_to_i16(chunk) # <<<<<<<<<<<<<< * if SHOULD_SWAP: * n_bytes = swap_i16(n_bytes) */ - if (!(likely(PyBytes_CheckExact(__pyx_v_chunk))||((__pyx_v_chunk) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_chunk)->tp_name), 0))) __PYX_ERR(0, 246, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_v_chunk))||((__pyx_v_chunk) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_chunk)->tp_name), 0))) __PYX_ERR(0, 252, __pyx_L1_error) __pyx_v_n_bytes = __pyx_f_6pysilk_8backends_6cython_8_silk_cy_bytes_to_i16(((PyObject*)__pyx_v_chunk)); - /* "pysilk/backends/cython/_silk_cy.pyx":247 + /* "pysilk/backends/cython/_silk_cy.pyx":253 * break * n_bytes = bytes_to_i16(chunk) * if SHOULD_SWAP: # <<<<<<<<<<<<<< @@ -4661,7 +4676,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = (SHOULD_SWAP != 0); if (__pyx_t_1) { - /* "pysilk/backends/cython/_silk_cy.pyx":248 + /* "pysilk/backends/cython/_silk_cy.pyx":254 * n_bytes = bytes_to_i16(chunk) * if SHOULD_SWAP: * n_bytes = swap_i16(n_bytes) # <<<<<<<<<<<<<< @@ -4670,7 +4685,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ __pyx_v_n_bytes = swap_i16(__pyx_v_n_bytes); - /* "pysilk/backends/cython/_silk_cy.pyx":247 + /* "pysilk/backends/cython/_silk_cy.pyx":253 * break * n_bytes = bytes_to_i16(chunk) * if SHOULD_SWAP: # <<<<<<<<<<<<<< @@ -4679,7 +4694,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":249 + /* "pysilk/backends/cython/_silk_cy.pyx":255 * if SHOULD_SWAP: * n_bytes = swap_i16(n_bytes) * if n_bytes > frame_size: # <<<<<<<<<<<<<< @@ -4689,7 +4704,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_n_bytes > ((int16_t)__pyx_v_frame_size)) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":250 + /* "pysilk/backends/cython/_silk_cy.pyx":256 * n_bytes = swap_i16(n_bytes) * if n_bytes > frame_size: * PyMem_Free(buf) # <<<<<<<<<<<<<< @@ -4698,7 +4713,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_buf); - /* "pysilk/backends/cython/_silk_cy.pyx":251 + /* "pysilk/backends/cython/_silk_cy.pyx":257 * if n_bytes > frame_size: * PyMem_Free(buf) * PyMem_Free(dec) # <<<<<<<<<<<<<< @@ -4707,14 +4722,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":252 + /* "pysilk/backends/cython/_silk_cy.pyx":258 * PyMem_Free(buf) * PyMem_Free(dec) * raise SilkError("INVALID") # <<<<<<<<<<<<<< * chunk = input.read(n_bytes) # type: bytes * if PyBytes_Size(chunk) < n_bytes: # not enough data */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4728,14 +4743,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_INVALID) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_INVALID); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 252, __pyx_L1_error) + __PYX_ERR(0, 258, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":249 + /* "pysilk/backends/cython/_silk_cy.pyx":255 * if SHOULD_SWAP: * n_bytes = swap_i16(n_bytes) * if n_bytes > frame_size: # <<<<<<<<<<<<<< @@ -4744,16 +4759,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":253 + /* "pysilk/backends/cython/_silk_cy.pyx":259 * PyMem_Free(dec) * raise SilkError("INVALID") * chunk = input.read(n_bytes) # type: bytes # <<<<<<<<<<<<<< * if PyBytes_Size(chunk) < n_bytes: # not enough data * PyMem_Free(buf) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int16_t(__pyx_v_n_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int16_t(__pyx_v_n_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4768,24 +4783,24 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_chunk, __pyx_t_3); __pyx_t_3 = 0; - /* "pysilk/backends/cython/_silk_cy.pyx":254 + /* "pysilk/backends/cython/_silk_cy.pyx":260 * raise SilkError("INVALID") * chunk = input.read(n_bytes) # type: bytes * if PyBytes_Size(chunk) < n_bytes: # not enough data # <<<<<<<<<<<<<< * PyMem_Free(buf) * PyMem_Free(dec) */ - __pyx_t_7 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_7 = PyBytes_Size(__pyx_v_chunk); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 260, __pyx_L1_error) __pyx_t_1 = ((((int16_t)__pyx_t_7) < __pyx_v_n_bytes) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":255 + /* "pysilk/backends/cython/_silk_cy.pyx":261 * chunk = input.read(n_bytes) # type: bytes * if PyBytes_Size(chunk) < n_bytes: # not enough data * PyMem_Free(buf) # <<<<<<<<<<<<<< @@ -4794,23 +4809,23 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_buf); - /* "pysilk/backends/cython/_silk_cy.pyx":256 + /* "pysilk/backends/cython/_silk_cy.pyx":262 * if PyBytes_Size(chunk) < n_bytes: # not enough data * PyMem_Free(buf) * PyMem_Free(dec) # <<<<<<<<<<<<<< * raise SilkError("INVALID") - * code = SKP_Silk_SDK_Decode(dec, + * chunk_ptr = PyBytes_AS_STRING(chunk) */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":257 + /* "pysilk/backends/cython/_silk_cy.pyx":263 * PyMem_Free(buf) * PyMem_Free(dec) * raise SilkError("INVALID") # <<<<<<<<<<<<<< - * code = SKP_Silk_SDK_Decode(dec, - * &dec_control, + * chunk_ptr = PyBytes_AS_STRING(chunk) + * with nogil: */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4824,14 +4839,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_INVALID) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_INVALID); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 257, __pyx_L1_error) + __PYX_ERR(0, 263, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":254 + /* "pysilk/backends/cython/_silk_cy.pyx":260 * raise SilkError("INVALID") * chunk = input.read(n_bytes) # type: bytes * if PyBytes_Size(chunk) < n_bytes: # not enough data # <<<<<<<<<<<<<< @@ -4840,18 +4855,62 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ } - /* "pysilk/backends/cython/_silk_cy.pyx":258 + /* "pysilk/backends/cython/_silk_cy.pyx":264 * PyMem_Free(dec) * raise SilkError("INVALID") - * code = SKP_Silk_SDK_Decode(dec, # <<<<<<<<<<<<<< - * &dec_control, - * loss, + * chunk_ptr = PyBytes_AS_STRING(chunk) # <<<<<<<<<<<<<< + * with nogil: + * code = SKP_Silk_SDK_Decode(dec, */ - __pyx_v_code = SKP_Silk_SDK_Decode(__pyx_v_dec, (&__pyx_v_dec_control), __pyx_v_loss, ((uint8_t const *)PyBytes_AS_STRING(__pyx_v_chunk)), ((int32_t const )__pyx_v_n_bytes), ((int16_t *)__pyx_v_buf), (&__pyx_v_n_bytes)); + __pyx_v_chunk_ptr = ((uint8_t const *)PyBytes_AS_STRING(__pyx_v_chunk)); /* "pysilk/backends/cython/_silk_cy.pyx":265 - * buf, - * &n_bytes) + * raise SilkError("INVALID") + * chunk_ptr = PyBytes_AS_STRING(chunk) + * with nogil: # <<<<<<<<<<<<<< + * code = SKP_Silk_SDK_Decode(dec, + * &dec_control, + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "pysilk/backends/cython/_silk_cy.pyx":266 + * chunk_ptr = PyBytes_AS_STRING(chunk) + * with nogil: + * code = SKP_Silk_SDK_Decode(dec, # <<<<<<<<<<<<<< + * &dec_control, + * loss, + */ + __pyx_v_code = SKP_Silk_SDK_Decode(__pyx_v_dec, (&__pyx_v_dec_control), __pyx_v_loss, __pyx_v_chunk_ptr, ((int32_t const )__pyx_v_n_bytes), ((int16_t *)__pyx_v_buf), (&__pyx_v_n_bytes)); + } + + /* "pysilk/backends/cython/_silk_cy.pyx":265 + * raise SilkError("INVALID") + * chunk_ptr = PyBytes_AS_STRING(chunk) + * with nogil: # <<<<<<<<<<<<<< + * code = SKP_Silk_SDK_Decode(dec, + * &dec_control, + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L24; + } + __pyx_L24:; + } + } + + /* "pysilk/backends/cython/_silk_cy.pyx":273 + * buf, + * &n_bytes) * if code != 0: # <<<<<<<<<<<<<< * PyMem_Free(buf) * PyMem_Free(dec) @@ -4859,8 +4918,8 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_1 = ((__pyx_v_code != 0) != 0); if (unlikely(__pyx_t_1)) { - /* "pysilk/backends/cython/_silk_cy.pyx":266 - * &n_bytes) + /* "pysilk/backends/cython/_silk_cy.pyx":274 + * &n_bytes) * if code != 0: * PyMem_Free(buf) # <<<<<<<<<<<<<< * PyMem_Free(dec) @@ -4868,7 +4927,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_buf); - /* "pysilk/backends/cython/_silk_cy.pyx":267 + /* "pysilk/backends/cython/_silk_cy.pyx":275 * if code != 0: * PyMem_Free(buf) * PyMem_Free(dec) # <<<<<<<<<<<<<< @@ -4877,16 +4936,16 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":268 + /* "pysilk/backends/cython/_silk_cy.pyx":276 * PyMem_Free(buf) * PyMem_Free(dec) * raise SilkError(code) # <<<<<<<<<<<<<< * output.write( buf[:n_bytes * 2]) * PyMem_Free(buf) */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SilkError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -4901,32 +4960,32 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 268, __pyx_L1_error) + __PYX_ERR(0, 276, __pyx_L1_error) - /* "pysilk/backends/cython/_silk_cy.pyx":265 - * buf, - * &n_bytes) + /* "pysilk/backends/cython/_silk_cy.pyx":273 + * buf, + * &n_bytes) * if code != 0: # <<<<<<<<<<<<<< * PyMem_Free(buf) * PyMem_Free(dec) */ } - /* "pysilk/backends/cython/_silk_cy.pyx":269 + /* "pysilk/backends/cython/_silk_cy.pyx":277 * PyMem_Free(dec) * raise SilkError(code) * output.write( buf[:n_bytes * 2]) # <<<<<<<<<<<<<< * PyMem_Free(buf) * PyMem_Free(dec) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_output, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_output, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_buf) + 0, (__pyx_v_n_bytes * 2) - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_buf) + 0, (__pyx_v_n_bytes * 2) - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4941,14 +5000,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L15_break:; - /* "pysilk/backends/cython/_silk_cy.pyx":270 + /* "pysilk/backends/cython/_silk_cy.pyx":278 * raise SilkError(code) * output.write( buf[:n_bytes * 2]) * PyMem_Free(buf) # <<<<<<<<<<<<<< @@ -4956,14 +5015,14 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO */ PyMem_Free(__pyx_v_buf); - /* "pysilk/backends/cython/_silk_cy.pyx":271 + /* "pysilk/backends/cython/_silk_cy.pyx":279 * output.write( buf[:n_bytes * 2]) * PyMem_Free(buf) * PyMem_Free(dec) # <<<<<<<<<<<<<< */ PyMem_Free(__pyx_v_dec); - /* "pysilk/backends/cython/_silk_cy.pyx":182 + /* "pysilk/backends/cython/_silk_cy.pyx":187 * PyMem_Free(enc) * * cpdef inline void decode(object input, # <<<<<<<<<<<<<< @@ -4981,12 +5040,7 @@ static CYTHON_INLINE void __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(PyO __Pyx_WriteUnraisable("pysilk.backends.cython._silk_cy.decode", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_chunk); - __Pyx_XDECREF(__pyx_v_input); - __Pyx_XDECREF(__pyx_v_output); __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif } /* Python wrapper */ @@ -5042,13 +5096,13 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_3decode(PyObject * case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, 1); __PYX_ERR(0, 182, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, 1); __PYX_ERR(0, 187, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_rate)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, 2); __PYX_ERR(0, 182, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, 2); __PYX_ERR(0, 187, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: @@ -5082,7 +5136,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_3decode(PyObject * } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decode") < 0)) __PYX_ERR(0, 182, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decode") < 0)) __PYX_ERR(0, 187, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5105,43 +5159,43 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_3decode(PyObject * } __pyx_v_input = values[0]; __pyx_v_output = values[1]; - __pyx_v_sample_rate = __Pyx_PyInt_As_int32_t(values[2]); if (unlikely((__pyx_v_sample_rate == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L3_error) + __pyx_v_sample_rate = __Pyx_PyInt_As_int32_t(values[2]); if (unlikely((__pyx_v_sample_rate == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error) if (values[3]) { - __pyx_v_frame_size = __Pyx_PyInt_As_int32_t(values[3]); if (unlikely((__pyx_v_frame_size == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 185, __pyx_L3_error) + __pyx_v_frame_size = __Pyx_PyInt_As_int32_t(values[3]); if (unlikely((__pyx_v_frame_size == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) } else { __pyx_v_frame_size = ((int32_t)0); } if (values[4]) { - __pyx_v_frames_per_packet = __Pyx_PyInt_As_int32_t(values[4]); if (unlikely((__pyx_v_frames_per_packet == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 186, __pyx_L3_error) + __pyx_v_frames_per_packet = __Pyx_PyInt_As_int32_t(values[4]); if (unlikely((__pyx_v_frames_per_packet == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L3_error) } else { __pyx_v_frames_per_packet = ((int32_t)1); } if (values[5]) { - __pyx_v_more_internal_decoder_frames = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_more_internal_decoder_frames == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 187, __pyx_L3_error) + __pyx_v_more_internal_decoder_frames = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_more_internal_decoder_frames == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L3_error) } else { - /* "pysilk/backends/cython/_silk_cy.pyx":187 + /* "pysilk/backends/cython/_silk_cy.pyx":192 * int32_t frame_size=0, * int32_t frames_per_packet=1, * bint more_internal_decoder_frames=False, # <<<<<<<<<<<<<< * int32_t in_band_fec_offset=0, - * bint loss=False) with gil: + * bint loss=False): */ __pyx_v_more_internal_decoder_frames = ((int)0); } if (values[6]) { - __pyx_v_in_band_fec_offset = __Pyx_PyInt_As_int32_t(values[6]); if (unlikely((__pyx_v_in_band_fec_offset == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L3_error) + __pyx_v_in_band_fec_offset = __Pyx_PyInt_As_int32_t(values[6]); if (unlikely((__pyx_v_in_band_fec_offset == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 193, __pyx_L3_error) } else { __pyx_v_in_band_fec_offset = ((int32_t)0); } if (values[7]) { - __pyx_v_loss = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_loss == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error) + __pyx_v_loss = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_loss == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L3_error) } else { - /* "pysilk/backends/cython/_silk_cy.pyx":189 + /* "pysilk/backends/cython/_silk_cy.pyx":194 * bint more_internal_decoder_frames=False, * int32_t in_band_fec_offset=0, - * bint loss=False) with gil: # <<<<<<<<<<<<<< + * bint loss=False): # <<<<<<<<<<<<<< * """decode(input: BinaryIO, output: BinaryIO, sample_rate: int, frame_size: int = 0, frames_per_packet: int = 1, more_internal_decoder_frames: bool = False, in_band_fec_offset: int = 0, loss: bool = False) -> bytes * */ @@ -5150,7 +5204,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_3decode(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 182, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("decode", 0, 3, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 187, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pysilk.backends.cython._silk_cy.decode", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5158,7 +5212,7 @@ static PyObject *__pyx_pw_6pysilk_8backends_6cython_8_silk_cy_3decode(PyObject * __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6pysilk_8backends_6cython_8_silk_cy_2decode(__pyx_self, __pyx_v_input, __pyx_v_output, __pyx_v_sample_rate, __pyx_v_frame_size, __pyx_v_frames_per_packet, __pyx_v_more_internal_decoder_frames, __pyx_v_in_band_fec_offset, __pyx_v_loss); - /* "pysilk/backends/cython/_silk_cy.pyx":182 + /* "pysilk/backends/cython/_silk_cy.pyx":187 * PyMem_Free(enc) * * cpdef inline void decode(object input, # <<<<<<<<<<<<<< @@ -5188,7 +5242,7 @@ static PyObject *__pyx_pf_6pysilk_8backends_6cython_8_silk_cy_2decode(CYTHON_UNU __pyx_t_1.in_band_fec_offset = __pyx_v_in_band_fec_offset; __pyx_t_1.loss = __pyx_v_loss; __pyx_f_6pysilk_8backends_6cython_8_silk_cy_decode(__pyx_v_input, __pyx_v_output, __pyx_v_sample_rate, 0, &__pyx_t_1); - __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -5608,11 +5662,9 @@ if (!__Pyx_RefNanny) { #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ + #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif - #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; @@ -6173,7 +6225,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; - ternaryfunc call = func->ob_type->tp_call; + ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) @@ -6671,7 +6723,7 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq return (equals == Py_EQ); } else { int result; -#if CYTHON_USE_UNICODE_INTERNALS +#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; @@ -7130,7 +7182,8 @@ static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromString(m->func.m_ml->ml_name); + Py_INCREF(m->func_qualname); + return m->func_qualname; #else return PyString_FromString(m->func.m_ml->ml_name); #endif @@ -7333,6 +7386,9 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); + PyErr_Format(PyExc_TypeError, + "unbound method %.200S() needs an argument", + cyfunc->func_qualname); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); @@ -7401,12 +7457,15 @@ static PyTypeObject __pyx_CyFunctionType_type = { #if PY_VERSION_HEX >= 0x030400a1 0, #endif -#if PY_VERSION_HEX >= 0x030800b1 +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, #endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, +#endif }; static int __pyx_CyFunction_init(void) { __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); @@ -7553,7 +7612,7 @@ static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int } if (!use_cline) { c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; @@ -7647,33 +7706,40 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { #include "compile.h" #include "frameobject.h" #include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; + PyCodeObject *py_code = NULL; + PyObject *py_funcname = NULL; #if PY_MAJOR_VERSION < 3 + PyObject *py_srcfile = NULL; py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif if (!py_srcfile) goto bad; + #endif if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + funcname = PyUnicode_AsUTF8(py_funcname); + if (!funcname) goto bad; #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); + if (!py_funcname) goto bad; #endif } - if (!py_funcname) goto bad; + #if PY_MAJOR_VERSION < 3 py_code = __Pyx_PyCode_New( 0, 0, @@ -7692,11 +7758,16 @@ static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); + #else + py_code = PyCode_NewEmpty(filename, funcname, py_line); + #endif + Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline return py_code; bad: - Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_srcfile); + #endif return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, @@ -7704,14 +7775,24 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); - if (!py_code) goto bad; + if (!py_code) { + /* If the code object creation fails, then we should clear the + fetched exception references and propagate the new exception */ + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + goto bad; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( @@ -8750,11 +8831,33 @@ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObj /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char ctversion[5]; + int same=1, i, found_dot; + const char* rt_from_call = Py_GetVersion(); + PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + found_dot = 0; + for (i = 0; i < 4; i++) { + if (!ctversion[i]) { + same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); + break; + } + if (rt_from_call[i] != ctversion[i]) { + same = 0; + break; + } + } + if (!same) { + char rtversion[5] = {'\0'}; char message[200]; + for (i=0; i<4; ++i) { + if (rt_from_call[i] == '.') { + if (found_dot) break; + found_dot = 1; + } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { + break; + } + rtversion[i] = rt_from_call[i]; + } PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", @@ -9012,6 +9115,23 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_DECREF(x); return ival; } +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { + if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { + return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); +#if PY_MAJOR_VERSION < 3 + } else if (likely(PyInt_CheckExact(o))) { + return PyInt_AS_LONG(o); +#endif + } else { + Py_ssize_t ival; + PyObject *x; + x = PyNumber_Index(o); + if (!x) return -1; + ival = PyInt_AsLong(x); + Py_DECREF(x); + return ival; + } +} static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } diff --git a/pysilk/backends/cython/_silk_cy.pyx b/pysilk/backends/cython/_silk_cy.pyx index 564f8c3..54ef42d 100644 --- a/pysilk/backends/cython/_silk_cy.pyx +++ b/pysilk/backends/cython/_silk_cy.pyx @@ -97,7 +97,7 @@ cpdef inline void encode(object input, int32_t complexity = 2, bint use_inband_fec = False, bint use_dtx = False, - bint tencent = True) with gil: + bint tencent = True): """encode(input: BinaryIO, output: BinaryIO, sample_rate: int, bit_rate: int, max_internal_sample_rate: int = 24000, packet_loss_percentage: int = 0, complexity: int = 2, use_inband_fec: bool = False, use_dtx: bool = False, tencent: bool = True) -> bytes encode pcm to silk @@ -156,6 +156,8 @@ cpdef inline void encode(object input, output.write(b"#!SILK_V3") cdef int16_t n_bytes = 1250 cdef uint8_t payload[1250] + cdef int16_t* chunk_ptr + cdef int32_t chunk_size while True: chunk = input.read(frame_size) # type: bytes if not PyBytes_Check(chunk): @@ -165,12 +167,15 @@ cpdef inline void encode(object input, n_bytes = 1250 if PyBytes_Size(chunk) < frame_size: break - code = SKP_Silk_SDK_Encode(enc, - &enc_control, - PyBytes_AS_STRING(chunk), - (PyBytes_Size(chunk) / 2), - payload, - &n_bytes) + chunk_ptr = PyBytes_AS_STRING(chunk) + chunk_size = (PyBytes_Size(chunk) / 2) + with nogil: + code = SKP_Silk_SDK_Encode(enc, + &enc_control, + chunk_ptr, + chunk_size, + payload, + &n_bytes) if code != 0: PyMem_Free(enc) raise SilkError(code) @@ -186,7 +191,7 @@ cpdef inline void decode(object input, int32_t frames_per_packet=1, bint more_internal_decoder_frames=False, int32_t in_band_fec_offset=0, - bint loss=False) with gil: + bint loss=False): """decode(input: BinaryIO, output: BinaryIO, sample_rate: int, frame_size: int = 0, frames_per_packet: int = 1, more_internal_decoder_frames: bool = False, in_band_fec_offset: int = 0, loss: bool = False) -> bytes decode silk to pcm @@ -239,6 +244,7 @@ cpdef inline void decode(object input, PyMem_Free(dec) raise MemoryError cdef int16_t n_bytes + cdef const uint8_t *chunk_ptr while True: chunk = input.read(2) if PyBytes_Size(chunk) < 2: @@ -255,13 +261,15 @@ cpdef inline void decode(object input, PyMem_Free(buf) PyMem_Free(dec) raise SilkError("INVALID") - code = SKP_Silk_SDK_Decode(dec, - &dec_control, - loss, - PyBytes_AS_STRING(chunk), - n_bytes, - buf, - &n_bytes) + chunk_ptr = PyBytes_AS_STRING(chunk) + with nogil: + code = SKP_Silk_SDK_Decode(dec, + &dec_control, + loss, + chunk_ptr, + n_bytes, + buf, + &n_bytes) if code != 0: PyMem_Free(buf) PyMem_Free(dec)