From 21b5c4bc4dc596b20065a74d39ee4ac53519a9b4 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 25 Jan 2011 06:52:31 +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. --- ChangeLog.txt | 10 ++++++++++ turbojpegl.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index f8b391a7..11c9a77d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,13 @@ +Significant changes since 1.0.90 +================================ + +[1] 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. + + Significant changes since 1.0.1 =============================== diff --git a/turbojpegl.c b/turbojpegl.c index 9dd6eb66..58f96273 100644 --- a/turbojpegl.c +++ b/turbojpegl.c @@ -193,7 +193,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;