From 3005990c16b3bd7b2264d7b6342601cb29ecea6e Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 13 Oct 2013 06:32:36 +0000 Subject: [PATCH] make the buffer read/write by default so we can use it with opencl csc.. git-svn-id: https://xpra.org/svn/Xpra/trunk@4480 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/codecs/dec_avcodec/decoder.pyx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/xpra/codecs/dec_avcodec/decoder.pyx b/src/xpra/codecs/dec_avcodec/decoder.pyx index 5e1d386450..e8ad343213 100644 --- a/src/xpra/codecs/dec_avcodec/decoder.pyx +++ b/src/xpra/codecs/dec_avcodec/decoder.pyx @@ -9,6 +9,9 @@ log = Logger() debug = debug_if_env(log, "XPRA_AVCODEC_DEBUG") error = log.error +#some consumers need a writeable buffer (ie: OpenCL...) +READ_ONLY = False + from xpra.codecs.codec_constants import get_subsampling_divs, get_colorspace_from_avutil_enum, RGB_FORMATS from xpra.codecs.image_wrapper import ImageWrapper @@ -22,6 +25,7 @@ cdef extern from "Python.h": ctypedef int Py_ssize_t ctypedef object PyObject 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 @@ -492,13 +496,19 @@ cdef class Decoder: stride = self.frame.linesize[i] size = height * stride outsize += size - plane = PyBuffer_FromMemory(self.frame.data[i], size) + if READ_ONLY: + plane = PyBuffer_FromMemory(self.frame.data[i], size) + else: + plane = PyBuffer_FromReadWriteMemory(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 = PyBuffer_FromMemory(self.frame.data[0], outsize) + if READ_ONLY: + out = PyBuffer_FromMemory(self.frame.data[0], outsize) + else: + out = PyBuffer_FromReadWriteMemory(self.frame.data[0], outsize) nplanes = 0 if outsize==0: self.frame_error()