Skip to content

Commit

Permalink
#948:
Browse files Browse the repository at this point in the history
* add full selftests for nvenc4 and nvenc5
* increase width before increasing height when testing max size
* use bytes for the buffers so we can create bigger buffers than with bytearray

git-svn-id: https://xpra.org/svn/Xpra/trunk@10323 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 17, 2015
1 parent 756ba96 commit 66f06c5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
35 changes: 18 additions & 17 deletions src/xpra/codecs/codec_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def make_test_image(pixel_format, w, h):
if pixel_format.startswith("YUV") or pixel_format=="GBRP":
divs = get_subsampling_divs(pixel_format)
ydiv = divs[0] #always (1,1)
y = bytearray(w*h//(ydiv[0]*ydiv[1]))
y = bytes("\0"*(w*h//(ydiv[0]*ydiv[1])))
udiv = divs[1]
u = bytearray(w*h//(udiv[0]*udiv[1]))
u = bytes("\0"*(w*h//(udiv[0]*udiv[1])))
vdiv = divs[2]
v = bytearray(w*h//(vdiv[0]*vdiv[1]))
v = bytes("\0"*(w*h//(vdiv[0]*vdiv[1])))
image = ImageWrapper(0, 0, w, h, [y, u, v], pixel_format, 32, [w//ydiv[0], w//udiv[0], w//vdiv[0]], planes=ImageWrapper._3_PLANES, thread_safe=True)
#l = len(y)+len(u)+len(v)
elif pixel_format in ("RGB", "BGR", "RGBX", "BGRX", "XRGB", "BGRA", "RGBA"):
rgb_data = bytearray(w*h*len(pixel_format))
rgb_data = bytes("\0"*(w*h*len(pixel_format)))
image = ImageWrapper(0, 0, w, h, rgb_data, pixel_format, 32, w*len(pixel_format), planes=ImageWrapper.PACKED, thread_safe=True)
#l = len(rgb_data)
else:
Expand Down Expand Up @@ -152,19 +152,20 @@ def einfo():
MAX_WIDTH = maxw
MAX_HEIGHT = maxh
for v in (512, 1024, 2048, 4096, 8192, 16384):
if v>=limit:
break
try:
w = min(maxw, v)
h = min(maxh, v)
do_testencoding(encoder_module, encoding, w, h)
log("%s can handle %ix%i for %s", einfo(), w, h, encoding)
MAX_WIDTH = w
MAX_HEIGHT = h
except Exception as e:
log("%s is limited to %ix%i for %s", einfo(), MAX_WIDTH, MAX_HEIGHT, encoding)
log(" %s", e)
break
for tw, th in ((v, v), (v*2, v)):
if tw>limit or th>limit:
continue
try:
w = min(maxw, tw)
h = min(maxh, th)
do_testencoding(encoder_module, encoding, w, h)
log("%s can handle %ix%i for %s", einfo(), w, h, encoding)
MAX_WIDTH = w
MAX_HEIGHT = h
except Exception as e:
log("%s is limited to %ix%i for %s", einfo(), MAX_WIDTH, MAX_HEIGHT, encoding)
log(" %s", e)
break
log("%s max dimensions for %s: %ix%i", einfo(), encoding, MAX_WIDTH, MAX_HEIGHT)
return MAX_WIDTH, MAX_HEIGHT

Expand Down
4 changes: 2 additions & 2 deletions src/xpra/codecs/enc_x264/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ if X264_BUILD<146:
MAX_WIDTH = 4096
MAX_HEIGHT = 4096
else:
MAX_WIDTH = 8192
MAX_HEIGHT = 8192
MAX_WIDTH = 16384
MAX_HEIGHT = 16384

def get_spec(encoding, colorspace):
assert encoding in get_encodings(), "invalid encoding: %s (must be one of %s" % (encoding, get_encodings())
Expand Down
8 changes: 8 additions & 0 deletions src/xpra/codecs/nvenc4/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2408,3 +2408,11 @@ def init_module():
def cleanup_module():
log("nvenc.cleanup_module()")
reset_state()

def selftest(full=False):
#this is expensive, so don't run it unless "full" is set:
if full:
from xpra.codecs.codec_checks import get_encoder_max_sizes
from xpra.codecs.nvenc4 import encoder
init_module()
log.info("%s max dimensions: %s", encoder, get_encoder_max_sizes(encoder))
8 changes: 8 additions & 0 deletions src/xpra/codecs/nvenc5/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2404,3 +2404,11 @@ def init_module():
def cleanup_module():
log("nvenc.cleanup_module()")
reset_state()

def selftest(full=False):
#this is expensive, so don't run it unless "full" is set:
if full:
from xpra.codecs.codec_checks import get_encoder_max_sizes
from xpra.codecs.nvenc5 import encoder
init_module()
log.info("%s max dimensions: %s", encoder, get_encoder_max_sizes(encoder))
5 changes: 3 additions & 2 deletions src/xpra/codecs/vpx/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ cdef const vpx_codec_iface_t *make_codec_cx(encoding):

#educated guess:
MAX_SIZE = {"vp8" : (4096, 4096),
"vp9" : (4096, 4096),
"vp9" : (8192, 8192),
}
IF LIBVPX14:
MAX_SIZE["vp9"] = (8192, 8192)
MAX_SIZE["vp8"] = (8192, 8192)
MAX_SIZE["vp9"] = (16384, 8192)

def get_spec(encoding, colorspace):
assert encoding in CODECS, "invalid encoding: %s (must be one of %s" % (encoding, get_encodings())
Expand Down

0 comments on commit 66f06c5

Please sign in to comment.