Re: [PATCH spice-server 1/2] Fix GStreamer encoding if stride is not 4 bytes aligned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 22, 2017 at 11:04:27AM -0400, Frediano Ziglio wrote:
> > 
> > Hi Frediano,
> > 
> > On Wed, 2017-03-22 at 10:18 +0000, Frediano Ziglio wrote:
> > > This is required by GStreamer.
> > 
> > Is it related to the gstreamer bug you have opened recently ?
> 
> Not strictly, I was trying to reproduce the issue with chunks
> and adapt my test script to not use a video on my pc (so could
> be upstreamed).
> The --split-lines option reproduce the chunks issue but changing
> the video source size I started having this alignment issue due to
> the fact that the width I was not multiple of 4.
> 
> > > 
> > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > > ---
> > >  server/gstreamer-encoder.c | 8 ++++++--
> > >  1 file changed, 6 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> > > index df54cad..e637b8a 100644
> > > --- a/server/gstreamer-encoder.c
> > > +++ b/server/gstreamer-encoder.c
> > > @@ -1260,7 +1260,7 @@ static inline int line_copy(SpiceGstEncoder
> > > *encoder, const SpiceBitmap *bitmap,
> > >  
> > >           /* Copy the line */
> > >           uint8_t *src = chunks->chunk[chunk_index].data +
> > > chunk_offset;
> > > -         memcpy(dst, src, stream_stride);
> > > +         memcpy(dst, src, MIN(stream_stride, bitmap->stride));
> > >           dst += stream_stride;
> > >           chunk_offset += bitmap->stride;
> > >       }
> > > @@ -1351,7 +1351,7 @@ static int push_raw_frame(SpiceGstEncoder
> > > *encoder,
> > >  {
> > >      uint32_t height = src->bottom - src->top;
> > >      uint32_t stream_stride = (src->right - src->left) * encoder-
> > > >format->bpp / 8;
> > > -    uint32_t len = stream_stride * height;
> > > +    uint32_t len;
> > >      GstBuffer *buffer = gst_buffer_new();
> > >      /* TODO Use GST_MAP_INFO_INIT once GStreamer 1.4.5 is no longer
> > > relevant */
> > >      GstMapInfo map = { .memory = NULL };
> > > @@ -1362,6 +1362,10 @@ static int push_raw_frame(SpiceGstEncoder
> > > *encoder,
> > >      uint32_t skip_lines = top_down ? src->top : bitmap->y - (src-
> > > >bottom - 0);
> > >      uint32_t chunk_offset = bitmap->stride * skip_lines;
> > >  
> > > +    // GStreamer require the stream to be 4 bytes aligned
> > > +    stream_stride = (stream_stride + 3) & -4;
> > 
> > (maybe it is just me but) imho is not easy to read binary operation
> > with negative numbers. Can you switch to ~3
> > 
> > Thanks,
> > Pavel
> > 
> 
> No problem.

Even better, GST_ROUND_UP_4(stream_stride)

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]