Generated by Cython 0.28.3

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: encode.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: import os
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 009: 
+010: from xpra.log import Logger
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __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(0, 10, __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(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+011: log = Logger("encoder", "webp")
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __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(0, 11, __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(0, 11, __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(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
 012: 
 013: from xpra.buffers.membuf cimport memalign, object_as_buffer
+014: from xpra.os_util import bytestostr
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_bytestostr);
  __Pyx_GIVEREF(__pyx_n_s_bytestostr);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_bytestostr);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_os_util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __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_bytestostr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytestostr, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 015: 
+016: from xpra.util import envbool, envint
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_envbool);
  __Pyx_GIVEREF(__pyx_n_s_envbool);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_envbool);
  __Pyx_INCREF(__pyx_n_s_envint);
  __Pyx_GIVEREF(__pyx_n_s_envint);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_envint);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_xpra_util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __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_envbool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_envbool, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_envint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_envint, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+017: cdef int LOG_CONFIG = envbool("XPRA_WEBP_LOG_CONFIG", False)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_LOG_CONFIG = __pyx_t_3;
/* … */
  __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_LOG_CONFIG, Py_False); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
+018: cdef int WEBP_THREADING = envbool("XPRA_WEBP_THREADING", True)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_WEBP_THREADING = __pyx_t_3;
/* … */
  __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_THREADING, Py_True); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
+019: cdef int LOSSLESS_THRESHOLD = envint("XPRA_WEBP_LOSSLESS_THRESHOLD", 75)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_envint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD = __pyx_t_3;
/* … */
  __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_LOSSLESS_THRESHOLD, __pyx_int_75); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
+020: cdef int SUBSAMPLING_THRESHOLD = envint("XPRA_WEBP_SUBSAMPLING_THRESHOLD", 40)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_envint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_SUBSAMPLING_THRESHOLD = __pyx_t_3;
/* … */
  __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_SUBSAMPLING_THRESHOLD, __pyx_int_40); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
+021: assert SUBSAMPLING_THRESHOLD<=LOSSLESS_THRESHOLD, "lossless threshold must be higher than subsampling threshold"
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_4xpra_6codecs_4webp_6encode_SUBSAMPLING_THRESHOLD <= __pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD) != 0))) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_lossless_threshold_must_be_highe);
      __PYX_ERR(0, 21, __pyx_L1_error)
    }
  }
  #endif
+022: assert LOSSLESS_THRESHOLD>=0 and LOSSLESS_THRESHOLD<=100, "invalid lossless threshold: %i" % LOSSLESS_THRESHOLD
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = ((__pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD >= 0) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L2_bool_binop_done;
    }
    __pyx_t_5 = ((__pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD <= 0x64) != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L2_bool_binop_done:;
    if (unlikely(!__pyx_t_4)) {
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_lossless_threshold_i, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 22, __pyx_L1_error)
    }
  }
  #endif
 023: 
