summaryrefslogtreecommitdiffstats
path: root/libvncserver/zrle.c
diff options
context:
space:
mode:
authordscho <dscho>2008-01-29 11:50:16 +0000
committerdscho <dscho>2008-01-29 11:50:16 +0000
commit059afcdf819f63a5ac3a93ef3060fd172234ab82 (patch)
tree2eef987a58512b44445040fb8e78bd65aba09f26 /libvncserver/zrle.c
parent09d902c5b7ce1881e7a4d9642bfae8202f13387f (diff)
downloadlibtdevnc-059afcdf819f63a5ac3a93ef3060fd172234ab82.tar.gz
libtdevnc-059afcdf819f63a5ac3a93ef3060fd172234ab82.zip
Add ZYWRLE server-side support (thanks Noriaki Yamazaki, Hitachi)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'libvncserver/zrle.c')
-rw-r--r--libvncserver/zrle.c86
1 files changed, 74 insertions, 12 deletions
diff --git a/libvncserver/zrle.c b/libvncserver/zrle.c
index d72993e..5481893 100644
--- a/libvncserver/zrle.c
+++ b/libvncserver/zrle.c
@@ -40,18 +40,50 @@
#define EXTRA_ARGS , rfbClientPtr cl
+#define ENDIAN_LITTLE 0
+#define ENDIAN_BIG 1
+#define ENDIAN_NO 2
#define BPP 8
+#define ZYWRLE_ENDIAN ENDIAN_NO
+#include <zrleencodetemplate.c>
+#undef BPP
+#define BPP 15
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_LITTLE
+#include <zrleencodetemplate.c>
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_BIG
#include <zrleencodetemplate.c>
#undef BPP
#define BPP 16
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_LITTLE
+#include <zrleencodetemplate.c>
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_BIG
#include <zrleencodetemplate.c>
#undef BPP
#define BPP 32
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_LITTLE
+#include <zrleencodetemplate.c>
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_BIG
#include <zrleencodetemplate.c>
#define CPIXEL 24A
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_LITTLE
+#include <zrleencodetemplate.c>
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_BIG
#include <zrleencodetemplate.c>
#undef CPIXEL
#define CPIXEL 24B
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_LITTLE
+#include <zrleencodetemplate.c>
+#undef ZYWRLE_ENDIAN
+#define ZYWRLE_ENDIAN ENDIAN_BIG
#include <zrleencodetemplate.c>
#undef CPIXEL
#undef BPP
@@ -80,6 +112,20 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
rfbZRLEHeader hdr;
int i;
+ if (cl->preferredEncoding == rfbEncodingZYWRLE) {
+ if (cl->tightQualityLevel < 0) {
+ zywrle_level = 1;
+ } else if (cl->tightQualityLevel < 3) {
+ zywrle_level = 2;
+ } else if (cl->tightQualityLevel < 6) {
+ zywrle_level = 3;
+ } else {
+ zywrle_level = 1;
+ }
+ } else {
+ zywrle_level = 0;
+ }
+
if (!cl->zrleData)
cl->zrleData = zrleOutStreamNew();
zos = cl->zrleData;
@@ -89,11 +135,21 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
switch (cl->format.bitsPerPixel) {
case 8:
- zrleEncode8( x, y, w, h, zos, zrleBeforeBuf, cl);
+ zrleEncode8NE(x, y, w, h, zos, zrleBeforeBuf, cl);
break;
case 16:
- zrleEncode16(x, y, w, h, zos, zrleBeforeBuf, cl);
+ if (cl->format.greenMax > 0x1F) {
+ if (cl->format.bigEndian)
+ zrleEncode16BE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else
+ zrleEncode16LE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ } else {
+ if (cl->format.bigEndian)
+ zrleEncode15BE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else
+ zrleEncode15LE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ }
break;
case 32: {
@@ -107,18 +163,24 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
cl->format.blueShift > 7);
if ((fitsInLS3Bytes && !cl->format.bigEndian) ||
- (fitsInMS3Bytes && cl->format.bigEndian))
- {
- zrleEncode24A(x, y, w, h, zos, zrleBeforeBuf, cl);
+ (fitsInMS3Bytes && cl->format.bigEndian)) {
+ if (cl->format.bigEndian)
+ zrleEncode24ABE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else
+ zrleEncode24ALE(x, y, w, h, zos, zrleBeforeBuf, cl);
}
else if ((fitsInLS3Bytes && cl->format.bigEndian) ||
- (fitsInMS3Bytes && !cl->format.bigEndian))
- {
- zrleEncode24B(x, y, w, h, zos, zrleBeforeBuf, cl);
+ (fitsInMS3Bytes && !cl->format.bigEndian)) {
+ if (cl->format.bigEndian)
+ zrleEncode24BBE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else
+ zrleEncode24BLE(x, y, w, h, zos, zrleBeforeBuf, cl);
}
- else
- {
- zrleEncode32(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else {
+ if (cl->format.bigEndian)
+ zrleEncode32BE(x, y, w, h, zos, zrleBeforeBuf, cl);
+ else
+ zrleEncode32LE(x, y, w, h, zos, zrleBeforeBuf, cl);
}
}
break;
@@ -138,7 +200,7 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
rect.r.y = Swap16IfLE(y);
rect.r.w = Swap16IfLE(w);
rect.r.h = Swap16IfLE(h);
- rect.encoding = Swap32IfLE(rfbEncodingZRLE);
+ rect.encoding = Swap32IfLE(cl->preferredEncoding);
memcpy(cl->updateBuf+cl->ublen, (char *)&rect,
sz_rfbFramebufferUpdateRectHeader);