Generated by Cython 0.29

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-2018 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: #cython: auto_pickle=False, cdivision=True, language_level=3
 007: 
 008: from __future__ import absolute_import
 009: 
+010: import os
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); 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_os, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 011: 
+012: from xpra.log import Logger
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __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, 12, __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, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+013: log = Logger("encoder", "webp")
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __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, 13, __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, 13, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_u_encoder, __pyx_n_u_webp); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
 014: 
 015: from xpra.buffers.membuf cimport object_as_buffer
+016: from xpra.os_util import bytestostr
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __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, 16, __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, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytestostr, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 017: 
+018: from xpra.util import envbool, envint
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __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, 18, __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, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_envbool, __pyx_t_2) < 0) __PYX_ERR(0, 18, __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, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_envint, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+019: cdef int LOG_CONFIG = envbool("XPRA_WEBP_LOG_CONFIG", False)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_envbool); 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__11, 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_LOG_CONFIG = __pyx_t_3;
/* … */
  __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_u_XPRA_WEBP_LOG_CONFIG, Py_False); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
+020: cdef int WEBP_THREADING = envbool("XPRA_WEBP_THREADING", True)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_envbool); 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__12, 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_WEBP_THREADING = __pyx_t_3;
/* … */
  __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_u_XPRA_WEBP_THREADING, Py_True); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
+021: cdef int LOSSLESS_THRESHOLD = envint("XPRA_WEBP_LOSSLESS_THRESHOLD", 75)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_envint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __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, 21, __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, 21, __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_u_XPRA_WEBP_LOSSLESS_THRESHOLD, __pyx_int_75); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
+022: cdef int SUBSAMPLING_THRESHOLD = envint("XPRA_WEBP_SUBSAMPLING_THRESHOLD", 40)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_envint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __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, 22, __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, 22, __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_u_XPRA_WEBP_SUBSAMPLING_THRESHOLD, __pyx_int_40); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
+023: 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_u_lossless_threshold_must_be_highe);
      __PYX_ERR(0, 23, __pyx_L1_error)
    }
  }
  #endif
+024: 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, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_invalid_lossless_threshold_i, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __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, 24, __pyx_L1_error)
    }
  }
  #endif
 025: 
+026: 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;
}
+027:     if a<=b:
  __pyx_t_1 = ((__pyx_v_a <= __pyx_v_b) != 0);
  if (__pyx_t_1) {
/* … */
  }
+028:         return a
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
+029:     return b
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;
+030: 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;
}
+031:     if a>=b:
  __pyx_t_1 = ((__pyx_v_a >= __pyx_v_b) != 0);
  if (__pyx_t_1) {
/* … */
  }
