Skip to content

Commit

Permalink
#1232: don't try to do scrolling detection with hashes without xxhash…
Browse files Browse the repository at this point in the history
…, too slow

git-svn-id: https://xpra.org/svn/Xpra/trunk@13442 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 23, 2016
1 parent 50788ba commit 5e140af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
18 changes: 12 additions & 6 deletions src/xpra/server/window/motion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
import os
import time

from xpra.log import Logger
logger = Logger("encoding")

import zlib
hashfn = zlib.crc32
hashfn = None
if os.environ.get("XPRA_XXHASH", "1")=="1":
try:
import xxhash
def hashfn(x):
return xxhash.xxh64(x).intdigest()
except ImportError as e:
from xpra.log import Logger
logger = Logger("encoding")
logger.warn("Warning: xxhash python bindings not found,")
logger.warn(" using the slow zlib.crc32 fallback")
logger.warn("Warning: xxhash python bindings not found")
else:
logger.warn("Warning: xxhash disabled")
if hashfn is None:
logger.warn(" no scrolling detection")


cdef extern from "math.h":
Expand All @@ -45,13 +49,15 @@ cdef extern from "../../buffers/buffers.h":


def CRC_Image(pixels, unsigned int width, unsigned int height, unsigned int rowstride, unsigned char bpp=4):
global hashfn
if not hashfn:
return None
cdef uint8_t *buf = NULL
cdef Py_ssize_t buf_len = 0
assert object_as_buffer(pixels, <const void**> &buf, &buf_len)==0
assert buf_len>=0 and (<unsigned int> buf_len)>=rowstride*height, "buffer is too small for %ix%i" % (rowstride, height)
cdef unsigned int i
cdef size_t row_len = width*bpp
global hashfn
f = hashfn
crcs = []
for i in range(height):
Expand Down
7 changes: 4 additions & 3 deletions src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,9 +1459,10 @@ def video_fallback():
width = image.get_width()
height = image.get_height()
csums = CRC_Image(pixels, width, height, stride)
self.scroll_data = (width, height, csums)
scrolllog("updated scroll data")
if lsd:
if csums:
self.scroll_data = (width, height, csums)
scrolllog("updated scroll data")
if lsd and csums:
lw, lh, lcsums = lsd
if lw!=width or lh!=height:
scrolllog("scroll data size mismatch: %ix%i vs %ix%i", lw, lh, width, height)
Expand Down

0 comments on commit 5e140af

Please sign in to comment.