[Spice-devel] RFC: remove Adler checksum and zlib header/trailer from zlib compressed images
Yaniv Kaul
ykaul at redhat.com
Sat Jan 28 23:28:34 PST 2012
These small changes to server and (gtk) client seem to work, and remove
both the zlib header/trailer from the deflate stream as well as the
Adler checksum, which removes several bytes from the stream as well as
speedup (unnoticeable) of the compression/decompression due to the
removal of the checksum calculation.
Problem is - not sure how to test it - don't know how to get an image
once with and once without the patch - and ensure it's the same image.
The fact that the first image is never zlib compressed complicates
things. I could not reliably get a 2nd image sent to the client which
looks the same as one in a different connection.
Nevertheless it does no harm - and images pass well - verified by
connecting with a modified Spice GTK client to a modified Spice server,
as well as looking at the network capture via wireshark.
It's of course missing the display channel specific capability
negotiation for this change.
Comments are welcome.
Client change:
diff --git a/gtk/decode-zlib.c b/gtk/decode-zlib.c
index a692020..997f350 100644
--- a/gtk/decode-zlib.c
+++ b/gtk/decode-zlib.c
@@ -63,7 +63,7 @@ SpiceZlibDecoder *zlib_decoder_new(void)
d->_z_strm.opaque = Z_NULL;
d->_z_strm.next_in = Z_NULL;
d->_z_strm.avail_in = 0;
- z_ret = inflateInit(&d->_z_strm);
+ z_ret = inflateInit2(&d->_z_strm, -15);
if (z_ret != Z_OK) {
g_warning("zlib decoder init failed, error %d", z_ret);
goto fail;
server change:
diff --git a/server/zlib_encoder.c b/server/zlib_encoder.c
index c51466b..66a039a 100644
--- a/server/zlib_encoder.c
+++ b/server/zlib_encoder.c
@@ -47,7 +47,7 @@ ZlibEncoder* zlib_encoder_create(ZlibEncoderUsrContext
*usr, int level)
enc->strm.zfree = Z_NULL;
enc->strm.opaque = Z_NULL;
- z_ret = deflateInit(&enc->strm, level);
+ z_ret = deflateInit2(&enc->strm, level, Z_DEFLATED, -15, 8,
Z_DEFAULT_STRATEGY);
enc->last_level = level;
if (z_ret != Z_OK) {
red_printf("zlib error");
More information about the Spice-devel
mailing list