summaryrefslogtreecommitdiffstats
path: root/libvncserver/zrleencodetemplate.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/zrleencodetemplate.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/zrleencodetemplate.c')
-rw-r--r--libvncserver/zrleencodetemplate.c64
1 files changed, 54 insertions, 10 deletions
diff --git a/libvncserver/zrleencodetemplate.c b/libvncserver/zrleencodetemplate.c
index 7c89c40..7d19766 100644
--- a/libvncserver/zrleencodetemplate.c
+++ b/libvncserver/zrleencodetemplate.c
@@ -43,17 +43,37 @@
#define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b)
#endif
+#ifndef __RFB_CONCAT3E
+#define __RFB_CONCAT3(a,b,c) a##b##c
+#define __RFB_CONCAT3E(a,b,c) __RFB_CONCAT3(a,b,c)
+#endif
+
+#undef END_FIX
+#if ZYWRLE_ENDIAN == ENDIAN_LITTLE
+# define END_FIX LE
+#elif ZYWRLE_ENDIAN == ENDIAN_BIG
+# define END_FIX BE
+#else
+# define END_FIX NE
+#endif
+
#ifdef CPIXEL
#define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP)
#define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,CPIXEL)
-#define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,CPIXEL)
-#define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,CPIXEL)
+#define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,CPIXEL,END_FIX)
+#define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,CPIXEL,END_FIX)
#define BPPOUT 24
+#elif BPP==15
+#define PIXEL_T __RFB_CONCAT2E(zrle_U,16)
+#define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,16)
+#define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX)
+#define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX)
+#define BPPOUT 16
#else
#define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP)
#define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,BPP)
-#define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,BPP)
-#define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,BPP)
+#define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX)
+#define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX)
#define BPPOUT BPP
#endif
@@ -64,12 +84,20 @@ static const int bitsPerPackedPixel[] = {
0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};
+int zywrle_level;
+int zywrleBuf[rfbZRLETileWidth*rfbZRLETileHeight];
+
static zrlePaletteHelper paletteHelper;
#endif /* ZRLE_ONCE */
void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os);
+#if BPP!=8
+#define ZYWRLE_ENCODE
+#include "zywrletemplate.c"
+#endif
+
static void ZRLE_ENCODE (int x, int y, int w, int h,
zrleOutStream* os, void* buf
EXTRA_ARGS
@@ -92,7 +120,7 @@ static void ZRLE_ENCODE (int x, int y, int w, int h,
}
-void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os)
+void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os)
{
/* First find the palette and the number of runs */
@@ -144,6 +172,11 @@ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os)
estimatedBytes = w * h * (BPPOUT/8); /* start assuming raw */
+#if BPP!=8
+ if (zywrle_level > 0 && !(zywrle_level & 0x80))
+ estimatedBytes >>= zywrle_level;
+#endif
+
plainRleBytes = ((BPPOUT/8)+1) * (runs + singlePixels);
if (plainRleBytes < estimatedBytes) {
@@ -253,14 +286,24 @@ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os)
/* raw */
-#ifdef CPIXEL
- PIXEL_T *ptr;
- for (ptr = data; ptr < data+w*h; ptr++) {
- zrleOutStreamWRITE_PIXEL(os, *ptr);
+#if BPP!=8
+ if (zywrle_level > 0 && !(zywrle_level & 0x80)) {
+ ZYWRLE_ANALYZE( data, data, w, h, w, zywrle_level, zywrleBuf );
+ zywrle_level |= 0x80;
+ ZRLE_ENCODE_TILE( data, w, h, os );
+ zywrle_level &= 0x7F;
}
+ else
+#endif
+ {
+#ifdef CPIXEL
+ PIXEL_T *ptr;
+ for (ptr = data; ptr < data+w*h; ptr++)
+ zrleOutStreamWRITE_PIXEL(os, *ptr);
#else
- zrleOutStreamWriteBytes(os, (zrle_U8 *)data, w*h*(BPP/8));
+ zrleOutStreamWriteBytes(os, (zrle_U8 *)data, w*h*(BPP/8));
#endif
+ }
}
}
}
@@ -269,4 +312,5 @@ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os)
#undef zrleOutStreamWRITE_PIXEL
#undef ZRLE_ENCODE
#undef ZRLE_ENCODE_TILE
+#undef ZYWRLE_ENCODE_TILE
#undef BPPOUT