Skip to content

Commit

Permalink
always use ints for speed and quality target values
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@21008 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 16, 2018
1 parent 7fc84ec commit b43a226
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/xpra/server/window/batch_delay_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_target_speed(window_dimensions, batch, global_statistics, statistics, ba
},
"congestion-value" : int(1000*global_statistics.congestion_value),
}
return info, target_speed
return info, int(target_speed)


def get_target_quality(window_dimensions, batch, global_statistics, statistics, bandwidth_limit, min_quality, min_speed):
Expand Down Expand Up @@ -296,4 +296,4 @@ def get_target_quality(window_dimensions, batch, global_statistics, statistics,
#apply min-quality:
mq = min(100.0, max(min_quality, 0.0))
target_quality = mq + (100.0-mq) * target
return info, target_quality
return info, int(target_quality)
26 changes: 14 additions & 12 deletions src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,13 @@ def update_speed(self):
now = monotonic_time()
#make a copy to work on:
speed_data = list(self._encoding_speed)
info, target_speed = get_target_speed(self.window_dimensions, self.batch_config, self.global_statistics, self.statistics, self.bandwidth_limit, self._fixed_min_speed, speed_data)
speed_data.append((monotonic_time(), target_speed))
speed = max(self._fixed_min_speed, time_weighted_average(speed_data, min_offset=1, rpow=1.1))
speed = min(99, speed)
self._current_speed = int(speed)
statslog("update_speed() wid=%s, info=%s, speed=%s", self.wid, info, speed)
info, target = get_target_speed(self.window_dimensions, self.batch_config, self.global_statistics, self.statistics, self.bandwidth_limit, self._fixed_min_speed, speed_data)
speed_data.append((monotonic_time(), target))
speed = int(time_weighted_average(speed_data, min_offset=1, rpow=1.1))
speed = max(0, self._fixed_min_speed, speed)
speed = int(min(99, speed))
self._current_speed = speed
statslog("update_speed() wid=%s, info=%s, speed=%i (target=%i)", self.wid, info, speed, target)
self._encoding_speed_info = info
self._encoding_speed.append((monotonic_time(), speed))
ww, wh = self.window_dimensions
Expand Down Expand Up @@ -1031,14 +1032,15 @@ def update_quality(self):
self._encoding_quality_info = {"fixed" : True}
return
now = monotonic_time()
info, quality = get_target_quality(self.window_dimensions, self.batch_config, self.global_statistics, self.statistics, self.bandwidth_limit, self._fixed_min_quality, self._fixed_min_speed)
info, target = get_target_quality(self.window_dimensions, self.batch_config, self.global_statistics, self.statistics, self.bandwidth_limit, self._fixed_min_quality, self._fixed_min_speed)
#make a copy to work on:
ves_copy = list(self._encoding_quality)
ves_copy.append((now, quality))
quality = max(self._fixed_min_quality, time_weighted_average(ves_copy, min_offset=0.1, rpow=1.2))
quality = min(99, quality)
self._current_quality = int(quality)
statslog("update_quality() wid=%i, info=%s, quality=%s", self.wid, info, quality)
ves_copy.append((now, target))
quality = int(time_weighted_average(ves_copy, min_offset=0.1, rpow=1.2))
quality = max(0, self._fixed_min_quality, quality)
quality = int(min(99, quality))
self._current_quality = quality
statslog("update_quality() wid=%i, info=%s, quality=%i (target=%i)", self.wid, info, quality, target)
self._encoding_quality_info = info
self._encoding_quality.append((now, quality))
ww, wh = self.window_dimensions
Expand Down

0 comments on commit b43a226

Please sign in to comment.