From 7f59deacf6d807d0b06b58e9f09e964bba6a48f0 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 11 Jul 2020 04:07:31 +0000 Subject: [PATCH] #2828 use opengl for byte-swapping git-svn-id: https://xpra.org/svn/Xpra/trunk@26948 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gl/gl_window_backing_base.py | 3 +++ src/xpra/codecs/dec_avcodec2/decoder.pyx | 16 +--------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/xpra/client/gl/gl_window_backing_base.py b/src/xpra/client/gl/gl_window_backing_base.py index 4fb9a200d6..03e53154cb 100644 --- a/src/xpra/client/gl/gl_window_backing_base.py +++ b/src/xpra/client/gl/gl_window_backing_base.py @@ -21,6 +21,7 @@ GL_DONT_CARE, GL_TRUE, GL_DEPTH_TEST, GL_SCISSOR_TEST, GL_LIGHTING, GL_DITHER, GL_RGB, GL_RGBA, GL_BGR, GL_BGRA, GL_RGBA8, GL_RGB8, GL_RGB10_A2, GL_RGB565, GL_RGB5_A1, GL_RGBA4, GL_RGBA16, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_SHORT_5_6_5, + GL_UNPACK_SWAP_BYTES, GL_BLEND, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_BASE_LEVEL, GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST, @@ -1192,6 +1193,7 @@ def update_planar_textures(self, width : int, height : int, img, pixel_format, s rowstrides = img.get_rowstride() img_data = img.get_pixels() BPP = 2 if pixel_format.endswith("P10") else 1 + glPixelStorei(GL_UNPACK_SWAP_BYTES, BPP==2) assert len(rowstrides)==3 and len(img_data)==3 for texture, index, tex_name in ( (GL_TEXTURE0, TEX_Y, "Y"*BPP), @@ -1221,6 +1223,7 @@ def update_planar_textures(self, width : int, height : int, img, pixel_format, s glTexSubImage2D(target, 0, 0, 0, w, h, GL_LUMINANCE, upload_format, pixel_data) glBindTexture(target, 0) #glActiveTexture(GL_TEXTURE0) #redundant, we always call render_planar_update afterwards + glPixelStorei(GL_UNPACK_SWAP_BYTES, False) def render_planar_update(self, rx : int, ry : int, rw : int, rh : int, x_scale=1, y_scale=1, shader=YUV2RGB_SHADER): log("%s.render_planar_update%s pixel_format=%s", diff --git a/src/xpra/codecs/dec_avcodec2/decoder.pyx b/src/xpra/codecs/dec_avcodec2/decoder.pyx index 0597b4479c..a58d77639c 100644 --- a/src/xpra/codecs/dec_avcodec2/decoder.pyx +++ b/src/xpra/codecs/dec_avcodec2/decoder.pyx @@ -982,21 +982,7 @@ cdef class Decoder: size = height * stride outsize += size - if cs=="GBRP10": - b = bytearray(size) - for z in range(size//2): - b[z*2] = av_frame.data[i][z*2+1] - b[z*2+1] = av_frame.data[i][z*2] - obuf = bytes(b) - else: - obuf = memory_as_pybuffer(av_frame.data[i], size, True) - out.append(obuf) - #if cs=="GBRP10": - # from xpra.os_util import memoryview_to_bytes - # for y in range(12): - # line = height*y//12 - # line_data = memoryview_to_bytes(out[-1])[line*stride:(line+1)*stride] - # log("plane %s line %3i %s..%s", cs[i:i+1], line, hexstr(line_data[:10]), hexstr(line_data[-10:])) + out.append(memory_as_pybuffer(av_frame.data[i], size, True)) strides.append(stride) log("decompress_image() read back '%s' plane: %s bytes", cs[i:i+1], size) else: