From d32f9b049716e5d87a5fc509255d3c80143ef76e Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 5 Aug 2013 05:50:57 +0000 Subject: [PATCH] revert r4017: PyString_FromStringAndSize makes a copy of the data whereas PyBuffer_FromMemory does not, so we might as well make the copy only in the codepath that needs it: in the opengl backing, but now we also do this copy from the decoding thread rather than the UI thread git-svn-id: https://xpra.org/svn/Xpra/trunk@4048 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gl/gl_window_backing.py | 3 ++- src/xpra/codecs/dec_avcodec/decoder.pyx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/xpra/client/gl/gl_window_backing.py b/src/xpra/client/gl/gl_window_backing.py index 5ebc9e0caa..d25e158cf5 100644 --- a/src/xpra/client/gl/gl_window_backing.py +++ b/src/xpra/client/gl/gl_window_backing.py @@ -360,6 +360,7 @@ def _do_paint_rgb24(self, img_data, x, y, width, height, rowstride, options, cal return True def do_video_paint(self, img, x, y, enc_width, enc_height, width, height, options, callbacks): + img.clone_pixel_data() gobject.idle_add(self.gl_paint_planar, img, x, y, enc_width, enc_height, width, height, callbacks) def gl_paint_planar(self, img, x, y, enc_width, enc_height, width, height, callbacks): @@ -424,7 +425,7 @@ def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling glActiveTexture(texture) glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[index]) glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[index]) - pixel_data = img_data[index] + pixel_data = img_data[index][:] debug("texture %s: div=%s, rowstride=%s, %sx%s, data=%s bytes", index, divs[index], rowstrides[index], width/div_w, height/div_h, len(pixel_data)) glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data) if index == 1: diff --git a/src/xpra/codecs/dec_avcodec/decoder.pyx b/src/xpra/codecs/dec_avcodec/decoder.pyx index 553c0b587e..d96ee3af27 100644 --- a/src/xpra/codecs/dec_avcodec/decoder.pyx +++ b/src/xpra/codecs/dec_avcodec/decoder.pyx @@ -21,7 +21,7 @@ cdef extern from *: cdef extern from "Python.h": ctypedef int Py_ssize_t ctypedef object PyObject - object PyString_FromStringAndSize(const char *v, Py_ssize_t len) + object PyBuffer_FromMemory(void *ptr, Py_ssize_t size) object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) int PyObject_AsReadBuffer(object obj, void ** buffer, Py_ssize_t * buffer_len) except -1 @@ -451,13 +451,13 @@ cdef class Decoder: stride = self.frame.linesize[i] size = height * stride outsize += size - plane = PyString_FromStringAndSize(self.frame.data[i], size) + plane = PyBuffer_FromMemory(self.frame.data[i], size) out.append(plane) strides.append(stride) else: strides = self.frame.linesize[0]+self.frame.linesize[1]+self.frame.linesize[2] outsize = self.codec_ctx.height * strides - out = PyString_FromStringAndSize(self.frame.data[0], outsize) + out = PyBuffer_FromMemory(self.frame.data[0], outsize) nplanes = 0 if outsize==0: raise Exception("output size is zero!")