aboutsummaryrefslogtreecommitdiff
path: root/ui/vnc.h
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2011-02-04 09:05:55 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2011-02-23 16:28:28 -0600
commit999342a0fe959dcd549396a255a04d000678e910 (patch)
tree691a2efef3cf2d56c704e946360d8cf9ec8cd288 /ui/vnc.h
parentb31f519e278601225c53519e3b16333d86770ecf (diff)
vnc: add a way to get the update frequency for a given region
This patch compute the update frequency (in Hz) for each 64x64 rects. Any adaptive encoding can get this value using vnc_update_freq(), and switch to a lossy encoding if the value is too high. The frequency is pre-calculated every 500ms, based on the last 10 updates per 64x64 rect. If a 64x64 rect was not updated in the last 2 second, then the frequency became 0, and all the stored timestamp are reseted. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui/vnc.h')
-rw-r--r--ui/vnc.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/vnc.h b/ui/vnc.h
index 4f895becb9..c0e5ff30ba 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -80,6 +80,10 @@ typedef void VncSendHextileTile(VncState *vs,
#define VNC_MAX_HEIGHT 2048
#define VNC_DIRTY_WORDS (VNC_MAX_WIDTH / (16 * 32))
+#define VNC_STAT_RECT 64
+#define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT)
+#define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT)
+
#define VNC_AUTH_CHALLENGE_SIZE 16
typedef struct VncDisplay VncDisplay;
@@ -92,9 +96,23 @@ typedef struct VncDisplay VncDisplay;
#include "vnc-auth-sasl.h"
#endif
+struct VncRectStat
+{
+ /* time of last 10 updates, to find update frequency */
+ struct timeval times[10];
+ int idx;
+
+ double freq; /* Update frequency (in Hz) */
+ bool updated; /* Already updated during this refresh */
+};
+
+typedef struct VncRectStat VncRectStat;
+
struct VncSurface
{
+ struct timeval last_freq_check;
uint32_t dirty[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS];
+ VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS];
DisplaySurface *ds;
};
@@ -479,6 +497,7 @@ void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
int32_t encoding);
void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v);
+double vnc_update_freq(VncState *vs, int x, int y, int w, int h);
/* Encodings */
int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);