summaryrefslogtreecommitdiffstats
path: root/libvncserver/zrleencodetemplate.c
diff options
context:
space:
mode:
authordscho <dscho>2008-01-30 20:38:51 +0000
committerdscho <dscho>2008-01-30 20:38:51 +0000
commitce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2 (patch)
treec3c6200b7442bab417b05ae90bdf08037c98dc83 /libvncserver/zrleencodetemplate.c
parent5b9b4543616db4cefc5eb052287a32f03fdd8e85 (diff)
downloadlibtdevnc-ce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2.tar.gz
libtdevnc-ce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2.zip
Make ZYWRLE thread-safe for multiple clients
ZYWRLE used a static buffer, which does not work too well if you have more than one client in a threaded server. Instead, we have the data in the client structure now. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'libvncserver/zrleencodetemplate.c')
-rw-r--r--libvncserver/zrleencodetemplate.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libvncserver/zrleencodetemplate.c b/libvncserver/zrleencodetemplate.c
index 7d19766..6e81b3c 100644
--- a/libvncserver/zrleencodetemplate.c
+++ b/libvncserver/zrleencodetemplate.c
@@ -84,14 +84,12 @@ 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);
+void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os,
+ int zywrle_level, int *zywrleBuf);
#if BPP!=8
#define ZYWRLE_ENCODE
@@ -113,14 +111,16 @@ static void ZRLE_ENCODE (int x, int y, int w, int h,
GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf);
- ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os);
+ ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os,
+ cl->zywrleLevel, cl->zywrleBuf);
}
}
zrleOutStreamFlush(os);
}
-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,
+ int zywrle_level, int *zywrleBuf)
{
/* First find the palette and the number of runs */
@@ -288,10 +288,8 @@ void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os)
#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;
+ ZYWRLE_ANALYZE(data, data, w, h, w, zywrle_level, zywrleBuf);
+ ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf);
}
else
#endif