Generated by Cython 0.28.2
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: decode.c
001: # This file is part of Xpra.
002: # Copyright (C) 2014-2017 Antoine Martin <antoine@devloop.org.uk>
003: # Xpra is released under the terms of the GNU GPL v2, or, at your option, any
004: # later version. See the file COPYING for details.
005:
006: from __future__ import absolute_import
007:
+008: from xpra.log import Logger
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Logger); __Pyx_GIVEREF(__pyx_n_s_Logger); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Logger); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_log, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_1) < 0) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+009: log = Logger("encoder", "webp")
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_1) < 0) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_s_encoder, __pyx_n_s_webp); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10);
010:
+011: from xpra.codecs.image_wrapper import ImageWrapper
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_ImageWrapper); __Pyx_GIVEREF(__pyx_n_s_ImageWrapper); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ImageWrapper); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_codecs_image_wrapper, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ImageWrapper, __pyx_t_1) < 0) __PYX_ERR(1, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
012: from xpra.buffers.membuf cimport memalign, memory_as_pybuffer
+013: from xpra.os_util import bytestostr
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_bytestostr); __Pyx_GIVEREF(__pyx_n_s_bytestostr); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_bytestostr); __pyx_t_1 = __Pyx_Import(__pyx_n_s_xpra_os_util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_bytestostr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytestostr, __pyx_t_2) < 0) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
014:
015:
016: from libc.stdint cimport uint8_t, uint32_t, uintptr_t
017:
018: cdef extern from *:
019: ctypedef unsigned long size_t
020:
021: cdef extern from "stdlib.h":
022: void free(void *ptr)
023:
024:
025: cdef extern from "webp/decode.h":
026:
027: int WebPGetDecoderVersion()
028:
029: ctypedef int VP8StatusCode
030: VP8StatusCode VP8_STATUS_OK
031: VP8StatusCode VP8_STATUS_OUT_OF_MEMORY
032: VP8StatusCode VP8_STATUS_INVALID_PARAM
033: VP8StatusCode VP8_STATUS_BITSTREAM_ERROR
034: VP8StatusCode VP8_STATUS_UNSUPPORTED_FEATURE
035: VP8StatusCode VP8_STATUS_SUSPENDED
036: VP8StatusCode VP8_STATUS_USER_ABORT
037: VP8StatusCode VP8_STATUS_NOT_ENOUGH_DATA
038:
039: ctypedef int WEBP_CSP_MODE
040: WEBP_CSP_MODE MODE_RGB
041: WEBP_CSP_MODE MODE_RGBA
042: WEBP_CSP_MODE MODE_BGR
043: WEBP_CSP_MODE MODE_BGRA
044: WEBP_CSP_MODE MODE_ARGB
045: WEBP_CSP_MODE MODE_RGBA_4444
046: WEBP_CSP_MODE MODE_RGB_565
047: #RGB-premultiplied transparent modes (alpha value is preserved)
048: WEBP_CSP_MODE MODE_rgbA
049: WEBP_CSP_MODE MODE_bgrA
050: WEBP_CSP_MODE MODE_Argb
051: WEBP_CSP_MODE MODE_rgbA_4444
052: #YUV modes must come after RGB ones.
053: WEBP_CSP_MODE MODE_YUV
054: WEBP_CSP_MODE MODE_YUVA #yuv 4:2:0
055:
056:
057: ctypedef struct WebPDecoderOptions:
058: int bypass_filtering #if true, skip the in-loop filtering
059: int no_fancy_upsampling #if true, use faster pointwise upsampler
060: int use_cropping #if true, cropping is applied _first_
061: int crop_left
062: int crop_top #top-left position for cropping.
063: #Will be snapped to even values.
064: int crop_width
065: int crop_height #dimension of the cropping area
066: int use_scaling #if true, scaling is applied _afterward_
067: int scaled_width, scaled_height #final resolution
068: int use_threads #if true, use multi-threaded decoding
069:
070: int force_rotation #forced rotation (to be applied _last_)
071: int no_enhancement #if true, discard enhancement layer
072: uint32_t pad[6] #padding for later use
073:
074: ctypedef struct WebPBitstreamFeatures:
075: int width #Width in pixels, as read from the bitstream.
076: int height #Height in pixels, as read from the bitstream.
077: int has_alpha #True if the bitstream contains an alpha channel.
078: int has_animation #True if the bitstream is an animation.
079: #Unused for now:
080: int bitstream_version #should be 0 for now. TODO(later)
081: int no_incremental_decoding #if true, using incremental decoding is not recommended.
082: int rotate #TODO(later)
083: int uv_sampling #should be 0 for now. TODO(later)
084: uint32_t pad[2] #padding for later use
085:
086: ctypedef struct WebPRGBABuffer: #view as RGBA
087: uint8_t* rgba #pointer to RGBA samples
088: int stride #stride in bytes from one scanline to the next.
089: size_t size #total size of the *rgba buffer.
090:
091: ctypedef struct WebPYUVABuffer: #view as YUVA
092: uint8_t* y #pointer to luma
093: uint8_t* u #pointer to chroma U
094: uint8_t* v #pointer to chroma V
095: uint8_t* a #pointer to alpha samples
096: int y_stride #luma stride
097: int u_stride, v_stride #chroma strides
098: int a_stride #alpha stride
099: size_t y_size #luma plane size
100: size_t u_size, v_size #chroma planes size
101: size_t a_size #alpha-plane size
102:
103: ctypedef struct u:
104: WebPRGBABuffer RGBA
105: WebPYUVABuffer YUVA
106:
107: ctypedef struct WebPDecBuffer:
108: WEBP_CSP_MODE colorspace #Colorspace.
109: int width, height #Dimensions.
110: int is_external_memory #If true, 'internal_memory' pointer is not used.
111: u u
112: uint32_t pad[4] #padding for later use
113: uint8_t* private_memory #Internally allocated memory (only when
114: #is_external_memory is false). Should not be used
115: #externally, but accessed via the buffer union.
116:
117: ctypedef struct WebPDecoderConfig:
118: WebPBitstreamFeatures input #Immutable bitstream features (optional)
119: WebPDecBuffer output #Output buffer (can point to external mem)
120: WebPDecoderOptions options #Decoding options
121:
122:
123: VP8StatusCode WebPGetFeatures(const uint8_t* data, size_t data_size,
124: WebPBitstreamFeatures* features)
125:
126: int WebPInitDecoderConfig(WebPDecoderConfig* config)
127: VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
128: WebPDecoderConfig* config)
129: void WebPFreeDecBuffer(WebPDecBuffer* buffer)
130:
131:
132: ERROR_TO_NAME = {
133: #VP8_STATUS_OK
+134: VP8_STATUS_OUT_OF_MEMORY : "out of memory",
__pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_OUT_OF_MEMORY); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_out_of_memory) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+135: VP8_STATUS_INVALID_PARAM : "invalid parameter",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_INVALID_PARAM); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_invalid_parameter) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+136: VP8_STATUS_BITSTREAM_ERROR : "bitstream error",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_BITSTREAM_ERROR); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_bitstream_error) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+137: VP8_STATUS_UNSUPPORTED_FEATURE : "unsupported feature",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_UNSUPPORTED_FEATURE); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_unsupported_feature) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+138: VP8_STATUS_SUSPENDED : "suspended",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_SUSPENDED); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_s_suspended) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+139: VP8_STATUS_USER_ABORT : "user abort",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_USER_ABORT); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_user_abort) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+140: VP8_STATUS_NOT_ENOUGH_DATA : "not enough data",
__pyx_t_2 = __Pyx_PyInt_From_VP8StatusCode(VP8_STATUS_NOT_ENOUGH_DATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_s_not_enough_data) < 0) __PYX_ERR(1, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_ERROR_TO_NAME, __pyx_t_1) < 0) __PYX_ERR(1, 132, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
141: }
142:
+143: def get_version():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_1get_version = {"get_version", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_1get_version, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_version (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_get_version(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_get_version(CYTHON_UNUSED PyObject *__pyx_self) { int __pyx_v_version; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_version", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("xpra.codecs.webp.decode.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_version); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_1get_version, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_1) < 0) __PYX_ERR(1, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_get_version, 143, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(1, 143, __pyx_L1_error)
+144: cdef int version = WebPGetDecoderVersion()
__pyx_v_version = WebPGetDecoderVersion();
+145: log("WebPGetDecoderVersion()=%#x", version)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_version); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_WebPGetDecoderVersion_x, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_WebPGetDecoderVersion_x, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_WebPGetDecoderVersion_x); __Pyx_GIVEREF(__pyx_kp_s_WebPGetDecoderVersion_x); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_WebPGetDecoderVersion_x); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+146: return (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_long(((__pyx_v_version >> 16) & 0xff)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_version >> 8) & 0xff)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_version & 0xff)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
147:
+148: def get_info():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_3get_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_3get_info = {"get_info", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_3get_info, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_3get_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_2get_info(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_2get_info(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("xpra.codecs.webp.decode.get_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_3get_info, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_info, __pyx_t_1) < 0) __PYX_ERR(1, 148, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_get_info, 148, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(1, 148, __pyx_L1_error)
+149: return {
__Pyx_XDECREF(__pyx_r);
+150: "version" : get_version(),
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_version); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 150, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_version, __pyx_t_2) < 0) __PYX_ERR(1, 150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+151: "encodings" : get_encodings(),
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_encodings); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 151, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_encodings, __pyx_t_2) < 0) __PYX_ERR(1, 150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
152: }
153:
+154: def webp_check(int ret):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_5webp_check(PyObject *__pyx_self, PyObject *__pyx_arg_ret); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_5webp_check = {"webp_check", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_5webp_check, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_5webp_check(PyObject *__pyx_self, PyObject *__pyx_arg_ret) { int __pyx_v_ret; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("webp_check (wrapper)", 0); assert(__pyx_arg_ret); { __pyx_v_ret = __Pyx_PyInt_As_int(__pyx_arg_ret); if (unlikely((__pyx_v_ret == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 154, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.webp_check", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_4webp_check(__pyx_self, ((int)__pyx_v_ret)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_4webp_check(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_ret) { PyObject *__pyx_v_err = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("webp_check", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("xpra.codecs.webp.decode.webp_check", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_err); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__14 = PyTuple_Pack(3, __pyx_n_s_ret, __pyx_n_s_ret, __pyx_n_s_err); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_5webp_check, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_webp_check, __pyx_t_1) < 0) __PYX_ERR(1, 154, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_webp_check, 154, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(1, 154, __pyx_L1_error)
+155: if ret==0:
__pyx_t_1 = ((__pyx_v_ret == 0) != 0); if (__pyx_t_1) { /* … */ }
+156: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+157: err = ERROR_TO_NAME.get(ret, ret)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ERROR_TO_NAME); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ret); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_ret); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_err = __pyx_t_2; __pyx_t_2 = 0;
+158: raise Exception("error: %s" % err)
__pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_error_s, __pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 158, __pyx_L1_error)
159:
+160: def get_encodings():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_7get_encodings(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_7get_encodings = {"get_encodings", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_7get_encodings, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_7get_encodings(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encodings (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_6get_encodings(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_6get_encodings(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encodings", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.webp.decode.get_encodings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_7get_encodings, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_encodings, __pyx_t_1) < 0) __PYX_ERR(1, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_get_encodings, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(1, 160, __pyx_L1_error)
+161: return ["webp"]
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_webp); __Pyx_GIVEREF(__pyx_n_s_webp); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_webp); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
162:
+163: cdef inline int roundup(int n, int m):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_4webp_6decode_roundup(int __pyx_v_n, int __pyx_v_m) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("roundup", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+164: return (n + m - 1) & ~(m - 1)
__pyx_r = (((__pyx_v_n + __pyx_v_m) - 1) & (~(__pyx_v_m - 1))); goto __pyx_L0;
165:
166:
+167: cdef class WebpBufferWrapper:
struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper { PyObject_HEAD uintptr_t buffer_ptr; size_t size; };
168: """
169: Opaque object wrapping the buffer,
170: calling free will free the underlying memory.
171: """
172:
173: cdef uintptr_t buffer_ptr
174: cdef size_t size
175:
+176: def __cinit__(self, uintptr_t buffer_ptr, size_t size):
/* Python wrapper */ static int __pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { uintptr_t __pyx_v_buffer_ptr; size_t __pyx_v_size; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_buffer_ptr,&__pyx_n_s_size,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buffer_ptr)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(1, 176, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 176, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_buffer_ptr = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_buffer_ptr == ((uintptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 176, __pyx_L3_error) __pyx_v_size = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 176, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 176, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.WebpBufferWrapper.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper___cinit__(((struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *)__pyx_v_self), __pyx_v_buffer_ptr, __pyx_v_size); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper___cinit__(struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *__pyx_v_self, uintptr_t __pyx_v_buffer_ptr, size_t __pyx_v_size) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); /* … */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+177: self.buffer_ptr = buffer_ptr
__pyx_v_self->buffer_ptr = __pyx_v_buffer_ptr;
+178: self.size = size
__pyx_v_self->size = __pyx_v_size;
179:
+180: def __del__(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_2__del__(((struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_2__del__(struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.WebpBufferWrapper.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+181: assert self.buffer_ptr==0, "WebpBufferWrapper out of scope before being freed!"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->buffer_ptr == 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_WebpBufferWrapper_out_of_scope_b); __PYX_ERR(1, 181, __pyx_L1_error) } } #endif
182:
+183: def get_pixels(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_5get_pixels(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_5get_pixels(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_pixels (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_4get_pixels(((struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_4get_pixels(struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_pixels", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.webp.decode.WebpBufferWrapper.get_pixels", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+184: assert self.buffer_ptr>0, "WebpBufferWrapper has already been freed!"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->buffer_ptr > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_WebpBufferWrapper_has_already_be); __PYX_ERR(1, 184, __pyx_L1_error) } } #endif
+185: return memory_as_pybuffer(<void *> self.buffer_ptr, self.size, True)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_self->buffer_ptr), __pyx_v_self->size, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
186:
+187: def free(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_7free(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_7free(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("free (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_6free(((struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_17WebpBufferWrapper_6free(struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("free", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+188: if self.buffer_ptr!=0:
__pyx_t_1 = ((__pyx_v_self->buffer_ptr != 0) != 0); if (__pyx_t_1) { /* … */ }
+189: free(<void *>self.buffer_ptr)
free(((void *)__pyx_v_self->buffer_ptr));
+190: self.buffer_ptr = 0
__pyx_v_self->buffer_ptr = 0;
191:
192:
+193: def decompress(data, has_alpha, rgb_format=None):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_9decompress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4xpra_6codecs_4webp_6decode_8decompress[] = "\n This returns a WebpBufferWrapper, you MUST call free() on it\n once the pixel buffer can be freed.\n "; static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_9decompress = {"decompress", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_9decompress, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4xpra_6codecs_4webp_6decode_8decompress}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_9decompress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_has_alpha = 0; PyObject *__pyx_v_rgb_format = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decompress (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_has_alpha,&__pyx_n_s_rgb_format,0}; PyObject* values[3] = {0,0,0}; values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_has_alpha)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("decompress", 0, 2, 3, 1); __PYX_ERR(1, 193, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb_format); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decompress") < 0)) __PYX_ERR(1, 193, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_has_alpha = values[1]; __pyx_v_rgb_format = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("decompress", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 193, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.decompress", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_8decompress(__pyx_self, __pyx_v_data, __pyx_v_has_alpha, __pyx_v_rgb_format); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_8decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_has_alpha, PyObject *__pyx_v_rgb_format) { WebPDecoderConfig __pyx_v_config; int __pyx_v_stride; size_t __pyx_v_size; uint8_t *__pyx_v_buf; struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *__pyx_v_b = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decompress", 0); __Pyx_INCREF(__pyx_v_rgb_format); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("xpra.codecs.webp.decode.decompress", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_b); __Pyx_XDECREF(__pyx_v_rgb_format); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__17 = PyTuple_Pack(8, __pyx_n_s_data, __pyx_n_s_has_alpha, __pyx_n_s_rgb_format, __pyx_n_s_config, __pyx_n_s_stride, __pyx_n_s_size, __pyx_n_s_buf, __pyx_n_s_b); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_9decompress, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_decompress, __pyx_t_1) < 0) __PYX_ERR(1, 193, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_decompress, 193, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(1, 193, __pyx_L1_error)
194: """
195: This returns a WebpBufferWrapper, you MUST call free() on it
196: once the pixel buffer can be freed.
197: """
198: cdef WebPDecoderConfig config
+199: config.options.use_threads = 1
__pyx_v_config.options.use_threads = 1;
+200: WebPInitDecoderConfig(&config)
(void)(WebPInitDecoderConfig((&__pyx_v_config)));
+201: webp_check(WebPGetFeatures(data, len(data), &config.input))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_webp_check); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_AsUString(__pyx_v_data); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 201, __pyx_L1_error) __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 201, __pyx_L1_error) __pyx_t_5 = __Pyx_PyInt_From_VP8StatusCode(WebPGetFeatures(__pyx_t_3, __pyx_t_4, (&__pyx_v_config.input))); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+202: log("webp decompress found features: width=%4i, height=%4i, has_alpha=%-5s, input rgb_format=%s", config.input.width, config.input.height, bool(config.input.has_alpha), rgb_format)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_config.input.width); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_config.input.height); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_config.input.has_alpha); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyBool_FromLong((!(!__pyx_t_8))); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_kp_s_webp_decompress_found_features_w, __pyx_t_7, __pyx_t_5, __pyx_t_6, __pyx_v_rgb_format}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_kp_s_webp_decompress_found_features_w, __pyx_t_7, __pyx_t_5, __pyx_t_6, __pyx_v_rgb_format}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_11 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_webp_decompress_found_features_w); __Pyx_GIVEREF(__pyx_kp_s_webp_decompress_found_features_w); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_kp_s_webp_decompress_found_features_w); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_6); __Pyx_INCREF(__pyx_v_rgb_format); __Pyx_GIVEREF(__pyx_v_rgb_format); PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_v_rgb_format); __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
203:
+204: cdef int stride = 4 * config.input.width
__pyx_v_stride = (4 * __pyx_v_config.input.width);
+205: if has_alpha:
__pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_has_alpha); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 205, __pyx_L1_error) if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+206: if len(rgb_format or "")!=4:
__pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_rgb_format); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 206, __pyx_L1_error) if (!__pyx_t_8) { } else { __Pyx_INCREF(__pyx_v_rgb_format); __pyx_t_1 = __pyx_v_rgb_format; goto __pyx_L5_bool_binop_done; } __Pyx_INCREF(__pyx_kp_s__3); __pyx_t_1 = __pyx_kp_s__3; __pyx_L5_bool_binop_done:; __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 206, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = ((__pyx_t_4 != 4) != 0); if (__pyx_t_8) { /* … */ }
207: #use default if the format given is not valid:
+208: rgb_format = "BGRA"
__Pyx_INCREF(__pyx_n_s_BGRA); __Pyx_DECREF_SET(__pyx_v_rgb_format, __pyx_n_s_BGRA);
+209: config.output.colorspace = MODE_bgrA
__pyx_v_config.output.colorspace = MODE_bgrA;
210: else:
+211: rgb_format = (rgb_format or "").replace("A", "").replace("X", "")
/*else*/ { __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_rgb_format); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 211, __pyx_L1_error) if (!__pyx_t_8) { } else { __Pyx_INCREF(__pyx_v_rgb_format); __pyx_t_1 = __pyx_v_rgb_format; goto __pyx_L7_bool_binop_done; } __Pyx_INCREF(__pyx_kp_s__3); __pyx_t_1 = __pyx_kp_s__3; __pyx_L7_bool_binop_done:; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_A, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_rgb_format, __pyx_t_1); __pyx_t_1 = 0; __pyx_tuple__5 = PyTuple_Pack(2, __pyx_n_s_X, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5);
212: #the webp encoder takes BGRA input,
213: #so we have to swap the colours in the output to match:
+214: if rgb_format=="RGB":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_rgb_format, __pyx_n_s_RGB, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 214, __pyx_L1_error) if (__pyx_t_8) { /* … */ goto __pyx_L9; }
+215: rgb_format = "BGR"
__Pyx_INCREF(__pyx_n_s_BGR); __Pyx_DECREF_SET(__pyx_v_rgb_format, __pyx_n_s_BGR);
216: else:
+217: rgb_format = "RGB"
/*else*/ { __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_DECREF_SET(__pyx_v_rgb_format, __pyx_n_s_RGB); } __pyx_L9:;
+218: config.output.colorspace = MODE_RGB
__pyx_v_config.output.colorspace = MODE_RGB; } __pyx_L3:;
+219: cdef size_t size = stride * config.input.height
__pyx_v_size = (__pyx_v_stride * __pyx_v_config.input.height);
220: #allocate the buffer:
+221: cdef uint8_t *buf = <uint8_t*> memalign(size + stride) #add one line of padding
__pyx_v_buf = ((uint8_t *)__pyx_f_4xpra_7buffers_6membuf_memalign((__pyx_v_size + __pyx_v_stride)));
+222: cdef WebpBufferWrapper b = WebpBufferWrapper(<uintptr_t> buf, size)
__pyx_t_1 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4xpra_6codecs_4webp_6decode_WebpBufferWrapper), __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_b = ((struct __pyx_obj_4xpra_6codecs_4webp_6decode_WebpBufferWrapper *)__pyx_t_2); __pyx_t_2 = 0;
+223: config.output.u.RGBA.rgba = buf
__pyx_v_config.output.u.RGBA.rgba = __pyx_v_buf;
+224: config.output.u.RGBA.stride = stride
__pyx_v_config.output.u.RGBA.stride = __pyx_v_stride;
+225: config.output.u.RGBA.size = size
__pyx_v_config.output.u.RGBA.size = __pyx_v_size;
+226: config.output.is_external_memory = 1
__pyx_v_config.output.is_external_memory = 1;
227:
+228: webp_check(WebPDecode(data, len(data), &config))
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_webp_check); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyObject_AsUString(__pyx_v_data); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(1, 228, __pyx_L1_error) __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 228, __pyx_L1_error) __pyx_t_1 = __Pyx_PyInt_From_VP8StatusCode(WebPDecode(__pyx_t_12, __pyx_t_4, (&__pyx_v_config))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (!__pyx_t_6) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
229: #we use external memory, so this is not needed:
230: #WebPFreeDecBuffer(&config.output)
231:
+232: return b, config.input.width, config.input.height, stride, has_alpha and config.input.has_alpha, rgb_format
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config.input.width); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_config.input.height); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_stride); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_has_alpha); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 232, __pyx_L1_error) if (__pyx_t_8) { } else { __Pyx_INCREF(__pyx_v_has_alpha); __pyx_t_1 = __pyx_v_has_alpha; goto __pyx_L10_bool_binop_done; } __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_config.input.has_alpha); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; __pyx_L10_bool_binop_done:; __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_b)); __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_b)); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_1); __Pyx_INCREF(__pyx_v_rgb_format); __Pyx_GIVEREF(__pyx_v_rgb_format); PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_rgb_format); __pyx_t_2 = 0; __pyx_t_11 = 0; __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
233:
234:
+235: def decompress_yuv(data, has_alpha=False):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_11decompress_yuv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4xpra_6codecs_4webp_6decode_10decompress_yuv[] = "\n This returns a WebpBufferWrapper, you MUST call free() on it\n once the pixel buffer can be freed.\n "; static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_11decompress_yuv = {"decompress_yuv", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_11decompress_yuv, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4xpra_6codecs_4webp_6decode_10decompress_yuv}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_11decompress_yuv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_has_alpha = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decompress_yuv (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_has_alpha,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_has_alpha); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decompress_yuv") < 0)) __PYX_ERR(1, 235, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_has_alpha = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("decompress_yuv", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 235, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.decompress_yuv", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_10decompress_yuv(__pyx_self, __pyx_v_data, __pyx_v_has_alpha); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_10decompress_yuv(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_has_alpha) { WebPDecoderConfig __pyx_v_config; int __pyx_v_alpha; int __pyx_v_w; int __pyx_v_h; WebPYUVABuffer *__pyx_v_YUVA; size_t __pyx_v_y_size; size_t __pyx_v_u_size; size_t __pyx_v_v_size; size_t __pyx_v_a_size; uint8_t *__pyx_v_buf; PyObject *__pyx_v_strides = NULL; PyObject *__pyx_v_planes = NULL; PyObject *__pyx_v_img = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decompress_yuv", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("xpra.codecs.webp.decode.decompress_yuv", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_strides); __Pyx_XDECREF(__pyx_v_planes); __Pyx_XDECREF(__pyx_v_img); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__19 = PyTuple_Pack(15, __pyx_n_s_data, __pyx_n_s_has_alpha, __pyx_n_s_config, __pyx_n_s_alpha, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_YUVA, __pyx_n_s_y_size, __pyx_n_s_u_size, __pyx_n_s_v_size, __pyx_n_s_a_size, __pyx_n_s_buf, __pyx_n_s_strides, __pyx_n_s_planes, __pyx_n_s_img); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_11decompress_yuv, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_decompress_yuv, __pyx_t_1) < 0) __PYX_ERR(1, 235, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_decompress_yuv, 235, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(1, 235, __pyx_L1_error)
236: """
237: This returns a WebpBufferWrapper, you MUST call free() on it
238: once the pixel buffer can be freed.
239: """
240: cdef WebPDecoderConfig config
+241: config.options.use_threads = 1
__pyx_v_config.options.use_threads = 1;
+242: WebPInitDecoderConfig(&config)
(void)(WebPInitDecoderConfig((&__pyx_v_config)));
+243: webp_check(WebPGetFeatures(data, len(data), &config.input))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_webp_check); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_AsUString(__pyx_v_data); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 243, __pyx_L1_error) __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 243, __pyx_L1_error) __pyx_t_5 = __Pyx_PyInt_From_VP8StatusCode(WebPGetFeatures(__pyx_t_3, __pyx_t_4, (&__pyx_v_config.input))); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+244: log("webp decompress_yuv found features: width=%4i, height=%4i, has_alpha=%-5s", config.input.width, config.input.height, bool(config.input.has_alpha))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_config.input.width); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_config.input.height); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_config.input.has_alpha); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyBool_FromLong((!(!__pyx_t_8))); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_kp_s_webp_decompress_yuv_found_featur, __pyx_t_7, __pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_kp_s_webp_decompress_yuv_found_featur, __pyx_t_7, __pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_webp_decompress_yuv_found_featur); __Pyx_GIVEREF(__pyx_kp_s_webp_decompress_yuv_found_featur); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_kp_s_webp_decompress_yuv_found_featur); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_6); __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
245:
+246: config.output.colorspace = MODE_YUV
__pyx_v_config.output.colorspace = MODE_YUV;
+247: cdef int alpha = has_alpha and config.input.has_alpha
__pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_has_alpha); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 247, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_has_alpha); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 247, __pyx_L1_error) __pyx_t_10 = __pyx_t_12; goto __pyx_L3_bool_binop_done; } __pyx_t_10 = __pyx_v_config.input.has_alpha; __pyx_L3_bool_binop_done:; __pyx_v_alpha = __pyx_t_10;
+248: if alpha:
__pyx_t_8 = (__pyx_v_alpha != 0); if (__pyx_t_8) { /* … */ }
+249: log.warn("Warning: webp YUVA colorspace not supported yet")
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Warning_webp_YUVA_colorspace_not); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6);
+250: alpha = 0
__pyx_v_alpha = 0;
251: #config.output.colorspace = MODE_YUVA
252:
+253: cdef int w = config.input.width
__pyx_t_10 = __pyx_v_config.input.width; __pyx_v_w = __pyx_t_10;
+254: cdef int h = config.input.height
__pyx_t_10 = __pyx_v_config.input.height; __pyx_v_h = __pyx_t_10;
+255: cdef WebPYUVABuffer *YUVA = &config.output.u.YUVA
__pyx_v_YUVA = (&__pyx_v_config.output.u.YUVA);
+256: YUVA.y_stride = roundup(w, 4)
__pyx_v_YUVA->y_stride = __pyx_f_4xpra_6codecs_4webp_6decode_roundup(__pyx_v_w, 4);
+257: YUVA.u_stride = roundup((w+1)//2, 4)
__pyx_v_YUVA->u_stride = __pyx_f_4xpra_6codecs_4webp_6decode_roundup(__Pyx_div_long((__pyx_v_w + 1), 2), 4);
+258: YUVA.v_stride = roundup((w+1)//2, 4)
__pyx_v_YUVA->v_stride = __pyx_f_4xpra_6codecs_4webp_6decode_roundup(__Pyx_div_long((__pyx_v_w + 1), 2), 4);
+259: if alpha:
__pyx_t_8 = (__pyx_v_alpha != 0); if (__pyx_t_8) { /* … */ goto __pyx_L6; }
+260: YUVA.a_stride = w
__pyx_v_YUVA->a_stride = __pyx_v_w;
261: else:
+262: YUVA.a_stride = 0
/*else*/ { __pyx_v_YUVA->a_stride = 0; } __pyx_L6:;
+263: cdef size_t y_size = YUVA.y_stride * h
__pyx_v_y_size = (__pyx_v_YUVA->y_stride * __pyx_v_h);
+264: cdef size_t u_size = YUVA.u_stride * ((h+1)//2)
__pyx_v_u_size = (__pyx_v_YUVA->u_stride * __Pyx_div_long((__pyx_v_h + 1), 2));
+265: cdef size_t v_size = YUVA.v_stride * ((h+1)//2)
__pyx_v_v_size = (__pyx_v_YUVA->v_stride * __Pyx_div_long((__pyx_v_h + 1), 2));
+266: cdef size_t a_size = YUVA.a_stride * h
__pyx_v_a_size = (__pyx_v_YUVA->a_stride * __pyx_v_h);
+267: YUVA.y_size = y_size
__pyx_v_YUVA->y_size = __pyx_v_y_size;
+268: YUVA.u_size = u_size
__pyx_v_YUVA->u_size = __pyx_v_u_size;
+269: YUVA.v_size = v_size
__pyx_v_YUVA->v_size = __pyx_v_v_size;
+270: YUVA.a_size = a_size
__pyx_v_YUVA->a_size = __pyx_v_a_size;
271: #allocate a buffer big enough for all planes with 1 stride of padding after each:
+272: cdef uint8_t *buf = <uint8_t*> memalign(y_size + u_size + v_size + a_size + YUVA.y_stride + YUVA.u_stride + YUVA.v_stride + YUVA.a_stride)
__pyx_v_buf = ((uint8_t *)__pyx_f_4xpra_7buffers_6membuf_memalign((((((((__pyx_v_y_size + __pyx_v_u_size) + __pyx_v_v_size) + __pyx_v_a_size) + __pyx_v_YUVA->y_stride) + __pyx_v_YUVA->u_stride) + __pyx_v_YUVA->v_stride) + __pyx_v_YUVA->a_stride)));
+273: YUVA.y = buf
__pyx_v_YUVA->y = __pyx_v_buf;
+274: YUVA.u = <uint8_t*> (<uintptr_t> buf + y_size + YUVA.y_stride)
__pyx_v_YUVA->u = ((uint8_t *)((((uintptr_t)__pyx_v_buf) + __pyx_v_y_size) + __pyx_v_YUVA->y_stride));
+275: YUVA.v = <uint8_t*> (<uintptr_t> buf + y_size + YUVA.y_stride + u_size + YUVA.u_stride)
__pyx_v_YUVA->v = ((uint8_t *)((((((uintptr_t)__pyx_v_buf) + __pyx_v_y_size) + __pyx_v_YUVA->y_stride) + __pyx_v_u_size) + __pyx_v_YUVA->u_stride));
+276: if alpha:
__pyx_t_8 = (__pyx_v_alpha != 0); if (__pyx_t_8) { /* … */ goto __pyx_L7; }
+277: YUVA.a = <uint8_t*> (<uintptr_t> buf + y_size + YUVA.y_stride + u_size + YUVA.u_stride + v_size + YUVA.v_stride)
__pyx_v_YUVA->a = ((uint8_t *)((((((((uintptr_t)__pyx_v_buf) + __pyx_v_y_size) + __pyx_v_YUVA->y_stride) + __pyx_v_u_size) + __pyx_v_YUVA->u_stride) + __pyx_v_v_size) + __pyx_v_YUVA->v_stride));
+278: strides = (YUVA.y_stride, YUVA.u_stride, YUVA.v_stride, YUVA.a_stride)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_YUVA->y_stride); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_YUVA->u_stride); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_YUVA->v_stride); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_YUVA->a_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_6); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_11 = 0; __pyx_t_6 = 0; __pyx_v_strides = __pyx_t_5; __pyx_t_5 = 0;
279: else:
+280: YUVA.a = NULL
/*else*/ { __pyx_v_YUVA->a = NULL;
+281: strides = (YUVA.y_stride, YUVA.u_stride, YUVA.v_stride)
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_YUVA->y_stride); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_YUVA->u_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_YUVA->v_stride); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_11); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_11 = 0; __pyx_v_strides = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L7:;
+282: config.output.is_external_memory = 1
__pyx_v_config.output.is_external_memory = 1;
+283: log("WebPDecode: image size %ix%i : buffer=%#x, strides=%s", w, h, <uintptr_t> buf, strides)
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_kp_s_WebPDecode_image_size_ix_i_buffe, __pyx_t_6, __pyx_t_5, __pyx_t_1, __pyx_v_strides}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_kp_s_WebPDecode_image_size_ix_i_buffe, __pyx_t_6, __pyx_t_5, __pyx_t_1, __pyx_v_strides}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_9 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_WebPDecode_image_size_ix_i_buffe); __Pyx_GIVEREF(__pyx_kp_s_WebPDecode_image_size_ix_i_buffe); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_kp_s_WebPDecode_image_size_ix_i_buffe); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_v_strides); __Pyx_GIVEREF(__pyx_v_strides); PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_10, __pyx_v_strides); __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+284: webp_check(WebPDecode(data, len(data), &config))
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_webp_check); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyObject_AsUString(__pyx_v_data); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(1, 284, __pyx_L1_error) __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 284, __pyx_L1_error) __pyx_t_9 = __Pyx_PyInt_From_VP8StatusCode(WebPDecode(__pyx_t_13, __pyx_t_4, (&__pyx_v_config))); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (!__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+285: if alpha:
__pyx_t_8 = (__pyx_v_alpha != 0); if (__pyx_t_8) { /* … */ goto __pyx_L8; }
286: planes = (
+287: memory_as_pybuffer(<void *> YUVA.y, y_size, True),
__pyx_t_2 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->y), __pyx_v_y_size, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_9); __pyx_t_2 = 0; __pyx_t_11 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; __pyx_v_planes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+288: memory_as_pybuffer(<void *> YUVA.u, u_size, True),
__pyx_t_11 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->u), __pyx_v_u_size, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11);
+289: memory_as_pybuffer(<void *> YUVA.v, v_size, True),
__pyx_t_5 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->v), __pyx_v_v_size, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5);
+290: memory_as_pybuffer(<void *> YUVA.a, a_size, True),
__pyx_t_9 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->a), __pyx_v_a_size, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9);
291: )
292: else:
293: planes = (
+294: memory_as_pybuffer(<void *> YUVA.y, y_size, True),
/*else*/ { __pyx_t_1 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->y), __pyx_v_y_size, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_5); __pyx_t_1 = 0; __pyx_t_9 = 0; __pyx_t_5 = 0; __pyx_v_planes = ((PyObject*)__pyx_t_11); __pyx_t_11 = 0; } __pyx_L8:;
+295: memory_as_pybuffer(<void *> YUVA.u, u_size, True),
__pyx_t_9 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->u), __pyx_v_u_size, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9);
+296: memory_as_pybuffer(<void *> YUVA.v, v_size, True),
__pyx_t_5 = __pyx_f_4xpra_7buffers_6membuf_memory_as_pybuffer(((void *)__pyx_v_YUVA->v), __pyx_v_v_size, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5);
297: )
+298: img = YUVImageWrapper(0, 0, w, h, planes, "YUV420P", (3+alpha)*8, strides, 3+alpha, ImageWrapper._3_PLANES+alpha)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUVImageWrapper); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_long(((3 + __pyx_v_alpha) * 8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyInt_From_long((3 + __pyx_v_alpha)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_3_PLANES); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_alpha); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = PyNumber_Add(__pyx_t_14, __pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[11] = {__pyx_t_7, __pyx_int_0, __pyx_int_0, __pyx_t_9, __pyx_t_1, __pyx_v_planes, __pyx_n_s_YUV420P, __pyx_t_2, __pyx_v_strides, __pyx_t_6, __pyx_t_15}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 10+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[11] = {__pyx_t_7, __pyx_int_0, __pyx_int_0, __pyx_t_9, __pyx_t_1, __pyx_v_planes, __pyx_n_s_YUV420P, __pyx_t_2, __pyx_v_strides, __pyx_t_6, __pyx_t_15}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 10+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif { __pyx_t_14 = PyTuple_New(10+__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_10, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_10, __pyx_int_0); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_10, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_v_planes); __Pyx_GIVEREF(__pyx_v_planes); PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_10, __pyx_v_planes); __Pyx_INCREF(__pyx_n_s_YUV420P); __Pyx_GIVEREF(__pyx_n_s_YUV420P); PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_10, __pyx_n_s_YUV420P); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_10, __pyx_t_2); __Pyx_INCREF(__pyx_v_strides); __Pyx_GIVEREF(__pyx_v_strides); PyTuple_SET_ITEM(__pyx_t_14, 7+__pyx_t_10, __pyx_v_strides); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_14, 8+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_14, 9+__pyx_t_10, __pyx_t_15); __pyx_t_9 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_img = __pyx_t_11; __pyx_t_11 = 0;
+299: img.cython_buffer = <uintptr_t> buf
__pyx_t_11 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_buf)); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__Pyx_PyObject_SetAttrStr(__pyx_v_img, __pyx_n_s_cython_buffer, __pyx_t_11) < 0) __PYX_ERR(1, 299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+300: return img
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_img); __pyx_r = __pyx_v_img; goto __pyx_L0;
301:
302:
+303: class YUVImageWrapper(ImageWrapper):
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_YUVImageWrapper, __pyx_n_s_YUVImageWrapper, (PyObject *) NULL, __pyx_n_s_xpra_codecs_webp_decode, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_YUVImageWrapper, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_YUVImageWrapper, __pyx_t_4) < 0) __PYX_ERR(1, 303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
304:
+305: def _cn(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_1_cn(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_1_cn = {"_cn", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_1_cn, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_1_cn(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_cn (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_15YUVImageWrapper__cn(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_15YUVImageWrapper__cn(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_cn", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21); /* … */ __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_1_cn, 0, __pyx_n_s_YUVImageWrapper__cn, NULL, __pyx_n_s_xpra_codecs_webp_decode, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_cn, __pyx_t_4) < 0) __PYX_ERR(1, 305, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_cn, 305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(1, 305, __pyx_L1_error)
+306: return "webp.YUVImageWrapper"
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_kp_s_webp_YUVImageWrapper); __pyx_r = __pyx_kp_s_webp_YUVImageWrapper; goto __pyx_L0;
307:
+308: def free(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_3free(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_3free = {"free", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_3free, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_3free(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("free (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_2free(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_2free(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("free", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.webp.decode.YUVImageWrapper.free", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* … */ __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_15YUVImageWrapper_3free, 0, __pyx_n_s_YUVImageWrapper_free, NULL, __pyx_n_s_xpra_codecs_webp_decode, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_free, __pyx_t_4) < 0) __PYX_ERR(1, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_decode_pyx, __pyx_n_s_free, 308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(1, 308, __pyx_L1_error)
+309: log("webp.YUVImageWrapper.free() cython_buffer=%#x", <unsigned long> self.cython_buffer)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cython_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_As_unsigned_long(__pyx_t_3); if (unlikely((__pyx_t_4 == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_unsigned_long(((unsigned long)__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_webp_YUVImageWrapper_free_cython, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_webp_YUVImageWrapper_free_cython, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_webp_YUVImageWrapper_free_cython); __Pyx_GIVEREF(__pyx_kp_s_webp_YUVImageWrapper_free_cython); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_webp_YUVImageWrapper_free_cython); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+310: ImageWrapper.free(self)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_free); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_self}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_self); __Pyx_GIVEREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_self); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+311: if self.cython_buffer>0:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cython_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 311, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 311, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_8) { /* … */ }
+312: free(<void *> (<uintptr_t> self.cython_buffer))
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cython_buffer); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_7); if (unlikely((__pyx_t_9 == ((uintptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 312, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; free(((void *)((uintptr_t)__pyx_t_9)));
+313: self.cython_buffer = 0
if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cython_buffer, __pyx_int_0) < 0) __PYX_ERR(1, 313, __pyx_L1_error)
314:
315:
+316: def selftest(full=False):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_13selftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6decode_13selftest = {"selftest", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6decode_13selftest, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_4webp_6decode_13selftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_full = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("selftest (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_full,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_full); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "selftest") < 0)) __PYX_ERR(1, 316, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_full = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("selftest", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 316, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.webp.decode.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6decode_12selftest(__pyx_self, __pyx_v_full); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_4webp_6decode_12selftest(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_full) { long __pyx_v_w; long __pyx_v_h; PyObject *__pyx_v_has_alpha = NULL; PyObject *__pyx_v_hexdata = NULL; PyObject *__pyx_v_binascii = NULL; PyObject *__pyx_v_bdata = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_iw = NULL; PyObject *__pyx_v_ih = NULL; CYTHON_UNUSED PyObject *__pyx_v_stride = NULL; PyObject *__pyx_v_ia = NULL; CYTHON_UNUSED PyObject *__pyx_v_rgb = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("selftest", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("xpra.codecs.webp.decode.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_has_alpha); __Pyx_XDECREF(__pyx_v_hexdata); __Pyx_XDECREF(__pyx_v_binascii); __Pyx_XDECREF(__pyx_v_bdata); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_iw); __Pyx_XDECREF(__pyx_v_ih); __Pyx_XDECREF(__pyx_v_stride); __Pyx_XDECREF(__pyx_v_ia); __Pyx_XDECREF(__pyx_v_rgb); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__25 = PyTuple_Pack(13, __pyx_n_s_full, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_has_alpha, __pyx_n_s_hexdata, __pyx_n_s_binascii, __pyx_n_s_bdata, __pyx_n_s_b, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_stride, __pyx_n_s_ia, __pyx_n_s_rgb); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6decode_13selftest, NULL, __pyx_n_s_xpra_codecs_webp_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_selftest, __pyx_t_2) < 0) __PYX_ERR(1, 316, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+317: w, h = 24, 16 #hard coded size of test data
__pyx_t_1 = 24; __pyx_t_2 = 16; __pyx_v_w = __pyx_t_1; __pyx_v_h = __pyx_t_2;
+318: for has_alpha, hexdata in ((True, "52494646c001000057454250565038580a000000100000001700000f0000414c504881010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056503820180000003401009d012a1800100000004c00000f040000fef81f8000"),
__pyx_tuple__7 = PyTuple_Pack(2, Py_True, __pyx_kp_s_52494646c00100005745425056503858); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* … */ __pyx_t_3 = __pyx_tuple__9; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; for (;;) { if (__pyx_t_4 >= 2) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 318, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif if (likely(__pyx_t_5 != Py_None)) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 318, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 318, __pyx_L1_error) } __Pyx_XDECREF_SET(__pyx_v_has_alpha, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_hexdata, __pyx_t_7); __pyx_t_7 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__9 = PyTuple_Pack(2, __pyx_tuple__7, __pyx_tuple__8); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9);
+319: (False, "52494646c001000057454250565038580a000000100000001700000f0000414c50488101000010ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056503820180000003401009d012a1800100000004c00000f040000fef81f8000")):
__pyx_tuple__8 = PyTuple_Pack(2, Py_False, __pyx_kp_s_52494646c00100005745425056503858_2); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8);
+320: import binascii
__pyx_t_5 = __Pyx_Import(__pyx_n_s_binascii, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_binascii, __pyx_t_5); __pyx_t_5 = 0;
+321: bdata = binascii.unhexlify(hexdata)
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_binascii, __pyx_n_s_unhexlify); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_6) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_hexdata); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_hexdata}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_hexdata}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_hexdata); __Pyx_GIVEREF(__pyx_v_hexdata); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_hexdata); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_bdata, __pyx_t_5); __pyx_t_5 = 0;
+322: b, iw, ih, stride, ia, rgb = decompress(bdata, has_alpha)
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_decompress); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_bdata, __pyx_v_has_alpha}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_bdata, __pyx_v_has_alpha}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_bdata); __Pyx_GIVEREF(__pyx_v_bdata); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_bdata); __Pyx_INCREF(__pyx_v_has_alpha); __Pyx_GIVEREF(__pyx_v_has_alpha); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_has_alpha); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 6)) { if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 322, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 4); __pyx_t_12 = PyTuple_GET_ITEM(sequence, 5); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); __pyx_t_8 = PyList_GET_ITEM(sequence, 2); __pyx_t_10 = PyList_GET_ITEM(sequence, 3); __pyx_t_11 = PyList_GET_ITEM(sequence, 4); __pyx_t_12 = PyList_GET_ITEM(sequence, 5); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); #else { Py_ssize_t i; PyObject** temps[6] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_8,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12}; for (i=0; i < 6; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; PyObject** temps[6] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_8,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12}; __pyx_t_13 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext; for (index=0; index < 6; index++) { PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 6) < 0) __PYX_ERR(1, 322, __pyx_L1_error) __pyx_t_14 = NULL; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_14 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 322, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_iw, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_ih, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_stride, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_ia, __pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF_SET(__pyx_v_rgb, __pyx_t_12); __pyx_t_12 = 0;
+323: assert iw==w and ih==h and ia==has_alpha
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_w); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = PyObject_RichCompare(__pyx_v_iw, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_16) { } else { __pyx_t_15 = __pyx_t_16; goto __pyx_L7_bool_binop_done; } __pyx_t_12 = __Pyx_PyInt_From_long(__pyx_v_h); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = PyObject_RichCompare(__pyx_v_ih, __pyx_t_12, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_16) { } else { __pyx_t_15 = __pyx_t_16; goto __pyx_L7_bool_binop_done; } __pyx_t_5 = PyObject_RichCompare(__pyx_v_ia, __pyx_v_has_alpha, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 323, __pyx_L1_error) __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(1, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_15 = __pyx_t_16; __pyx_L7_bool_binop_done:; if (unlikely(!__pyx_t_15)) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(1, 323, __pyx_L1_error) } } #endif
+324: assert len(b.get_pixels())>0
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_get_pixels); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (__pyx_t_11) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 324, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_17 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(1, 324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!((__pyx_t_17 > 0) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(1, 324, __pyx_L1_error) } } #endif
325: #print("compressed data(%s)=%s" % (has_alpha, binascii.hexlify(r)))