+024: cdef inline int MIN(int a, int b):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_4webp_6encode_MIN(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("MIN", 0);
/* … */
  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+025:     if a<=b:
  __pyx_t_1 = ((__pyx_v_a <= __pyx_v_b) != 0);
  if (__pyx_t_1) {
/* … */
  }
+026:         return a
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
+027:     return b
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;
+028: cdef inline int MAX(int a, int b):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_4webp_6encode_MAX(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("MAX", 0);
/* … */
  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+029:     if a>=b:
  __pyx_t_1 = ((__pyx_v_a >= __pyx_v_b) != 0);
  if (__pyx_t_1) {
/* … */
  }
+030:         return a
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
+031:     return b
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;
 032: 
 033: 
 034: from libc.stdint cimport uint8_t, uint32_t, uintptr_t
 035: 
 036: cdef extern from "string.h":
 037:     void * memset ( void * ptr, int value, size_t num )
 038: 
 039: cdef extern from *:
 040:     ctypedef unsigned long size_t
 041: 
 042: cdef extern from "stdlib.h":
 043:     void free(void *ptr)
 044: 
 045: 
 046: DEF WEBP_MAX_DIMENSION = 16383
 047: 
 048: cdef extern from "webp/encode.h":
 049: 
 050:     int WebPGetEncoderVersion()
 051: 
 052:     ctypedef int WebPImageHint
 053:     # WebPImageHint:
 054:     WebPImageHint WEBP_HINT_DEFAULT     #default preset
 055:     WebPImageHint WEBP_HINT_PICTURE     #digital picture, like portrait, inner shot
 056:     WebPImageHint WEBP_HINT_PHOTO       #outdoor photograph, with natural lighting
 057:     WebPImageHint WEBP_HINT_GRAPH       #Discrete tone image (graph, map-tile etc).
 058: 
 059:     ctypedef int WebPPreset
 060:     WebPPreset WEBP_PRESET_DEFAULT      #default preset.
 061:     WebPPreset WEBP_PRESET_PICTURE      #digital picture, like portrait, inner shot
 062:     WebPPreset WEBP_PRESET_PHOTO        #outdoor photograph, with natural lighting
 063:     WebPPreset WEBP_PRESET_DRAWING      #hand or line drawing, with high-contrast details
 064:     WebPPreset WEBP_PRESET_ICON         #small-sized colorful images
 065:     WebPPreset WEBP_PRESET_TEXT         #text-like
 066: 
 067:     ctypedef int WebPEncCSP
 068:     #chroma sampling
 069:     WebPEncCSP WEBP_YUV420              #4:2:0
 070:     WebPEncCSP WEBP_YUV422              #4:2:2
 071:     WebPEncCSP WEBP_YUV444              #4:4:4
 072:     WebPEncCSP WEBP_YUV400              #grayscale
 073:     WebPEncCSP WEBP_CSP_UV_MASK         #bit-mask to get the UV sampling factors
 074:     WebPEncCSP WEBP_YUV420A
 075:     WebPEncCSP WEBP_YUV422A
 076:     WebPEncCSP WEBP_YUV444A
 077:     WebPEncCSP WEBP_YUV400A             #grayscale + alpha
 078:     WebPEncCSP WEBP_CSP_ALPHA_BIT       #bit that is set if alpha is present
 079: 
 080:     ctypedef int WebPEncodingError
 081:     WebPEncodingError VP8_ENC_OK
 082:     WebPEncodingError VP8_ENC_ERROR_OUT_OF_MEMORY
 083:     WebPEncodingError VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY
 084:     WebPEncodingError VP8_ENC_ERROR_NULL_PARAMETER
 085:     WebPEncodingError VP8_ENC_ERROR_INVALID_CONFIGURATION
 086:     WebPEncodingError VP8_ENC_ERROR_BAD_DIMENSION
 087:     WebPEncodingError VP8_ENC_ERROR_PARTITION0_OVERFLOW
 088:     WebPEncodingError VP8_ENC_ERROR_PARTITION_OVERFLOW
 089:     WebPEncodingError VP8_ENC_ERROR_BAD_WRITE
 090:     WebPEncodingError VP8_ENC_ERROR_FILE_TOO_BIG
 091:     WebPEncodingError VP8_ENC_ERROR_USER_ABORT
 092:     WebPEncodingError VP8_ENC_ERROR_LAST
 093: 
 094:     ctypedef struct WebPConfig:
 095:         int lossless                    #Lossless encoding (0=lossy(default), 1=lossless).
 096:         float quality                   #between 0 (smallest file) and 100 (biggest)
 097:         int method                      #quality/speed trade-off (0=fast, 6=slower-better)
 098: 
 099:         WebPImageHint image_hint        #Hint for image type (lossless only for now).
 100: 
 101:         #Parameters related to lossy compression only:
 102:         int target_size                 #if non-zero, set the desired target size in bytes.
 103:                                         #Takes precedence over the 'compression' parameter.
 104:         float target_PSNR               #if non-zero, specifies the minimal distortion to
 105:                                         #try to achieve. Takes precedence over target_size.
 106:         int segments                    #maximum number of segments to use, in [1..4]
 107:         int sns_strength                #Spatial Noise Shaping. 0=off, 100=maximum.
 108:         int filter_strength             #range: [0 = off .. 100 = strongest]
 109:         int filter_sharpness            #range: [0 = off .. 7 = least sharp]
 110:         int filter_type                 #filtering type: 0 = simple, 1 = strong (only used
 111:                                         #if filter_strength > 0 or autofilter > 0)
 112:         int autofilter                  #Auto adjust filter's strength [0 = off, 1 = on]
 113:         int alpha_compression           #Algorithm for encoding the alpha plane (0 = none,
 114:                                         #1 compressed with WebP lossless). Default is 1.
 115:         int alpha_filtering             #Predictive filtering method for alpha plane.
 116:                                         #0: none, 1: fast, 2: best. Default if 1.
 117:         int alpha_quality               #Between 0 (smallest size) and 100 (lossless).
 118:                                         #Default is 100.
 119:         int _pass "pass"                #number of entropy-analysis passes (in [1..10]).
 120: 
 121:         int show_compressed             #if true, export the compressed picture back.
 122:                                         #In-loop filtering is not applied.
 123:         int preprocessing               #preprocessing filter (0=none, 1=segment-smooth)
 124:         int partitions                  #log2(number of token partitions) in [0..3]. Default
 125:                                         #is set to 0 for easier progressive decoding.
 126:         int partition_limit             #quality degradation allowed to fit the 512k limit
 127:                                         #on prediction modes coding (0: no degradation,
 128:                                         #100: maximum possible degradation).
 129:         int emulate_jpeg_size           #If true, compression parameters will be remapped
 130:                                         #to better match the expected output size from
 131:                                         #JPEG compression. Generally, the output size will
 132:                                         #be similar but the degradation will be lower.
 133:         int thread_level                #If non-zero, try and use multi-threaded encoding.
 134:         int low_memory                  #If set, reduce memory usage (but increase CPU use).
 135: 
 136:         int near_lossless               #Near lossless encoding [0 = max loss .. 100 = off
 137:                                         #(default)
 138:         int exact                       #if non-zero, preserve the exact RGB values under
 139:                                         #transparent area. Otherwise, discard this invisible
 140:                                         #RGB information for better compression. The default
 141:                                         #value is 0.
 142:         uint32_t pad[3]                 #padding for later use
 143: 
 144:     ctypedef struct WebPMemoryWriter:
 145:         uint8_t* mem                    #final buffer (of size 'max_size', larger than 'size').
 146:         size_t   size                   #final size
 147:         size_t   max_size               #total capacity
 148:         uint32_t pad[1]
 149: 
 150:     ctypedef void *WebPWriterFunction
 151:     ctypedef void *WebPProgressHook
 152:     ctypedef void *WebPAuxStats
 153: 
 154:     ctypedef struct WebPPicture:
 155:         #   INPUT
 156:         # Main flag for encoder selecting between ARGB or YUV input.
 157:         # It is recommended to use ARGB input (*argb, argb_stride) for lossless
 158:         # compression, and YUV input (*y, *u, *v, etc.) for lossy compression
 159:         # since these are the respective native colorspace for these formats.
 160:         int use_argb
 161: 
 162:         # YUV input (mostly used for input to lossy compression)
 163:         WebPEncCSP colorspace           #colorspace: should be YUV420 for now (=Y'CbCr).
 164:         int width, height               #dimensions (less or equal to WEBP_MAX_DIMENSION)
 165:         uint8_t *y
 166:         uint8_t *u
 167:         uint8_t *v
 168:         int y_stride, uv_stride         #luma/chroma strides.
 169:         uint8_t* a                      #pointer to the alpha plane
 170:         int a_stride                    #stride of the alpha plane
 171:         uint32_t pad1[2]                #padding for later use
 172: 
 173:         # ARGB input (mostly used for input to lossless compression)
 174:         uint32_t* argb                  #Pointer to argb (32 bit) plane.
 175:         int argb_stride                 #This is stride in pixels units, not bytes.
 176:         uint32_t pad2[3]                #padding for later use
 177: 
 178:         #   OUTPUT
 179:         # Byte-emission hook, to store compressed bytes as they are ready.
 180:         WebPWriterFunction writer       #can be NULL
 181:         void* custom_ptr                #can be used by the writer.
 182: 
 183:         # map for extra information (only for lossy compression mode)
 184:         int extra_info_type             #1: intra type, 2: segment, 3: quant
 185:                                         #4: intra-16 prediction mode,
 186:                                         #5: chroma prediction mode,
 187:                                         #6: bit cost, 7: distortion
 188:         uint8_t* extra_info             #if not NULL, points to an array of size
 189:                                         # ((width + 15) / 16) * ((height + 15) / 16) that
 190:                                         #will be filled with a macroblock map, depending
 191:                                         #on extra_info_type.
 192: 
 193:         #   STATS AND REPORTS
 194:         # Pointer to side statistics (updated only if not NULL)
 195:         WebPAuxStats* stats
 196: 
 197:         # Error code for the latest error encountered during encoding
 198:         WebPEncodingError error_code
 199: 
 200:         #If not NULL, report progress during encoding.
 201:         WebPProgressHook progress_hook
 202: 
 203:         void* user_data                 #this field is free to be set to any value and
 204:                                         #used during callbacks (like progress-report e.g.).
 205: 
 206:         uint32_t pad3[3]                #padding for later use
 207: 
 208:         # Unused for now: original samples (for non-YUV420 modes)
 209:         uint8_t *u0
 210:         uint8_t *v0
 211:         int uv0_stride
 212: 
 213:         uint32_t pad4[7]                #padding for later use
 214: 
 215:         # PRIVATE FIELDS
 216:         void* memory_                   #row chunk of memory for yuva planes
 217:         void* memory_argb_              #and for argb too.
 218:         void* pad5[2]                   #padding for later use
 219: 
 220:     void WebPMemoryWriterInit(WebPMemoryWriter* writer)
 221:     int WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture)
 222: 
 223:     int WebPConfigInit(WebPConfig* config)
 224:     int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality)
 225:     int WebPValidateConfig(const WebPConfig* config)
 226:     int WebPPictureInit(WebPPicture* picture)
 227:     void WebPPictureFree(WebPPicture* picture)
 228: 
 229:     # Colorspace conversion function to import RGB samples.
 230:     # Previous buffer will be free'd, if any.
 231:     # *rgb buffer should have a size of at least height * rgb_stride.
 232:     # Returns false in case of memory error.
 233:     int WebPPictureImportRGB(WebPPicture* picture, const uint8_t* rgb, int rgb_stride)
 234:     # Same, but for RGBA buffer.
 235:     int WebPPictureImportRGBA(WebPPicture* picture, const uint8_t* rgba, int rgba_stride)
 236:     # Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
 237:     # input buffer ignoring the alpha channel. Avoids needing to copy the data
 238:     # to a temporary 24-bit RGB buffer to import the RGB only.
 239:     int WebPPictureImportRGBX(WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride)
 240: 
 241:     # Variants of the above, but taking BGR(A|X) input.
 242:     int WebPPictureImportBGR(WebPPicture* picture, const uint8_t* bgr, int bgr_stride)
 243:     int WebPPictureImportBGRA(WebPPicture* picture, const uint8_t* bgra, int bgra_stride)
 244:     int WebPPictureImportBGRX(WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride)
 245: 
 246:     # Converts picture->argb data to the YUVA format specified by 'colorspace'.
 247:     # Upon return, picture->use_argb is set to false. The presence of real
 248:     # non-opaque transparent values is detected, and 'colorspace' will be
 249:     # adjusted accordingly. Note that this method is lossy.
 250:     # Returns false in case of error.
 251:     int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace)
 252: 
 253:     # Converts picture->yuv to picture->argb and sets picture->use_argb to true.
 254:     # The input format must be YUV_420 or YUV_420A.
 255:     # Note that the use of this method is discouraged if one has access to the
 256:     # raw ARGB samples, since using YUV420 is comparatively lossy. Also, the
 257:     # conversion from YUV420 to ARGB incurs a small loss too.
 258:     # Returns false in case of error.
 259:     int WebPPictureYUVAToARGB(WebPPicture* picture)
 260: 
 261:     # Helper function: given a width x height plane of YUV(A) samples
 262:     # (with stride 'stride'), clean-up the YUV samples under fully transparent
 263:     # area, to help compressibility (no guarantee, though).
 264:     void WebPCleanupTransparentArea(WebPPicture* picture)
 265: 
 266:     # Scan the picture 'picture' for the presence of non fully opaque alpha values.
 267:     # Returns true in such case. Otherwise returns false (indicating that the
 268:     # alpha plane can be ignored altogether e.g.).
 269:     int WebPPictureHasTransparency(const WebPPicture* picture)
 270: 
 271:     # Main encoding call, after config and picture have been initialized.
 272:     # 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION),
 273:     # and the 'config' object must be a valid one.
 274:     # Returns false in case of error, true otherwise.
 275:     # In case of error, picture->error_code is updated accordingly.
 276:     # 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
 277:     # on the value of 'picture->use_argb'. It is highly recommended to use
 278:     # the former for lossy encoding, and the latter for lossless encoding
 279:     # (when config.lossless is true). Automatic conversion from one format to
 280:     # another is provided but they both incur some loss.
 281:     int WebPEncode(const WebPConfig* config, WebPPicture* picture)
 282: 
 283: 
 284: ERROR_TO_NAME = {
 285: #VP8_ENC_OK
+286:                 VP8_ENC_ERROR_OUT_OF_MEMORY             : "memory error allocating objects",
  __pyx_t_2 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_OUT_OF_MEMORY); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_memory_error_allocating_objects) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+287:                 VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY   : "memory error while flushing bits",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_memory_error_while_flushing_bits) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+288:                 VP8_ENC_ERROR_NULL_PARAMETER            : "a pointer parameter is NULL",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_NULL_PARAMETER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_a_pointer_parameter_is_NULL) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+289:                 VP8_ENC_ERROR_INVALID_CONFIGURATION     : "configuration is invalid",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_INVALID_CONFIGURATION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_configuration_is_invalid) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+290:                 VP8_ENC_ERROR_BAD_DIMENSION             : "picture has invalid width/height",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_BAD_DIMENSION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_picture_has_invalid_width_height) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+291:                 VP8_ENC_ERROR_PARTITION0_OVERFLOW       : "partition is bigger than 512k",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_PARTITION0_OVERFLOW); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_partition_is_bigger_than_512k) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+292:                 VP8_ENC_ERROR_PARTITION_OVERFLOW        : "partition is bigger than 16M",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_PARTITION_OVERFLOW); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_partition_is_bigger_than_16M) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+293:                 VP8_ENC_ERROR_BAD_WRITE                 : "error while flushing bytes",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_BAD_WRITE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_error_while_flushing_bytes) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+294:                 VP8_ENC_ERROR_FILE_TOO_BIG              : "file is bigger than 4G",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_FILE_TOO_BIG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_file_is_bigger_than_4G) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+295:                 VP8_ENC_ERROR_USER_ABORT                : "abort request by user",
  __pyx_t_1 = __Pyx_PyInt_From_WebPEncodingError(VP8_ENC_ERROR_USER_ABORT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_s_abort_request_by_user) < 0) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ERROR_TO_NAME, __pyx_t_2) < 0) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 296:                 }
 297: 
 298: PRESETS = {
+299:            WEBP_PRESET_DEFAULT      : "default",
  __pyx_t_2 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_DEFAULT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_default) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+300:            WEBP_PRESET_PICTURE      : "picture",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PICTURE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_picture) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+301:            WEBP_PRESET_PHOTO        : "photo",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PHOTO); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_photo) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+302:            WEBP_PRESET_DRAWING      : "drawing",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_DRAWING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_drawing) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+303:            WEBP_PRESET_ICON         : "icon",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_ICON); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_icon) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+304:            WEBP_PRESET_TEXT         : "text",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_s_text) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PRESETS, __pyx_t_2) < 0) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 305:            }
