From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Lieven <pl@kamp.de>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 5/6] vnc: allow fall back to RAW encoding
Date: Tue, 3 Nov 2015 11:01:30 +0100 [thread overview]
Message-ID: <1446544891-3600-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1446544891-3600-1-git-send-email-kraxel@redhat.com>
From: Peter Lieven <pl@kamp.de>
I have observed that depending on the contents and the encoding it happens
that sending data as RAW sometimes would take less space than the encoded data.
This is especially the case for small updates or areas with high color images.
If sending RAW encoded data is beneficial allow a fall back to RAW encoding
for the framebuffer update.
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/vnc.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index 7b37e3b..166d1b5 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -840,6 +840,8 @@ int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
{
int n = 0;
+ bool encode_raw = false;
+ size_t saved_offs = vs->output.offset;
switch(vs->vnc_encoding) {
case VNC_ENCODING_ZLIB:
@@ -862,10 +864,24 @@ int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
n = vnc_zywrle_send_framebuffer_update(vs, x, y, w, h);
break;
default:
- vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_RAW);
- n = vnc_raw_send_framebuffer_update(vs, x, y, w, h);
+ encode_raw = true;
break;
}
+
+ /* If the client has the same pixel format as our internal buffer and
+ * a RAW encoding would need less space fall back to RAW encoding to
+ * save bandwidth and processing power in the client. */
+ if (!encode_raw && vs->write_pixels == vnc_write_pixels_copy &&
+ 12 + h * w * VNC_SERVER_FB_BYTES <= (vs->output.offset - saved_offs)) {
+ vs->output.offset = saved_offs;
+ encode_raw = true;
+ }
+
+ if (encode_raw) {
+ vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_RAW);
+ n = vnc_raw_send_framebuffer_update(vs, x, y, w, h);
+ }
+
return n;
}
--
1.8.3.1
next prev parent reply other threads:[~2015-11-03 10:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 10:01 [Qemu-devel] [PULL 0/6] ui patch queue Gerd Hoffmann
2015-11-03 10:01 ` [Qemu-devel] [PULL 1/6] ui/curses: Fix monitor color with -curses when 256 colors Gerd Hoffmann
2015-11-03 10:01 ` [Qemu-devel] [PULL 2/6] ui/curses: Support line graphics chars on -curses mode Gerd Hoffmann
2015-11-03 10:01 ` [Qemu-devel] [PULL 3/6] ui/curses: Fix pageup/pagedown on -curses Gerd Hoffmann
2015-11-03 10:01 ` [Qemu-devel] [PULL 4/6] ui/opengl: Reduce build required libraries for opengl Gerd Hoffmann
2015-11-03 10:01 ` Gerd Hoffmann [this message]
2015-11-03 10:01 ` [Qemu-devel] [PULL 6/6] vnc: fix bug: vnc server can't start when 'to' is specified Gerd Hoffmann
2015-11-05 8:21 ` Markus Armbruster
2015-11-03 11:17 ` [Qemu-devel] [PULL 0/6] ui patch queue Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446544891-3600-6-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).