Skip to content

Commit

Permalink
validate input data
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13912 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 29, 2016
1 parent f5b261f commit b360eed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/xpra/codecs/codec_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def do_testencoding(encoder_module, encoding, W, H, full=False, limit_w=TEST_LIM
#print("compressed data with %s: %s bytes (%s), metadata: %s" % (encoder_module.get_type(), len(data), type(data), meta))
#print("compressed data(%s, %s)=%s" % (encoding, cs_in, binascii.hexlify(data)))
if full:
wrong_formats = [x for x in ("YUV420P", "YUV444P", "BGRX") if x!=cs_in]
wrong_formats = [x for x in ("YUV420P", "YUV444P", "BGRX", "r210") if x!=cs_in]
#log("wrong formats (not %s): %s", cs_in, wrong_formats)
if wrong_formats:
wrong_format = wrong_formats[0]
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/codecs/enc_ffmpeg/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ cdef class Encoder(object):
assert self.codec!=NULL

if image:
assert image.get_pixel_format()==self.src_format, "invalid input format %s, expected %s" % (image.get_pixel_format, self.src_format)
assert image.get_width()==self.width and image.get_height()==self.height

pixels = image.get_pixels()
istrides = image.get_rowstride()
assert len(pixels)==3, "image pixels does not have 3 planes! (found %s)" % len(pixels)
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/codecs/vpx/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ cdef class Encoder:
assert self.context!=NULL
pixels = image.get_pixels()
istrides = image.get_rowstride()
assert image.get_pixel_format()==self.src_format, "invalid input format %s, expected %s" % (image.get_pixel_format, self.src_format)
assert image.get_width()==self.width and image.get_height()==self.height
assert pixels, "failed to get pixels from %s" % image
assert len(pixels)==3, "image pixels does not have 3 planes! (found %s)" % len(pixels)
assert len(istrides)==3, "image strides does not have 3 values! (found %s)" % len(istrides)
Expand Down

0 comments on commit b360eed

Please sign in to comment.