+306: PRESET_NAME_TO_CONSTANT = {}
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PRESET_NAME_TO_CONSTANT, __pyx_t_2) < 0) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+307: for k,v in PRESETS.items():
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESETS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_items); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 307, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 307, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 307, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_6);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 307, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      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(0, 307, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 307, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 307, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 307, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 307, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_k, __pyx_t_1) < 0) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_v, __pyx_t_9) < 0) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* … */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+308:     PRESET_NAME_TO_CONSTANT[v] = k
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyObject_SetItem(__pyx_t_9, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 308, __pyx_L1_error)
    __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;
 309: 
 310: CONTENT_TYPE_PRESET = {
+311:     "picture"   : WEBP_PRESET_PICTURE,
  __pyx_t_6 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PICTURE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_picture, __pyx_t_2) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+312:     "text"      : WEBP_PRESET_TEXT,
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_text, __pyx_t_2) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+313:     "browser"   : WEBP_PRESET_TEXT,
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_browser, __pyx_t_2) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CONTENT_TYPE_PRESET, __pyx_t_6) < 0) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 314:     }
 315: 
 316: IMAGE_HINT = {
+317:               WEBP_HINT_DEFAULT     : "default",
  __pyx_t_6 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_DEFAULT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_2, __pyx_n_s_default) < 0) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+318:               WEBP_HINT_PICTURE     : "picture",
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PICTURE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_2, __pyx_n_s_picture) < 0) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+319:               WEBP_HINT_PHOTO       : "photo",
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PHOTO); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_2, __pyx_n_s_photo) < 0) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+320:               WEBP_HINT_GRAPH       : "graph",
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_GRAPH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_2, __pyx_n_s_graph) < 0) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_IMAGE_HINT, __pyx_t_6) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 321:               }
+322: HINT_NAME_TO_CONSTANT = {}
  __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HINT_NAME_TO_CONSTANT, __pyx_t_6) < 0) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+323: for k,v in IMAGE_HINT.items():
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 323, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 323, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 323, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 323, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      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(0, 323, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 323, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 323, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 323, __pyx_L1_error)
      __pyx_L11_unpacking_done:;
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_k, __pyx_t_2) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_v, __pyx_t_9) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* … */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+324:     HINT_NAME_TO_CONSTANT[v] = k
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_k); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_HINT_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyObject_SetItem(__pyx_t_9, __pyx_t_2, __pyx_t_6) < 0)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 325: 
 326: CONTENT_TYPE_HINT = {
+327:     "picture"   : WEBP_HINT_PICTURE,
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PICTURE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_picture, __pyx_t_6) < 0) __PYX_ERR(0, 327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CONTENT_TYPE_HINT, __pyx_t_1) < 0) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 328:     }
 329: 
+330: cdef WebPImageHint DEFAULT_IMAGE_HINT = HINT_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_IMAGE_HINT", "graph").lower(), WEBP_HINT_GRAPH)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_HINT_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_GRAPH); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_WebPImageHint(__pyx_t_1); if (unlikely((__pyx_t_12 == ((WebPImageHint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_IMAGE_HINT = __pyx_t_12;
/* … */
  __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_IMAGE_HINT, __pyx_n_s_graph); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
+331: cdef WebPPreset DEFAULT_PRESET = PRESET_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_PRESET", "text").lower(), WEBP_PRESET_TEXT)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_lower); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_13 = __Pyx_PyInt_As_WebPPreset(__pyx_t_1); if (unlikely((__pyx_t_13 == ((WebPPreset)-1)) && PyErr_Occurred())) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_PRESET = __pyx_t_13;
/* … */
  __pyx_tuple__16 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_PRESET, __pyx_n_s_text); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
+332: cdef WebPPreset PRESET_SMALL = PRESET_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_PRESET_SMALL", "icon").lower(), WEBP_PRESET_ICON)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_lower); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_ICON); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __pyx_t_9 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_13 = __Pyx_PyInt_As_WebPPreset(__pyx_t_1); if (unlikely((__pyx_t_13 == ((WebPPreset)-1)) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_PRESET_SMALL = __pyx_t_13;
/* … */
  __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_s_XPRA_WEBP_PRESET_SMALL, __pyx_n_s_icon); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);
 333: 
 334: 
