From c6a445f2ae95c96608705b40a7c15f95d56e1ebf Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 11 Mar 2009 16:15:29 +0000 Subject: [PATCH] Tweak the quality to JPEG settings mapping a bit. The percieved quality isn't really linear compared to the actual quality setting, so make it a bit more top heavy. Also disable color subsampling at some levels and make the highest quality lossless. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3660 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/TightEncoder.cxx | 20 ++++++++++---------- common/rfb/TightEncoder.h | 2 +- common/rfb/tightEncode.h | 7 +++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx index e89a5609..159ebbfb 100644 --- a/common/rfb/TightEncoder.cxx +++ b/common/rfb/TightEncoder.cxx @@ -45,16 +45,16 @@ using namespace rfb; // const TIGHT_CONF TightEncoder::conf[10] = { - { 512, 32, 6, 0, 0, 0, 4, 5 }, - { 2048, 64, 6, 1, 1, 1, 8, 10 }, - { 4096, 128, 8, 3, 3, 2, 24, 15 }, - { 8192, 256, 12, 5, 5, 2, 32, 25 }, - { 16384, 512, 12, 6, 7, 3, 32, 37 }, - { 32768, 512, 12, 7, 8, 4, 32, 50 }, - { 65536, 1024, 16, 7, 8, 5, 32, 60 }, - { 65536, 1024, 16, 8, 9, 6, 64, 70 }, - { 65536, 2048, 24, 9, 9, 7, 64, 75 }, - { 65536, 2048, 32, 9, 9, 9, 96, 80 } + { 512, 32, 6, 0, 0, 0, 4, 10, 1 }, // 0 + { 2048, 64, 6, 1, 1, 1, 8, 25, 1 }, // 1 + { 4096, 128, 8, 3, 3, 2, 24, 25, 0 }, // 2 + { 8192, 256, 12, 5, 5, 2, 32, 50, 1 }, // 3 + { 16384, 512, 12, 6, 7, 3, 32, 50, 0 }, // 4 + { 32768, 512, 12, 7, 8, 4, 32, 75, 1 }, // 5 + { 65536, 1024, 16, 7, 8, 5, 32, 75, 0 }, // 6 + { 65536, 1024, 16, 8, 9, 6, 64, 83, 0 }, // 7 + { 65536, 2048, 24, 9, 9, 7, 64, 92, 0 }, // 8 + { 65536, 2048, 32, 9, 9, 9, 96,100, 0 } // 9 }; const int TightEncoder::defaultCompressLevel = 6; diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h index 97731350..35f2f599 100644 --- a/common/rfb/TightEncoder.h +++ b/common/rfb/TightEncoder.h @@ -35,7 +35,7 @@ namespace rfb { unsigned int monoMinRectSize; int idxZlibLevel, monoZlibLevel, rawZlibLevel; int idxMaxColorsDivisor; - int jpegQuality; + int jpegQuality, jpegSubSample; }; // diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index cdcb141b..f2192bba 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -537,6 +537,13 @@ static void ENCODE_JPEG_RECT (rdr::OutStream *os, PIXEL_T *buf, jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, s_pjconf->jpegQuality, TRUE); + if (s_pjconf->jpegSubSample) { + cinfo.comp_info[0].h_samp_factor = 2; + cinfo.comp_info[0].v_samp_factor = 2; + } else { + cinfo.comp_info[0].h_samp_factor = 1; + cinfo.comp_info[0].v_samp_factor = 1; + } rdr::U8 *dstBuf = new rdr::U8[2048]; JpegSetDstManager(&cinfo, dstBuf, 2048); -- 2.39.5