Skip to content

Commit

Permalink
reduce the range of the CPUUSED parameter further for vp9: vp9 as of …
Browse files Browse the repository at this point in the history
…abi version 11 or later is actually quite fast, as long as we keep the speed setting artificially high

git-svn-id: https://xpra.org/svn/Xpra/trunk@13175 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 2, 2016
1 parent 6daebd7 commit 4794c72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
11 changes: 8 additions & 3 deletions src/tests/xpra/codecs/test_vpx.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2013 Antoine Martin <antoine@devloop.org.uk>
# Copyright (C) 2013-2016 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.

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
Expand All @@ -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__":
Expand Down
33 changes: 14 additions & 19 deletions src/xpra/codecs/vpx/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4794c72

Please sign in to comment.