Generated by Cython 0.27

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: argb.c

 001: # This file is part of Xpra.
 002: # Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
 003: # Copyright (C) 2012-2017 Antoine Martin <antoine@devloop.org.uk>
 004: # Xpra is released under the terms of the GNU GPL v2, or, at your option, any
 005: # later version. See the file COPYING for details.
 006: 
 007: #cython: boundscheck=False, wraparound=False, cdivision=True
 008: from __future__ import absolute_import
 009: 
 010: from xpra.buffers.membuf cimport getbuf, padbuf, MemBuf
 011: from xpra.buffers.membuf cimport object_as_buffer, object_as_write_buffer
 012: 
 013: from libc.stdint cimport uint32_t, uint16_t, uint8_t
 014: 
+015: import struct
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+016: from xpra.log import Logger
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Logger);
  __Pyx_GIVEREF(__pyx_n_s_Logger);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Logger);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_xpra_log, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+017: log = Logger("encoding")
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* … */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_encoding); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);
 018: 
+019: assert sizeof(int) == 4
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(((sizeof(int)) == 4) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 19, __pyx_L1_error)
    }
  }
  #endif
 020: 
 021: 
+022: cdef int as_buffer(object obj, const void ** buffer, Py_ssize_t * buffer_len) except -1:
static int __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(PyObject *__pyx_v_obj, void const **__pyx_v_buffer, Py_ssize_t *__pyx_v_buffer_len) {
  size_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_buffer", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("xpra.codecs.argb.argb.as_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 023:     cdef size_t l
+024:     if isinstance(obj, MemBuf):
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+025:         buffer[0] = <const void*> (<MemBuf> obj).get_mem()
    (__pyx_v_buffer[0]) = ((void const *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_obj)->__pyx_vtab)->get_mem(((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_obj)));
+026:         l = len(obj)
    __pyx_t_3 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 26, __pyx_L1_error)
    __pyx_v_l = __pyx_t_3;
+027:         buffer_len[0] = <Py_ssize_t> l
    (__pyx_v_buffer_len[0]) = ((Py_ssize_t)__pyx_v_l);
+028:         return 0
    __pyx_r = 0;
    goto __pyx_L0;
+029:     return object_as_buffer(obj, buffer, buffer_len)
  __pyx_r = __pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_obj, __pyx_v_buffer, __pyx_v_buffer_len);
  goto __pyx_L0;
 030: 
 031: 
+032: cdef inline unsigned char clamp(int v):
static CYTHON_INLINE unsigned char __pyx_f_4xpra_6codecs_4argb_4argb_clamp(int __pyx_v_v) {
  unsigned char __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clamp", 0);
/* … */
  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+033:     if v>255:
  __pyx_t_1 = ((__pyx_v_v > 0xFF) != 0);
  if (__pyx_t_1) {
/* … */
  }
+034:         return 255
    __pyx_r = 0xFF;
    goto __pyx_L0;
+035:     return <unsigned char> v
  __pyx_r = ((unsigned char)__pyx_v_v);
  goto __pyx_L0;
 036: 
 037: 
+038: def bgr565_to_rgbx(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx = {"bgr565_to_rgbx", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgbx (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_bgr565_to_rgbx(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_bgr565_to_rgbx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  uint16_t const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__2 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgr565_to_rgbx, __pyx_t_2) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgr565_to_rgbx, 38, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 38, __pyx_L1_error)
+039:     assert len(buf) % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 39, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 2) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 39, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 39, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 39, __pyx_L1_error)
    }
  }
  #endif
 040:     # buf is a Python buffer object
+041:     cdef const uint16_t* cbuf = <const uint16_t*> 0
  __pyx_v_cbuf = ((uint16_t const *)0);
+042:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+043:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 43, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 43, __pyx_L1_error)
    }
  }
  #endif
