Skip to content

Commit

Permalink
#3706 we can and should use a full mask for RGB input formats
Browse files Browse the repository at this point in the history
we can't specify the input image's rowstride, so this is the best we can do
  • Loading branch information
totaam committed Feb 2, 2023
1 parent a42e234 commit 774b66c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xpra/codecs/gstreamer/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
}
}

PACKED_RGB_FORMATS = ("RGBA", "BGRA", "ARGB", "ABGR", "RGB", "BGR", "BGRX", "XRGB", "XBGR")

COLORSPACES = {}
def get_encodings():
Expand Down Expand Up @@ -110,6 +111,10 @@ def make_spec(element, encoding, cs_in, css_out, cpu_cost=50, gpu_cost=50):
encoder_options = dict(DEFAULT_ENCODER_OPTIONS.get(element, {}))
class ElementEncoder(Encoder):
pass
if cs_in in PACKED_RGB_FORMATS:
width_mask = height_mask = 0xFFFF
else:
width_mask = height_mask = 0xFFFE
ElementEncoder.encoder_element = element
ElementEncoder.encoder_options = encoder_options or {}
spec = video_spec(
Expand All @@ -119,7 +124,7 @@ class ElementEncoder(Encoder):
codec_class=ElementEncoder, codec_type=get_type(),
quality=40, speed=40,
setup_cost=100, cpu_cost=cpu_cost, gpu_cost=gpu_cost,
width_mask=0xFFFE, height_mask=0xFFFE,
width_mask=width_mask, height_mask=height_mask,
min_w=64, min_h=64,
max_w=4096, max_h=4096)
spec.gstreamer_element = element
Expand Down Expand Up @@ -201,6 +206,9 @@ def create_pipeline(self, options):
#"RGB8P"
}[self.colorspace]
CAPS = f"video/x-raw,width={self.width},height={self.height},format=(string){gst_rgb_format},framerate=60/1,interlace=progressive"
#this would only guess the rowstride - actual input images may well be different!
#if self.colorspace in PACKED_RGB_FORMATS:
# CAPS += f",rowstride={self.width*len(self.colorspace)}"
encoder_str = self.encoder_element
if self.encoder_options:
encoder_str += " "+" ".join(f"{k}={v}" for k,v in self.encoder_options.items())
Expand Down

0 comments on commit 774b66c

Please sign in to comment.