From 33a0c8174c67ed728fbb8822921e56ff855ccf1a Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Sun, 31 Oct 2010 20:10:21 +0100 Subject: [PATCH] Fixed a bug where RT would crash sometimes after writing output file in batch queue. Plus small improvements to JPG thumbnails. Some little cleanups. --- rtengine/rtthumbnail.cc | 11 ++++++++++- rtgui/batchqueue.cc | 10 ++++++---- rtgui/cachemanager.cc | 10 ++-------- rtgui/thumbnail.cc | 6 ------ rtgui/thumbnail.h | 2 -- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 43f64539c..d91705227 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -336,7 +336,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei baseImg->b[i][j] = CLIP(val); } - // appy highlight recovery, if needed + // apply highlight recovery, if needed if (isRaw && params.hlrecovery.enabled) { int maxval = 65535 / defGain; if (params.hlrecovery.method=="Luminance" || params.hlrecovery.method=="Color") @@ -623,6 +623,7 @@ void Thumbnail::transformPixel (int x, int y, int tran, int& tx, int& ty) { ty/=scale; } +// format: 1=8bit direct, 2=16bit direct, 3=JPG bool Thumbnail::writeImage (const Glib::ustring& fname, int format) { if (!thumbImg) @@ -689,6 +690,14 @@ bool Thumbnail::writeImage (const Glib::ustring& fname, int format) { cinfo.input_components = 3; jpeg_set_defaults (&cinfo); cinfo.write_JFIF_header = FALSE; + + // compute optimal Huffman coding tables for the image. Bit slower to generate, but size of result image is a bit less (default was FALSE) + cinfo.optimize_coding = TRUE; + + // Since math coprocessors are common these days, FLOAT should be a bit more accurate AND fast (default is ISLOW) + // (machine dependency is not really an issue, since we all run on x86 and having exactly the same file is not a requirement) + cinfo.dct_method = JDCT_FLOAT; + jpeg_set_quality (&cinfo, 85, true); jpeg_start_compress(&cinfo, TRUE); int rowlen = thumbImg->width*3; diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index d6cd5ab32..4146ca78d 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -195,7 +195,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) { fname = autoCompleteFileName (removeExtension(processing->outFileName), getExtension(processing->outFileName)); saveFormat = processing->saveFormat; } - printf ("fname=%s, %s\n", fname.c_str(), removeExtension(fname).c_str()); + //printf ("fname=%s, %s\n", fname.c_str(), removeExtension(fname).c_str()); if (img && fname!="") { int err = 0; if (saveFormat.format=="tif") @@ -205,14 +205,16 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) { else if (saveFormat.format=="jpg") err = img->saveAsJPEG (fname, saveFormat.jpegQuality); img->free (); - if (!err && saveFormat.saveParams) + + if (err) throw "Unable to save output file"; + + if (saveFormat.saveParams) { // We keep the extension to avoid overwriting the profile when we have // the same output filename with different extension //processing->params.save (removeExtension(fname) + paramFileExtension); processing->params.save (fname + paramFileExtension); - else { - printf("Unable to process or save %s\n", fname.c_str()); } + if (processing->thumbnail) { processing->thumbnail->imageDeveloped (); processing->thumbnail->imageRemovedFromQueue (); diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index f44fcb165..34c01a2fa 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -98,9 +98,9 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname) { } delete cfs; } - // if not, create a new one - if (!res) { + // if not, create a new one + if (!res) { res = new Thumbnail (this, fname, md5); if (!res->isSupported ()) { delete res; @@ -241,15 +241,9 @@ void CacheManager::clearThumbImages () { deleteDir ("images"); deleteDir ("aehistograms"); deleteDir ("embprofiles"); - - // re-generate thumbnail images of open thumbnails - //string_thumb_map::iterator i; - //for (i=openEntries.begin(); i!=openEntries.end(); i++) - // i->second->generateThumbnailImage (); } void CacheManager::clearProfiles () { - Glib::Mutex::Lock lock(mutex_); deleteDir ("profiles"); diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 0ffe641de..95b6f5470 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -131,13 +131,7 @@ void Thumbnail::_generateThumbnailImage () { generateExifDateTimeStrings (); } -void Thumbnail::generateThumbnailImage () { - Glib::Mutex::Lock lock(mutex); - _generateThumbnailImage(); -} - bool Thumbnail::isSupported () { - return cfs.supported; } diff --git a/rtgui/thumbnail.h b/rtgui/thumbnail.h index 0373f4f3d..ac75236d4 100644 --- a/rtgui/thumbnail.h +++ b/rtgui/thumbnail.h @@ -98,8 +98,6 @@ class Thumbnail { void getThumbnailSize (int &w, int &h); void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) { if (tpp) tpp->getFinalSize (pparams, w, h); } - void generateThumbnailImage (); - const Glib::ustring& getExifString (); const Glib::ustring& getDateTimeString (); void getCamWB (double& temp, double& green) { if (tpp) tpp->getCamWB (temp, green); }