]> source.dussan.org Git - tigervnc.git/commitdiff
Improved error handling: if JpegCompressor could not compress the data,
authorConstantin Kaplinsky <const@tightvnc.com>
Thu, 5 Jun 2008 03:05:13 +0000 (03:05 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Thu, 5 Jun 2008 03:05:13 +0000 (03:05 +0000)
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

common/rfb/JpegEncoder.cxx

index f3dbdeede4221757ec7e7fec5929685fe6ef328c..4542da413500d421ecfa2b7441705e0c73aa57f4 100644 (file)
@@ -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());