Hi,
The attached patch implements ALR, based on a Xt timeout that is reset after
each framebuffer update.
I have added -alrjpeg to enable use of JPEG Q95 for "ALR", because in some
cases I do not want to use truly lossless (low bandwidth).
If you're happy, please apply.
Next in line: add both options to the F8 menu, and factorize the code with the
"request ALR" feature.
--
Greetings,
A. Huillet
>From d215d0b31aef4c63a0c7e04f2e7377b132aec41e Mon Sep 17 00:00:00 2001
From: Arthur Huillet <arthur.huil...@free.fr>
Date: Thu, 12 May 2011 12:04:44 +0200
Subject: [PATCH] vncviewer: Implement automatic lossless refresh (ALR).
-alr <delay> specifies the delay after which ALR is done
-alrjpeg enables use of JPEG Q95 for refresh
---
vnc_unixsrc/vncviewer/argsresources.c | 12 ++++++++-
vnc_unixsrc/vncviewer/rfbproto.c | 44 +++++++++++++++++++++++++++++++++
vnc_unixsrc/vncviewer/vncviewer.h | 2 +
3 files changed, 57 insertions(+), 1 deletions(-)
diff --git a/vnc_unixsrc/vncviewer/argsresources.c b/vnc_unixsrc/vncviewer/argsresources.c
index 040b4c5..731c2c2 100644
--- a/vnc_unixsrc/vncviewer/argsresources.c
+++ b/vnc_unixsrc/vncviewer/argsresources.c
@@ -360,6 +360,12 @@ static XtResource appDataResourceList[] = {
{"configFile", "ConfigFile", XtRString, sizeof(String),
XtOffsetOf(AppData, configFile), XtRImmediate, (XtPointer) 0},
+
+ {"automaticLosslessRefresh", "AutomaticLosslessRefresh", XtRFloat, sizeof(float),
+ XtOffsetOf(AppData, automaticLosslessRefresh), XtRString, (XtPointer) "0.0"},
+
+ {"automaticRefreshJPEG", "AutomaticRefreshJPEG", XtRBool, sizeof(Bool),
+ XtOffsetOf(AppData, automaticRefreshJPEG), XtRImmediate, (XtPointer) False},
};
@@ -396,7 +402,9 @@ XrmOptionDescRec cmdLineOptions[] = {
{"-user", "*userLogin", XrmoptionSepArg, 0},
{"-nounixlogin", "*noUnixLogin", XrmoptionNoArg, "True"},
{"-cu", "*continuousUpdates", XrmoptionNoArg, "True"},
- {"-config", "*configFile", XrmoptionSepArg, 0}
+ {"-config", "*configFile", XrmoptionSepArg, 0},
+ {"-alr", "*automaticLosslessRefresh", XrmoptionSepArg, 0},
+ {"-alrjpeg", "*automaticRefreshJPEG", XrmoptionNoArg, "True"},
};
int numCmdLineOptions = XtNumber(cmdLineOptions);
@@ -493,6 +501,8 @@ usage(void)
" -nounixlogin\n"
" -cu\n"
" -config <CONFIG-FILENAME>\n"
+ " -alr <delay>\n"
+ " -alrjpeg\n"
"\n"
"Option names may be abbreviated, for example, -q instead of -quality.\n"
"See the manual page for more information."
diff --git a/vnc_unixsrc/vncviewer/rfbproto.c b/vnc_unixsrc/vncviewer/rfbproto.c
index 6240c18..b2096a9 100644
--- a/vnc_unixsrc/vncviewer/rfbproto.c
+++ b/vnc_unixsrc/vncviewer/rfbproto.c
@@ -79,6 +79,8 @@ static void SendContinuousUpdatesMessage(Bool enable);
extern void UpdateQual(void);
extern Bool HandleCursorPos(int, int);
+static void alr_timeout(XtPointer start, XtIntervalId *timer);
+
int rfbsock;
char *desktopName;
rfbPixelFormat myFormat;
@@ -86,6 +88,8 @@ rfbServerInitMsg si;
char *serverCutText = NULL;
Bool newServerCutText = False;
+static XtIntervalId alr_timeout_id = 0;
+
/*
* Profiling stuff
@@ -1687,6 +1691,13 @@ HandleRFBServerMessage()
}
}
+ if (appData.automaticLosslessRefresh > 0.0) {
+ if (alr_timeout_id)
+ XtRemoveTimeOut(alr_timeout_id);
+
+ alr_timeout_id = XtAppAddTimeOut(appContext, (int)(appData.automaticLosslessRefresh * 1000), alr_timeout, NULL);
+ }
+
break;
}
@@ -1847,3 +1858,36 @@ ReadCompactLen (void)
}
return len;
}
+
+static void alr_timeout(XtPointer dummy, XtIntervalId *timer)
+{
+ printf("Doing ALR\n");
+ String encodings = appData.encodingsString;
+ int compressLevel = appData.compressLevel;
+ int qual = appData.qualityLevel;
+ int subsampLevel = appData.subsampLevel;
+ Bool enableJPEG = appData.enableJPEG;
+
+ if (appData.automaticRefreshJPEG) {
+ appData.qualityLevel = 95;
+ appData.enableJPEG = True;
+ appData.subsampLevel = TVNC_1X;
+ } else {
+ appData.enableJPEG = False;
+ }
+
+ appData.encodingsString = "tight copyrect";
+ appData.compressLevel = 1;
+ SetFormatAndEncodings();
+ SendFramebufferUpdateRequest(0, 0, si.framebufferWidth,
+ si.framebufferHeight, False);
+ appData.qualityLevel = qual;
+ appData.enableJPEG = enableJPEG;
+ appData.encodingsString = encodings;
+ appData.compressLevel = compressLevel;
+ appData.subsampLevel = subsampLevel;
+
+ SetFormatAndEncodings();
+ alr_timeout_id = 0;
+}
+
diff --git a/vnc_unixsrc/vncviewer/vncviewer.h b/vnc_unixsrc/vncviewer/vncviewer.h
index c83ffc0..2041332 100644
--- a/vnc_unixsrc/vncviewer/vncviewer.h
+++ b/vnc_unixsrc/vncviewer/vncviewer.h
@@ -139,6 +139,8 @@ typedef struct {
char *configFile;
+ float automaticLosslessRefresh;
+ Bool automaticRefreshJPEG;
} AppData;
extern AppData appData;
--
1.7.5.1
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
VirtualGL-Devel mailing list
VirtualGL-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtualgl-devel