Skip to content

Commit

Permalink
* don't test rgb with pillow
Browse files Browse the repository at this point in the history
* add test for triggering selftest code

git-svn-id: https://xpra.org/svn/Xpra/trunk@14637 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 29, 2016
1 parent fb44cff commit 116693d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/tests/xpra/codecs/test_Pillow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2014 Antoine Martin <antoine@devloop.org.uk>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.


def main():
from xpra.codecs.pillow.encode import selftest
#from xpra.codecs.pillow.encode import log
#log.enable_debug()
selftest(True)


if __name__ == "__main__":
main()
16 changes: 4 additions & 12 deletions src/tests/xpra/codecs/test_Pillow_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,26 @@
from io import BytesIO


def do_test_encode(rgb_data, w, h, encodings=["png", "png/P", "png/L", "jpeg", "rgb"], N=5, Q=[0, 50, 100], S=[0, 1, 50, 90, 100], has_alpha=False):
from xpra.server.picture_encode import PIL_encode, rgb_encode
def do_test_encode(rgb_data, w, h, encodings=["png", "png/P", "png/L", "jpeg"], N=5, Q=[0, 50, 100], S=[0, 1, 50, 90, 100], has_alpha=False):
from xpra.codecs.pillow.encode import encode
from xpra.codecs.image_wrapper import ImageWrapper
image = ImageWrapper(0, 0, w, h, rgb_data, "BGRA", 32, w*4, planes=ImageWrapper.PACKED, thread_safe=True)
#buf = "\0" * (w*h*4)
#buf = get_source_data(w*h*4)
for encoding in encodings:
Q_options = Q
if encoding in ("png", "png/P", "png/L", "rgb"):
if encoding in ("png", "png/P", "png/L"):
Q_options = [-1]
S_options = S
if encoding in ("jpeg"):
S_options = [0, -1]
elif encoding=="rgb":
S_options = [0, 30, 70, 90]
for q in Q_options:
for s in S_options:
#print("test_encode() quality=%s, speed=%s" % (q, s))
coding = encoding
start = time.time()
for _ in range(N):
if encoding=="rgb":
coding = "rgb24"
if has_alpha:
coding = "rgb32"
data = rgb_encode(coding, image, ["BGRA"], True, speed=s)
else:
data = PIL_encode(coding, image, q, s, True)
data = encode(coding, image, q, s, True)
#def compress(pixels, width, height, quality=50, speed=50):
end = time.time()
mps = w*h*N/(end-start)/1024/1024
Expand Down

0 comments on commit 116693d

Please sign in to comment.