Ticket #146: xpra-decompress-padded-nogil.patch
File xpra-decompress-padded-nogil.patch, 2.2 KB (added by , 9 years ago) |
---|
-
src/xpra/x264/codec.pyx
7 7 8 8 from libc.stdlib cimport free 9 9 10 cdef extern from "string.h": 11 void * memcpy ( void * destination, void * source, size_t num ) 12 void * memset ( void * ptr, int value, size_t num ) 13 14 cdef extern from "stdlib.h": 15 void *malloc(size_t size) 16 10 17 cdef extern from "Python.h": 11 18 ctypedef int Py_ssize_t 12 19 ctypedef object PyObject … … 24 31 25 32 x264lib_ctx* init_decoder(int width, int height) 26 33 void clean_decoder(x264lib_ctx *context) 27 int decompress_image(x264lib_ctx *context, uint8_t *input, int size, uint8_t *(*out)[3], int *outsize, int (*outstride)[3]) 34 int decompress_image(x264lib_ctx *context, uint8_t *input, int size, uint8_t *(*out)[3], int *outsize, int (*outstride)[3]) nogil 28 35 int csc_image_yuv2rgb(x264lib_ctx *ctx, uint8_t *input[3], int stride[3], uint8_t **out, int *outsz, int *outstride) nogil 29 36 void change_encoding_speed(x264lib_ctx *context, int increase) 30 37 … … 94 101 cdef int outsize 95 102 cdef int yuvstrides[3] 96 103 cdef int outstride 104 cdef unsigned char * padded_buf = <uint8_t *> 0 97 105 cdef unsigned char * buf = <uint8_t *> 0 98 106 cdef Py_ssize_t buf_len = 0 99 107 assert self.context!=NULL 100 108 assert self.last_image==NULL 101 109 PyObject_AsReadBuffer(input, <const_void_pp> &buf, &buf_len) 102 i = decompress_image(self.context, buf, buf_len, &yuvplanes, &outsize, &yuvstrides)103 if i!=0:104 return i, 0, ""110 padded_buf = <unsigned char *> malloc(buf_len+32) 111 memcpy(padded_buf, buf, buf_len) 112 memset(padded_buf+buf_len, 0, 32) 105 113 with nogil: 106 i = csc_image_yuv2rgb(self.context, yuvplanes, yuvstrides, &dout, &outsize, &outstride) 114 i = decompress_image(self.context, padded_buf, buf_len, &yuvplanes, &outsize, &yuvstrides) 115 if i==0: 116 i = csc_image_yuv2rgb(self.context, yuvplanes, yuvstrides, &dout, &outsize, &outstride) 117 free(padded_buf) 107 118 if i!=0: 108 119 return i, 0, "" 109 120 self.last_image = dout