Commit 059afcdf authored by dscho's avatar dscho

Add ZYWRLE server-side support (thanks Noriaki Yamazaki, Hitachi)

Signed-off-by: 's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
parent 09d902c5
...@@ -30,7 +30,8 @@ Glenn Mabutt, Paul Kreiner, Erik Kunze, Mike Frysinger, Martin Waitz, ...@@ -30,7 +30,8 @@ Glenn Mabutt, Paul Kreiner, Erik Kunze, Mike Frysinger, Martin Waitz,
Mark McLoughlin, Paul Fox, Juan Jose Costello, Andre Leiadella, Mark McLoughlin, Paul Fox, Juan Jose Costello, Andre Leiadella,
Alberto Lusiani, Malvina Mazin, Dave Stuart, Rohit Kumar, Donald Dugger, Alberto Lusiani, Malvina Mazin, Dave Stuart, Rohit Kumar, Donald Dugger,
Steven Carr, Uwe Völker, Charles Coffing, Guillaume Rousse, Steven Carr, Uwe Völker, Charles Coffing, Guillaume Rousse,
Alessandro Praduroux, Brad Hards, Timo Ketola, and Christian Ehrlicher. Alessandro Praduroux, Brad Hards, Timo Ketola, Christian Ehrlicher, and
Noriaki Yamazaki.
Probably I forgot quite a few people sending a patch here and there, which Probably I forgot quite a few people sending a patch here and there, which
really made a difference. Without those, some obscure bugs still would really made a difference. Without those, some obscure bugs still would
......
2008-01-28 Noriaki Yamazaki <micro-vnc@ias.hitachi-system.co.jp>
* rfb/rfbproto.h, libvncserver/rfbserver.c, libvncserver/scale.c,
libvncserver/zrle.c, libvncserver/zrleencodetemplate.c,
libvncserver/zywrletemplate.c: add (server-side) ZYWRLE support,
and fix a few endian/scale errors
2008-01-27 Christian Ehrlicher <Ch.Ehrlicher@gmx.de> 2008-01-27 Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
* CMakeLists, rfb/rfbconfig.h.cmake, rfb/rfbint.h.cmake: * CMakeLists, rfb/rfbconfig.h.cmake, rfb/rfbint.h.cmake:
support CMake support CMake
......
...@@ -962,6 +962,7 @@ rfbSendSupportedEncodings(rfbClientPtr cl) ...@@ -962,6 +962,7 @@ rfbSendSupportedEncodings(rfbClientPtr cl)
#endif #endif
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZRLE); rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZRLE);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZYWRLE);
#endif #endif
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltra); rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltra);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltraZip); rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltraZip);
...@@ -1908,6 +1909,7 @@ rfbProcessClientNormalMessage(rfbClientPtr cl) ...@@ -1908,6 +1909,7 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingZlib: case rfbEncodingZlib:
case rfbEncodingZRLE: case rfbEncodingZRLE:
case rfbEncodingZYWRLE:
#ifdef LIBVNCSERVER_HAVE_LIBJPEG #ifdef LIBVNCSERVER_HAVE_LIBJPEG
case rfbEncodingTight: case rfbEncodingTight:
#endif #endif
...@@ -2806,6 +2808,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -2806,6 +2808,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
#endif #endif
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingZRLE: case rfbEncodingZRLE:
case rfbEncodingZYWRLE:
if (!rfbSendRectEncodingZRLE(cl, x, y, w, h)) if (!rfbSendRectEncodingZRLE(cl, x, y, w, h))
goto updateFailed; goto updateFailed;
break; break;
......
...@@ -151,6 +151,10 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in ...@@ -151,6 +151,10 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
h1 = h0; h1 = h0;
rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, "rfbScaledScreenUpdateRect"); rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, "rfbScaledScreenUpdateRect");
x0 = ScaleX(ptr, screen, x1);
y0 = ScaleY(ptr, screen, y1);
w0 = ScaleX(ptr, screen, w1);
h0 = ScaleY(ptr, screen, h1);
bitsPerPixel = screen->bitsPerPixel; bitsPerPixel = screen->bitsPerPixel;
bytesPerPixel = bitsPerPixel / 8; bytesPerPixel = bitsPerPixel / 8;
...@@ -197,8 +201,8 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in ...@@ -197,8 +201,8 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
/* Get the totals for rgb from the source grid... */ /* Get the totals for rgb from the source grid... */
for (w = 0; w < areaX; w++) { for (w = 0; w < areaX; w++) {
for (v = 0; v < areaY; v++) { for (v = 0; v < areaY; v++) {
srcptr2 = &srcptr[(((x * areaX) + v) * bytesPerPixel) + srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) +
(w * screen->paddedWidthInBytes)]; (v * screen->paddedWidthInBytes)];
pixel_value = 0; pixel_value = 0;
......
...@@ -40,18 +40,50 @@ ...@@ -40,18 +40,50 @@
#define EXTRA_ARGS , rfbClientPtr cl #define EXTRA_ARGS , rfbClientPtr cl
#define ENDIAN_LITTLE 0
#define ENDIAN_BIG 1
#define ENDIAN_NO 2
#define BPP 8 #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> #include <zrleencodetemplate.c>
#undef BPP #undef BPP
#define BPP 16 #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> #include <zrleencodetemplate.c>
#undef BPP #undef BPP
#define BPP 32 #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> #include <zrleencodetemplate.c>
#define CPIXEL 24A #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> #include <zrleencodetemplate.c>
#undef CPIXEL #undef CPIXEL
#define CPIXEL 24B #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> #include <zrleencodetemplate.c>
#undef CPIXEL #undef CPIXEL
#undef BPP #undef BPP
...@@ -80,6 +112,20 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -80,6 +112,20 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
rfbZRLEHeader hdr; rfbZRLEHeader hdr;
int i; 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) if (!cl->zrleData)
cl->zrleData = zrleOutStreamNew(); cl->zrleData = zrleOutStreamNew();
zos = cl->zrleData; zos = cl->zrleData;
...@@ -89,11 +135,21 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -89,11 +135,21 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
zrleEncode8( x, y, w, h, zos, zrleBeforeBuf, cl); zrleEncode8NE(x, y, w, h, zos, zrleBeforeBuf, cl);
break; break;
case 16: 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; break;
case 32: { case 32: {
...@@ -107,18 +163,24 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -107,18 +163,24 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
cl->format.blueShift > 7); cl->format.blueShift > 7);
if ((fitsInLS3Bytes && !cl->format.bigEndian) || if ((fitsInLS3Bytes && !cl->format.bigEndian) ||
(fitsInMS3Bytes && cl->format.bigEndian)) (fitsInMS3Bytes && cl->format.bigEndian)) {
{ if (cl->format.bigEndian)
zrleEncode24A(x, y, w, h, zos, zrleBeforeBuf, cl); zrleEncode24ABE(x, y, w, h, zos, zrleBeforeBuf, cl);
else
zrleEncode24ALE(x, y, w, h, zos, zrleBeforeBuf, cl);
} }
else if ((fitsInLS3Bytes && cl->format.bigEndian) || else if ((fitsInLS3Bytes && cl->format.bigEndian) ||
(fitsInMS3Bytes && !cl->format.bigEndian)) (fitsInMS3Bytes && !cl->format.bigEndian)) {
{ if (cl->format.bigEndian)
zrleEncode24B(x, y, w, h, zos, zrleBeforeBuf, cl); zrleEncode24BBE(x, y, w, h, zos, zrleBeforeBuf, cl);
else
zrleEncode24BLE(x, y, w, h, zos, zrleBeforeBuf, cl);
} }
else {
if (cl->format.bigEndian)
zrleEncode32BE(x, y, w, h, zos, zrleBeforeBuf, cl);
else else
{ zrleEncode32LE(x, y, w, h, zos, zrleBeforeBuf, cl);
zrleEncode32(x, y, w, h, zos, zrleBeforeBuf, cl);
} }
} }
break; break;
...@@ -138,7 +200,7 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -138,7 +200,7 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
rect.r.y = Swap16IfLE(y); rect.r.y = Swap16IfLE(y);
rect.r.w = Swap16IfLE(w); rect.r.w = Swap16IfLE(w);
rect.r.h = Swap16IfLE(h); rect.r.h = Swap16IfLE(h);
rect.encoding = Swap32IfLE(rfbEncodingZRLE); rect.encoding = Swap32IfLE(cl->preferredEncoding);
memcpy(cl->updateBuf+cl->ublen, (char *)&rect, memcpy(cl->updateBuf+cl->ublen, (char *)&rect,
sz_rfbFramebufferUpdateRectHeader); sz_rfbFramebufferUpdateRectHeader);
......
...@@ -43,17 +43,37 @@ ...@@ -43,17 +43,37 @@
#define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b)
#endif #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 #ifdef CPIXEL
#define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP) #define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP)
#define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,CPIXEL) #define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,CPIXEL)
#define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,CPIXEL) #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,CPIXEL,END_FIX)
#define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,CPIXEL) #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,CPIXEL,END_FIX)
#define BPPOUT 24 #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 #else
#define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP) #define PIXEL_T __RFB_CONCAT2E(zrle_U,BPP)
#define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,BPP) #define zrleOutStreamWRITE_PIXEL __RFB_CONCAT2E(zrleOutStreamWriteOpaque,BPP)
#define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,BPP) #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX)
#define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,BPP) #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX)
#define BPPOUT BPP #define BPPOUT BPP
#endif #endif
...@@ -64,12 +84,20 @@ static const int bitsPerPackedPixel[] = { ...@@ -64,12 +84,20 @@ static const int bitsPerPackedPixel[] = {
0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 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; static zrlePaletteHelper paletteHelper;
#endif /* ZRLE_ONCE */ #endif /* ZRLE_ONCE */
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);
#if BPP!=8
#define ZYWRLE_ENCODE
#include "zywrletemplate.c"
#endif
static void ZRLE_ENCODE (int x, int y, int w, int h, static void ZRLE_ENCODE (int x, int y, int w, int h,
zrleOutStream* os, void* buf zrleOutStream* os, void* buf
EXTRA_ARGS EXTRA_ARGS
...@@ -92,7 +120,7 @@ static void ZRLE_ENCODE (int x, int y, int w, int h, ...@@ -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 */ /* 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) ...@@ -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 */ 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); plainRleBytes = ((BPPOUT/8)+1) * (runs + singlePixels);
if (plainRleBytes < estimatedBytes) { if (plainRleBytes < estimatedBytes) {
...@@ -253,20 +286,31 @@ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os) ...@@ -253,20 +286,31 @@ void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os)
/* raw */ /* raw */
#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 #ifdef CPIXEL
PIXEL_T *ptr; PIXEL_T *ptr;
for (ptr = data; ptr < data+w*h; ptr++) { for (ptr = data; ptr < data+w*h; ptr++)
zrleOutStreamWRITE_PIXEL(os, *ptr); zrleOutStreamWRITE_PIXEL(os, *ptr);
}
#else #else
zrleOutStreamWriteBytes(os, (zrle_U8 *)data, w*h*(BPP/8)); zrleOutStreamWriteBytes(os, (zrle_U8 *)data, w*h*(BPP/8));
#endif #endif
} }
} }
}
} }
#undef PIXEL_T #undef PIXEL_T
#undef zrleOutStreamWRITE_PIXEL #undef zrleOutStreamWRITE_PIXEL
#undef ZRLE_ENCODE #undef ZRLE_ENCODE
#undef ZRLE_ENCODE_TILE #undef ZRLE_ENCODE_TILE
#undef ZYWRLE_ENCODE_TILE
#undef BPPOUT #undef BPPOUT
This diff is collapsed.
...@@ -403,6 +403,7 @@ typedef struct { ...@@ -403,6 +403,7 @@ typedef struct {
#define rfbEncodingZlibHex 8 #define rfbEncodingZlibHex 8
#define rfbEncodingUltra 9 #define rfbEncodingUltra 9
#define rfbEncodingZRLE 16 #define rfbEncodingZRLE 16
#define rfbEncodingZYWRLE 17
/* Cache & XOR-Zlib - rdv@2002 */ /* Cache & XOR-Zlib - rdv@2002 */
#define rfbEncodingCache 0xFFFF0000 #define rfbEncodingCache 0xFFFF0000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment