Skip to content

Commit

Permalink
* add XPRA_VIDEO_SKIP_EDGE to make it easier to debug paint packets (…
Browse files Browse the repository at this point in the history
…less noise)

* move video_fallback function into a method we can re-use
* log encoder info when we schedule the flush timer
* whitespace

git-svn-id: https://xpra.org/svn/Xpra/trunk@12885 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 22, 2016
1 parent 6cafc0d commit 682053d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def envint(name, d):

VIDEO_SUBREGION = os.environ.get("XPRA_VIDEO_SUBREGION", "1")=="1"
B_FRAMES = os.environ.get("XPRA_B_FRAMES", "1")=="1"
VIDEO_SKIP_EDGE = os.environ.get("XPRA_VIDEO_SKIP_EDGE", "0")=="1"


class WindowVideoSource(WindowSource):
Expand Down Expand Up @@ -653,10 +654,9 @@ def process_damage_region(self, damage_time, x, y, w, h, coding, options, flush=
dh = h - (h & self.height_mask)
else:
dw, dh = 0, 0
if self.edge_encoding:
#we can't send the edges, no big deal
if self.edge_encoding and not VIDEO_SKIP_EDGE:
if dw>0:
WindowSource.process_damage_region(self, damage_time, x+w-dw, y, dw, h, self.edge_encoding, options, flush=1)
WindowSource.process_damage_region(self, damage_time, x+w-dw, y, dw, h, self.edge_encoding, options, flush=1+int(dh>0))
if dh>0:
WindowSource.process_damage_region(self, damage_time, x, y+h-dh, x+w, dh, self.edge_encoding, options, flush=1)
WindowSource.process_damage_region(self, damage_time, x, y, w-dw, h-dh, coding, options, flush=flush)
Expand Down Expand Up @@ -1276,8 +1276,8 @@ def setup_pipeline_option(self, width, height, src_format,
dst_formats = self.full_csc_modes.get(encoder_spec.encoding)
ve = encoder_spec.make_instance()
options = self.encoding_options.copy()
if encoder_spec.encoding in self.supports_video_b_frames:
options["b-frames"] = B_FRAMES
if encoder_spec.encoding in self.supports_video_b_frames and B_FRAMES:
options["b-frames"] = True
ve.init_context(enc_width, enc_height, enc_in_format, dst_formats, encoder_spec.encoding, quality, speed, encoder_scaling, options)
#record new actual limits:
self.actual_scaling = scaling
Expand All @@ -1295,6 +1295,16 @@ def setup_pipeline_option(self, width, height, src_format,
return True


def video_fallback(self, image, options):
#find one that is not video:
fallback_encodings = [x for x in PREFERED_ENCODING_ORDER if (x in self.non_video_encodings and x in self._encoders and x!="mmap")]
if not fallback_encodings:
log.error("no non-video fallback encodings are available!")
return None
fallback_encoding = fallback_encodings[0]
encode_fn = self._encoders[fallback_encoding]
return encode_fn(fallback_encoding, image, options)

def video_encode(self, encoding, image, options):
"""
This method is used by make_data_packet to encode frames using video encoders.
Expand All @@ -1312,15 +1322,8 @@ def video_encode(self, encoding, image, options):
self.pixel_format = src_format

def video_fallback():
#find one that is not video:
fallback_encodings = [x for x in PREFERED_ENCODING_ORDER if (x in self.non_video_encodings and x in self._encoders and x!="mmap")]
if not fallback_encodings:
log.error("no non-video fallback encodings are available!")
return None
fallback_encoding = fallback_encodings[0]
encode_fn = self._encoders[fallback_encoding]
videolog.warn("using '%s' as non-video fallback using %s", fallback_encoding, encode_fn)
return encode_fn(fallback_encoding, image, options)
videolog.warn("using non-video fallback encoding")
return self.video_fallback(image, options)

vh = self.video_helper
if vh is None:
Expand Down Expand Up @@ -1378,7 +1381,7 @@ def video_fallback():
if delayed is not None:
last_frame = client_options.get("frame")
flush_delay = max(100, min(500, int(self.batch_config.delay*10)))
videolog("schedule video_encoder_flush for last frame=%i, flush delay=%i", last_frame, flush_delay)
videolog("schedule video_encoder_flush for encoder %s, last frame=%i, client_options=%s, flush delay=%i", ve, last_frame, client_options, flush_delay)
self.b_frame_flush_timer = self.timeout_add(flush_delay, self.flush_video_encoder, ve, csc, last_frame, x, y)
if data is None:
return None
Expand Down Expand Up @@ -1411,7 +1414,7 @@ def do_flush_video_encoder(self, ve, csc, frame, x, y):
self._video_encoder = None
ve.clean()
self.idle_add(self.full_quality_refresh)
return
return
v = ve.flush(frame)
if not v:
videolog("do_flush_video_encoder%s=%s", (ve, frame, x, y), v)
Expand Down

0 comments on commit 682053d

Please sign in to comment.