+032:         return a
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
+033:     return b
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;
 034: 
 035: 
 036: from libc.stdint cimport uint8_t, uint32_t, uintptr_t
 037: 
 038: cdef extern from "string.h":
 039:     void * memset ( void * ptr, int value, size_t num )
 040: 
 041: cdef extern from *:
 042:     ctypedef unsigned long size_t
 043: 
 044: cdef extern from "stdlib.h":
 045:     void free(void *ptr)
 046: 
 047: 
 048: DEF WEBP_MAX_DIMENSION = 16383
 049: 
 050: cdef extern from "webp/encode.h":
 051: 
 052:     int WebPGetEncoderVersion()
 053: 
 054:     ctypedef int WebPImageHint
 055:     # WebPImageHint:
 056:     WebPImageHint WEBP_HINT_DEFAULT     #default preset
 057:     WebPImageHint WEBP_HINT_PICTURE     #digital picture, like portrait, inner shot
 058:     WebPImageHint WEBP_HINT_PHOTO       #outdoor photograph, with natural lighting
 059:     WebPImageHint WEBP_HINT_GRAPH       #Discrete tone image (graph, map-tile etc).
 060: 
 061:     ctypedef int WebPPreset
 062:     WebPPreset WEBP_PRESET_DEFAULT      #default preset.
 063:     WebPPreset WEBP_PRESET_PICTURE      #digital picture, like portrait, inner shot
 064:     WebPPreset WEBP_PRESET_PHOTO        #outdoor photograph, with natural lighting
 065:     WebPPreset WEBP_PRESET_DRAWING      #hand or line drawing, with high-contrast details
 066:     WebPPreset WEBP_PRESET_ICON         #small-sized colorful images
 067:     WebPPreset WEBP_PRESET_TEXT         #text-like
 068: 
 069:     ctypedef int WebPEncCSP
 070:     #chroma sampling
 071:     WebPEncCSP WEBP_YUV420              #4:2:0
 072:     WebPEncCSP WEBP_YUV422              #4:2:2
 073:     WebPEncCSP WEBP_YUV444              #4:4:4
 074:     WebPEncCSP WEBP_YUV400              #grayscale
 075:     WebPEncCSP WEBP_CSP_UV_MASK         #bit-mask to get the UV sampling factors
 076:     WebPEncCSP WEBP_YUV420A
 077:     WebPEncCSP WEBP_YUV422A
 078:     WebPEncCSP WEBP_YUV444A
 079:     WebPEncCSP WEBP_YUV400A             #grayscale + alpha
 080:     WebPEncCSP WEBP_CSP_ALPHA_BIT       #bit that is set if alpha is present
 081: 
 082:     ctypedef int WebPEncodingError
 083:     WebPEncodingError VP8_ENC_OK
 084:     WebPEncodingError VP8_ENC_ERROR_OUT_OF_MEMORY
 085:     WebPEncodingError VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY
 086:     WebPEncodingError VP8_ENC_ERROR_NULL_PARAMETER
 087:     WebPEncodingError VP8_ENC_ERROR_INVALID_CONFIGURATION
 088:     WebPEncodingError VP8_ENC_ERROR_BAD_DIMENSION
 089:     WebPEncodingError VP8_ENC_ERROR_PARTITION0_OVERFLOW
 090:     WebPEncodingError VP8_ENC_ERROR_PARTITION_OVERFLOW
 091:     WebPEncodingError VP8_ENC_ERROR_BAD_WRITE
 092:     WebPEncodingError VP8_ENC_ERROR_FILE_TOO_BIG
 093:     WebPEncodingError VP8_ENC_ERROR_USER_ABORT
 094:     WebPEncodingError VP8_ENC_ERROR_LAST
 095: 
 096:     ctypedef struct WebPConfig:
 097:         int lossless                    #Lossless encoding (0=lossy(default), 1=lossless).
 098:         float quality                   #between 0 (smallest file) and 100 (biggest)
 099:         int method                      #quality/speed trade-off (0=fast, 6=slower-better)
 100: 
 101:         WebPImageHint image_hint        #Hint for image type (lossless only for now).
 102: 
 103:         #Parameters related to lossy compression only:
 104:         int target_size                 #if non-zero, set the desired target size in bytes.
 105:                                         #Takes precedence over the 'compression' parameter.
 106:         float target_PSNR               #if non-zero, specifies the minimal distortion to
 107:                                         #try to achieve. Takes precedence over target_size.
 108:         int segments                    #maximum number of segments to use, in [1..4]
 109:         int sns_strength                #Spatial Noise Shaping. 0=off, 100=maximum.
 110:         int filter_strength             #range: [0 = off .. 100 = strongest]
 111:         int filter_sharpness            #range: [0 = off .. 7 = least sharp]
 112:         int filter_type                 #filtering type: 0 = simple, 1 = strong (only used
 113:                                         #if filter_strength > 0 or autofilter > 0)
 114:         int autofilter                  #Auto adjust filter's strength [0 = off, 1 = on]
 115:         int alpha_compression           #Algorithm for encoding the alpha plane (0 = none,
 116:                                         #1 compressed with WebP lossless). Default is 1.
 117:         int alpha_filtering             #Predictive filtering method for alpha plane.
 118:                                         #0: none, 1: fast, 2: best. Default if 1.
 119:         int alpha_quality               #Between 0 (smallest size) and 100 (lossless).
 120:                                         #Default is 100.
 121:         int _pass "pass"                #number of entropy-analysis passes (in [1..10]).
 122: 
 123:         int show_compressed             #if true, export the compressed picture back.
 124:                                         #In-loop filtering is not applied.
 125:         int preprocessing               #preprocessing filter (0=none, 1=segment-smooth)
 126:         int partitions                  #log2(number of token partitions) in [0..3]. Default
 127:                                         #is set to 0 for easier progressive decoding.
 128:         int partition_limit             #quality degradation allowed to fit the 512k limit
 129:                                         #on prediction modes coding (0: no degradation,
 130:                                         #100: maximum possible degradation).
 131:         int emulate_jpeg_size           #If true, compression parameters will be remapped
 132:                                         #to better match the expected output size from
 133:                                         #JPEG compression. Generally, the output size will
 134:                                         #be similar but the degradation will be lower.
 135:         int thread_level                #If non-zero, try and use multi-threaded encoding.
 136:         int low_memory                  #If set, reduce memory usage (but increase CPU use).
 137: 
 138:         int near_lossless               #Near lossless encoding [0 = max loss .. 100 = off
 139:                                         #(default)
 140:         int exact                       #if non-zero, preserve the exact RGB values under
 141:                                         #transparent area. Otherwise, discard this invisible
 142:                                         #RGB information for better compression. The default
 143:                                         #value is 0.
 144:         uint32_t pad[3]                 #padding for later use
 145: 
 146:     ctypedef struct WebPMemoryWriter:
 147:         uint8_t* mem                    #final buffer (of size 'max_size', larger than 'size').
 148:         size_t   size                   #final size
 149:         size_t   max_size               #total capacity
 150:         uint32_t pad[1]
 151: 
 152:     ctypedef void *WebPWriterFunction
 153:     ctypedef void *WebPProgressHook
 154:     ctypedef void *WebPAuxStats
 155: 
 156:     ctypedef struct WebPPicture:
 157:         #   INPUT
 158:         # Main flag for encoder selecting between ARGB or YUV input.
 159:         # It is recommended to use ARGB input (*argb, argb_stride) for lossless
 160:         # compression, and YUV input (*y, *u, *v, etc.) for lossy compression
 161:         # since these are the respective native colorspace for these formats.
 162:         int use_argb
 163: 
 164:         # YUV input (mostly used for input to lossy compression)
 165:         WebPEncCSP colorspace           #colorspace: should be YUV420 for now (=Y'CbCr).
 166:         int width, height               #dimensions (less or equal to WEBP_MAX_DIMENSION)
 167:         uint8_t *y
 168:         uint8_t *u
 169:         uint8_t *v
 170:         int y_stride, uv_stride         #luma/chroma strides.
 171:         uint8_t* a                      #pointer to the alpha plane
 172:         int a_stride                    #stride of the alpha plane
 173:         uint32_t pad1[2]                #padding for later use
 174: 
 175:         # ARGB input (mostly used for input to lossless compression)
 176:         uint32_t* argb                  #Pointer to argb (32 bit) plane.
 177:         int argb_stride                 #This is stride in pixels units, not bytes.
 178:         uint32_t pad2[3]                #padding for later use
 179: 
 180:         #   OUTPUT
 181:         # Byte-emission hook, to store compressed bytes as they are ready.
 182:         WebPWriterFunction writer       #can be NULL
 183:         void* custom_ptr                #can be used by the writer.
 184: 
 185:         # map for extra information (only for lossy compression mode)
 186:         int extra_info_type             #1: intra type, 2: segment, 3: quant
 187:                                         #4: intra-16 prediction mode,
 188:                                         #5: chroma prediction mode,
 189:                                         #6: bit cost, 7: distortion
 190:         uint8_t* extra_info             #if not NULL, points to an array of size
 191:                                         # ((width + 15) / 16) * ((height + 15) / 16) that
 192:                                         #will be filled with a macroblock map, depending
 193:                                         #on extra_info_type.
 194: 
 195:         #   STATS AND REPORTS
 196:         # Pointer to side statistics (updated only if not NULL)
 197:         WebPAuxStats* stats
 198: 
 199:         # Error code for the latest error encountered during encoding
 200:         WebPEncodingError error_code
 201: 
 202:         #If not NULL, report progress during encoding.
 203:         WebPProgressHook progress_hook
 204: 
 205:         void* user_data                 #this field is free to be set to any value and
 206:                                         #used during callbacks (like progress-report e.g.).
 207: 
 208:         uint32_t pad3[3]                #padding for later use
 209: 
 210:         # Unused for now: original samples (for non-YUV420 modes)
 211:         uint8_t *u0
 212:         uint8_t *v0
 213:         int uv0_stride
 214: 
 215:         uint32_t pad4[7]                #padding for later use
 216: 
 217:         # PRIVATE FIELDS
 218:         void* memory_                   #row chunk of memory for yuva planes
 219:         void* memory_argb_              #and for argb too.
 220:         void* pad5[2]                   #padding for later use
 221: 
 222:     void WebPMemoryWriterInit(WebPMemoryWriter* writer)
 223:     int WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture)
 224: 
 225:     int WebPConfigInit(WebPConfig* config)
 226:     int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality)
 227:     int WebPValidateConfig(const WebPConfig* config)
 228:     int WebPPictureInit(WebPPicture* picture)
 229:     void WebPPictureFree(WebPPicture* picture)
 230: 
 231:     # Colorspace conversion function to import RGB samples.
 232:     # Previous buffer will be free'd, if any.
 233:     # *rgb buffer should have a size of at least height * rgb_stride.
 234:     # Returns false in case of memory error.
 235:     int WebPPictureImportRGB(WebPPicture* picture, const uint8_t* rgb, int rgb_stride)
 236:     # Same, but for RGBA buffer.
 237:     int WebPPictureImportRGBA(WebPPicture* picture, const uint8_t* rgba, int rgba_stride)
 238:     # Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
 239:     # input buffer ignoring the alpha channel. Avoids needing to copy the data
 240:     # to a temporary 24-bit RGB buffer to import the RGB only.
 241:     int WebPPictureImportRGBX(WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride)
 242: 
 243:     # Variants of the above, but taking BGR(A|X) input.
 244:     int WebPPictureImportBGR(WebPPicture* picture, const uint8_t* bgr, int bgr_stride)
 245:     int WebPPictureImportBGRA(WebPPicture* picture, const uint8_t* bgra, int bgra_stride)
 246:     int WebPPictureImportBGRX(WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride)
 247: 
 248:     # Converts picture->argb data to the YUVA format specified by 'colorspace'.
 249:     # Upon return, picture->use_argb is set to false. The presence of real
 250:     # non-opaque transparent values is detected, and 'colorspace' will be
 251:     # adjusted accordingly. Note that this method is lossy.
 252:     # Returns false in case of error.
 253:     int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace)
 254: 
 255:     # Converts picture->yuv to picture->argb and sets picture->use_argb to true.
 256:     # The input format must be YUV_420 or YUV_420A.
 257:     # Note that the use of this method is discouraged if one has access to the
 258:     # raw ARGB samples, since using YUV420 is comparatively lossy. Also, the
 259:     # conversion from YUV420 to ARGB incurs a small loss too.
 260:     # Returns false in case of error.
 261:     int WebPPictureYUVAToARGB(WebPPicture* picture)
 262: 
 263:     # Helper function: given a width x height plane of YUV(A) samples
 264:     # (with stride 'stride'), clean-up the YUV samples under fully transparent
 265:     # area, to help compressibility (no guarantee, though).
 266:     void WebPCleanupTransparentArea(WebPPicture* picture)
 267: 
 268:     # Scan the picture 'picture' for the presence of non fully opaque alpha values.
 269:     # Returns true in such case. Otherwise returns false (indicating that the
 270:     # alpha plane can be ignored altogether e.g.).
 271:     int WebPPictureHasTransparency(const WebPPicture* picture)
 272: 
 273:     # Main encoding call, after config and picture have been initialized.
 274:     # 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION),
 275:     # and the 'config' object must be a valid one.
 276:     # Returns false in case of error, true otherwise.
 277:     # In case of error, picture->error_code is updated accordingly.
 278:     # 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
 279:     # on the value of 'picture->use_argb'. It is highly recommended to use
 280:     # the former for lossy encoding, and the latter for lossless encoding
 281:     # (when config.lossless is true). Automatic conversion from one format to
 282:     # another is provided but they both incur some loss.
 283:     int WebPEncode(const WebPConfig* config, WebPPicture* picture)
 284: 
 285: 
 286: ERROR_TO_NAME = {
 287: #VP8_ENC_OK
+288:                 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, 288, __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, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_memory_error_allocating_objects) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+289:                 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, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_memory_error_while_flushing_bits) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+290:                 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, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_a_pointer_parameter_is_NULL) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+291:                 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, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_configuration_is_invalid) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+292:                 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, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_picture_has_invalid_width_height) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+293:                 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, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_partition_is_bigger_than_512k) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+294:                 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, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_partition_is_bigger_than_16M) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+295:                 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, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_error_while_flushing_bytes) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+296:                 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, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_file_is_bigger_than_4G) < 0) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+297:                 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, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_kp_u_abort_request_by_user) < 0) __PYX_ERR(0, 288, __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, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 298:                 }
 299: 
 300: PRESETS = {
+301:            WEBP_PRESET_DEFAULT      : "default",
  __pyx_t_2 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __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, 301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_default) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+302:            WEBP_PRESET_PICTURE      : "picture",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PICTURE); 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_u_picture) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+303:            WEBP_PRESET_PHOTO        : "photo",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PHOTO); 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_u_photo) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+304:            WEBP_PRESET_DRAWING      : "drawing",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_DRAWING); 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_u_drawing) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+305:            WEBP_PRESET_ICON         : "icon",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_ICON); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_icon) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+306:            WEBP_PRESET_TEXT         : "text",
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_text) < 0) __PYX_ERR(0, 301, __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, 300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 307:            }
+308: PRESET_NAME_TO_CONSTANT = {}
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __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, 308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+309: for k,v in PRESETS.items():
  __pyx_t_6 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PRESETS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 309, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_dict_iterator(__pyx_t_1, 0, __pyx_n_s_items, (&__pyx_t_7), (&__pyx_t_3)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_8;
  __pyx_t_8 = 0;
  while (1) {
    __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_7, &__pyx_t_6, &__pyx_t_8, &__pyx_t_1, NULL, __pyx_t_3);
    if (unlikely(__pyx_t_9 == 0)) break;
    if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_k, __pyx_t_8) < 0) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_v, __pyx_t_1) < 0) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+310:     PRESET_NAME_TO_CONSTANT[v] = k
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_k); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_v); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (unlikely(PyObject_SetItem(__pyx_t_8, __pyx_t_10, __pyx_t_1) < 0)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 311: 
 312: CONTENT_TYPE_PRESET = {
+313:     "picture"   : WEBP_PRESET_PICTURE,
  __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_PICTURE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_picture, __pyx_t_1) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+314:     "text"      : WEBP_PRESET_TEXT,
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_text, __pyx_t_1) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+315:     "browser"   : WEBP_PRESET_TEXT,
  __pyx_t_1 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_browser, __pyx_t_1) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CONTENT_TYPE_PRESET, __pyx_t_2) < 0) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 316:     }
 317: 
 318: IMAGE_HINT = {
+319:               WEBP_HINT_DEFAULT     : "default",
  __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_DEFAULT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_default) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+320:               WEBP_HINT_PICTURE     : "picture",
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PICTURE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_picture) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+321:               WEBP_HINT_PHOTO       : "photo",
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PHOTO); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_photo) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+322:               WEBP_HINT_GRAPH       : "graph",
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_GRAPH); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_t_1, __pyx_n_u_graph) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_IMAGE_HINT, __pyx_t_2) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 323:               }
+324: HINT_NAME_TO_CONSTANT = {}
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HINT_NAME_TO_CONSTANT, __pyx_t_2) < 0) __PYX_ERR(0, 324, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+325: for k,v in IMAGE_HINT.items():
  __pyx_t_7 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 325, __pyx_L1_error)
  }
  __pyx_t_10 = __Pyx_dict_iterator(__pyx_t_1, 0, __pyx_n_s_items, (&__pyx_t_6), (&__pyx_t_3)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_10;
  __pyx_t_10 = 0;
  while (1) {
    __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_6, &__pyx_t_7, &__pyx_t_10, &__pyx_t_1, NULL, __pyx_t_3);
    if (unlikely(__pyx_t_9 == 0)) break;
    if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_k, __pyx_t_10) < 0) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_v, __pyx_t_1) < 0) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+326:     HINT_NAME_TO_CONSTANT[v] = k
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_k); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_HINT_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_v); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_8, __pyx_t_1) < 0)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 327: 
 328: CONTENT_TYPE_HINT = {
+329:     "picture"   : WEBP_HINT_PICTURE,
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_PICTURE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_picture, __pyx_t_1) < 0) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CONTENT_TYPE_HINT, __pyx_t_2) < 0) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 330:     }
 331: 