+335: def get_encodings():
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_1get_encodings(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_1get_encodings = {"get_encodings", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_1get_encodings, METH_NOARGS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_1get_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_6encode_get_encodings(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_get_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.encode.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_6encode_1get_encodings, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_encodings, __pyx_t_1) < 0) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_codeobj__18 = (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_encode_pyx, __pyx_n_s_get_encodings, 335, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 335, __pyx_L1_error)
+336:     return ["webp"]
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __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;
 337: 
+338: def get_version():
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_3get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_3get_version = {"get_version", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_3get_version, METH_NOARGS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_3get_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_6encode_2get_version(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_2get_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.encode.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_version); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_3get_version, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_1) < 0) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 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_encode_pyx, __pyx_n_s_get_version, 338, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 338, __pyx_L1_error)
+339:     cdef int version = WebPGetEncoderVersion()
  __pyx_v_version = WebPGetEncoderVersion();
+340:     log("WebPGetEncoderVersion()=%#x", version)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __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(0, 340, __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_WebPGetEncoderVersion_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(0, 340, __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_WebPGetEncoderVersion_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(0, 340, __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(0, 340, __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_WebPGetEncoderVersion_x);
    __Pyx_GIVEREF(__pyx_kp_s_WebPGetEncoderVersion_x);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_WebPGetEncoderVersion_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(0, 340, __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;
+341:     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(0, 341, __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(0, 341, __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(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 341, __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;
 342: 
+343: def get_info():
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_5get_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_5get_info = {"get_info", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_5get_info, METH_NOARGS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_5get_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_6encode_4get_info(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_4get_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.encode.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_6encode_5get_info, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_info, __pyx_t_1) < 0) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_codeobj__21 = (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_encode_pyx, __pyx_n_s_get_info, 343, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 343, __pyx_L1_error)
+344:     return  {
  __Pyx_XDECREF(__pyx_r);
+345:             "version"       : get_version(),
  __pyx_t_1 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __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(0, 345, __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(0, 345, __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(0, 345, __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(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+346:             "encodings"     : get_encodings(),
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_encodings); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __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(0, 346, __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(0, 346, __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(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+347:             "threading"     : bool(WEBP_THREADING),
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_4webp_6encode_WEBP_THREADING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_5))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_threading, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+348:             "image-hint"    : DEFAULT_IMAGE_HINT,
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_IMAGE_HINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s_image_hint, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+349:             "image-hints"   : IMAGE_HINT.values(),
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s_image_hints, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+350:             "preset"        : DEFAULT_PRESET,
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(__pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_PRESET); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_preset, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+351:             "preset-small"  : PRESET_SMALL,
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(__pyx_v_4xpra_6codecs_4webp_6encode_PRESET_SMALL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s_preset_small, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+352:             "presets"       : PRESETS.values(),
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESETS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __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(0, 352, __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(0, 352, __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_presets, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 353:             }
 354: 
+355: def webp_check(int ret):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_7webp_check(PyObject *__pyx_self, PyObject *__pyx_arg_ret); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_7webp_check = {"webp_check", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_7webp_check, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_7webp_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(0, 355, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.webp.encode.webp_check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6encode_6webp_check(__pyx_self, ((int)__pyx_v_ret));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_6webp_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.encode.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__22 = PyTuple_Pack(3, __pyx_n_s_ret, __pyx_n_s_ret, __pyx_n_s_err); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_7webp_check, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_webp_check, __pyx_t_1) < 0) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_encode_pyx, __pyx_n_s_webp_check, 355, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 355, __pyx_L1_error)
+356:     if ret==0:
  __pyx_t_1 = ((__pyx_v_ret == 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+357:         return
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+358:     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(0, 358, __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(0, 358, __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(0, 358, __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(0, 358, __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(0, 358, __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(0, 358, __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(0, 358, __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(0, 358, __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;
+359:     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(0, 359, __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(0, 359, __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(0, 359, __pyx_L1_error)
 360: 
+361: cdef float fclamp(int v):
static float __pyx_f_4xpra_6codecs_4webp_6encode_fclamp(int __pyx_v_v) {
  float __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fclamp", 0);
/* … */
  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+362:     if v<0:
  __pyx_t_1 = ((__pyx_v_v < 0) != 0);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L3;
  }
+363:         v = 0
    __pyx_v_v = 0;
+364:     elif v>100:
  __pyx_t_1 = ((__pyx_v_v > 0x64) != 0);
  if (__pyx_t_1) {
/* … */
  }
  __pyx_L3:;
+365:         v = 100
    __pyx_v_v = 0x64;
+366:     return <float> v
  __pyx_r = ((float)__pyx_v_v);
  goto __pyx_L0;
 367: 
 368: 
+369: cdef get_config_info(WebPConfig *config):
static PyObject *__pyx_f_4xpra_6codecs_4webp_6encode_get_config_info(WebPConfig *__pyx_v_config) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_config_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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("xpra.codecs.webp.encode.get_config_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+370:     return {
  __Pyx_XDECREF(__pyx_r);
+371:         "lossless"          : config.lossless,
  __pyx_t_1 = __Pyx_PyDict_NewPresized(22); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->lossless); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_lossless, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+372:         "method"            : config.method,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->method); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_method, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+373:         "image_hint"        : IMAGE_HINT.get(config.image_hint, config.image_hint),
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __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(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_config->image_hint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_config->image_hint); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 373, __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(0, 373, __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(0, 373, __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(0, 373, __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(0, 373, __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;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_image_hint_2, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+374:         "target_size"       : config.target_size,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->target_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_target_size, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+375:         "target_PSNR"       : config.target_PSNR,
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_config->target_PSNR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_target_PSNR, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+376:         "segments"          : config.segments,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->segments); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_segments, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+377:         "sns_strength"      : config.sns_strength,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->sns_strength); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sns_strength, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+378:         "filter_strength"   : config.filter_strength,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->filter_strength); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_filter_strength, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+379:         "filter_sharpness"  : config.filter_sharpness,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->filter_sharpness); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_filter_sharpness, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+380:         "filter_type"       : config.filter_type,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->filter_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_filter_type, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+381:         "autofilter"        : config.autofilter,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->autofilter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_autofilter, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+382:         "alpha_compression" : config.alpha_compression,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->alpha_compression); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alpha_compression, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+383:         "alpha_filtering"   : config.alpha_filtering,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->alpha_filtering); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alpha_filtering, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+384:         "alpha_quality"     : config.alpha_quality,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->alpha_quality); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alpha_quality, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+385:         "pass"              : config._pass,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->pass); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pass, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+386:         "show_compressed"   : config.show_compressed,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->show_compressed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_show_compressed, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+387:         "preprocessing"     : config.preprocessing,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->preprocessing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_preprocessing, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+388:         "partitions"        : config.partitions,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->partitions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_partitions, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+389:         "partition_limit"   : config.partition_limit,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->partition_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_partition_limit, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+390:         "emulate_jpeg_size" : config.emulate_jpeg_size,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->emulate_jpeg_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_emulate_jpeg_size, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+391:         "thread_level"      : config.thread_level,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->thread_level); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_thread_level, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+392:         "low_memory"        : config.low_memory,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->low_memory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_low_memory, __pyx_t_2) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 393:         }
 394: 
+395: def compress(image, int quality=50, int speed=50, supports_alpha=False, content_type=""):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_9compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_9compress = {"compress", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_9compress, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_9compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_image = 0;
  int __pyx_v_quality;
  int __pyx_v_speed;
  PyObject *__pyx_v_supports_alpha = 0;
  PyObject *__pyx_v_content_type = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compress (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_quality,&__pyx_n_s_speed,&__pyx_n_s_supports_alpha,&__pyx_n_s_content_type,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[3] = ((PyObject *)Py_False);
    values[4] = ((PyObject *)__pyx_kp_s_);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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_image)) != 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_quality);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_speed);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_supports_alpha);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_content_type);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compress") < 0)) __PYX_ERR(0, 395, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_image = values[0];
    if (values[1]) {
      __pyx_v_quality = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_quality == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error)
    } else {
      __pyx_v_quality = ((int)50);
    }
    if (values[2]) {
      __pyx_v_speed = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_speed == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error)
    } else {
      __pyx_v_speed = ((int)50);
    }
    __pyx_v_supports_alpha = values[3];
    __pyx_v_content_type = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compress", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 395, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.webp.encode.compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6encode_8compress(__pyx_self, __pyx_v_image, __pyx_v_quality, __pyx_v_speed, __pyx_v_supports_alpha, __pyx_v_content_type);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_8compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, int __pyx_v_quality, int __pyx_v_speed, PyObject *__pyx_v_supports_alpha, PyObject *__pyx_v_content_type) {
  PyObject *__pyx_v_pixel_format = NULL;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_stride;
  unsigned int __pyx_v_Bpp;
  PyObject *__pyx_v_pixels = NULL;
  uint8_t *__pyx_v_pic_buf;
  Py_ssize_t __pyx_v_pic_buf_len;
  WebPConfig __pyx_v_config;
  WebPPreset __pyx_v_preset;
  WebPImageHint __pyx_v_image_hint;
  int __pyx_v_ret;
  int __pyx_v_size;
  int __pyx_v_i;
  int __pyx_v_alpha_int;
  int __pyx_v_use_argb;
  PyObject *__pyx_v_info = NULL;
  WebPPicture __pyx_v_pic;
  PyObject *__pyx_v_client_options = NULL;
  WebPMemoryWriter __pyx_v_memory_writer;
  PyObject *__pyx_v_cdata = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compress", 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_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("xpra.codecs.webp.encode.compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pixel_format);
  __Pyx_XDECREF(__pyx_v_pixels);
  __Pyx_XDECREF(__pyx_v_info);
  __Pyx_XDECREF(__pyx_v_client_options);
  __Pyx_XDECREF(__pyx_v_cdata);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__24 = PyTuple_Pack(26, __pyx_n_s_image, __pyx_n_s_quality, __pyx_n_s_speed, __pyx_n_s_supports_alpha, __pyx_n_s_content_type, __pyx_n_s_pixel_format, __pyx_n_s_width, __pyx_n_s_height, __pyx_n_s_stride, __pyx_n_s_Bpp, __pyx_n_s_pixels, __pyx_n_s_pic_buf, __pyx_n_s_pic_buf_len, __pyx_n_s_config, __pyx_n_s_preset, __pyx_n_s_image_hint_2, __pyx_n_s_ret, __pyx_n_s_size, __pyx_n_s_i, __pyx_n_s_alpha_int, __pyx_n_s_use_argb, __pyx_n_s_info, __pyx_n_s_pic, __pyx_n_s_client_options, __pyx_n_s_memory_writer, __pyx_n_s_cdata); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_9compress, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compress, __pyx_t_1) < 0) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(5, 0, 26, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_webp_encode_pyx, __pyx_n_s_compress, 395, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 395, __pyx_L1_error)
+396:     pixel_format = image.get_pixel_format()
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pixel_format = __pyx_t_1;
  __pyx_t_1 = 0;
+397:     if pixel_format not in ("RGBX", "RGBA", "BGRX", "BGRA"):
  __Pyx_INCREF(__pyx_v_pixel_format);
  __pyx_t_1 = __pyx_v_pixel_format;
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_RGBX, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 397, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_RGBA, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 397, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_BGRX, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 397, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_BGRA, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 397, __pyx_L1_error)
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+398:         raise Exception("unsupported pixel format %s" % pixel_format)
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_unsupported_pixel_format_s, __pyx_v_pixel_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 398, __pyx_L1_error)
+399:     cdef unsigned int width = image.get_width()
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_width); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_width = __pyx_t_6;
+400:     cdef unsigned int height = image.get_height()
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_height = __pyx_t_6;
+401:     cdef unsigned int stride = image.get_rowstride()
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_rowstride); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_stride = __pyx_t_6;
+402:     cdef unsigned int Bpp = len(pixel_format)
  __pyx_t_7 = PyObject_Length(__pyx_v_pixel_format); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 402, __pyx_L1_error)
  __pyx_v_Bpp = __pyx_t_7;
+403:     if width>WEBP_MAX_DIMENSION or height>WEBP_MAX_DIMENSION:
  __pyx_t_4 = ((__pyx_v_width > 0x3FFF) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_height > 0x3FFF) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L9_bool_binop_done:;
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+404:         raise Exception("this image is too big for webp: %ix%i" % (width, height))
    __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_this_image_is_too_big_for_webp_i, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 404, __pyx_L1_error)
+405:     pixels = image.get_pixels()
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_pixels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_pixels = __pyx_t_3;
  __pyx_t_3 = 0;
 406: 
 407:     cdef uint8_t *pic_buf
+408:     cdef Py_ssize_t pic_buf_len = 0
  __pyx_v_pic_buf_len = 0;
 409:     cdef WebPConfig config
+410:     cdef WebPPreset preset = DEFAULT_PRESET
  __pyx_v_preset = __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_PRESET;
 411:     #only use icon for small squarish rectangles
+412:     if width*height<=2304 and abs(width-height)<=16:
  __pyx_t_4 = (((__pyx_v_width * __pyx_v_height) <= 0x900) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_4 = ((/*abs_unsigned_int*/((__pyx_v_width - __pyx_v_height)) <= 16) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_5) {
/* … */
  }
+413:         preset = PRESET_SMALL
    __pyx_v_preset = __pyx_v_4xpra_6codecs_4webp_6encode_PRESET_SMALL;
+414:     preset = CONTENT_TYPE_PRESET.get(content_type, preset)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_CONTENT_TYPE_PRESET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(__pyx_v_preset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_content_type, __pyx_t_1};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_content_type, __pyx_t_1};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_v_content_type);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_WebPPreset(__pyx_t_3); if (unlikely((__pyx_t_11 == ((WebPPreset)-1)) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_preset = __pyx_t_11;
+415:     cdef WebPImageHint image_hint = CONTENT_TYPE_HINT.get(content_type, DEFAULT_IMAGE_HINT)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CONTENT_TYPE_HINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_IMAGE_HINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_content_type, __pyx_t_2};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_content_type, __pyx_t_2};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_v_content_type);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_WebPImageHint(__pyx_t_3); if (unlikely((__pyx_t_12 == ((WebPImageHint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_image_hint = __pyx_t_12;
 416: 
+417:     cdef int ret = object_as_buffer(pixels, <const void**> &pic_buf, &pic_buf_len)
  __pyx_v_ret = __pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_pixels, ((void const **)(&__pyx_v_pic_buf)), (&__pyx_v_pic_buf_len));
+418:     assert ret==0, "failed to get buffer from pixel object: %s (returned %s)" % (type(pixels), ret)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ret == 0) != 0))) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ret); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
      __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_get_buffer_from_pixel, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 418, __pyx_L1_error)
    }
  }
  #endif
