Skip to content

Commit

Permalink
#1462 move colourspace conversion to the restored csc_cython module
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26940 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 10, 2020
1 parent dc7afca commit 3652e93
Show file tree
Hide file tree
Showing 7 changed files with 772 additions and 53 deletions.
34 changes: 0 additions & 34 deletions src/xpra/codecs/argb/argb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -192,40 +192,6 @@ cdef r210data_to_rgb(unsigned int* r210,
return memoryview(output_buf)


def r210_to_bgr48(buf,
const unsigned int w, const unsigned int h,
const unsigned int src_stride, const unsigned int dst_stride):
assert buf, "no buffer"
assert w*4<=src_stride, "invalid source stride %i for width %i" % (src_stride, w)
assert w*6<=dst_stride, "invalid destination stride %i for width %i" % (dst_stride, w)
assert (dst_stride%2)==0, "invalid destination stride %i (odd number)" % (dst_stride)
cdef unsigned int* cbuf = <unsigned int *> 0
cdef Py_ssize_t cbuf_len = 0
assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
assert cbuf_len>0, "invalid buffer size: %i" % cbuf_len
assert cbuf_len>=h*src_stride, "source buffer is %i bytes, which is too small for %ix%i" % (cbuf_len, src_stride, h)
return r210data_to_bgr48(cbuf, w, h, src_stride, dst_stride)

cdef r210data_to_bgr48(unsigned int* r210,
const unsigned int w, const unsigned int h,
const unsigned int src_stride, const unsigned int dst_stride):
cdef MemBuf output_buf = getbuf(h*dst_stride*10)
cdef unsigned short* rgba = <unsigned short*> output_buf.get_mem()
cdef unsigned int y = 0
cdef unsigned int i = 0
cdef unsigned int v
for y in range(h):
i = y*dst_stride//2
for x in range(w):
v = r210[x]
rgba[i] = v&0x000003ff
rgba[i+1] = (v&0x000ffc00) >> 10
rgba[i+2] = (v&0x3ff00000) >> 20
i = i + 3
r210 = <unsigned int*> ((<uintptr_t> r210) + src_stride)
return memoryview(output_buf)


def argb_to_rgba(buf):
assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
# buf is a Python buffer object
Expand Down
7 changes: 5 additions & 2 deletions src/xpra/codecs/codec_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def make_test_image(pixel_format, w, h):
strides.append(w//vdiv[0])
image = ImageWrapper(0, 0, w, h, planes, pixel_format, 32, strides, planes=nplanes, thread_safe=True)
#l = len(y)+len(u)+len(v)
elif pixel_format in ("RGB", "BGR", "RGBX", "BGRX", "XRGB", "BGRA", "RGBA", "r210"):
stride = w*len(pixel_format)
elif pixel_format in ("RGB", "BGR", "RGBX", "BGRX", "XRGB", "BGRA", "RGBA", "r210", "BGR48"):
if pixel_format=="BGR48":
stride = w*6
else:
stride = w*len(pixel_format)
rgb_data = makebuf(stride*h)
image = ImageWrapper(0, 0, w, h, rgb_data, pixel_format, 32, stride, planes=ImageWrapper.PACKED, thread_safe=True)
#l = len(rgb_data)
Expand Down
4 changes: 4 additions & 0 deletions src/xpra/codecs/csc_cython/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of Xpra.
# Copyright (C) 2013 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Loading

0 comments on commit 3652e93

Please sign in to comment.