+332: cdef WebPImageHint DEFAULT_IMAGE_HINT = HINT_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_IMAGE_HINT", "graph").lower(), WEBP_HINT_GRAPH)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_HINT_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __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_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_environ); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __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_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_WebPImageHint(WEBP_HINT_GRAPH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
  __pyx_t_8 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); 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_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_WebPImageHint(__pyx_t_2); if (unlikely((__pyx_t_11 == ((WebPImageHint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_IMAGE_HINT = __pyx_t_11;
/* … */
  __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_u_XPRA_WEBP_IMAGE_HINT, __pyx_n_u_graph); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
+333: cdef WebPPreset DEFAULT_PRESET = PRESET_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_PRESET", "text").lower(), WEBP_PRESET_TEXT)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __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, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_environ); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_TEXT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_WebPPreset(__pyx_t_2); if (unlikely((__pyx_t_12 == ((WebPPreset)-1)) && PyErr_Occurred())) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_PRESET = __pyx_t_12;
/* … */
  __pyx_tuple__16 = PyTuple_Pack(2, __pyx_n_u_XPRA_WEBP_PRESET, __pyx_n_u_text); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
+334: cdef WebPPreset PRESET_SMALL = PRESET_NAME_TO_CONSTANT.get(os.environ.get("XPRA_WEBP_PRESET_SMALL", "icon").lower(), WEBP_PRESET_ICON)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PRESET_NAME_TO_CONSTANT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_environ); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_WebPPreset(WEBP_PRESET_ICON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __pyx_t_10 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_WebPPreset(__pyx_t_2); if (unlikely((__pyx_t_12 == ((WebPPreset)-1)) && PyErr_Occurred())) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4webp_6encode_PRESET_SMALL = __pyx_t_12;
/* … */
  __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_u_XPRA_WEBP_PRESET_SMALL, __pyx_n_u_icon); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);
 335: 
 336: 
+337: 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_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_1get_encodings, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_encodings, __pyx_t_2) < 0) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 337, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 337, __pyx_L1_error)
+338:     return ["webp"]
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_u_webp);
  __Pyx_GIVEREF(__pyx_n_u_webp);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_webp);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 339: 
