Skip to content

Commit

Permalink
#3706 restride the image if required
Browse files Browse the repository at this point in the history
(not done yet for YUV input)
  • Loading branch information
totaam committed Feb 2, 2023
1 parent c057456 commit fad5f1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xpra/codecs/gstreamer/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from gi.repository import GObject # @UnresolvedImport

from xpra.util import parse_simple_dict, envbool, csv
from xpra.util import parse_simple_dict, envbool, csv, roundup
from xpra.codecs.codec_constants import video_spec
from xpra.gst_common import (
import_gst, normv,
Expand Down Expand Up @@ -206,9 +206,6 @@ 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 Expand Up @@ -267,6 +264,11 @@ def wrap(self, data):
def compress_image(self, image, options=None):
if image.get_planes()==ImageWrapper.PACKED:
data = image.get_pixels()
rowstride = image.get_rowstride()
want_rowstride = roundup(self.width, 2)*len(self.colorspace)
if rowstride!=want_rowstride:
if not image.restride(want_rowstride):
raise RuntimeError(f"failed to restride image from {rowstride}to {want_rowstride}")
else:
#merge all planes into a single buffer:
data = b"".join(image.get_pixels())
Expand Down

0 comments on commit fad5f1b

Please sign in to comment.