Skip to content

Commit

Permalink
remove rgbimage wrapper: since we copy from the swscale buffer to a p…
Browse files Browse the repository at this point in the history
…ython string anyway, do it early to prevent races between the decoding thread and the paint thread: previously we could end up copying from the swscaled buffer too late: after a new frame is decoded (and the buffer may have been freed, size changed, etc - I couldn't make it misbehave, but the design was broken)

git-svn-id: https://xpra.org/svn/Xpra/trunk@2991 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 16, 2013
1 parent 391e30e commit 758583c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 63 deletions.
31 changes: 1 addition & 30 deletions src/xpra/vpx/codec.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,6 @@ cdef class xcoder:
def get_height(self):
return self.height

cdef class RGBImage:
cdef uint8_t *data
cdef int size
cdef int rowstride

cdef init(self, uint8_t *data, int size, int rowstride):
self.data = data
self.size = size
self.rowstride = rowstride

cdef free(self):
assert self.data!=NULL
xmemfree(self.data)
self.data = NULL

def get_data(self):
return (<char *>self.data)[:self.size]

def get_size(self):
return self.size

def get_rowstride(self):
return self.rowstride

def __dealloc__(self): #@DuplicatedSignature
self.free()


cdef class Decoder(xcoder):

Expand Down Expand Up @@ -136,9 +109,7 @@ cdef class Decoder(xcoder):
i = csc_image_yuv2rgb(self.context, yuvplanes, yuvstrides, &dout, &outsize, &outstride)
if i!=0:
return i, None
rgb_image = RGBImage()
rgb_image.init(dout, outsize, outstride)
return i, rgb_image
return i, (<char *>dout)[:outsize], outstride


cdef class Encoder(xcoder):
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/window_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ def paint_with_video_decoder(self, factory, coding, img_data, x, y, width, heigh
def do_video_paint(self, coding, img_data, x, y, width, height, options, callbacks):
if DRAW_DEBUG:
log.info("paint_with_video_decoder: options=%s, decoder=%s", options, type(self._video_decoder))
err, rgb_image = self._video_decoder.decompress_image_to_rgb(img_data, options)
success = err==0 and rgb_image and rgb_image.get_size()>0
err, data, rowstride = self._video_decoder.decompress_image_to_rgb(img_data, options)
success = err==0 and data is not None and rowstride>0
if not success:
raise Exception("paint_with_video_decoder: %s decompression error %s on %s bytes of picture data for %sx%s pixels, options=%s" % (
coding, err, len(img_data), width, height, options))
#this will also take care of firing callbacks (from the UI thread):
gobject.idle_add(self.do_paint_rgb24, rgb_image.get_data(), x, y, width, height, rgb_image.get_rowstride(), options, callbacks)
gobject.idle_add(self.do_paint_rgb24, data, x, y, width, height, rowstride, options, callbacks)


def cairo_draw(self, context):
Expand Down
31 changes: 1 addition & 30 deletions src/xpra/x264/codec.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,6 @@ cdef class xcoder:
def get_type(self):
return "x264"

cdef class RGBImage:
cdef uint8_t *data
cdef int size
cdef int rowstride

cdef init(self, uint8_t *data, int size, int rowstride):
self.data = data
self.size = size
self.rowstride = rowstride

cdef free(self):
assert self.data!=NULL
xmemfree(self.data)
self.data = NULL

def get_data(self):
return (<char *>self.data)[:self.size]

def get_size(self):
return self.size

def get_rowstride(self):
return self.rowstride

def __dealloc__(self): #@DuplicatedSignature
self.free()


cdef class Decoder(xcoder):

Expand Down Expand Up @@ -183,9 +156,7 @@ cdef class Decoder(xcoder):
xmemfree(padded_buf)
if i!=0:
return i, None
rgb_image = RGBImage()
rgb_image.init(dout, outsize, outstride)
return i, rgb_image
return i, (<char *>dout)[:outsize], outstride


cdef class Encoder(xcoder):
Expand Down

0 comments on commit 758583c

Please sign in to comment.