+340: 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, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_3get_version, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_2) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 340, __pyx_L1_error)
+341:     cdef int version = WebPGetEncoderVersion()
  __pyx_v_version = WebPGetEncoderVersion();
+342:     log("WebPGetEncoderVersion()=%#x", version)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __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, 342, __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_u_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, 342, __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_u_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, 342, __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, 342, __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_u_WebPGetEncoderVersion_x);
    __Pyx_GIVEREF(__pyx_kp_u_WebPGetEncoderVersion_x);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_u_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, 342, __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;
+343:     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, 343, __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, 343, __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, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __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;
 344: 
+345: 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_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_5get_info, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_info, __pyx_t_2) < 0) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 345, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 345, __pyx_L1_error)
+346:     return  {
  __Pyx_XDECREF(__pyx_r);
+347:             "version"       : get_version(),
  __pyx_t_1 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_version); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __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_u_version, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+348:             "encodings"     : get_encodings(),
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_encodings); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 348, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __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_u_encodings, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+349:             "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, 349, __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, 349, __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, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_threading, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+350:             "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, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_image_hint, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+351:             "image-hints"   : IMAGE_HINT.values(),
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __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, 351, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __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_u_image_hints, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+352:             "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, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_preset, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+353:             "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, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_preset_small, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+354:             "presets"       : PRESETS.values(),
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_PRESETS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __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, 354, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __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_u_presets, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 355:             }
 356: 
+357: 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, 357, __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, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_7webp_check, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_webp_check, __pyx_t_2) < 0) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 357, __pyx_L1_error)
+358:     if ret==0:
  __pyx_t_1 = ((__pyx_v_ret == 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+359:         return
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+360:     err = ERROR_TO_NAME.get(ret, ret)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ERROR_TO_NAME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __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, 360, __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, 360, __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, 360, __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, 360, __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, 360, __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, 360, __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, 360, __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;
+361:     raise Exception("error: %s" % err)
  __pyx_t_2 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_error_s, __pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __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, 361, __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, 361, __pyx_L1_error)
 362: 
+363: 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;
}
+364:     if v<0:
  __pyx_t_1 = ((__pyx_v_v < 0) != 0);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L3;
  }
+365:         v = 0
    __pyx_v_v = 0;
+366:     elif v>100:
  __pyx_t_1 = ((__pyx_v_v > 0x64) != 0);
  if (__pyx_t_1) {
/* … */
  }
  __pyx_L3:;
+367:         v = 100
    __pyx_v_v = 0x64;