+419:     log("webp.compress(%s, %i, %i, %s, %s) buf=%#x", image, width, height, supports_alpha, content_type, <uintptr_t> pic_buf)
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_8 = __Pyx_PyInt_From_unsigned_int(__pyx_v_width); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_height); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_pic_buf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_13 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_kp_s_webp_compress_s_i_i_s_s_buf_x, __pyx_v_image, __pyx_t_8, __pyx_t_2, __pyx_v_supports_alpha, __pyx_v_content_type, __pyx_t_1};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_kp_s_webp_compress_s_i_i_s_s_buf_x, __pyx_v_image, __pyx_t_8, __pyx_t_2, __pyx_v_supports_alpha, __pyx_v_content_type, __pyx_t_1};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_webp_compress_s_i_i_s_s_buf_x);
    __Pyx_GIVEREF(__pyx_kp_s_webp_compress_s_i_i_s_s_buf_x);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_kp_s_webp_compress_s_i_i_s_s_buf_x);
    __Pyx_INCREF(__pyx_v_image);
    __Pyx_GIVEREF(__pyx_v_image);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_v_image);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_9, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_supports_alpha);
    __Pyx_GIVEREF(__pyx_v_supports_alpha);
    PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_9, __pyx_v_supports_alpha);
    __Pyx_INCREF(__pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_v_content_type);
    PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_9, __pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_9, __pyx_t_1);
    __pyx_t_8 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+420:     cdef int size = stride * height
  __pyx_v_size = (__pyx_v_stride * __pyx_v_height);
