Skip to content

Commit

Permalink
#2828 use opengl for byte-swapping
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26948 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 11, 2020
1 parent 898d69c commit 7f59dea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 1 addition & 15 deletions src/xpra/codecs/dec_avcodec2/decoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<void *>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(<void *>av_frame.data[i], size, True))
strides.append(stride)
log("decompress_image() read back '%s' plane: %s bytes", cs[i:i+1], size)
else:
Expand Down

0 comments on commit 7f59dea

Please sign in to comment.