+368:     return <float> v
  __pyx_r = ((float)__pyx_v_v);
  goto __pyx_L0;
 369: 
 370: 
+371: 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;
}
+372:     return {
  __Pyx_XDECREF(__pyx_r);
+373:         "lossless"          : config.lossless,
  __pyx_t_1 = __Pyx_PyDict_NewPresized(22); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __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, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_lossless, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+374:         "method"            : config.method,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->method); 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_u_method, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+375:         "image_hint"        : IMAGE_HINT.get(config.image_hint, config.image_hint),
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __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, 375, __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, 375, __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, 375, __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, 375, __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, 375, __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, 375, __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, 375, __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_u_image_hint_2, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+376:         "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, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_target_size, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+377:         "target_PSNR"       : config.target_PSNR,
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_config->target_PSNR); 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_u_target_PSNR, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+378:         "segments"          : config.segments,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->segments); 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_u_segments, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+379:         "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, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sns_strength, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+380:         "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, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_filter_strength, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+381:         "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, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_filter_sharpness, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+382:         "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, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_filter_type, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+383:         "autofilter"        : config.autofilter,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->autofilter); 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_u_autofilter, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+384:         "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, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_alpha_compression, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+385:         "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, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_alpha_filtering, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+386:         "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, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_alpha_quality, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+387:         "pass"              : config._pass,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->pass); 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_u_pass, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+388:         "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, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_show_compressed, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+389:         "preprocessing"     : config.preprocessing,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->preprocessing); 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_u_preprocessing, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+390:         "partitions"        : config.partitions,
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_config->partitions); 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_u_partitions, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+391:         "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, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_partition_limit, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+392:         "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, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_emulate_jpeg_size, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+393:         "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, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_thread_level, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+394:         "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, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_low_memory, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 395:         }
 396: 
+397: 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)(void*)(PyCFunctionWithKeywords)__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_u_);
    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, 397, __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, 397, __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, 397, __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, 397, __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_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_XDECREF(__pyx_t_23);
  __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_2, __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, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_9compress, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compress, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 397, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 397, __pyx_L1_error)
+398:     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, 398, __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);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __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;
+399:     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_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_RGBX, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_RGBA, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_BGRX, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_BGRA, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 399, __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)) {
/* … */
  }
+400:         raise Exception("unsupported pixel format %s" % pixel_format)
    __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unsupported_pixel_format_s, __pyx_v_pixel_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __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, 400, __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, 400, __pyx_L1_error)
+401:     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, 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);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  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_width = __pyx_t_6;
+402:     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, 402, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __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, 402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_height = __pyx_t_6;
+403:     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, 403, __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);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __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, 403, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_stride = __pyx_t_6;
+404:     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, 404, __pyx_L1_error)
  __pyx_v_Bpp = __pyx_t_7;
+405:     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)) {
/* … */
  }
+406:         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, 406, __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, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __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 = PyUnicode_Format(__pyx_kp_u_this_image_is_too_big_for_webp_i, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __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, 406, __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, 406, __pyx_L1_error)
+407:     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, 407, __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);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __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;
 408: 
 409:     cdef uint8_t *pic_buf
+410:     cdef Py_ssize_t pic_buf_len = 0
  __pyx_v_pic_buf_len = 0;
 411:     cdef WebPConfig config
+412:     cdef WebPPreset preset = DEFAULT_PRESET
  __pyx_v_preset = __pyx_v_4xpra_6codecs_4webp_6encode_DEFAULT_PRESET;
 413:     #only use icon for small squarish rectangles
+414:     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) {
/* … */
  }
+415:         preset = PRESET_SMALL
    __pyx_v_preset = __pyx_v_4xpra_6codecs_4webp_6encode_PRESET_SMALL;
+416:     preset = CONTENT_TYPE_PRESET.get(content_type, preset)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_CONTENT_TYPE_PRESET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __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, 416, __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, 416, __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, 416, __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, 416, __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, 416, __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, 416, __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, 416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_preset = __pyx_t_11;
+417:     cdef WebPImageHint image_hint = CONTENT_TYPE_HINT.get(content_type, DEFAULT_IMAGE_HINT)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CONTENT_TYPE_HINT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __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, 417, __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, 417, __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, 417, __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, 417, __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, 417, __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, 417, __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, 417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_image_hint = __pyx_t_12;
 418: 
+419:     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));
+420:     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 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = 0;
      __pyx_t_13 = 127;
      __Pyx_INCREF(__pyx_kp_u_failed_to_get_buffer_from_pixel);
      __pyx_t_7 += 40;
      __Pyx_GIVEREF(__pyx_kp_u_failed_to_get_buffer_from_pixel);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_failed_to_get_buffer_from_pixel);
      __pyx_t_10 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(((PyObject *)Py_TYPE(__pyx_v_pixels))), __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_13;
      __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_INCREF(__pyx_kp_u_returned);
      __pyx_t_7 += 11;
      __Pyx_GIVEREF(__pyx_kp_u_returned);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_returned);
      __pyx_t_10 = __Pyx_PyUnicode_From_int(__pyx_v_ret, 0, ' ', 'd'); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_INCREF(__pyx_kp_u__2);
      __pyx_t_7 += 1;
      __Pyx_GIVEREF(__pyx_kp_u__2);
      PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u__2);
      __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_7, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 420, __pyx_L1_error)
    }
  }
  #endif
+421:     log("webp.compress(%s, %i, %i, %s, %s) buf=%#x", image, width, height, supports_alpha, content_type, <uintptr_t> pic_buf)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_From_unsigned_int(__pyx_v_width); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __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, 421, __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, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_kp_u_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_10 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __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_3)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_kp_u_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_10 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __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_15 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_webp_compress_s_i_i_s_s_buf_x);
    __Pyx_GIVEREF(__pyx_kp_u_webp_compress_s_i_i_s_s_buf_x);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_9, __pyx_kp_u_webp_compress_s_i_i_s_s_buf_x);
    __Pyx_INCREF(__pyx_v_image);
    __Pyx_GIVEREF(__pyx_v_image);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_9, __pyx_v_image);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_9, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_supports_alpha);
    __Pyx_GIVEREF(__pyx_v_supports_alpha);
    PyTuple_SET_ITEM(__pyx_t_15, 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_15, 5+__pyx_t_9, __pyx_v_content_type);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_9, __pyx_t_1);
    __pyx_t_8 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+422:     cdef int size = stride * height
  __pyx_v_size = (__pyx_v_stride * __pyx_v_height);