+421:     assert pic_buf_len>=size, "pixel buffer is too small: expected at least %s bytes but got %s" % (size, pic_buf_len)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_pic_buf_len >= __pyx_v_size) != 0))) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_pic_buf_len); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_10);
      __pyx_t_3 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_pixel_buffer_is_too_small_expect, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 421, __pyx_L1_error)
    }
  }
  #endif
 422: 
 423:     cdef int i
+424:     cdef int alpha_int = int(supports_alpha and pixel_format.find("A")>=0)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_supports_alpha); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 424, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __Pyx_INCREF(__pyx_v_supports_alpha);
    __pyx_t_10 = __pyx_v_supports_alpha;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_pixel_format, __pyx_n_s_find); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_t_14);
  __pyx_t_10 = __pyx_t_14;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_t_14 = __Pyx_PyNumber_Int(__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_v_alpha_int = __pyx_t_9;
/* … */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_n_s_A); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
+425:     cdef int use_argb = int(quality>=SUBSAMPLING_THRESHOLD)
  __pyx_v_use_argb = ((int)(__pyx_v_quality >= __pyx_v_4xpra_6codecs_4webp_6encode_SUBSAMPLING_THRESHOLD));
+426:     if alpha_int==0 and Bpp==4:
  __pyx_t_4 = ((__pyx_v_alpha_int == 0) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L17_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_Bpp == 4) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L17_bool_binop_done:;
  if (__pyx_t_5) {
/* … */
  }
 427:         #ensure webp will not decide to encode the alpha channel
 428:         #(this is stupid: we should be able to pass a flag instead)
+429:         i = 3
    __pyx_v_i = 3;
+430:         while i<size:
    while (1) {
      __pyx_t_5 = ((__pyx_v_i < __pyx_v_size) != 0);
      if (!__pyx_t_5) break;
+431:             pic_buf[i] = 0xff
      (__pyx_v_pic_buf[__pyx_v_i]) = 0xff;
+432:             i += 4
      __pyx_v_i = (__pyx_v_i + 4);
    }
 433: 
+434:     ret = WebPConfigInit(&config)
  __pyx_v_ret = WebPConfigInit((&__pyx_v_config));
+435:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+436:         raise Exception("failed to initialize webp config")
    __pyx_t_14 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 436, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_Raise(__pyx_t_14, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __PYX_ERR(0, 436, __pyx_L1_error)
/* … */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_failed_to_initialize_webp_config); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
 437: 
+438:     ret = WebPConfigPreset(&config, preset, fclamp(quality))
  __pyx_v_ret = WebPConfigPreset((&__pyx_v_config), __pyx_v_preset, __pyx_f_4xpra_6codecs_4webp_6encode_fclamp(__pyx_v_quality));
+439:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+440:         raise Exception("failed to set webp preset")
    __pyx_t_14 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_Raise(__pyx_t_14, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __PYX_ERR(0, 440, __pyx_L1_error)
/* … */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_failed_to_set_webp_preset); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
 441: 
 442:     #tune it:
+443:     config.lossless = quality>=LOSSLESS_THRESHOLD
  __pyx_v_config.lossless = (__pyx_v_quality >= __pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD);
+444:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L23;
  }
 445:         #not much to gain from setting a high quality here,
 446:         #the latency will be higher for a negligible compression gain:
+447:         config.quality = fclamp(50-speed//2)
    __pyx_v_config.quality = __pyx_f_4xpra_6codecs_4webp_6encode_fclamp((50 - __Pyx_div_long(__pyx_v_speed, 2)));
 448:     else:
 449:         #normalize quality: webp quality is much higher than jpeg's
 450:         #so we can go lower,
 451:         #[0,10,...,90,100] maps to:
 452:         #[0, 3, 7, 13, 20, 29, 40, 52, 66, 82, 100]
+453:         config.quality = fclamp(((quality+10)**2//121))
  /*else*/ {
    __pyx_v_config.quality = __pyx_f_4xpra_6codecs_4webp_6encode_fclamp(__Pyx_div_long(__Pyx_pow_long((__pyx_v_quality + 10), 2), 0x79));
  }
  __pyx_L23:;
 454:     #"method" takes values from 0 to 6,
 455:     #but anything higher than 1 is dreadfully slow,
 456:     #so only use method=1 when speed is already very low
+457:     config.method = int(speed<10)
  __pyx_v_config.method = ((int)(__pyx_v_speed < 10));
+458:     config.alpha_compression = alpha_int
  __pyx_v_config.alpha_compression = __pyx_v_alpha_int;
+459:     config.alpha_filtering = MAX(0, MIN(2, speed/50)) * alpha_int
  __pyx_v_config.alpha_filtering = (__pyx_f_4xpra_6codecs_4webp_6encode_MAX(0, __pyx_f_4xpra_6codecs_4webp_6encode_MIN(2, __Pyx_div_long(__pyx_v_speed, 50))) * __pyx_v_alpha_int);
+460:     config.alpha_quality = quality * alpha_int
  __pyx_v_config.alpha_quality = (__pyx_v_quality * __pyx_v_alpha_int);
+461:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L24;
  }
+462:         config.autofilter = 1
    __pyx_v_config.autofilter = 1;
 463:     else:
+464:         config.segments = 1
  /*else*/ {
    __pyx_v_config.segments = 1;
+465:         config.sns_strength = 0
    __pyx_v_config.sns_strength = 0;
+466:         config.filter_strength = 0
    __pyx_v_config.filter_strength = 0;
+467:         config.filter_sharpness = 7-quality//15
    __pyx_v_config.filter_sharpness = (7 - __Pyx_div_long(__pyx_v_quality, 15));
+468:         config.filter_type = 0
    __pyx_v_config.filter_type = 0;
+469:         config.autofilter = 0
    __pyx_v_config.autofilter = 0;
  }
  __pyx_L24:;
+470:     config._pass = MAX(1, MIN(10, (100-speed)//10))
  __pyx_v_config.pass = __pyx_f_4xpra_6codecs_4webp_6encode_MAX(1, __pyx_f_4xpra_6codecs_4webp_6encode_MIN(10, __Pyx_div_long((0x64 - __pyx_v_speed), 10)));
+471:     config.preprocessing = int(speed<50)
  __pyx_v_config.preprocessing = ((int)(__pyx_v_speed < 50));
+472:     config.image_hint = image_hint
  __pyx_v_config.image_hint = __pyx_v_image_hint;
+473:     config.thread_level = WEBP_THREADING
  __pyx_v_config.thread_level = __pyx_v_4xpra_6codecs_4webp_6encode_WEBP_THREADING;
+474:     config.partitions = 3
  __pyx_v_config.partitions = 3;
+475:     config.partition_limit = MAX(0, MIN(100, 100-quality))
  __pyx_v_config.partition_limit = __pyx_f_4xpra_6codecs_4webp_6encode_MAX(0, __pyx_f_4xpra_6codecs_4webp_6encode_MIN(0x64, (0x64 - __pyx_v_quality)));
 476: 
+477:     log("webp.compress config: lossless=%-5s, quality=%3i, method=%i, alpha=%3i,%3i,%3i, preset=%-8s, image hint=%s", config.lossless, config.quality, config.method,
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_config.lossless); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_config.quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config.method); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+478:                     config.alpha_compression, config.alpha_filtering, config.alpha_quality, PRESETS.get(preset, preset), IMAGE_HINT.get(image_hint, image_hint))
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_config.alpha_compression); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_config.alpha_filtering); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_config.alpha_quality); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESETS); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_get); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = __Pyx_PyInt_From_WebPPreset(__pyx_v_preset); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_19 = __Pyx_PyInt_From_WebPPreset(__pyx_v_preset); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_18);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_18, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_18)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_17, __pyx_t_19};
    __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_18)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_17, __pyx_t_19};
    __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  } else
  #endif
  {
    __pyx_t_21 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_9, __pyx_t_17);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_9, __pyx_t_19);
    __pyx_t_17 = 0;
    __pyx_t_19 = 0;
    __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_21, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  }
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_get); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_21 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_image_hint); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_17 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_image_hint); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_20 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_19);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_19, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_21, __pyx_t_17};
    __pyx_t_18 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_21, __pyx_t_17};
    __pyx_t_18 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_9, __pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_9, __pyx_t_17);
    __pyx_t_21 = 0;
    __pyx_t_17 = 0;
    __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_22, NULL); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[10] = {__pyx_t_19, __pyx_kp_s_webp_compress_config_lossless_5s, __pyx_t_3, __pyx_t_1, __pyx_t_2, __pyx_t_8, __pyx_t_13, __pyx_t_15, __pyx_t_16, __pyx_t_18};
    __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 9+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_14);
    __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;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[10] = {__pyx_t_19, __pyx_kp_s_webp_compress_config_lossless_5s, __pyx_t_3, __pyx_t_1, __pyx_t_2, __pyx_t_8, __pyx_t_13, __pyx_t_15, __pyx_t_16, __pyx_t_18};
    __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 9+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_14);
    __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;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(9+__pyx_t_9); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_19) {
      __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_19); __pyx_t_19 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_webp_compress_config_lossless_5s);
    __Pyx_GIVEREF(__pyx_kp_s_webp_compress_config_lossless_5s);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_9, __pyx_kp_s_webp_compress_config_lossless_5s);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_9, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_22, 3+__pyx_t_9, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_22, 4+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_22, 5+__pyx_t_9, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_22, 6+__pyx_t_9, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_22, 7+__pyx_t_9, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_22, 8+__pyx_t_9, __pyx_t_18);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_8 = 0;
    __pyx_t_13 = 0;
    __pyx_t_15 = 0;
    __pyx_t_16 = 0;
    __pyx_t_18 = 0;
    __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_22, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+479:     ret = WebPValidateConfig(&config)
  __pyx_v_ret = WebPValidateConfig((&__pyx_v_config));
