Push encoding specific formats into the encoders and decoders
Keep the generic stream classes clean and general.
diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx
index 622dc3d..b94b53e 100644
--- a/common/rfb/TightEncoder.cxx
+++ b/common/rfb/TightEncoder.cxx
@@ -410,3 +410,21 @@
os->writeBytes(mos.data(), mos.length());
writer->endRect();
}
+
+void TightEncoder::writeCompact(rdr::OutStream* os, rdr::U32 value)
+{
+ rdr::U8 b;
+ b = value & 0x7F;
+ if (value <= 0x7F) {
+ os->writeU8(b);
+ } else {
+ os->writeU8(b | 0x80);
+ b = value >> 7 & 0x7F;
+ if (value <= 0x3FFF) {
+ os->writeU8(b);
+ } else {
+ os->writeU8(b | 0x80);
+ os->writeU8(value >> 14 & 0xFF);
+ }
+ }
+}