]> git.proxmox.com Git - qemu.git/blobdiff - ui/vnc-enc-tight.c
net: Consistently use qemu_macaddr_default_if_unset
[qemu.git] / ui / vnc-enc-tight.c
index 59333940ed0cdf44699b83424977526e3a65b5ab..5c028034112787befc2f46a14b6962a417eeb599 100644 (file)
 
 #include "config-host.h"
 
+/* This needs to be before jpeglib.h line because of conflict with
+   INT32 definitions between jmorecfg.h (included by jpeglib.h) and
+   Win32 basetsd.h (included by windows.h). */
+#include "qemu-common.h"
+
 #ifdef CONFIG_VNC_PNG
+/* The following define is needed by pngconf.h. Otherwise it won't compile,
+   because setjmp.h was already included by qemu-common.h. */
+#define PNG_SKIP_SETJMP_CHECK
 #include <png.h>
 #endif
 #ifdef CONFIG_VNC_JPEG
@@ -36,8 +44,6 @@
 #include <jpeglib.h>
 #endif
 
-#include "qemu-common.h"
-
 #include "bswap.h"
 #include "qint.h"
 #include "vnc.h"
@@ -868,8 +874,8 @@ static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
     zstream->avail_in = vs->tight.tight.offset;
     zstream->next_out = vs->tight.zlib.buffer + vs->tight.zlib.offset;
     zstream->avail_out = vs->tight.zlib.capacity - vs->tight.zlib.offset;
+    previous_out = zstream->avail_out;
     zstream->data_type = Z_BINARY;
-    previous_out = zstream->total_out;
 
     /* start encoding */
     if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
@@ -878,7 +884,8 @@ static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
     }
 
     vs->tight.zlib.offset = vs->tight.zlib.capacity - zstream->avail_out;
-    bytes = zstream->total_out - previous_out;
+    /* ...how much data has actually been produced by deflate() */
+    bytes = previous_out - zstream->avail_out;
 
     tight_send_compact_size(vs, bytes);
     vnc_write(vs, vs->tight.zlib.buffer, bytes);
@@ -1536,8 +1543,10 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
     uint32_t bg = 0, fg = 0;
     int colors;
     int ret = 0;
+#ifdef CONFIG_VNC_JPEG
     bool force_jpeg = false;
     bool allow_jpeg = true;
+#endif
 
     vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);
 
@@ -1711,6 +1720,7 @@ static int tight_send_framebuffer_update(VncState *vs, int x, int y,
         vs->tight.pixel24 = false;
     }
 
+#ifdef CONFIG_VNC_JPEG
     if (vs->tight.quality != (uint8_t)-1) {
         double freq = vnc_update_freq(vs, x, y, w, h);
 
@@ -1718,6 +1728,7 @@ static int tight_send_framebuffer_update(VncState *vs, int x, int y,
             return send_rect_simple(vs, x, y, w, h, false);
         }
     }
+#endif
 
     if (w * h < VNC_TIGHT_MIN_SPLIT_RECT_SIZE) {
         return send_rect_simple(vs, x, y, w, h, true);