Skip to content

Commit

Permalink
smoothe the new batch delay so small / big windows don't differ too m…
Browse files Browse the repository at this point in the history
…uch when we generate a value from the per-megapixel normalized value, always store delays as ints

git-svn-id: https://xpra.org/svn/Xpra/trunk@21621 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 11, 2019
1 parent fd1b6b5 commit 2015bd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/xpra/server/source/encodings_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ def recalculate_delays(self):
#store the delay as a normalized value per megapixel
#so we can adapt it to different window sizes:
avg_size = tsize // tcount
normalized_delay = wdelay * 1000000 // avg_size
ratio = sqrt(1000000.0 / avg_size)
normalized_delay = int(delay * ratio)
self.global_batch_config.delay_per_megapixel = normalized_delay
log("delay_per_megapixel=%i, delay=%i, for wdelay=%i, avg_size=%i, ratio=%.2f", normalized_delay, delay, wdelay, avg_size, ratio)

def may_recalculate(self, wid, pixel_count):
if wid in self.calculate_window_ids:
Expand Down Expand Up @@ -488,8 +490,10 @@ def make_batch_config(self, wid, window):
#(ie: a 4MPixel window, will start at 2 times the global delay)
#(ie: a 0.5MPixel window will start at 0.7 times the global delay)
dpm = self.global_batch_config.delay_per_megapixel
w, h = window.get_dimensions()
if dpm>=0:
w, h = window.get_dimensions()
ratio = float(w*h) / 1000000
batch_config.delay = dpm * sqrt(ratio)
ratio = sqrt(1000000.0 / (w*h))
batch_config.delay = max(batch_config.min_delay, min(batch_config.max_delay, int(dpm * sqrt(ratio))))
log("make_batch_config(%i, %s) global delay per megapixel=%i, new window delay for %ix%i=%s",
wid, window, dpm, w, h, batch_config.delay)
return batch_config
2 changes: 1 addition & 1 deletion src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ def calculate_batch_delay(self, has_focus, other_is_fullscreen, other_is_maximiz
calculate_batch_delay(self.wid, self.window_dimensions, has_focus, other_is_fullscreen, other_is_maximized, self.is_OR, self.soft_expired, self.batch_config, self.global_statistics, self.statistics, self.bandwidth_limit)
#update the normalized value:
ww, wh = self.window_dimensions
self.batch_config.delay_per_megapixel = self.batch_config.delay*1000000//(ww*wh)
self.batch_config.delay_per_megapixel = int(self.batch_config.delay*1000000//(ww*wh))
self.statistics.last_recalculate = now
self.update_av_sync_frame_delay()

Expand Down

0 comments on commit 2015bd1

Please sign in to comment.