+044:     return bgr565data_to_rgbx(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgbx(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 045: 
+046: cdef bgr565data_to_rgbx(const uint16_t* rgb565, const int rgb565_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgbx(uint16_t const *__pyx_v_rgb565, int const __pyx_v_rgb565_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  uint32_t *__pyx_v_rgbx;
  uint16_t __pyx_v_v;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565data_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565data_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+047:     if rgb565_len <= 0:
  __pyx_t_1 = ((__pyx_v_rgb565_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+048:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+049:     assert rgb565_len>0 and rgb565_len % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % rgb565_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_rgb565_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_rgb565_len % 2) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb565_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 49, __pyx_L1_error)
    }
  }
  #endif
+050:     cdef MemBuf output_buf = padbuf(rgb565_len*2, 2)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_rgb565_len * 2), 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 50, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+051:     cdef uint32_t *rgbx = <uint32_t*> output_buf.get_mem()
  __pyx_v_rgbx = ((uint32_t *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 052:     cdef uint16_t v
+053:     cdef unsigned int i = 0
  __pyx_v_i = 0;
+054:     cdef unsigned int l = rgb565_len//2
  __pyx_v_l = (__pyx_v_rgb565_len / 2);
+055:     for i in range(l):
  __pyx_t_5 = __pyx_v_l;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;
+056:         v = rgb565[i]
    __pyx_v_v = (__pyx_v_rgb565[__pyx_v_i]);
+057:         rgbx[i] = 0xff000000 | (((v & 0xF800) >> 8) + ((v & 0x07E0) << 5) + ((v & 0x001F) << 19))
    __pyx_t_4 = __Pyx_PyInt_From_long(((((__pyx_v_v & 0xF800) >> 8) + ((__pyx_v_v & 0x07E0) << 5)) + ((__pyx_v_v & 0x001F) << 19))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Or(__pyx_int_4278190080, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    (__pyx_v_rgbx[__pyx_v_i]) = __pyx_t_7;
  }
+058:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 059: 
+060: def bgr565_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb = {"bgr565_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_2bgr565_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_2bgr565_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  uint16_t const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__4 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgr565_to_rgb, __pyx_t_2) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgr565_to_rgb, 60, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 60, __pyx_L1_error)
+061:     assert len(buf) % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 2) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 61, __pyx_L1_error)
    }
  }
  #endif
 062:     # buf is a Python buffer object
+063:     cdef const uint16_t* cbuf = <const uint16_t*> 0
  __pyx_v_cbuf = ((uint16_t const *)0);
+064:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+065:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 65, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 65, __pyx_L1_error)
    }
  }
  #endif
+066:     return bgr565data_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 067: 
+068: cdef bgr565data_to_rgb(const uint16_t* rgb565, const int rgb565_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgb(uint16_t const *__pyx_v_rgb565, int const __pyx_v_rgb565_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  uint8_t *__pyx_v_rgb;
  uint32_t __pyx_v_v;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565data_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565data_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+069:     if rgb565_len <= 0:
  __pyx_t_1 = ((__pyx_v_rgb565_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+070:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+071:     assert rgb565_len>0 and rgb565_len % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % rgb565_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_rgb565_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_rgb565_len % 2) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb565_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 71, __pyx_L1_error)
    }
  }
  #endif
+072:     cdef MemBuf output_buf = padbuf(rgb565_len*3//2, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf(((__pyx_v_rgb565_len * 3) / 2), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 72, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+073:     cdef uint8_t *rgb = <uint8_t*> output_buf.get_mem()
  __pyx_v_rgb = ((uint8_t *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 074:     cdef uint32_t v
+075:     cdef unsigned int i = 0
  __pyx_v_i = 0;
+076:     cdef unsigned int l = rgb565_len//2
  __pyx_v_l = (__pyx_v_rgb565_len / 2);
+077:     for i in range(l):
  __pyx_t_5 = __pyx_v_l;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;
+078:         v = rgb565[i]
    __pyx_v_v = (__pyx_v_rgb565[__pyx_v_i]);
+079:         rgb[0] = (v & 0xF800) >> 8
    (__pyx_v_rgb[0]) = ((__pyx_v_v & 0xF800) >> 8);
+080:         rgb[1] = (v & 0x07E0) >> 3
    (__pyx_v_rgb[1]) = ((__pyx_v_v & 0x07E0) >> 3);
+081:         rgb[2] = (v & 0x001F) << 3
    (__pyx_v_rgb[2]) = ((__pyx_v_v & 0x001F) << 3);
+082:         rgb += 3
    __pyx_v_rgb = (__pyx_v_rgb + 3);
  }
+083:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 084: 
 085: 
+086: def r210_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_5r210_to_rgba = {"r210_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_4r210_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_4r210_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_5r210_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgba, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgba, 86, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 86, __pyx_L1_error)
+087:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 87, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 87, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 87, __pyx_L1_error)
    }
  }
  #endif
 088:     # buf is a Python buffer object
+089:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+090:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+091:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 91, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 91, __pyx_L1_error)
    }
  }
  #endif
