Skip to content

Commit

Permalink
#1951: add video-scaling=auto option and make it the default, in this…
Browse files Browse the repository at this point in the history
… case only use speed and quality for calculating the scaling based on a target pixels-per-second rather than hardcoded sizes, use scoring algorithm to support proper edge resistance

git-svn-id: https://xpra.org/svn/Xpra/trunk@20366 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 9, 2018
1 parent f48df08 commit 881497d
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 82 deletions.
5 changes: 3 additions & 2 deletions src/etc/xpra/conf.d/30_picture.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ video-decoders = all
# Automatic video downscaling:
# video-scaling = 0 #same as off
# video-scaling = off
# video-scaling = on
# video-scaling = auto #use quality and speed settings
# video-scaling = on #same as auto
# video-scaling = 10 #mild automatic downscaling
# video-scaling = 100 #very aggressive downscaling
video-scaling = on
video-scaling = auto

# Use fixed quality
# (value is a percentage or "auto"):
Expand Down
10 changes: 7 additions & 3 deletions src/xpra/client/mixins/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self):
self.min_quality = 0
self.speed = 0
self.min_speed = -1
self.video_scaling = 0
self.video_scaling = None
self.video_max_size = VIDEO_MAX_SIZE

self.server_encodings = []
Expand All @@ -57,7 +57,10 @@ def __init__(self):
def init(self, opts, _extra_args=[]):
self.allowed_encodings = opts.encodings
self.encoding = opts.encoding
self.video_scaling = parse_bool_or_int("video-scaling", opts.video_scaling)
if opts.video_scaling.lower() in ("auto", "on"):
self.video_scaling = None
else:
self.video_scaling = parse_bool_or_int("video-scaling", opts.video_scaling)
self.quality = opts.quality
self.min_quality = opts.min_quality
self.speed = opts.speed
Expand Down Expand Up @@ -130,7 +133,6 @@ def get_encodings_caps(self):
video_b_frames = []
caps = {
"flush" : PAINT_FLUSH,
"scaling.control" : self.video_scaling,
"client_options" : True,
"csc_atoms" : True,
#TODO: check for csc support (swscale only?)
Expand All @@ -145,6 +147,8 @@ def get_encodings_caps(self):
"send-timestamps" : SEND_TIMESTAMPS,
"supports_delta" : tuple(x for x in ("png", "rgb24", "rgb32") if x in self.get_core_encodings()),
}
if self.video_scaling is not None:
caps["scaling.control"] = self.video_scaling
if self.encoding:
caps[""] = self.encoding
for k,v in codec_versions.items():
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ def may_create_user_config(xpra_conf_filename=DEFAULT_XPRA_CONF_FILENAME):
"postscript-printer": str,
"debug" : str,
"input-method" : str,
"video-scaling" : str,
"microphone" : str,
"speaker" : str,
"sound-source" : str,
Expand Down Expand Up @@ -531,7 +532,6 @@ def may_create_user_config(xpra_conf_filename=DEFAULT_XPRA_CONF_FILENAME):
"min-speed" : int,
"compression_level" : int,
"dpi" : int,
"video-scaling" : int,
"file-size-limit" : int,
"idle-timeout" : int,
"server-idle-timeout" : int,
Expand Down Expand Up @@ -920,7 +920,6 @@ def addtrailingslash(v):
"min-speed" : 30,
"compression_level" : 1,
"dpi" : 0,
"video-scaling" : 1,
"file-size-limit" : 100,
"idle-timeout" : 0,
"server-idle-timeout" : 0,
Expand All @@ -944,6 +943,7 @@ def addtrailingslash(v):
"mmap-group" : False,
"speaker" : ["disabled", "on"][has_sound_support()],
"microphone" : ["disabled", "off"][has_sound_support()],
"video-scaling" : "auto",
"readonly" : False,
"keyboard-sync" : True,
"displayfd" : 0,
Expand Down
9 changes: 6 additions & 3 deletions src/xpra/server/dbus/dbus_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ def SetWindowScaling(self, wid, scaling):
s = parse_scaling_value(ns(scaling))
self.server.control_command_scaling(s, ni(wid))

@dbus.service.method(INTERFACE, in_signature='ii')
@dbus.service.method(INTERFACE, in_signature='is')
def SetWindowScalingControl(self, wid, scaling_control):
self.log(".SetWindowScalingControl(%i, %i)", wid, scaling_control)
sc = from0to100(ni(scaling_control))
self.log(".SetWindowScalingControl(%i, %s)", wid, scaling_control)
if scaling_control.lower() in ("auto", "on"):
sc = None
else:
sc = from0to100(int(ns(scaling_control)))
self.server.control_command_scaling_control(sc, ni(wid))

@dbus.service.method(INTERFACE, in_signature='is')
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/server/mixins/encoding_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
self.lossless_encodings = []
self.lossless_mode_encodings = []
self.default_encoding = None
self.scaling_control = False
self.scaling_control = None

def init(self, opts):
self.encoding = opts.encoding
Expand All @@ -39,7 +39,8 @@ def init(self, opts):
self.default_min_quality = opts.min_quality
self.default_speed = opts.speed
self.default_min_speed = opts.min_speed
self.scaling_control = parse_bool_or_int("video-scaling", opts.video_scaling)
if opts.video_scaling.lower() not in ("auto", "on"):
self.scaling_control = parse_bool_or_int("video-scaling", opts.video_scaling)
getVideoHelper().set_modules(video_encoders=opts.video_encoders, csc_modules=opts.csc_modules)

def setup(self):
Expand Down
4 changes: 3 additions & 1 deletion src/xpra/server/window/content_guesser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def load_content_type_dir(d):
try:
load_content_type_file(ct_file)
except Exception as e:
log.error("load_content_type_file(%s)", ct_file, exc_info=True)
log("load_content_type_file(%s)", ct_file, exc_info=True)
log.error("Error loading content-type data from '%s'", ct_file)
log.error(" %s", e)

def load_content_type_file(ct_file):
global content_type_defs
Expand Down
12 changes: 9 additions & 3 deletions src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ def __init__(self,
#where the window is mapped on the client:
self.mapped_at = None
self.fullscreen = not self.is_tray and window.get("fullscreen")
self.scaling_control = default_encoding_options.intget("scaling.control", 1) #ClientConnection sets defaults with the client's scaling.control value
if default_encoding_options.get("scaling.control") is None:
self.scaling_control = None #means "auto"
else:
self.scaling_control = default_encoding_options.intget("scaling.control", 1) #ClientConnection sets defaults with the client's scaling.control value
self.scaling = None
self.maximized = False #set by the client!
self.iconic = False
Expand Down Expand Up @@ -314,7 +317,7 @@ def init_vars(self):
self.has_alpha = False
self.window_dimensions = 0, 0
self.fullscreen = False
self.scaling_control = 0
self.scaling_control = None
self.scaling = None
self.maximized = False
#
Expand Down Expand Up @@ -542,7 +545,10 @@ def set_scaling(self, scaling):

def set_scaling_control(self, scaling_control):
scalinglog("set_scaling_control(%s)", scaling_control)
self.scaling_control = max(0, min(100, scaling_control))
if scaling_control is None:
self.scaling_control = None
else:
self.scaling_control = max(0, min(100, scaling_control))
self.reconfigure(True)

def _fullscreen_changed(self, _window, *_args):
Expand Down
Loading

0 comments on commit 881497d

Please sign in to comment.