Further optimizations to the Tight encoder to eliminate getImage() overhead. The encoder now directly accesses the framebuffer for solid rectangle computation, JPEG encoding, and color counting (if pixel translation is not required.) Also moved everything in tightEncode.h into the TightEncoder class to eliminate all of the static mess (this will be important later on if we decide to multi-thread the encoder.)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4631 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx
index e203560..a55fee7 100644
--- a/common/rfb/JpegCompressor.cxx
+++ b/common/rfb/JpegCompressor.cxx
@@ -114,7 +114,7 @@
jpeg_destroy_compress(&cinfo);
}
-void JpegCompressor::compress(rdr::U8 *buf, const Rect& r,
+void JpegCompressor::compress(rdr::U8 *buf, int pitch, const Rect& r,
const PixelFormat& pf, int quality, JPEG_SUBSAMP subsamp)
{
int w = r.width();
@@ -168,10 +168,13 @@
}
#endif
+ if (pitch == 0) pitch = w * pixelsize;
+
if (cinfo.in_color_space == JCS_RGB) {
srcBuf = new rdr::U8[w * h * pixelsize];
srcBufIsTemp = true;
- pf.rgbFromBuffer(srcBuf, (const rdr::U8 *)buf, w * h);
+ pf.rgbFromBuffer(srcBuf, (const rdr::U8 *)buf, w, pitch, h);
+ pitch = w * pixelsize;
}
cinfo.input_components = pixelsize;
@@ -197,7 +200,7 @@
rowPointer = new JSAMPROW[h];
for (int dy = 0; dy < h; dy++)
- rowPointer[dy] = (JSAMPROW)(&srcBuf[dy * w * pixelsize]);
+ rowPointer[dy] = (JSAMPROW)(&srcBuf[dy * pitch]);
jpeg_start_compress(&cinfo, TRUE);
while (cinfo.next_scanline < cinfo.image_height)