+092:     return r210data_to_rgba(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgba(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 093: 
+094: cdef r210data_to_rgba(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgba(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+095:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+096:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+097:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 97, __pyx_L1_error)
    }
  }
  #endif
+098:     cdef MemBuf output_buf = getbuf(r210_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_r210_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 98, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+099:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 100:     #number of pixels:
+101:     cdef int i = 0
  __pyx_v_i = 0;
 102:     cdef unsigned int v
+103:     while i < r210_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_r210_len) != 0);
    if (!__pyx_t_1) break;
+104:         v = r210[i//4]
    __pyx_v_v = (__pyx_v_r210[(__pyx_v_i / 4)]);
+105:         rgba[i+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+106:         rgba[i+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+107:         rgba[i]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgba[__pyx_v_i]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+108:         rgba[i+3] = ((v&(<unsigned int>0xc0000000)) >> 30)*85
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (((__pyx_v_v & ((unsigned int)0xc0000000)) >> 30) * 85);
+109:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+110:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 111: 
 112: 
+113: def r210_to_rgbx(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_7r210_to_rgbx = {"r210_to_rgbx", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgbx (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_6r210_to_rgbx(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_6r210_to_rgbx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__8 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_7r210_to_rgbx, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgbx, __pyx_t_2) < 0) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgbx, 113, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 113, __pyx_L1_error)
+114:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 114, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 114, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 114, __pyx_L1_error)
    }
  }
  #endif
 115:     # buf is a Python buffer object
+116:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+117:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+118:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 118, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 118, __pyx_L1_error)
    }
  }
  #endif
+119:     return r210data_to_rgbx(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgbx(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 120: 
+121: cdef r210data_to_rgbx(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgbx(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgbx;
  int __pyx_v_i;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+122:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+123:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+124:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 124, __pyx_L1_error)
    }
  }
  #endif
+125:     cdef MemBuf output_buf = getbuf(r210_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_r210_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 125, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+126:     cdef unsigned char* rgbx = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgbx = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 127:     #number of pixels:
+128:     cdef int i = 0
  __pyx_v_i = 0;
 129:     cdef unsigned int v
+130:     while i < r210_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_r210_len) != 0);
    if (!__pyx_t_1) break;
