[Spice-devel] [PATCH spice-streaming-agent] jpeg: Do not use next_output_byte buf_empty_output_buffer
Frediano Ziglio
fziglio at redhat.com
Tue Jul 17 15:28:06 UTC 2018
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.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
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;
--
2.17.1
More information about the Spice-devel
mailing list