Ported encoding optimizations from TurboVNC. The changes to the Tight parameters were determined through extensive low-level profiling (see http://www.virtualgl.org/pmwiki/uploads/About/turbototiger.pdf). The other enhancements involved: (1) porting the solid subrectangle pre-computation code from TightVNC/TurboVNC (it makes a pretty big difference-- see report), (2) encapsulating the JPEG encoder in its own class (this eliminates a buffer copy, and the JPEG buffer is now set to a decent size where it shouldn't ever need to be paged or re-allocated, except in rare corner cases), (3) adding support for last rect. encoding (necessary to support the solid rectangle pre-computation enhancements.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4626 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h
index a36340f..064a834 100644
--- a/common/rfb/TightEncoder.h
+++ b/common/rfb/TightEncoder.h
@@ -1,4 +1,5 @@
/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
+ * Copyright (C) 2011 D. R. Commander
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +21,7 @@
#include <rdr/MemOutStream.h>
#include <rdr/ZlibOutStream.h>
+#include <rfb/JpegCompressor.h>
#include <rfb/Encoder.h>
// FIXME: Check if specifying extern "C" is really necessary.
@@ -30,19 +32,14 @@
namespace rfb {
- enum subsampEnum {
- SUBSAMP_NONE,
- SUBSAMP_422,
- SUBSAMP_420
- };
-
struct TIGHT_CONF {
unsigned int maxRectSize, maxRectWidth;
unsigned int monoMinRectSize;
int idxZlibLevel, monoZlibLevel, rawZlibLevel;
int idxMaxColorsDivisor;
+ int palMaxColorsWithJPEG;
int jpegQuality;
- subsampEnum jpegSubSample;
+ JPEG_SUBSAMP jpegSubSample;
};
//
@@ -67,11 +64,19 @@
private:
TightEncoder(SMsgWriter* writer);
- void writeSubrect(const Rect& r, ImageGetter* ig);
+ bool checkSolidTile(Rect& r, ImageGetter *ig, rdr::U32* colorPtr,
+ bool needSameColor);
+ void extendSolidArea(const Rect& r, ImageGetter *ig,
+ rdr::U32 colorValue, Rect& er);
+ void findBestSolidArea(Rect& r, ImageGetter* ig, rdr::U32 colorValue,
+ Rect& bestr);
+ void sendRectSimple(const Rect& r, ImageGetter* ig);
+ void writeSubrect(const Rect& r, ImageGetter* ig, bool forceSolid = false);
SMsgWriter* writer;
rdr::MemOutStream mos;
rdr::ZlibOutStream zos[4];
+ JpegCompressor jc;
static const int defaultCompressLevel;
static const TIGHT_CONF conf[];