+131:         v = r210[i//4]
    __pyx_v_v = (__pyx_v_r210[(__pyx_v_i / 4)]);
+132:         rgbx[i+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgbx[(__pyx_v_i + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+133:         rgbx[i+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgbx[(__pyx_v_i + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+134:         rgbx[i]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgbx[__pyx_v_i]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+135:         rgbx[i+3] = 0xFF
    (__pyx_v_rgbx[(__pyx_v_i + 3)]) = 0xFF;
+136:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+137:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 138: 
 139: 
+140: def r210_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_9r210_to_rgb = {"r210_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_8r210_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_8r210_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__10 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_9r210_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgb, __pyx_t_2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgb, 140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 140, __pyx_L1_error)
+141:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 141, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 141, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 141, __pyx_L1_error)
    }
  }
  #endif
 142:     # buf is a Python buffer object
+143:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+144:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+145:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 145, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 145, __pyx_L1_error)
    }
  }
  #endif
+146:     return r210data_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 147: 
 148: #white:  3fffffff
 149: #red:    3ff00000
 150: #green:     ffc00
 151: #blue:        3ff
 152: #black:         0
+153: cdef r210data_to_rgb(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgb(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_s;
  int __pyx_v_d;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+154:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+155:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+156:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 156, __pyx_L1_error)
    }
  }
  #endif
+157:     cdef MemBuf output_buf = padbuf(r210_len//4*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf(((__pyx_v_r210_len / 4) * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+158:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 159:     #number of pixels:
+160:     cdef int s = 0
  __pyx_v_s = 0;
+161:     cdef int d = 0
  __pyx_v_d = 0;
 162:     cdef unsigned int v
+163:     while s < r210_len//4:
  while (1) {
    __pyx_t_1 = ((__pyx_v_s < (__pyx_v_r210_len / 4)) != 0);
    if (!__pyx_t_1) break;
+164:         v = r210[s]
    __pyx_v_v = (__pyx_v_r210[__pyx_v_s]);
+165:         rgb[d+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgb[(__pyx_v_d + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+166:         rgb[d+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgb[(__pyx_v_d + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+167:         rgb[d]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgb[__pyx_v_d]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+168:         s += 1
    __pyx_v_s = (__pyx_v_s + 1);
+169:         d += 3
    __pyx_v_d = (__pyx_v_d + 3);
  }
+170:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 171: 
 172: 
+173: def argb_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_11argb_to_rgba = {"argb_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_10argb_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_10argb_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_11argb_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_argb_to_rgba, __pyx_t_2) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_argb_to_rgba, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 173, __pyx_L1_error)
+174:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 174, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 174, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 174, __pyx_L1_error)
    }
  }
  #endif
 175:     # buf is a Python buffer object
+176:     cdef const unsigned char * cbuf = <unsigned char *> 0
  __pyx_v_cbuf = ((unsigned char *)0);
+177:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+178:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 178, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 178, __pyx_L1_error)
    }
  }
  #endif
+179:     return argbdata_to_rgba(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgba(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 180: 
+181: cdef argbdata_to_rgba(const unsigned char* argb, const int argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgba(unsigned char const *__pyx_v_argb, int const __pyx_v_argb_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argbdata_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argbdata_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+182:     if argb_len <= 0:
  __pyx_t_1 = ((__pyx_v_argb_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+183:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+184:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 184, __pyx_L1_error)
    }
  }
  #endif
+185:     cdef MemBuf output_buf = getbuf(argb_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 185, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+186:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 187:     #number of pixels:
+188:     cdef int i = 0
  __pyx_v_i = 0;
+189:     while i < argb_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_argb_len) != 0);
    if (!__pyx_t_1) break;
+190:         rgba[i]    = argb[i+1]              #R
    (__pyx_v_rgba[__pyx_v_i]) = (__pyx_v_argb[(__pyx_v_i + 1)]);
+191:         rgba[i+1]  = argb[i+2]              #G
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = (__pyx_v_argb[(__pyx_v_i + 2)]);
+192:         rgba[i+2]  = argb[i+3]              #B
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = (__pyx_v_argb[(__pyx_v_i + 3)]);
+193:         rgba[i+3]  = argb[i]                #A
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (__pyx_v_argb[__pyx_v_i]);
+194:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+195:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 196: 
+197: def argb_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_13argb_to_rgb = {"argb_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_12argb_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_12argb_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__14 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_13argb_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_argb_to_rgb, __pyx_t_2) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_argb_to_rgb, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 197, __pyx_L1_error)
+198:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 198, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 198, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 198, __pyx_L1_error)
    }
  }
  #endif
 199:     # buf is a Python buffer object
+200:     cdef unsigned char * cbuf = <unsigned char *> 0     #@DuplicateSignature
  __pyx_v_cbuf = ((unsigned char *)0);
+201:     cdef Py_ssize_t cbuf_len = 0                        #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+202:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 202, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 202, __pyx_L1_error)
    }
  }
  #endif
+203:     return argbdata_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 204: 
+205: cdef argbdata_to_rgb(const unsigned char *argb, const int argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgb(unsigned char const *__pyx_v_argb, int const __pyx_v_argb_len) {
  unsigned int __pyx_v_mi;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_i;
  int __pyx_v_di;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argbdata_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argbdata_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+206:     if argb_len <= 0:
  __pyx_t_1 = ((__pyx_v_argb_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+207:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+208:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 208, __pyx_L1_error)
    }
  }
  #endif
 209:     #number of pixels:
+210:     cdef unsigned int mi = argb_len//4                #@DuplicateSignature
  __pyx_v_mi = (__pyx_v_argb_len / 4);
 211:     #3 bytes per pixel:
+212:     cdef MemBuf output_buf = padbuf(mi*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_mi * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 212, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+213:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+214:     cdef int i = 0, di = 0                          #@DuplicateSignature
  __pyx_v_i = 0;
  __pyx_v_di = 0;
+215:     while i < argb_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_argb_len) != 0);
    if (!__pyx_t_1) break;
+216:         rgb[di]   = argb[i+1]               #R
    (__pyx_v_rgb[__pyx_v_di]) = (__pyx_v_argb[(__pyx_v_i + 1)]);
+217:         rgb[di+1] = argb[i+2]               #G
    (__pyx_v_rgb[(__pyx_v_di + 1)]) = (__pyx_v_argb[(__pyx_v_i + 2)]);
+218:         rgb[di+2] = argb[i+3]               #B
    (__pyx_v_rgb[(__pyx_v_di + 2)]) = (__pyx_v_argb[(__pyx_v_i + 3)]);
+219:         di += 3
    __pyx_v_di = (__pyx_v_di + 3);
+220:         i += 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+221:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 222: 
 223: 
+224: def bgra_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_15bgra_to_rgb = {"bgra_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_14bgra_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_14bgra_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_bgra_buf;
  Py_ssize_t __pyx_v_bgra_buf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgra_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_bgra_buf, __pyx_n_s_bgra_buf_len); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_15bgra_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgra_to_rgb, __pyx_t_2) < 0) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgra_to_rgb, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 224, __pyx_L1_error)