+423:     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_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 423, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = 0;
      __pyx_t_13 = 127;
      __Pyx_INCREF(__pyx_kp_u_pixel_buffer_is_too_small_expect);
      __pyx_t_7 += 45;
      __Pyx_GIVEREF(__pyx_kp_u_pixel_buffer_is_too_small_expect);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_pixel_buffer_is_too_small_expect);
      __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_kp_u_bytes_but_got);
      __pyx_t_7 += 15;
      __Pyx_GIVEREF(__pyx_kp_u_bytes_but_got);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_bytes_but_got);
      __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_pic_buf_len, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_7, __pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __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, 423, __pyx_L1_error)
    }
  }
  #endif
 424: 
 425:     cdef int i
+426:     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, 426, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __Pyx_INCREF(__pyx_v_supports_alpha);
    __pyx_t_3 = __pyx_v_supports_alpha;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_pixel_format, __pyx_n_s_find); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_1, __pyx_n_u_A) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_n_u_A);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = PyObject_RichCompare(__pyx_t_10, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_INCREF(__pyx_t_15);
  __pyx_t_3 = __pyx_t_15;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_t_15 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_v_alpha_int = __pyx_t_9;
+427:     cdef int use_argb = int(quality>=SUBSAMPLING_THRESHOLD)
  __pyx_v_use_argb = ((int)(__pyx_v_quality >= __pyx_v_4xpra_6codecs_4webp_6encode_SUBSAMPLING_THRESHOLD));
+428:     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) {
/* … */
  }
 429:         #ensure webp will not decide to encode the alpha channel
 430:         #(this is stupid: we should be able to pass a flag instead)
+431:         i = 3
    __pyx_v_i = 3;
+432:         while i<size:
    while (1) {
      __pyx_t_5 = ((__pyx_v_i < __pyx_v_size) != 0);
      if (!__pyx_t_5) break;
+433:             pic_buf[i] = 0xff
      (__pyx_v_pic_buf[__pyx_v_i]) = 0xff;
+434:             i += 4
      __pyx_v_i = (__pyx_v_i + 4);
    }
 435: 
+436:     ret = WebPConfigInit(&config)
  __pyx_v_ret = WebPConfigInit((&__pyx_v_config));
+437:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+438:         raise Exception("failed to initialize webp config")
    __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_Raise(__pyx_t_15, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __PYX_ERR(0, 438, __pyx_L1_error)
/* … */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_failed_to_initialize_webp_config); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
 439: 
+440:     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));
+441:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+442:         raise Exception("failed to set webp preset")
    __pyx_t_15 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_Raise(__pyx_t_15, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __PYX_ERR(0, 442, __pyx_L1_error)
/* … */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_failed_to_set_webp_preset); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
 443: 
 444:     #tune it:
+445:     config.lossless = quality>=LOSSLESS_THRESHOLD
  __pyx_v_config.lossless = (__pyx_v_quality >= __pyx_v_4xpra_6codecs_4webp_6encode_LOSSLESS_THRESHOLD);
+446:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L23;
  }
 447:         #not much to gain from setting a high quality here,
 448:         #the latency will be higher for a negligible compression gain:
+449:         config.quality = fclamp(50-speed//2)
    __pyx_v_config.quality = __pyx_f_4xpra_6codecs_4webp_6encode_fclamp((50 - (__pyx_v_speed / 2)));
 450:     else:
 451:         #normalize quality: webp quality is much higher than jpeg's
 452:         #so we can go lower,
 453:         #[0,10,...,90,100] maps to:
 454:         #[0, 3, 7, 13, 20, 29, 40, 52, 66, 82, 100]
+455:         config.quality = fclamp(((quality+10)**2//121))
  /*else*/ {
    __pyx_v_config.quality = __pyx_f_4xpra_6codecs_4webp_6encode_fclamp((__Pyx_pow_long((__pyx_v_quality + 10), 2) / 0x79));
  }
  __pyx_L23:;
 456:     #"method" takes values from 0 to 6,
 457:     #but anything higher than 1 is dreadfully slow,
 458:     #so only use method=1 when speed is already very low
+459:     config.method = int(speed<10)
  __pyx_v_config.method = ((int)(__pyx_v_speed < 10));
+460:     config.alpha_compression = alpha_int
  __pyx_v_config.alpha_compression = __pyx_v_alpha_int;
+461:     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, (((long)__pyx_v_speed) / 50))) * __pyx_v_alpha_int);
+462:     config.alpha_quality = quality * alpha_int
  __pyx_v_config.alpha_quality = (__pyx_v_quality * __pyx_v_alpha_int);
+463:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L24;
  }
+464:         config.autofilter = 1
    __pyx_v_config.autofilter = 1;
 465:     else:
+466:         config.segments = 1
  /*else*/ {
    __pyx_v_config.segments = 1;
+467:         config.sns_strength = 0
    __pyx_v_config.sns_strength = 0;
+468:         config.filter_strength = 0
    __pyx_v_config.filter_strength = 0;
+469:         config.filter_sharpness = 7-quality//15
    __pyx_v_config.filter_sharpness = (7 - (__pyx_v_quality / 15));
+470:         config.filter_type = 0
    __pyx_v_config.filter_type = 0;
+471:         config.autofilter = 0
    __pyx_v_config.autofilter = 0;
  }
  __pyx_L24:;
+472:     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, ((0x64 - __pyx_v_speed) / 10)));
+473:     config.preprocessing = int(speed<50)
  __pyx_v_config.preprocessing = ((int)(__pyx_v_speed < 50));
+474:     config.image_hint = image_hint
  __pyx_v_config.image_hint = __pyx_v_image_hint;
+475:     config.thread_level = WEBP_THREADING
  __pyx_v_config.thread_level = __pyx_v_4xpra_6codecs_4webp_6encode_WEBP_THREADING;
+476:     config.partitions = 3
  __pyx_v_config.partitions = 3;
+477:     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)));
 478: 
