From ca519532cecf64c690bb3ececd875ca6f7f4b2b2 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 21 Mar 2014 12:38:59 +0100 Subject: [PATCH] Support keeping libjpeg's default compression setting --- common/rfb/JpegCompressor.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx index b3c5f7c4..47f09d81 100644 --- a/common/rfb/JpegCompressor.cxx +++ b/common/rfb/JpegCompressor.cxx @@ -207,9 +207,14 @@ void JpegCompressor::compress(const rdr::U8 *buf, int pitch, const Rect& r, cinfo->input_components = pixelsize; jpeg_set_defaults(cinfo); - jpeg_set_quality(cinfo, quality, TRUE); - if(quality >= 96) cinfo->dct_method = JDCT_ISLOW; - else cinfo->dct_method = JDCT_FASTEST; + + if (quality >= 1 && quality <= 100) { + jpeg_set_quality(cinfo, quality, TRUE); + if (quality >= 96) + cinfo->dct_method = JDCT_ISLOW; + else + cinfo->dct_method = JDCT_FASTEST; + } switch (subsamp) { case SUBSAMP_420: -- 2.39.5