+225:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 225, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 225, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 225, __pyx_L1_error)
    }
  }
  #endif
 226:     # buf is a Python buffer object
+227:     cdef unsigned char * bgra_buf = NULL    #@DuplicateSignature
  __pyx_v_bgra_buf = NULL;
+228:     cdef Py_ssize_t bgra_buf_len = 0        #@DuplicateSignature
  __pyx_v_bgra_buf_len = 0;
+229:     assert as_buffer(buf, <const void**> &bgra_buf, &bgra_buf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_bgra_buf)), (&__pyx_v_bgra_buf_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 229, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 229, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 229, __pyx_L1_error)
    }
  }
  #endif
+230:     return bgradata_to_rgb(bgra_buf, bgra_buf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgb(__pyx_v_bgra_buf, __pyx_v_bgra_buf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 231: 
+232: cdef bgradata_to_rgb(const unsigned char* bgra, const int bgra_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgb(unsigned char const *__pyx_v_bgra, int const __pyx_v_bgra_len) {
  int __pyx_v_mi;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_di;
  int __pyx_v_si;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgradata_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgradata_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+233:     if bgra_len <= 0:
  __pyx_t_1 = ((__pyx_v_bgra_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+234:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+235:     assert bgra_len>0 and bgra_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % bgra_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_bgra_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_bgra_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_bgra_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 235, __pyx_L1_error)
    }
  }
  #endif
 236:     #number of pixels:
+237:     cdef int mi = bgra_len//4                #@DuplicateSignature
  __pyx_v_mi = (__pyx_v_bgra_len / 4);
 238:     #3 bytes per pixel:
+239:     cdef MemBuf output_buf = padbuf(mi*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_mi * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 239, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+240:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+241:     cdef int di = 0, si = 0                  #@DuplicateSignature
  __pyx_v_di = 0;
  __pyx_v_si = 0;
+242:     while si < bgra_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_si < __pyx_v_bgra_len) != 0);
    if (!__pyx_t_1) break;
+243:         rgb[di]   = bgra[si+2]              #R
    (__pyx_v_rgb[__pyx_v_di]) = (__pyx_v_bgra[(__pyx_v_si + 2)]);
+244:         rgb[di+1] = bgra[si+1]              #G
    (__pyx_v_rgb[(__pyx_v_di + 1)]) = (__pyx_v_bgra[(__pyx_v_si + 1)]);
+245:         rgb[di+2] = bgra[si]                #B
    (__pyx_v_rgb[(__pyx_v_di + 2)]) = (__pyx_v_bgra[__pyx_v_si]);
+246:         di += 3
    __pyx_v_di = (__pyx_v_di + 3);
+247:         si += 4
    __pyx_v_si = (__pyx_v_si + 4);
  }
+248:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 249: 
+250: def bgra_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_17bgra_to_rgba = {"bgra_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_16bgra_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_16bgra_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_bgra_buf2;
  Py_ssize_t __pyx_v_bgra_buf_len2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgra_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_bgra_buf2, __pyx_n_s_bgra_buf_len2); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_17bgra_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgra_to_rgba, __pyx_t_2) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgra_to_rgba, 250, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 250, __pyx_L1_error)
+251:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 251, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 251, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 251, __pyx_L1_error)
    }
  }
  #endif
 252:     # buf is a Python buffer object
+253:     cdef unsigned char * bgra_buf2 = NULL
  __pyx_v_bgra_buf2 = NULL;
+254:     cdef Py_ssize_t bgra_buf_len2 = 0
  __pyx_v_bgra_buf_len2 = 0;
+255:     assert as_buffer(buf, <const void**> &bgra_buf2, &bgra_buf_len2)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_bgra_buf2)), (&__pyx_v_bgra_buf_len2)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 255, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 255, __pyx_L1_error)
    }
  }
  #endif
