diff mbox

[v2,15/15] vnc: add a non-adaptive option

Message ID 1289494624-12807-16-git-send-email-corentincj@iksaif.net
State New
Headers show

Commit Message

Corentin Chary Nov. 11, 2010, 4:57 p.m. UTC
This option allow to disable adaptive behaviors in some encodings.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 qemu-options.hx    |    9 +++++++++
 ui/vnc-enc-tight.c |    2 +-
 ui/vnc.c           |   13 +++++++++----
 ui/vnc.h           |    1 +
 4 files changed, 20 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/qemu-options.hx b/qemu-options.hx
index 4d99a58..fc532b6 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -909,6 +909,15 @@  option is set, VNC client may receive lossy framebuffer updates
 depending on its encoding settings. Enabling this option can save
 a lot of bandwidth at the expense of quality.
 
+@item non-adaptive
+
+Disable adaptive encodings. Adaptive encodings are enabled by default.
+An adaptive encoding will try to detect frequently updated screen regions,
+and send updates in these regions using a lossy encoding (like JPEG).
+This can be really helpfull to save bandwidth when playing videos. Disabling
+adaptive encodings allow to restore the original static behavior of encodings
+like Tight.
+
 @end table
 ETEXI
 
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 82c1e96..5933394 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1546,7 +1546,7 @@  static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
     vnc_tight_stop(vs);
 
 #ifdef CONFIG_VNC_JPEG
-    if (vs->tight.quality != (uint8_t)-1) {
+    if (!vs->vd->non_adaptive && vs->tight.quality != (uint8_t)-1) {
         double freq = vnc_update_freq(vs, x, y, w, h);
 
         if (freq < tight_jpeg_conf[vs->tight.quality].jpeg_freq_min) {
diff --git a/ui/vnc.c b/ui/vnc.c
index 9189014..24c5f7e 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2384,10 +2384,12 @@  static int vnc_refresh_server_surface(VncDisplay *vd)
     VncState *vs;
     int has_dirty = 0;
 
-    struct timeval tv;
+    struct timeval tv = { 0, 0 };
 
-    gettimeofday(&tv, NULL);
-    has_dirty = vnc_update_stats(vd, &tv);
+    if (!vd->non_adaptive) {
+        gettimeofday(&tv, NULL);
+        has_dirty = vnc_update_stats(vd, &tv);
+    }
 
     /*
      * Walk through the guest dirty map.
@@ -2416,7 +2418,8 @@  static int vnc_refresh_server_surface(VncDisplay *vd)
                 if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0)
                     continue;
                 memcpy(server_ptr, guest_ptr, cmp_bytes);
-                vnc_rect_updated(vd, x, y, &tv);
+                if (!vd->non_adaptive)
+                    vnc_rect_updated(vd, x, y, &tv);
                 QTAILQ_FOREACH(vs, &vd->clients, next) {
                     set_bit((x / 16), vs->dirty[y]);
                 }
@@ -2725,6 +2728,8 @@  int vnc_display_open(DisplayState *ds, const char *display)
 #endif
         } else if (strncmp(options, "lossy", 5) == 0) {
             vs->lossy = true;
+        } else if (strncmp(options, "non-adapative", 13) == 0) {
+            vs->non_adaptive = true;
         }
     }
 
diff --git a/ui/vnc.h b/ui/vnc.h
index 979467b..f502690 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -143,6 +143,7 @@  struct VncDisplay
     char *password;
     int auth;
     bool lossy;
+    bool non_adaptive;
 #ifdef CONFIG_VNC_TLS
     int subauth; /* Used by VeNCrypt */
     VncDisplayTLS tls;