aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2011-08-09 20:19:59 +0000
committerDRC <dcommander@users.sourceforge.net>2011-08-09 20:19:59 +0000
commitff5ca2da00762c4d4004500d45aa44dfcc5fffce (patch)
treedcd2903128da4e30324bf95eaeb82c0871715c67 /common/rfb
parentf4a341bc85c931e24e27a088f27f19f574b0c455 (diff)
downloadtigervnc-ff5ca2da00762c4d4004500d45aa44dfcc5fffce.tar.gz
tigervnc-ff5ca2da00762c4d4004500d45aa44dfcc5fffce.zip
Merge further fixes to Zlib encoder from 1.1 branch
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4623 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb')
-rw-r--r--common/rfb/tightEncode.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h
index 9877759a..28d6dc2b 100644
--- a/common/rfb/tightEncode.h
+++ b/common/rfb/tightEncode.h
@@ -182,20 +182,22 @@ static int paletteInsert(rdr::U32 rgb, int numPixels, int bpp)
//
static void compressData(rdr::OutStream *os, rdr::ZlibOutStream *zos,
- const void *buf, unsigned int length, int zlibLevel)
+ const void *buf, const PixelFormat& pf,
+ unsigned int length, int zlibLevel)
{
if (length < TIGHT_MIN_TO_COMPRESS) {
os->writeBytes(buf, length);
} else {
// FIXME: Using a temporary MemOutStream may be not efficient.
// Maybe use the same static object used in the JPEG coder?
- int maxBeforeSize = s_pconf->maxRectSize * (BPP / 8);
+ int maxBeforeSize = s_pconf->maxRectSize * (pf.bpp / 8);
int maxAfterSize = maxBeforeSize + (maxBeforeSize + 99) / 100 + 12;
rdr::MemOutStream mem_os(maxAfterSize);
zos->setUnderlying(&mem_os);
zos->setCompressionLevel(zlibLevel);
zos->writeBytes(buf, length);
zos->flush();
+ zos->setUnderlying(NULL);
os->writeCompactLength(mem_os.length());
os->writeBytes(mem_os.data(), mem_os.length());
}
@@ -393,7 +395,7 @@ static void ENCODE_FULLCOLOR_RECT (rdr::OutStream *os, rdr::ZlibOutStream zos[4]
os->writeU8(streamId << 4);
int length = PACK_PIXELS(buf, r.area(), pf);
- compressData(os, &zos[streamId], buf, length, s_pconf->rawZlibLevel);
+ compressData(os, &zos[streamId], buf, pf, length, s_pconf->rawZlibLevel);
}
static void ENCODE_MONO_RECT (rdr::OutStream *os, rdr::ZlibOutStream zos[4],
@@ -459,7 +461,7 @@ static void ENCODE_MONO_RECT (rdr::OutStream *os, rdr::ZlibOutStream zos[4],
// Write the data
int length = (w + 7) / 8;
length *= h;
- compressData(os, &zos[streamId], buf, length, s_pconf->monoZlibLevel);
+ compressData(os, &zos[streamId], buf, pf, length, s_pconf->monoZlibLevel);
}
#if (BPP != 8)
@@ -507,7 +509,7 @@ static void ENCODE_INDEXED_RECT (rdr::OutStream *os, rdr::ZlibOutStream zos[4],
}
// Write the data
- compressData(os, &zos[streamId], buf, r.area(), s_pconf->idxZlibLevel);
+ compressData(os, &zos[streamId], buf, pf, r.area(), s_pconf->idxZlibLevel);
}
#endif // #if (BPP != 8)