+256:     return bgradata_to_rgba(bgra_buf2, bgra_buf_len2)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgba(__pyx_v_bgra_buf2, __pyx_v_bgra_buf_len2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 257: 
+258: cdef bgradata_to_rgba(const unsigned char* bgra, const int bgra_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgba(unsigned char const *__pyx_v_bgra, int const __pyx_v_bgra_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgradata_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgradata_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+259:     if bgra_len <= 0:
  __pyx_t_1 = ((__pyx_v_bgra_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+260:         return None
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
+261:     assert bgra_len>0 and bgra_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % bgra_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_bgra_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_bgra_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_bgra_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 261, __pyx_L1_error)
    }
  }
  #endif
 262:     #same number of bytes:
+263:     cdef MemBuf output_buf = getbuf(bgra_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_bgra_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 263, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+264:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+265:     cdef int i = 0                      #@DuplicateSignature
  __pyx_v_i = 0;
+266:     while i < bgra_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_bgra_len) != 0);
    if (!__pyx_t_1) break;
+267:         rgba[i]   = bgra[i+2]           #R
    (__pyx_v_rgba[__pyx_v_i]) = (__pyx_v_bgra[(__pyx_v_i + 2)]);
+268:         rgba[i+1] = bgra[i+1]           #G
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = (__pyx_v_bgra[(__pyx_v_i + 1)]);
+269:         rgba[i+2] = bgra[i]             #B
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = (__pyx_v_bgra[__pyx_v_i]);
+270:         rgba[i+3] = bgra[i+3]           #A
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (__pyx_v_bgra[(__pyx_v_i + 3)]);
+271:         i += 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+272:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 273: 
+274: def rgba_to_bgra(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_19rgba_to_bgra = {"rgba_to_bgra", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rgba_to_bgra (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_18rgba_to_bgra(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_18rgba_to_bgra(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rgba_to_bgra", 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.argb.argb.rgba_to_bgra", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_19rgba_to_bgra, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rgba_to_bgra, __pyx_t_2) < 0) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_rgba_to_bgra, 274, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 274, __pyx_L1_error)
 275:     #same: just a swap
+276:     return bgra_to_rgba(buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_bgra_to_rgba); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_buf};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_buf};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_buf);
      __Pyx_GIVEREF(__pyx_v_buf);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_buf);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 277: 
 278: 
+279: def premultiply_argb_in_place(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place = {"premultiply_argb_in_place", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("premultiply_argb_in_place (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_20premultiply_argb_in_place(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_20premultiply_argb_in_place(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("premultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.premultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_premultiply_argb_in_place, __pyx_t_2) < 0) __PYX_ERR(0, 279, __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_argb_argb_pyx, __pyx_n_s_premultiply_argb_in_place, 279, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 279, __pyx_L1_error)
 280:     # b is a Python buffer object
+281:     cdef unsigned int * cbuf = <unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int *)0);
+282:     cdef Py_ssize_t cbuf_len = 0                #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+283:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 283, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 283, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 283, __pyx_L1_error)
    }
  }
  #endif
+284:     assert object_as_write_buffer(buf, <void **>&cbuf, &cbuf_len)==0
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_write_buffer(__pyx_v_buf, ((void **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)) == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 284, __pyx_L1_error)
    }
  }
  #endif
+285:     do_premultiply_argb_in_place(cbuf, cbuf_len)
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_premultiply_argb_in_place(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 286: 
+287: cdef do_premultiply_argb_in_place(unsigned int *buf, Py_ssize_t argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_premultiply_argb_in_place(unsigned int *__pyx_v_buf, Py_ssize_t __pyx_v_argb_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_premultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_premultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 288:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 289:     # We convert to premultiplied ARGB32 data, in-place.
 290:     cdef unsigned char a, r, g, b
 291:     cdef unsigned int argb
+292:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 292, __pyx_L1_error)
    }
  }
  #endif
 293:     cdef int i
+294:     for 0 <= i < argb_len / 4:
  __pyx_t_5 = (__pyx_v_argb_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+295:         argb = buf[i]
    __pyx_v_argb = (__pyx_v_buf[__pyx_v_i]);
+296:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+297:         r = (argb >> 16) & 0xff
    __pyx_v_r = ((__pyx_v_argb >> 16) & 0xff);
+298:         r = r * a // 255
    __pyx_v_r = ((__pyx_v_r * __pyx_v_a) / 0xFF);
+299:         g = (argb >> 8) & 0xff
    __pyx_v_g = ((__pyx_v_argb >> 8) & 0xff);
+300:         g = g * a // 255
    __pyx_v_g = ((__pyx_v_g * __pyx_v_a) / 0xFF);
+301:         b = (argb >> 0) & 0xff
    __pyx_v_b = ((__pyx_v_argb >> 0) & 0xff);
+302:         b = b * a // 255
    __pyx_v_b = ((__pyx_v_b * __pyx_v_a) / 0xFF);
+303:         buf[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0)
    (__pyx_v_buf[__pyx_v_i]) = ((((__pyx_v_a << 24) | (__pyx_v_r << 16)) | (__pyx_v_g << 8)) | (__pyx_v_b << 0));
  }
 304: 
