xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #465: memoryview-encode.patch

File memoryview-encode.patch, 5.0 KB (added by Antoine Martin, 6 years ago)

changes that may be needed for memoryview support encoding side

  • xpra/codecs/nvenc3/encoder.pyx

     
    1414from pycuda import driver
    1515from pycuda.compiler import compile
    1616
     17from xpra.os_util import memoryview_to_bytes
    1718from xpra.util import AtomicInteger, updict
    1819from xpra.codecs.cuda_common.cuda_context import init_all_devices, select_device, get_pycuda_info, device_info, reset_state, \
    1920                get_CUDA_function, record_device_failure, record_device_success
     
    17701771        assert (w & WIDTH_MASK)<=self.input_width, "invalid width: %s" % w
    17711772        assert (h & HEIGHT_MASK)<=self.input_height, "invalid height: %s" % h
    17721773        pixels = image.get_pixels()
     1774        pixels = memoryview_to_bytes(image.get_pixels())
    17731775        image_stride = image.get_rowstride()
    17741776        input_size = self.inputPitch * self.input_height
    17751777
  • xpra/codecs/nvenc4/encoder.pyx

     
    1515from pycuda import driver
    1616from pycuda.compiler import compile
    1717
     18from xpra.os_util import memoryview_to_bytes
    1819from xpra.util import AtomicInteger, updict
    1920from xpra.codecs.cuda_common.cuda_context import init_all_devices, get_devices, select_device, get_pycuda_info, device_info, reset_state, \
    2021                get_CUDA_function, record_device_failure, record_device_success
     
    18051806        h = image.get_height()
    18061807        assert (w & WIDTH_MASK)<=self.input_width, "invalid width: %s" % w
    18071808        assert (h & HEIGHT_MASK)<=self.input_height, "invalid height: %s" % h
    1808         pixels = image.get_pixels()
     1809        pixels = memoryview_to_bytes(image.get_pixels())
    18091810        image_stride = image.get_rowstride()
    18101811        input_size = self.inputPitch * self.input_height
    18111812
  • xpra/codecs/nvenc5/encoder.pyx

     
    1515from pycuda import driver
    1616from pycuda.compiler import compile
    1717
     18from xpra.os_util import memoryview_to_bytes
    1819from xpra.util import AtomicInteger, updict
    1920from xpra.codecs.cuda_common.cuda_context import init_all_devices, get_devices, select_device, get_pycuda_info, device_info, reset_state, \
    2021                get_CUDA_function, record_device_failure, record_device_success
     
    17891790        assert (w & WIDTH_MASK)<=self.input_width, "invalid width: %s" % w
    17901791        assert (h & HEIGHT_MASK)<=self.input_height, "invalid height: %s" % h
    17911792        pixels = image.get_pixels()
     1793        pixels = memoryview_to_bytes(image.get_pixels())
    17921794        image_stride = image.get_rowstride()
    17931795        input_size = self.inputPitch * self.input_height
    17941796
  • xpra/codecs/webp/encode.pyx

     
    55
    66import os
    77
     8from xpra.os_util import memoryview_to_bytes
    89from xpra.log import Logger
    910log = Logger("encoder", "webp")
    1011
     
    338339    if width*height<8192:
    339340        preset = WEBP_PRESET_ICON
    340341
     342    pixels = memoryview_to_bytes(pixels)
    341343    i = object_as_buffer(pixels, <const void**> &pic_buf, &pic_buf_len)
    342344    assert i>=0, "failed to get buffer from pixel object: %s" % type(pixels)
    343345    log("webp.compress(%s bytes, %s, %s, %s, %s, %s, %s) buf=%#x", len(pixels), width, height, stride, quality, speed, has_alpha, <unsigned long> pic_buf)
  • xpra/net/mmap_pipe.py

     
    55
    66import os
    77import ctypes
    8 from xpra.os_util import strtobytes
     8from xpra.os_util import strtobytes, memoryview_to_bytes
    99from xpra.simple_stats import to_std_unit
    1010from xpra.log import Logger
    1111log = Logger("mmap")
     
    205205        #[+++++++++E------------------------]
    206206        #[+++++++++**********E--------------]
    207207        mmap_area.seek(end)
    208         mmap_area.write(data)
     208        mmap_area.write(memoryview_to_bytes(data))
    209209        data = [(end, l)]
    210210        mmap_data_end.value = end+l
    211211    else:
  • xpra/os_util.py

     
    2828    import __builtin__ as builtins      #@Reimport @UnusedImport
    2929_memoryview = builtins.__dict__.get("memoryview")
    3030has_memoryview = _memoryview is not None
     31#python3 only?
     32has_memoryview_cast = has_memoryview and hasattr(_memoryview, "cast")
    3133
    3234
    3335SIGNAMES = {}
     
    7274def memoryview_to_bytes(v):
    7375    if not has_memoryview:
    7476        return v
     77    if has_memoryview_cast:
     78        return v.cast('B')
    7579    if _memoryview and isinstance(v, _memoryview):
    7680        return v.tobytes()
    7781    return v