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,
Mark McLoughlin, Paul Fox, Juan Jose Costello, Andre Leiadella,
Alberto Lusiani, Malvina Mazin, Dave Stuart, Rohit Kumar, Donald Dugger,
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
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>
* CMakeLists, rfb/rfbconfig.h.cmake, rfb/rfbint.h.cmake:
support CMake
......
......@@ -962,6 +962,7 @@ rfbSendSupportedEncodings(rfbClientPtr cl)
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZRLE);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingZYWRLE);
#endif
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltra);
rfbSendSupporteddEncodings_SendEncoding(cl, rfbEncodingUltraZip);
......@@ -1908,6 +1909,7 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
#ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingZlib:
case rfbEncodingZRLE:
case rfbEncodingZYWRLE:
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
case rfbEncodingTight:
#endif
......@@ -2806,6 +2808,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingZRLE:
case rfbEncodingZYWRLE:
if (!rfbSendRectEncodingZRLE(cl, x, y, w, h))
goto updateFailed;
break;
......
......@@ -151,6 +151,10 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
h1 = h0;
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;
bytesPerPixel = bitsPerPixel / 8;
......@@ -197,8 +201,8 @@ void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, in
/* Get the totals for rgb from the source grid... */
for (w = 0; w < areaX; w++) {
for (v = 0; v < areaY; v++) {
srcptr2 = &srcptr[(((x * areaX) + v) * bytesPerPixel) +
(w * screen->paddedWidthInBytes)];
srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) +
(v * screen->paddedWidthInBytes)];
pixel_value = 0;
......
......@@ -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);
......
......@@ -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
This diff is collapsed.
......@@ -403,6 +403,7 @@ typedef struct {
#define rfbEncodingZlibHex 8
#define rfbEncodingUltra 9
#define rfbEncodingZRLE 16
#define rfbEncodingZYWRLE 17
/* Cache & XOR-Zlib - rdv@2002 */
#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