From e1716b8507209da541e1e05e030bbe9afb8b105e Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 18 Feb 2011 03:19:43 +0000 Subject: [PATCH] The fast integer DCT degrades for qualities > 95, so use the slow integer DCT instead to ensure that perceptually lossless performance is maintained. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@381 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 8 +++++++- turbojpegl.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d82b0f60..a1ad2e4d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,7 +3,13 @@ [1] Added further protections against invalid Huffman codes. -[2] Fixed visual artifacts in grayscale JPEG compression caused by a typo in +[2] Since the fast integer forward DCT seems to degrade for JPEG qualities +greater than 95, TurboJPEG/OSS will now automatically use the slow integer +forward DCT when generating JPEG images of quality 96 or greater. This +reduces compression performance by as much as 15% for these high-quality images +but is necessary to ensure that the images are perceptually lossless. + +[3] Fixed visual artifacts in grayscale JPEG compression caused by a typo in the RGB-to-chrominance lookup tables. diff --git a/turbojpegl.c b/turbojpegl.c index 2150a2d3..eeaedd17 100644 --- a/turbojpegl.c +++ b/turbojpegl.c @@ -166,7 +166,8 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h, jpeg_set_colorspace(&j->cinfo, JCS_GRAYSCALE); else jpeg_set_colorspace(&j->cinfo, JCS_YCbCr); - j->cinfo.dct_method = JDCT_FASTEST; + if(qual>=96) j->cinfo.dct_method=JDCT_ISLOW; + else j->cinfo.dct_method=JDCT_FASTEST; j->cinfo.comp_info[0].h_samp_factor=hsampfactor[jpegsub]; j->cinfo.comp_info[1].h_samp_factor=1;