+479:     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_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_config.lossless); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_config.quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __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, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+480:                     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, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_config.alpha_filtering); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_config.alpha_quality); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_PRESETS); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_get); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = __Pyx_PyInt_From_WebPPreset(__pyx_v_preset); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_20 = __Pyx_PyInt_From_WebPPreset(__pyx_v_preset); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_21 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_19);
    if (likely(__pyx_t_21)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_21);
      __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_21, __pyx_t_18, __pyx_t_20};
    __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_18, __pyx_t_20};
    __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_21) {
      __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21); __pyx_t_21 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_9, __pyx_t_18);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_9, __pyx_t_20);
    __pyx_t_18 = 0;
    __pyx_t_20 = 0;
    __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_22, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_n_s_IMAGE_HINT); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_n_s_get); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_image_hint); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_18 = __Pyx_PyInt_From_WebPImageHint(__pyx_v_image_hint); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 480, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_21 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_20))) {
    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20);
    if (likely(__pyx_t_21)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_21);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_20, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_22, __pyx_t_18};
    __pyx_t_19 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_22, __pyx_t_18};
    __pyx_t_19 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  } else
  #endif
  {
    __pyx_t_23 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    if (__pyx_t_21) {
      __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_21); __pyx_t_21 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_23, 0+__pyx_t_9, __pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_23, 1+__pyx_t_9, __pyx_t_18);
    __pyx_t_22 = 0;
    __pyx_t_18 = 0;
    __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_23, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
  }
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[10] = {__pyx_t_20, __pyx_kp_u_webp_compress_config_lossless_5s, __pyx_t_10, __pyx_t_1, __pyx_t_2, __pyx_t_8, __pyx_t_14, __pyx_t_16, __pyx_t_17, __pyx_t_19};
    __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 9+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __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_3)) {
    PyObject *__pyx_temp[10] = {__pyx_t_20, __pyx_kp_u_webp_compress_config_lossless_5s, __pyx_t_10, __pyx_t_1, __pyx_t_2, __pyx_t_8, __pyx_t_14, __pyx_t_16, __pyx_t_17, __pyx_t_19};
    __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 9+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  } else
  #endif
  {
    __pyx_t_23 = PyTuple_New(9+__pyx_t_9); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_webp_compress_config_lossless_5s);
    __Pyx_GIVEREF(__pyx_kp_u_webp_compress_config_lossless_5s);
    PyTuple_SET_ITEM(__pyx_t_23, 0+__pyx_t_9, __pyx_kp_u_webp_compress_config_lossless_5s);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_23, 1+__pyx_t_9, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_23, 2+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_23, 3+__pyx_t_9, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_23, 4+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_23, 5+__pyx_t_9, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_23, 6+__pyx_t_9, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_23, 7+__pyx_t_9, __pyx_t_17);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_23, 8+__pyx_t_9, __pyx_t_19);
    __pyx_t_10 = 0;
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_8 = 0;
    __pyx_t_14 = 0;
    __pyx_t_16 = 0;
    __pyx_t_17 = 0;
    __pyx_t_19 = 0;
    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_23, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+481:     ret = WebPValidateConfig(&config)
  __pyx_v_ret = WebPValidateConfig((&__pyx_v_config));
+482:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+483:         info = get_config_info(&config)
    __pyx_t_15 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_v_info = __pyx_t_15;
    __pyx_t_15 = 0;
+484:         raise Exception("invalid webp configuration: %s" % info)
    __pyx_t_15 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_invalid_webp_configuration_s, __pyx_v_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 484, __pyx_L1_error)
 485: 
 486:     cdef WebPPicture pic
+487:     ret = WebPPictureInit(&pic)
  __pyx_v_ret = WebPPictureInit((&__pyx_v_pic));
+488:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+489:         raise Exception("failed to initialise webp picture")
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 489, __pyx_L1_error)
/* … */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_failed_to_initialise_webp_pictur); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
 490: 
 491:     client_options = {
 492:         #no need to expose speed
 493:         #(not used for anything downstream)
 494:         #"speed"       : speed,
+495:         "rgb_format"  : pixel_format,
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_u_rgb_format, __pyx_v_pixel_format) < 0) __PYX_ERR(0, 495, __pyx_L1_error)
  __pyx_v_client_options = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 496:         }
 497: 
+498:     memset(&pic, 0, sizeof(WebPPicture))
  (void)(memset((&__pyx_v_pic), 0, (sizeof(WebPPicture))));
+499:     pic.width = width
  __pyx_v_pic.width = __pyx_v_width;
+500:     pic.height = height
  __pyx_v_pic.height = __pyx_v_height;
+501:     pic.use_argb = 1
  __pyx_v_pic.use_argb = 1;
+502:     pic.argb = <uint32_t*> pic_buf
  __pyx_v_pic.argb = ((uint32_t *)__pyx_v_pic_buf);
+503:     pic.argb_stride = stride//Bpp
  __pyx_v_pic.argb_stride = (__pyx_v_stride / __pyx_v_Bpp);
+504:     if not use_argb:
  __pyx_t_5 = ((!(__pyx_v_use_argb != 0)) != 0);
  if (__pyx_t_5) {
/* … */
  }
+505:         if WebPPictureARGBToYUVA(&pic, WEBP_YUV420A):
    __pyx_t_5 = (WebPPictureARGBToYUVA((&__pyx_v_pic), WEBP_YUV420A) != 0);
    if (likely(__pyx_t_5)) {
/* … */
      goto __pyx_L28;
    }
+506:             client_options["subsampling"] = "YUV420P"
      if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_u_subsampling, __pyx_n_u_YUV420P) < 0)) __PYX_ERR(0, 506, __pyx_L1_error)
 507:             #redundant (changed by WebPPictureARGBToYUVA):
 508:             #pic.use_argb = 0
 509:         else:
+510:             raise Exception("failed to convert picture to YUV")
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 510, __pyx_L1_error)
    }
    __pyx_L28:;
/* … */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_failed_to_convert_picture_to_YUV); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
 511: 
 512:     #TODO: custom writer that over-allocates memory
 513:     cdef WebPMemoryWriter memory_writer
+514:     WebPMemoryWriterInit(&memory_writer)
  WebPMemoryWriterInit((&__pyx_v_memory_writer));
+515:     pic.writer = <WebPWriterFunction> WebPMemoryWrite
  __pyx_v_pic.writer = ((WebPWriterFunction)WebPMemoryWrite);
+516:     pic.custom_ptr = <void*> &memory_writer
  __pyx_v_pic.custom_ptr = ((void *)(&__pyx_v_memory_writer));
+517:     ret = WebPEncode(&config, &pic)
  __pyx_v_ret = WebPEncode((&__pyx_v_config), (&__pyx_v_pic));
+518:     if not ret:
  __pyx_t_5 = ((!(__pyx_v_ret != 0)) != 0);
  if (unlikely(__pyx_t_5)) {
/* … */
  }
