diff --git a/src/tests/xpra/codecs/test_vpx.py b/src/tests/xpra/codecs/test_vpx.py index 3ed486b5bf..92ea3e3dd8 100755 --- a/src/tests/xpra/codecs/test_vpx.py +++ b/src/tests/xpra/codecs/test_vpx.py @@ -1,9 +1,10 @@ #!/usr/bin/env python # This file is part of Xpra. -# Copyright (C) 2013 Antoine Martin +# Copyright (C) 2013-2016 Antoine Martin # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. +from tests.xpra.codecs.test_encoder import test_performance from tests.xpra.codecs.test_video_codec import do_test_codec_roundtrip from xpra.codecs.vpx import encoder as vpx_encoder #@UnresolvedImport from xpra.codecs.vpx.decoder import Decoder #@UnresolvedImport @@ -14,14 +15,18 @@ def test_roundtrip(): print("") print("test_roundtrip() %s" % encoding) for populate in (True, False): - src_formats = vpx_encoder.get_input_colorspaces(encoding) + src_formats = vpx_encoder.get_input_colorspaces(encoding) #@UndefinedVariable print("test_roundtrip() src_formats(%s)=%s" % (encoding, src_formats)) for src_format in src_formats: do_test_codec_roundtrip(Encoder, Decoder, encoding, src_format, [src_format], 640, 480, populate) +def test_perf(): + test_performance(vpx_encoder) + def main(): - test_roundtrip() + #test_roundtrip() + test_perf() if __name__ == "__main__": diff --git a/src/xpra/codecs/vpx/encoder.pyx b/src/xpra/codecs/vpx/encoder.pyx index c84e9006d1..b5b062bcc4 100644 --- a/src/xpra/codecs/vpx/encoder.pyx +++ b/src/xpra/codecs/vpx/encoder.pyx @@ -266,8 +266,8 @@ def get_input_colorspaces(encoding): def get_output_colorspaces(encoding, input_colorspace): assert encoding in get_encodings(), "invalid encoding: %s" % encoding - csdict = COLORSPACES[encoding] - assert input_colorspace in csdict, "invalid input colorspace: %s" % input_colorspace + csoptions = COLORSPACES[encoding] + assert input_colorspace in csoptions, "invalid input colorspace: %s, %s only supports %s" % (input_colorspace, encoding, csoptions) #always unchanged in output: return [input_colorspace] @@ -325,21 +325,12 @@ def get_spec(encoding, colorspace): has_lossless_mode = colorspace=="YUV444P" speed = 20 quality = 50 + 50*int(has_lossless_mode) - v = get_version() - if v and v.startswith("v"): - v = v[1:] #strip "v" - def intor0(s): - try: - return int(s) - except: - return 0 - vnum = [intor0(x) for x in v.split(".")] - if vnum>=[1,5]: - #libvpx 1.5 made some significant performance improvements with vp9: - speed = 50 + if VPX_ENCODER_ABI_VERSION>=11: + #libvpx 1.5 made some significant performance improvements with vp9: + speed = 60 return video_spec(encoding=encoding, output_colorspaces=[colorspace], has_lossless_mode=has_lossless_mode, codec_class=Encoder, codec_type=get_type(), - quality=50+50*int(has_lossless_mode), speed=speed, + quality=quality, speed=speed, setup_cost=20, max_w=max_w, max_h=max_h) @@ -689,10 +680,14 @@ cdef class Encoder: #Valid range for VP8: -16..16 #Valid range for VP9: -8..8 #But we only use positive values, negative values are just too slow - cdef int range = 8*(1+int(self.encoding=="vp8")) - #note: we don't use the full range since the percentages are mapped to -30 to +70 - cdef int value = (speed-30)*2*range//100 - value = MIN(range, MAX(0, value)) + cdef int minv = 0 + cdef int range = 16 + if self.encoding=="vp9": + minv = 4 + range = 4 + #note: we don't use the full range since the percentages are mapped to -20% to +120% + cdef int value = (speed-20)*3*range//200 + value = minv + MIN(range, MAX(0, value)) self.codec_control("cpu speed", VP8E_SET_CPUUSED, value) def set_encoding_quality(self, int pct):