+305: def unpremultiply_argb_in_place(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place = {"unpremultiply_argb_in_place", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb_in_place (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_22unpremultiply_argb_in_place(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_22unpremultiply_argb_in_place(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.unpremultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpremultiply_argb_in_place, __pyx_t_2) < 0) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 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_argb_argb_pyx, __pyx_n_s_unpremultiply_argb_in_place, 305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 305, __pyx_L1_error)
 306:     # b is a Python buffer object
+307:     cdef unsigned int * cbuf = <unsigned int *> 0   #@DuplicateSignature
  __pyx_v_cbuf = ((unsigned int *)0);
+308:     cdef Py_ssize_t cbuf_len = 0                    #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+309:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 309, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 309, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 309, __pyx_L1_error)
    }
  }
  #endif
+310:     assert object_as_write_buffer(buf, <void **>&cbuf, &cbuf_len)==0, "cannot convert %s to a writable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_write_buffer(__pyx_v_buf, ((void **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)) == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_convert_s_to_a_writable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 310, __pyx_L1_error)
    }
  }
  #endif
+311:     do_unpremultiply_argb_in_place(cbuf, cbuf_len)
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb_in_place(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 312: 
+313: cdef do_unpremultiply_argb_in_place(unsigned int * buf, Py_ssize_t buf_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb_in_place(unsigned int *__pyx_v_buf, Py_ssize_t __pyx_v_buf_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_unpremultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_unpremultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 314:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 315:     # We convert to premultiplied ARGB32 data, in-place.
 316:     cdef unsigned char a, r, g, b                   #@DuplicateSignature
 317:     cdef unsigned int argb                          #@DuplicateSignature
+318:     assert buf_len>0 and buf_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % buf_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_buf_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_buf_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_buf_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 318, __pyx_L1_error)
    }
  }
  #endif
 319:     cdef int i                                      #@DuplicateSignature
+320:     for 0 <= i < buf_len // 4:
  __pyx_t_5 = (__pyx_v_buf_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+321:         argb = buf[i]
    __pyx_v_argb = (__pyx_v_buf[__pyx_v_i]);
+322:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+323:         if a==0:
    __pyx_t_1 = ((__pyx_v_a == 0) != 0);
    if (__pyx_t_1) {
/* … */
    }
+324:             buf[i] = 0
      (__pyx_v_buf[__pyx_v_i]) = 0;
+325:             continue
      goto __pyx_L5_continue;
+326:         r = clamp(((argb >> 16) & 0xff) * 255 // a)
    __pyx_v_r = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 16) & 0xff) * 0xFF) / __pyx_v_a));
+327:         g = clamp(((argb >> 8) & 0xff) * 255 // a)
    __pyx_v_g = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 8) & 0xff) * 0xFF) / __pyx_v_a));
+328:         b = clamp(((argb >> 0) & 0xff) * 255 // a)
    __pyx_v_b = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 0) & 0xff) * 0xFF) / __pyx_v_a));
+329:         buf[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0)
    (__pyx_v_buf[__pyx_v_i]) = ((((__pyx_v_a << 24) | (__pyx_v_r << 16)) | (__pyx_v_g << 8)) | (__pyx_v_b << 0));
    __pyx_L5_continue:;
  }
 330: 
+331: def unpremultiply_argb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_25unpremultiply_argb = {"unpremultiply_argb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_24unpremultiply_argb(__pyx_self, ((PyObject *)__pyx_v_buf));

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

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_24unpremultiply_argb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_argb;
  Py_ssize_t __pyx_v_argb_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.unpremultiply_argb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__26 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_argb, __pyx_n_s_argb_len); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_25unpremultiply_argb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpremultiply_argb, __pyx_t_2) < 0) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_unpremultiply_argb, 331, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 331, __pyx_L1_error)
 332:     # b is a Python buffer object
+333:     cdef unsigned int * argb = <unsigned int *> 0   #@DuplicateSignature
  __pyx_v_argb = ((unsigned int *)0);
+334:     cdef Py_ssize_t argb_len = 0                    #@DuplicateSignature
  __pyx_v_argb_len = 0;