+519:         raise Exception("WebPEncode failed: %s, config=%s" % (ERROR_TO_NAME.get(pic.error_code, pic.error_code), get_config_info(&config)))
    __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 0;
    __pyx_t_13 = 127;
    __Pyx_INCREF(__pyx_kp_u_WebPEncode_failed);
    __pyx_t_7 += 19;
    __Pyx_GIVEREF(__pyx_kp_u_WebPEncode_failed);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_WebPEncode_failed);
    __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_n_s_ERROR_TO_NAME); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_n_s_get); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    __pyx_t_23 = __Pyx_PyInt_From_WebPEncodingError(__pyx_v_pic.error_code); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __pyx_t_17 = __Pyx_PyInt_From_WebPEncodingError(__pyx_v_pic.error_code); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_16 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_19);
      if (likely(__pyx_t_16)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
        __Pyx_INCREF(__pyx_t_16);
        __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_16, __pyx_t_23, __pyx_t_17};
      __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 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_16, __pyx_t_23, __pyx_t_17};
      __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_16) {
        __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_16); __pyx_t_16 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_23);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_t_23);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_t_17);
      __pyx_t_23 = 0;
      __pyx_t_17 = 0;
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_14, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_19 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_15), __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_13;
    __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_19);
    __pyx_t_19 = 0;
    __Pyx_INCREF(__pyx_kp_u_config);
    __pyx_t_7 += 9;
    __Pyx_GIVEREF(__pyx_kp_u_config);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_config);
    __pyx_t_19 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_15 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_19), __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_13;
    __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_15);
    __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_3, 4, __pyx_t_7, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 519, __pyx_L1_error)
 520: 
+521:     cdata = memory_writer.mem[:memory_writer.size]
  __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_memory_writer.mem) + 0, __pyx_v_memory_writer.size - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_cdata = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
+522:     free(memory_writer.mem)
  free(__pyx_v_memory_writer.mem);
+523:     WebPPictureFree(&pic)
  WebPPictureFree((&__pyx_v_pic));
+524:     if config.lossless:
  __pyx_t_5 = (__pyx_v_config.lossless != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L30;
  }
+525:         client_options["quality"] = 100
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_u_quality, __pyx_int_100) < 0)) __PYX_ERR(0, 525, __pyx_L1_error)
+526:     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:;
+527:         client_options["quality"] = quality
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_quality); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_u_quality, __pyx_t_3) < 0)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+528:     if alpha_int:
  __pyx_t_5 = (__pyx_v_alpha_int != 0);
  if (__pyx_t_5) {
/* … */
  }
+529:         client_options["has_alpha"] = True
    if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_u_has_alpha, Py_True) < 0)) __PYX_ERR(0, 529, __pyx_L1_error)
+530:     log("webp.compress ratio=%i%%, client-options=%s", 100*memory_writer.size//size, client_options)
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_log); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_19 = __Pyx_PyInt_FromSize_t(((0x64 * __pyx_v_memory_writer.size) / __pyx_v_size)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_14 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_15)) {
    PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_kp_u_webp_compress_ratio_i_client_opt, __pyx_t_19, __pyx_v_client_options};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
    PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_kp_u_webp_compress_ratio_i_client_opt, __pyx_t_19, __pyx_v_client_options};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  } else
  #endif
  {
    __pyx_t_17 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_webp_compress_ratio_i_client_opt);
    __Pyx_GIVEREF(__pyx_kp_u_webp_compress_ratio_i_client_opt);
    PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_9, __pyx_kp_u_webp_compress_ratio_i_client_opt);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_9, __pyx_t_19);
    __Pyx_INCREF(__pyx_v_client_options);
    __Pyx_GIVEREF(__pyx_v_client_options);
    PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_9, __pyx_v_client_options);
    __pyx_t_19 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+531:     if LOG_CONFIG>0:
  __pyx_t_5 = ((__pyx_v_4xpra_6codecs_4webp_6encode_LOG_CONFIG > 0) != 0);
  if (__pyx_t_5) {
/* … */
  }
+532:         log("webp.compress used config: %s", get_config_info(&config))
    __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_log); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_17 = __pyx_f_4xpra_6codecs_4webp_6encode_get_config_info((&__pyx_v_config)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_19 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_19)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_19);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_u_webp_compress_used_config_s, __pyx_t_17};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_u_webp_compress_used_config_s, __pyx_t_17};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 532, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_19) {
        __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_19); __pyx_t_19 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_webp_compress_used_config_s);
      __Pyx_GIVEREF(__pyx_kp_u_webp_compress_used_config_s);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_kp_u_webp_compress_used_config_s);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_t_17);
      __pyx_t_17 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+533:     return cdata, client_options
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_cdata);
  __Pyx_GIVEREF(__pyx_v_cdata);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_cdata);
  __Pyx_INCREF(__pyx_v_client_options);
  __Pyx_GIVEREF(__pyx_v_client_options);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_client_options);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 534: 
 535: 
+536: 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)(void*)(PyCFunctionWithKeywords)__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, 536, __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, 536, __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, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4webp_6encode_11selftest, NULL, __pyx_n_s_xpra_codecs_webp_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_selftest, __pyx_t_2) < 0) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 537:     #fake empty buffer:
+538:     from xpra.codecs.codec_checks import make_test_image
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __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, 538, __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, 538, __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;
+539:     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;
+540:     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, 540, __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, 540, __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, 540, __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, 540, __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;
+541:     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, 541, __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, 541, __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, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);
/* … */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+542:         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, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_n_u_X);
    __Pyx_GIVEREF(__pyx_n_u_X);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_X);
    __Pyx_INCREF(__pyx_n_u_A);
    __Pyx_GIVEREF(__pyx_n_u_A);
    PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_A);
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_has_alpha); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_BGR_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __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, 542, __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, 542, __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, 542, __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, 542, __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;
+543:         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, 543, __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, 543, __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, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
+544:             r = compress(img, quality=q, speed=50, supports_alpha=has_alpha)
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_compress); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 544, __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, 544, __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, 544, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_speed, __pyx_int_50) < 0) __PYX_ERR(0, 544, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_supports_alpha, __pyx_v_has_alpha) < 0) __PYX_ERR(0, 544, __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, 544, __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;
+545:             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, 545, __pyx_L1_error)
        if (unlikely(!((__pyx_t_10 > 0) != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 545, __pyx_L1_error)
        }
      }
      #endif
 546:         #import binascii
 547:         #print("compressed data(%s)=%s" % (has_alpha, binascii.hexlify(r)))