+480:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+481:         info = get_config_info(&config)
    __pyx_t_14 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_v_info = __pyx_t_14;
    __pyx_t_14 = 0;
+482:         raise Exception("invalid webp configuration: %s" % info)
    __pyx_t_14 = __Pyx_PyString_Format(__pyx_kp_s_invalid_webp_configuration_s, __pyx_v_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 482, __pyx_L1_error)
 483: 
 484:     cdef WebPPicture pic
+485:     ret = WebPPictureInit(&pic)
  __pyx_v_ret = WebPPictureInit((&__pyx_v_pic));
+486:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+487:         raise Exception("failed to initialise webp picture")
    __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 487, __pyx_L1_error)
/* … */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_failed_to_initialise_webp_pictur); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
 488: 
 489:     client_options = {
 490:         #no need to expose speed
 491:         #(not used for anything downstream)
 492:         #"speed"       : speed,
+493:         "rgb_format"  : pixel_format,
  __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_rgb_format, __pyx_v_pixel_format) < 0) __PYX_ERR(0, 493, __pyx_L1_error)
  __pyx_v_client_options = ((PyObject*)__pyx_t_10);
  __pyx_t_10 = 0;
 494:         }
 495: 
+496:     memset(&pic, 0, sizeof(WebPPicture))
  (void)(memset((&__pyx_v_pic), 0, (sizeof(WebPPicture))));
+497:     pic.width = width
  __pyx_v_pic.width = __pyx_v_width;
+498:     pic.height = height
  __pyx_v_pic.height = __pyx_v_height;
+499:     pic.use_argb = 1
  __pyx_v_pic.use_argb = 1;
+500:     pic.argb = <uint32_t*> pic_buf
  __pyx_v_pic.argb = ((uint32_t *)__pyx_v_pic_buf);
+501:     pic.argb_stride = stride//Bpp
  if (unlikely(__pyx_v_Bpp == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 501, __pyx_L1_error)
  }
  __pyx_v_pic.argb_stride = (__pyx_v_stride / __pyx_v_Bpp);
+502:     if not use_argb:
  __pyx_t_5 = ((!(__pyx_v_use_argb != 0)) != 0);
  if (__pyx_t_5) {
/* … */
  }
+503:         if WebPPictureARGBToYUVA(&pic, WEBP_YUV420A):
    __pyx_t_5 = (WebPPictureARGBToYUVA((&__pyx_v_pic), WEBP_YUV420A) != 0);
    if (likely(__pyx_t_5)) {
/* … */
      goto __pyx_L28;
    }
+504:             client_options["subsampling"] = "YUV420P"
      if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_subsampling, __pyx_n_s_YUV420P) < 0)) __PYX_ERR(0, 504, __pyx_L1_error)
 505:             #redundant (changed by WebPPictureARGBToYUVA):
 506:             #pic.use_argb = 0
 507:         else:
+508:             raise Exception("failed to convert picture to YUV")
    /*else*/ {
      __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 508, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 508, __pyx_L1_error)
    }
    __pyx_L28:;
/* … */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_failed_to_convert_picture_to_YUV); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
 509: 
 510:     #TODO: custom writer that over-allocates memory
 511:     cdef WebPMemoryWriter memory_writer
+512:     WebPMemoryWriterInit(&memory_writer)
  WebPMemoryWriterInit((&__pyx_v_memory_writer));
+513:     pic.writer = <WebPWriterFunction> WebPMemoryWrite
  __pyx_v_pic.writer = ((WebPWriterFunction)WebPMemoryWrite);
+514:     pic.custom_ptr = <void*> &memory_writer
  __pyx_v_pic.custom_ptr = ((void *)(&__pyx_v_memory_writer));
+515:     ret = WebPEncode(&config, &pic)
  __pyx_v_ret = WebPEncode((&__pyx_v_config), (&__pyx_v_pic));
+516:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+517:         raise Exception("WebPEncode failed: %s, config=%s" % (ERROR_TO_NAME.get(pic.error_code, pic.error_code), get_config_info(&config)))
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_ERROR_TO_NAME); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_get); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = __Pyx_PyInt_From_WebPEncodingError(__pyx_v_pic.error_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_18 = __Pyx_PyInt_From_WebPEncodingError(__pyx_v_pic.error_code); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __pyx_t_16 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_22))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_22);
      if (likely(__pyx_t_16)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
        __Pyx_INCREF(__pyx_t_16);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_22, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_14, __pyx_t_18};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_14, __pyx_t_18};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    } else
    #endif
    {
      __pyx_t_15 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_16) {
        __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_16); __pyx_t_16 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_9, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_9, __pyx_t_18);
      __pyx_t_14 = 0;
      __pyx_t_18 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_15, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __pyx_t_22 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_22);
    __pyx_t_10 = 0;
    __pyx_t_22 = 0;
    __pyx_t_22 = __Pyx_PyString_Format(__pyx_kp_s_WebPEncode_failed_s_config_s, __pyx_t_15); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_22); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_Raise(__pyx_t_15, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __PYX_ERR(0, 517, __pyx_L1_error)
 518: 
+519:     cdata = memory_writer.mem[:memory_writer.size]
  __pyx_t_15 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_memory_writer.mem) + 0, __pyx_v_memory_writer.size - 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_v_cdata = ((PyObject*)__pyx_t_15);
  __pyx_t_15 = 0;
+520:     free(memory_writer.mem)
  free(__pyx_v_memory_writer.mem);