+335:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 335, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 335, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 335, __pyx_L1_error)
    }
  }
  #endif
+336:     assert as_buffer(buf, <const void **>&argb, &argb_len)==0
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_argb)), (&__pyx_v_argb_len)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 336, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 336, __pyx_L1_error)
    }
  }
  #endif
+337:     return do_unpremultiply_argb(argb, argb_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb(__pyx_v_argb, __pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 338: 
 339: 
 340: #precalculate indexes in native endianness:
+341: tmp = struct.pack("=L", 0 + 1*(2**8) + 2*(2**16) + 3*(2**24))
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pack); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_tmp, __pyx_t_2) < 0) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* … */
  __pyx_tuple__28 = PyTuple_Pack(2, __pyx_kp_s_L, __pyx_int_50462976); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);
 342: #little endian will give 0, 1, 2, 3
 343: #big endian should give 3, 2, 1, 0 (untested)
+344: cdef unsigned char B = tmp.index(b'\0')
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tmp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_unsigned_char(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_B = __pyx_t_4;
/* … */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_b__29); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
+345: cdef unsigned char G = tmp.index(b'\1')
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tmp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_unsigned_char(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_G = __pyx_t_4;
/* … */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_b__31); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
+346: cdef unsigned char R = tmp.index(b'\2')
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tmp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_unsigned_char(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_R = __pyx_t_4;
/* … */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_b__33); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
+347: cdef unsigned char A = tmp.index(b'\3')
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tmp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__36, NULL); 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;
  __pyx_t_4 = __Pyx_PyInt_As_unsigned_char(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_A = __pyx_t_4;
 348: 
+349: cdef do_unpremultiply_argb(unsigned int * argb_in, Py_ssize_t argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb(unsigned int *__pyx_v_argb_in, Py_ssize_t __pyx_v_argb_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_argb_out;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_unpremultiply_argb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_unpremultiply_argb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 350:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 351:     # We convert to premultiplied ARGB32 data
 352:     cdef unsigned char a, r, g, b                #@DuplicateSignature
 353:     cdef unsigned int argb                      #@DuplicateSignature
+354:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 354, __pyx_L1_error)
    }
  }
  #endif
+355:     cdef MemBuf output_buf = getbuf(argb_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 355, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+356:     cdef unsigned char* argb_out = <unsigned char*> output_buf.get_mem()
  __pyx_v_argb_out = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 357:     cdef int i                                  #@DuplicateSignature
+358:     for 0 <= i < argb_len // 4:
  __pyx_t_5 = (__pyx_v_argb_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+359:         argb = argb_in[i]
    __pyx_v_argb = (__pyx_v_argb_in[__pyx_v_i]);
+360:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+361:         r = (argb >> 16) & 0xff
    __pyx_v_r = ((__pyx_v_argb >> 16) & 0xff);
+362:         g = (argb >> 8) & 0xff
    __pyx_v_g = ((__pyx_v_argb >> 8) & 0xff);
+363:         b = (argb >> 0) & 0xff
    __pyx_v_b = ((__pyx_v_argb >> 0) & 0xff);
+364:         if a!=0:
    __pyx_t_1 = ((__pyx_v_a != 0) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L7;
    }
+365:             r = clamp(r * 255 // a)
      __pyx_v_r = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_r * 0xFF) / __pyx_v_a));
+366:             g = clamp(g * 255 // a)
      __pyx_v_g = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_g * 0xFF) / __pyx_v_a));
+367:             b = clamp(b * 255 // a)
      __pyx_v_b = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_b * 0xFF) / __pyx_v_a));
 368:         else:
+369:             r = 0
    /*else*/ {
      __pyx_v_r = 0;
+370:             g = 0
      __pyx_v_g = 0;
+371:             b = 0
      __pyx_v_b = 0;
    }
    __pyx_L7:;
 372:         #we could use struct pack to avoid endianness issues
 373:         #but this is python 2.5 onwards only and is probably slower:
 374:         #struct.pack_into("=BBBB", argb_out, i*4, b, g, r, a)
+375:         argb_out[i*4+B] = b
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_B)]) = __pyx_v_b;
+376:         argb_out[i*4+G] = g
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_G)]) = __pyx_v_g;
+377:         argb_out[i*4+R] = r
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_R)]) = __pyx_v_r;
+378:         argb_out[i*4+A] = a
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_A)]) = __pyx_v_a;
  }
+379:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_output_buf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_output_buf));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_output_buf));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;