Re: [PATCH spice-streaming-agent] jpeg: Do not use next_output_byte buf_empty_output_buffer

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

 



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.

typo: s/relaying/relying/


Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Acked-by: Uri Lublin <uril@xxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




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