+521:     WebPPictureFree(&pic)
  WebPPictureFree((&__pyx_v_pic));
+522:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L30;
  }
+523:         client_options["quality"] = 100
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_quality, __pyx_int_100) < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
+524:     elif quality>=0 and quality<=100:
  __pyx_t_4 = ((__pyx_v_quality >= 0) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_quality <= 0x64) != 0);
  __pyx_t_5 = __pyx_t_4;
  __pyx_L31_bool_binop_done:;
  if (__pyx_t_5) {
/* … */
  }
  __pyx_L30:;
+525:         client_options["quality"] = quality
    __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_quality); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_quality, __pyx_t_15) < 0)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+526:     if alpha_int:
  __pyx_t_5 = (__pyx_v_alpha_int != 0);
  if (__pyx_t_5) {
/* … */
  }
+527:         client_options["has_alpha"] = True
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_has_alpha, Py_True) < 0)) __PYX_ERR(0, 527, __pyx_L1_error)
+528:     log("webp.compress ratio=%i%%, client-options=%s", 100*memory_writer.size//size, client_options)
  __pyx_t_22 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_23 = (0x64 * __pyx_v_memory_writer.size);
  if (unlikely(__pyx_v_size == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 528, __pyx_L1_error)
  }
  __pyx_t_10 = __Pyx_PyInt_FromSize_t((__pyx_t_23 / __pyx_v_size)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_18 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_22))) {
    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_22);
    if (likely(__pyx_t_18)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
      __Pyx_INCREF(__pyx_t_18);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_22, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_kp_s_webp_compress_ratio_i_client_opt, __pyx_t_10, __pyx_v_client_options};
    __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_kp_s_webp_compress_ratio_i_client_opt, __pyx_t_10, __pyx_v_client_options};
    __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_18) {
      __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_18); __pyx_t_18 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_webp_compress_ratio_i_client_opt);
    __Pyx_GIVEREF(__pyx_kp_s_webp_compress_ratio_i_client_opt);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_kp_s_webp_compress_ratio_i_client_opt);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_t_10);
    __Pyx_INCREF(__pyx_v_client_options);
    __Pyx_GIVEREF(__pyx_v_client_options);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_9, __pyx_v_client_options);
    __pyx_t_10 = 0;
    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_14, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+529:     if LOG_CONFIG>0:
  __pyx_t_5 = ((__pyx_v_4xpra_6codecs_4webp_6encode_LOG_CONFIG > 0) != 0);
  if (__pyx_t_5) {
/* … */
  }
+530:         log("webp.compress used config: %s", get_config_info(&config))
    __pyx_t_22 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_14 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_10 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_22))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_22);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_22, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_webp_compress_used_config_s, __pyx_t_14};
      __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 530, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_webp_compress_used_config_s, __pyx_t_14};
      __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 530, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    } else
    #endif
    {
      __pyx_t_18 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_webp_compress_used_config_s);
      __Pyx_GIVEREF(__pyx_kp_s_webp_compress_used_config_s);
      PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_9, __pyx_kp_s_webp_compress_used_config_s);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_9, __pyx_t_14);
      __pyx_t_14 = 0;
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_18, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    }
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+531:     return cdata, client_options
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_INCREF(__pyx_v_cdata);
  __Pyx_GIVEREF(__pyx_v_cdata);
  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_cdata);
  __Pyx_INCREF(__pyx_v_client_options);
  __Pyx_GIVEREF(__pyx_v_client_options);
  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_client_options);
  __pyx_r = __pyx_t_15;
  __pyx_t_15 = 0;
  goto __pyx_L0;
 532: 
 533: 
+534: def selftest(full=False):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_11selftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4webp_6encode_11selftest = {"selftest", (PyCFunction)__pyx_pw_4xpra_6codecs_4webp_6encode_11selftest, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4webp_6encode_11selftest(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(0, 534, __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(0, 534, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.webp.encode.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_4webp_6encode_10selftest(__pyx_self, __pyx_v_full);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4webp_6encode_10selftest(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_full) {
  PyObject *__pyx_v_make_test_image = NULL;
  PyObject *__pyx_v_w = NULL;
  PyObject *__pyx_v_h = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_pixels = NULL;
  PyObject *__pyx_v_has_alpha = NULL;
  PyObject *__pyx_v_img = NULL;
  PyObject *__pyx_v_q = NULL;
  PyObject *__pyx_v_r = 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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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.encode.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_make_test_image);
  __Pyx_XDECREF(__pyx_v_w);
  __Pyx_XDECREF(__pyx_v_h);
  __Pyx_XDECREF(__pyx_v_pixels);
  __Pyx_XDECREF(__pyx_v_has_alpha);
  __Pyx_XDECREF(__pyx_v_img);
  __Pyx_XDECREF(__pyx_v_q);
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__26 = PyTuple_Pack(9, __pyx_n_s_full, __pyx_n_s_make_test_image, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_pixels, __pyx_n_s_has_alpha, __pyx_n_s_img, __pyx_n_s_q, __pyx_n_s_r); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_11selftest, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_selftest, __pyx_t_1) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 535:     #fake empty buffer:
+536:     from xpra.codecs.codec_checks import make_test_image
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_make_test_image);
  __Pyx_GIVEREF(__pyx_n_s_make_test_image);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_make_test_image);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_codecs_codec_checks, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 536, __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_make_test_image); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_make_test_image = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+537:     w, h = 24, 16
  __pyx_t_2 = __pyx_int_24;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_1 = __pyx_int_16;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_w = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_h = __pyx_t_1;
  __pyx_t_1 = 0;
+538:     pixels = bytearray(b"\0" * w*h*4)
  __pyx_t_1 = PyNumber_Multiply(__pyx_kp_b__7, __pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_int_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_pixels = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
+539:     for has_alpha in (True, False):
  __pyx_t_2 = __pyx_tuple__8; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= 2) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 539, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_has_alpha, __pyx_t_1);
    __pyx_t_1 = 0;
/* … */
  __pyx_tuple__8 = PyTuple_Pack(2, Py_True, Py_False); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);
/* … */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+540:         img = make_test_image("BGR%s" % ["X", "A"][has_alpha], w, h)
    __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_n_s_X);
    __Pyx_GIVEREF(__pyx_n_s_X);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_X);
    __Pyx_INCREF(__pyx_n_s_A);
    __Pyx_GIVEREF(__pyx_n_s_A);
    PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_A);
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_has_alpha); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_BGR_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_v_make_test_image);
    __pyx_t_5 = __pyx_v_make_test_image; __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_v_w, __pyx_v_h};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_v_w, __pyx_v_h};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 540, __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_4);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_w);
      __Pyx_GIVEREF(__pyx_v_w);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_w);
      __Pyx_INCREF(__pyx_v_h);
      __Pyx_GIVEREF(__pyx_v_h);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_h);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_img, __pyx_t_1);
    __pyx_t_1 = 0;
+541:         for q in (10, 50, 90):
    __pyx_t_1 = __pyx_tuple__9; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
    for (;;) {
      if (__pyx_t_9 >= 3) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 541, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_q, __pyx_t_5);
      __pyx_t_5 = 0;
/* … */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_tuple__9 = PyTuple_Pack(3, __pyx_int_10, __pyx_int_50, __pyx_int_90); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
+542:             r = compress(img, quality=q, speed=50, supports_alpha=has_alpha)
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_compress); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_img);
      __Pyx_GIVEREF(__pyx_v_img);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_img);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_quality, __pyx_v_q) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_speed, __pyx_int_50) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_supports_alpha, __pyx_v_has_alpha) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 542, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_r, __pyx_t_6);
      __pyx_t_6 = 0;
+543:             assert len(r)>0
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_10 = PyObject_Length(__pyx_v_r); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 543, __pyx_L1_error)
        if (unlikely(!((__pyx_t_10 > 0) != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 543, __pyx_L1_error)
        }
      }
      #endif
 544:         #import binascii
 545:         #print("compressed data(%s)=%s" % (has_alpha, binascii.hexlify(r)))