aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2008-06-05 03:05:13 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2008-06-05 03:05:13 +0000
commit67ebf00acc436b3bd8bcd9615d8b8610b91b0f09 (patch)
tree91987a452bc63fa924f7485b7f32cebc40b97124 /common
parent93d40aa83bc03e78eb39e8477b6b4d791708ec60 (diff)
downloadtigervnc-67ebf00acc436b3bd8bcd9615d8b8610b91b0f09.tar.gz
tigervnc-67ebf00acc436b3bd8bcd9615d8b8610b91b0f09.zip
Improved error handling: if JpegCompressor could not compress the data,
switch to StandardJpegCompressor and try to compress once again. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2580 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r--common/rfb/JpegEncoder.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/rfb/JpegEncoder.cxx b/common/rfb/JpegEncoder.cxx
index f3dbdeed..4542da41 100644
--- a/common/rfb/JpegEncoder.cxx
+++ b/common/rfb/JpegEncoder.cxx
@@ -133,9 +133,17 @@ void JpegEncoder::writeRect(PixelBuffer* pb, const Rect& r)
const rdr::U32* pixels = (const rdr::U32 *)pb->getPixelsR(r, &stride);
const PixelFormat& fmt = pb->getPF();
- // Encode data
+ // Try to encode data
jcomp->compress(pixels, &fmt, r.width(), r.height(), stride);
+ // If not successful, switch to StandardJpegCompressor
+ if (jcomp->getDataLength() == 0) {
+ vlog.info("switching to standard software JPEG compressor");
+ delete jcomp;
+ jcomp = new StandardJpegCompressor;
+ jcomp->setQuality(qualityMap[6]);
+ }
+
// Write Tight-encoded header and JPEG data.
os->writeU8(0x09 << 4);
os->writeCompactLength(jcomp->getDataLength());