Skip to content

Commit

Permalink
Use compressionLevel in ZRLEEncoder
Browse files Browse the repository at this point in the history
This change makes the ZRLEEncoder respect a client's desired
compressionLevel. The ZlibLevel option is marked deprecated and removed
from the manpages.
  • Loading branch information
adamhalim committed Nov 20, 2023
1 parent 9abf88e commit e2c4471
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
10 changes: 10 additions & 0 deletions common/rfb/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ Configuration* Configuration::viewer() {
return viewer_;
}

void warnDeprecatedOptions(const char* name)
{
if (!strcasecmp(name, "ZlibLevel")) {
fprintf(stderr, "Warning: The ZlibLevel option is deprecated and is "
"ignored by the server. The compression level can be set "
"by the client instead.\n");
}
}

// -=- Configuration implementation

bool Configuration::set(const char* n, const char* v, bool immutable) {
Expand All @@ -84,6 +93,7 @@ bool Configuration::set(const char* name, int len,
if ((int)strlen(current->getName()) == len &&
strncasecmp(current->getName(), name, len) == 0)
{
warnDeprecatedOptions(current->getName());
bool b = current->setParam(val);
if (b && immutable)
current->setImmutable();
Expand Down
9 changes: 7 additions & 2 deletions common/rfb/ZRLEEncoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

using namespace rfb;

IntParameter zlibLevel("ZlibLevel","Zlib compression level",-1);
IntParameter zlibLevel("ZlibLevel","[DEPRECATED] Zlib compression level",-1);

ZRLEEncoder::ZRLEEncoder(SConnection* conn)
: Encoder(conn, encodingZRLE, EncoderPlain, 127),
zos(0,zlibLevel), mos(129*1024)
zos(0, 2), mos(129*1024)
{
zos.setUnderlying(&mos);
}
Expand All @@ -50,6 +50,11 @@ bool ZRLEEncoder::isSupported()
return conn->client.supportsEncoding(encodingZRLE);
}

void ZRLEEncoder::setCompressLevel(int level)
{
zos.setCompressionLevel(level);
}

void ZRLEEncoder::writeRect(const PixelBuffer* pb, const Palette& palette)
{
int x, y;
Expand Down
2 changes: 2 additions & 0 deletions common/rfb/ZRLEEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace rfb {

virtual bool isSupported();

virtual void setCompressLevel(int level);

virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
virtual void writeSolidRect(int width, int height,
const PixelFormat& pf,
Expand Down
6 changes: 0 additions & 6 deletions unix/x0vncserver/x0vncserver.man
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ Use MIT-SHM extension if available. Using that extension accelerates reading
the screen. Default is on.
.
.TP
.B \-ZlibLevel \fIlevel\fP
Zlib compression level for ZRLE encoding (it does not affect Tight encoding).
Acceptable values are between 0 and 9. Default is to use the standard
compression level provided by the \fBzlib\fP(3) compression library.
.
.TP
.B \-ImprovedHextile
Use improved compression algorithm for Hextile encoding which achieves better
compression ratios by the cost of using slightly more CPU time. Default is
Expand Down
6 changes: 0 additions & 6 deletions unix/xserver/hw/vnc/Xvnc.man
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ be either \fB0\fP (off), \fB1\fP (always) or \fB2\fP (auto). Default is
\fB2\fP.
.
.TP
.B \-ZlibLevel \fIlevel\fP
Zlib compression level for ZRLE encoding (it does not affect Tight encoding).
Acceptable values are between 0 and 9. Default is to use the standard
compression level provided by the \fBzlib\fP(3) compression library.
.
.TP
.B \-ImprovedHextile
Use improved compression algorithm for Hextile encoding which achieves better
compression ratios by the cost of using slightly more CPU time. Default is
Expand Down

0 comments on commit e2c4471

Please sign in to comment.