Skip to content

Commit

Permalink
add h264 test data and test encoders with junk data whether we have v…
Browse files Browse the repository at this point in the history
…alid test data or not

git-svn-id: https://xpra.org/svn/Xpra/trunk@9270 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 6, 2015
1 parent 3e49bf9 commit f9d0038
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/xpra/codecs/codec_selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

#this test data was generated using a 24x16 blank image as input
TEST_COMPRESSED_DATA = {
"h264": {
"YUV420P" : binascii.unhexlify("000000016764000aacb317cbc2000003000200000300651e244cd00000000168e970312c8b0000010605ffff56dc45e9bde6d948b7962cd820d923eeef78323634202d20636f726520313432202d20482e3236342f4d5045472d342041564320636f646563202d20436f70796c65667420323030332d32303134202d20687474703a2f2f7777772e766964656f6c616e2e6f72672f783236342e68746d6c202d206f7074696f6e733a2063616261633d31207265663d35206465626c6f636b3d313a303a3020616e616c7973653d3078333a3078313133206d653d756d68207375626d653d38207073793d31207073795f72643d312e30303a302e3030206d697865645f7265663d31206d655f72616e67653d3136206368726f6d615f6d653d31207472656c6c69733d31203878386463743d312063716d3d3020646561647a6f6e653d32312c313120666173745f70736b69703d31206368726f6d615f71705f6f66667365743d2d3220746872656164733d31206c6f6f6b61686561645f746872656164733d3120736c696365645f746872656164733d30206e723d3020646563696d6174653d3120696e7465726c616365643d3020626c757261795f636f6d7061743d3020636f6e73747261696e65645f696e7472613d3020626672616d65733d3020776569676874703d32206b6579696e743d393939393939206b6579696e745f6d696e3d353030303030207363656e656375743d343020696e7472615f726566726573683d302072633d637266206d62747265653d30206372663d33382e322071636f6d703d302e36302071706d696e3d302071706d61783d3639207170737465703d342069705f726174696f3d312e34302061713d313a312e3030008000000165888404bffe841fc0a667f891ea1728763fecb5e1"),
"YUV422P" : binascii.unhexlify("00000001677a000abcb317cbc2000003000200000300651e244cd00000000168e970312c8b0000010605ffff56dc45e9bde6d948b7962cd820d923eeef78323634202d20636f726520313432202d20482e3236342f4d5045472d342041564320636f646563202d20436f70796c65667420323030332d32303134202d20687474703a2f2f7777772e766964656f6c616e2e6f72672f783236342e68746d6c202d206f7074696f6e733a2063616261633d31207265663d35206465626c6f636b3d313a303a3020616e616c7973653d3078333a3078313133206d653d756d68207375626d653d38207073793d31207073795f72643d312e30303a302e3030206d697865645f7265663d31206d655f72616e67653d3136206368726f6d615f6d653d31207472656c6c69733d31203878386463743d312063716d3d3020646561647a6f6e653d32312c313120666173745f70736b69703d31206368726f6d615f71705f6f66667365743d2d3220746872656164733d31206c6f6f6b61686561645f746872656164733d3120736c696365645f746872656164733d30206e723d3020646563696d6174653d3120696e7465726c616365643d3020626c757261795f636f6d7061743d3020636f6e73747261696e65645f696e7472613d3020626672616d65733d3020776569676874703d32206b6579696e743d393939393939206b6579696e745f6d696e3d353030303030207363656e656375743d343020696e7472615f726566726573683d302072633d637266206d62747265653d30206372663d33382e322071636f6d703d302e36302071706d696e3d302071706d61783d3639207170737465703d342069705f726174696f3d312e34302061713d313a312e3030008000000165888404bffe841fc0a667f891ec3d121e72aecb5f"),
"YUV444P" : binascii.unhexlify("0000000167f4000a919662f89e1000000300100000030328f12266800000000168e970311121100000010605ffff55dc45e9bde6d948b7962cd820d923eeef78323634202d20636f726520313432202d20482e3236342f4d5045472d342041564320636f646563202d20436f70796c65667420323030332d32303134202d20687474703a2f2f7777772e766964656f6c616e2e6f72672f783236342e68746d6c202d206f7074696f6e733a2063616261633d31207265663d35206465626c6f636b3d313a303a3020616e616c7973653d3078333a3078313133206d653d756d68207375626d653d38207073793d31207073795f72643d312e30303a302e3030206d697865645f7265663d31206d655f72616e67653d3136206368726f6d615f6d653d31207472656c6c69733d31203878386463743d312063716d3d3020646561647a6f6e653d32312c313120666173745f70736b69703d31206368726f6d615f71705f6f66667365743d3420746872656164733d31206c6f6f6b61686561645f746872656164733d3120736c696365645f746872656164733d30206e723d3020646563696d6174653d3120696e7465726c616365643d3020626c757261795f636f6d7061743d3020636f6e73747261696e65645f696e7472613d3020626672616d65733d3020776569676874703d32206b6579696e743d393939393939206b6579696e745f6d696e3d353030303030207363656e656375743d343020696e7472615f726566726573683d302072633d637266206d62747265653d30206372663d33382e322071636f6d703d302e36302071706d696e3d302071706d61783d3639207170737465703d342069705f726174696f3d312e34302061713d313a312e3030008000000165888404bffeeb1fc0a667f75e658f9a9fccb1f341ffff"),
},
"vp8" : {"YUV420P" : binascii.unhexlify("1003009d012a1800100000070885858899848800281013ad501fc01fd01050122780feffbb029ffffa2546bd18c06f7ffe8951fffe8951af46301bdfffa22a00")},
"vp9" : {"YUV420P" : binascii.unhexlify("8249834200017000f60038241c18000000200000047ffffffba9da00059fffffff753b413bffffffeea7680000"),
"YUV444P" : binascii.unhexlify("a249834200002e001ec007048383000000040000223fffffeea76800c7ffffffeea7680677ffffff753b40081000")},
Expand Down Expand Up @@ -48,23 +53,23 @@ def testdecoder(decoder_module, full):
log("%s: no test data for %s", decoder_module.get_type(), encoding)
continue
for cs in decoder_module.get_input_colorspaces(encoding):
test_data = test_data_set.get(cs)
if not test_data:
continue
log("%s: testing %s / %s", decoder_module.get_type(), encoding, cs)
e = decoder_module.Decoder()
try:
e.init_context(encoding, W, H, cs)
image = e.decompress_image(test_data, {})
assert image is not None, "failed to decode test data for encoding '%s' with colorspace '%s'" % (encoding, cs)
assert image.get_width()==W, "expected image of width %s but got %s" % (W, image.get_width())
assert image.get_height()==H, "expected image of height %s but got %s" % (H, image.get_height())
test_data = test_data_set.get(cs)
if test_data:
log("%s: testing %s / %s with %s bytes of data", decoder_module.get_type(), encoding, cs, len(test_data))
image = e.decompress_image(test_data, {})
assert image is not None, "failed to decode test data for encoding '%s' with colorspace '%s'" % (encoding, cs)
assert image.get_width()==W, "expected image of width %s but got %s" % (W, image.get_width())
assert image.get_height()==H, "expected image of height %s but got %s" % (H, image.get_height())
if full:
log("%s: testing %s / %s with junk data", decoder_module.get_type(), encoding, cs)
#test failures:
try:
image = e.decompress_image(b"junk", {})
except:
pass
image = None
if image is not None:
raise Exception("decoding junk with %s should have failed, got %s instead" % (decoder_module.get_type(), image))
finally:
Expand All @@ -83,9 +88,8 @@ def testencoder(encoder_module, full):
assert len(data)>0
assert meta is not None
#print("test_encoder: %s.compress_image(%s)=%s" % (encoder_module.get_type(), image, (data, meta)))
#import binascii
#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)))
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:
try:
wrong_format = [x for x in ("YUV420P", "YUV444P", "BGRX") if x!=cs_in][0]
Expand Down

0 comments on commit f9d0038

Please sign in to comment.