[Spice-devel] [PATCH spice-streaming-agent] jpeg: Do not use next_output_byte buf_empty_output_buffer
Victor Toso
victortoso at redhat.com
Thu Jul 19 09:04:54 UTC 2018
Hi,
On Wed, Jul 18, 2018 at 12:02:16PM +0300, Uri Lublin wrote:
> On 07/17/2018 06:28 PM, Frediano Ziglio wrote:
>
> Hi Frediano,
>
> > The pointer is not updated to the last byte used so using it
> > to compute the bytes written into the buffer we ignore some bytes
> > causing some image corruptions.
> > Note that also free_in_buffer is not updated to last written byte.
> > When buf_empty_output_buffer is called the buffer is full so use the
> > size of it instead of relaying on next_output_byte or free_in_buffer.
>
> I also found in /usr/share/doc/libjpeg-turbo-devel/libjpeg.txt,
> under empty_output_buffer:
> "(use the saved start address and buffer length;
> ignore the current state of next_output_byte and free_in_buffer)."
>
> Some printfs show that sometimes a few bytes are "missing".
>
> I tested this patch and it does fix the problem for me.
As a side note, could we try a bit harder in opening a bug
upstream when we find an issue? It helps a lot tracking important
fixes, finding the right commits, etc.
Cheers,
toso
> typo: s/relaying/relying/
>
> >
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
>
> Acked-by: Uri Lublin <uril at redhat.com>
>
> Thanks,
> Uri.
>
>
> > ---
> > src/jpeg.cpp | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/jpeg.cpp b/src/jpeg.cpp
> > index ceee359..5f6d128 100644
> > --- a/src/jpeg.cpp
> > +++ b/src/jpeg.cpp
> > @@ -23,7 +23,7 @@ struct JpegBuffer: public jpeg_destination_mgr
> > static boolean buf_empty_output_buffer(j_compress_ptr cinfo)
> > {
> > JpegBuffer *buf = (JpegBuffer *) cinfo->dest;
> > - size_t size = buf->next_output_byte - &buf->buffer[0];
> > + size_t size = buf->buffer.size();
> > buf->buffer.resize(buf->buffer.capacity() * 2);
> > buf->next_output_byte = &buf->buffer[0] + size;
> > buf->free_in_buffer = buf->buffer.size() - size;
> >
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180719/99815550/attachment.sig>
More information about the Spice-devel
mailing list