diff --git a/xpra/codecs/avif/decoder.pyx b/xpra/codecs/avif/decoder.pyx index 530674944f..bdc8bd3d92 100644 --- a/xpra/codecs/avif/decoder.pyx +++ b/xpra/codecs/avif/decoder.pyx @@ -33,9 +33,6 @@ from libc.stdlib cimport free cdef extern from *: ctypedef unsigned long size_t -cdef extern from "Python.h": - object PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags) - AVIF_PIXEL_FORMAT = { AVIF_PIXEL_FORMAT_NONE : "NONE", diff --git a/xpra/codecs/csc_cython/colorspace_converter.pyx b/xpra/codecs/csc_cython/colorspace_converter.pyx index 7e6b0a2144..f3892698e4 100644 --- a/xpra/codecs/csc_cython/colorspace_converter.pyx +++ b/xpra/codecs/csc_cython/colorspace_converter.pyx @@ -26,6 +26,7 @@ cdef extern from "Python.h": int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) void PyBuffer_Release(Py_buffer *view) int PyBUF_ANY_CONTIGUOUS + int PyBUF_WRITE cdef extern from "stdlib.h": void free(void *ptr) @@ -625,7 +626,7 @@ cdef class ColorspaceConverter: cdef unsigned char i for i in range(3): strides.append(self.dst_strides[i]) - planes.append(PyMemoryView_FromMemory( (( buf) + self.offsets[i]), self.dst_sizes[i], True)) + planes.append(PyMemoryView_FromMemory( (( buf) + self.offsets[i]), self.dst_sizes[i], PyBUF_WRITE)) out_image = CythonImageWrapper(0, 0, self.dst_width, self.dst_height, planes, self.dst_format, bpp, strides, planes=ImageWrapper.PLANAR_3) @@ -740,7 +741,7 @@ cdef class ColorspaceConverter: return self.packed_image_wrapper( bgr48, 48) cdef packed_image_wrapper(self, char *buf, unsigned char bpp=24): - pybuf = PyMemoryView_FromMemory(buf, self.dst_sizes[0], True) + pybuf = PyMemoryView_FromMemory(buf, self.dst_sizes[0], PyBUF_WRITE) out_image = CythonImageWrapper(0, 0, self.dst_width, self.dst_height, pybuf, self.dst_format, bpp, self.dst_strides[0], planes=ImageWrapper.PACKED) out_image.cython_buffer = buf return out_image diff --git a/xpra/codecs/libyuv/colorspace_converter.pyx b/xpra/codecs/libyuv/colorspace_converter.pyx index 07f7e9ee72..2569ff232c 100644 --- a/xpra/codecs/libyuv/colorspace_converter.pyx +++ b/xpra/codecs/libyuv/colorspace_converter.pyx @@ -23,6 +23,7 @@ from libc.stdlib cimport free cdef extern from "Python.h": object PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags) + int PyBUF_WRITE cdef extern from "libyuv/convert_from_argb.h" namespace "libyuv": #int BGRAToI420(const uint8_t* src_frame, ... @@ -575,7 +576,7 @@ cdef class ColorspaceConverter: log("libyuv.ScalePlane %i times, took %.1fms", self.planes, 1000.0*elapsed) for i in range(self.planes): strides.append(self.scaled_stride[i]) - planes.append(PyMemoryView_FromMemory( scaled_planes[i], self.scaled_size[i], True)) + planes.append(PyMemoryView_FromMemory( scaled_planes[i], self.scaled_size[i], PyBUF_WRITE)) self.frames += 1 out_image = YUVImageWrapper(0, 0, self.dst_width, self.dst_height, planes, self.dst_format, 24, strides, 1, self.planes) out_image.cython_buffer = scaled_buffer @@ -583,7 +584,7 @@ cdef class ColorspaceConverter: #use output buffer directly: for i in range(self.planes): strides.append(self.out_stride[i]) - planes.append(PyMemoryView_FromMemory( out_planes[i], self.out_size[i], True)) + planes.append(PyMemoryView_FromMemory( out_planes[i], self.out_size[i], PyBUF_WRITE)) self.frames += 1 out_image = YUVImageWrapper(0, 0, self.dst_width, self.dst_height, planes, self.dst_format, 24, strides, 1, self.planes) out_image.cython_buffer = output_buffer diff --git a/xpra/codecs/webp/decoder.pyx b/xpra/codecs/webp/decoder.pyx index 9215215421..7408bfbe30 100644 --- a/xpra/codecs/webp/decoder.pyx +++ b/xpra/codecs/webp/decoder.pyx @@ -20,6 +20,7 @@ cdef extern from *: cdef extern from "Python.h": object PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags) + int PyBUF_WRITE cdef extern from "webp/decode.h": @@ -181,7 +182,7 @@ cdef class WebpBufferWrapper: def get_pixels(self): assert self.buffer_ptr>0, "WebpBufferWrapper has already been freed!" - return PyMemoryView_FromMemory( self.buffer_ptr, self.size, True) + return PyMemoryView_FromMemory( self.buffer_ptr, self.size, PyBUF_WRITE) def free(self): if self.buffer_ptr!=0: @@ -308,16 +309,16 @@ def decompress_yuv(data, has_alpha=False): webp_check(ret) if alpha: planes = ( - PyMemoryView_FromMemory( YUVA.y, y_size, True), - PyMemoryView_FromMemory( YUVA.u, u_size, True), - PyMemoryView_FromMemory( YUVA.v, v_size, True), - PyMemoryView_FromMemory( YUVA.a, a_size, True), + PyMemoryView_FromMemory( YUVA.y, y_size, PyBUF_WRITE), + PyMemoryView_FromMemory( YUVA.u, u_size, PyBUF_WRITE), + PyMemoryView_FromMemory( YUVA.v, v_size, PyBUF_WRITE), + PyMemoryView_FromMemory( YUVA.a, a_size, PyBUF_WRITE), ) else: planes = ( - PyMemoryView_FromMemory( YUVA.y, y_size, True), - PyMemoryView_FromMemory( YUVA.u, u_size, True), - PyMemoryView_FromMemory( YUVA.v, v_size, True), + PyMemoryView_FromMemory( YUVA.y, y_size, PyBUF_WRITE), + PyMemoryView_FromMemory( YUVA.u, u_size, PyBUF_WRITE), + PyMemoryView_FromMemory( YUVA.v, v_size, PyBUF_WRITE), ) img = YUVImageWrapper(0, 0, w, h, planes, "YUV420P", (3+alpha)*8, strides, 3+alpha, ImageWrapper.PLANAR_3+alpha) img.cython_buffer = buf diff --git a/xpra/x11/bindings/ximage.pyx b/xpra/x11/bindings/ximage.pyx index eb9c368fda..edb687a404 100644 --- a/xpra/x11/bindings/ximage.pyx +++ b/xpra/x11/bindings/ximage.pyx @@ -58,6 +58,7 @@ cdef extern from "Python.h": int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) void PyBuffer_Release(Py_buffer *view) int PyBUF_ANY_CONTIGUOUS + int PyBUF_READ cdef extern from "stdlib.h": int posix_memalign(void **memptr, size_t alignment, size_t size) @@ -312,7 +313,7 @@ cdef class XImageWrapper: cdef void *pix_ptr = self.get_pixels_ptr() if pix_ptr==NULL: return None - return PyMemoryView_FromMemory( pix_ptr, self.get_size(), False) + return PyMemoryView_FromMemory( pix_ptr, self.get_size(), PyBUF_READ) def get_sub_image(self, unsigned int x, unsigned int y, unsigned int w, unsigned int h): if w<=0 or h<=0: