From 93296cff17d93b14b033ee63164a68eb72632bbd Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Wed, 8 Mar 2017 00:50:50 +0100 Subject: [PATCH] continuing with my experiments on an alternative "fast export" --- rtengine/processingjob.cc | 8 ++++---- rtengine/processingjob.h | 9 ++++---- rtengine/rtengine.h | 4 ++-- rtengine/simpleprocess.cc | 43 +++++++++++++++++++-------------------- rtgui/batchqueue.cc | 9 ++++++-- rtgui/filebrowser.cc | 6 +++++- rtgui/filecatalog.cc | 4 ++-- rtgui/main.cc | 8 +++++++- 8 files changed, 53 insertions(+), 38 deletions(-) diff --git a/rtengine/processingjob.cc b/rtengine/processingjob.cc index 612edc2a2..a377e3963 100644 --- a/rtengine/processingjob.cc +++ b/rtengine/processingjob.cc @@ -21,16 +21,16 @@ namespace rtengine { -ProcessingJob* ProcessingJob::create (const Glib::ustring& fname, bool isRaw, const procparams::ProcParams& pparams) +ProcessingJob* ProcessingJob::create (const Glib::ustring& fname, bool isRaw, const procparams::ProcParams& pparams, bool fast) { - return new ProcessingJobImpl (fname, isRaw, pparams); + return new ProcessingJobImpl (fname, isRaw, pparams, fast); } -ProcessingJob* ProcessingJob::create (InitialImage* initialImage, const procparams::ProcParams& pparams) +ProcessingJob* ProcessingJob::create (InitialImage* initialImage, const procparams::ProcParams& pparams, bool fast) { - return new ProcessingJobImpl (initialImage, pparams); + return new ProcessingJobImpl (initialImage, pparams, fast); } void ProcessingJob::destroy (ProcessingJob* job) diff --git a/rtengine/processingjob.h b/rtengine/processingjob.h index 2de426a31..fd3fe82a8 100644 --- a/rtengine/processingjob.h +++ b/rtengine/processingjob.h @@ -32,12 +32,13 @@ public: bool isRaw; InitialImage* initialImage; procparams::ProcParams pparams; + bool fast; - ProcessingJobImpl (const Glib::ustring& fn, bool iR, const procparams::ProcParams& pp) - : fname(fn), isRaw(iR), initialImage(nullptr), pparams(pp) {} + ProcessingJobImpl (const Glib::ustring& fn, bool iR, const procparams::ProcParams& pp, bool ff) + : fname(fn), isRaw(iR), initialImage(nullptr), pparams(pp), fast(ff) {} - ProcessingJobImpl (InitialImage* iImage, const procparams::ProcParams& pp) - : fname(""), isRaw(true), initialImage(iImage), pparams(pp) + ProcessingJobImpl (InitialImage* iImage, const procparams::ProcParams& pp, bool ff) + : fname(""), isRaw(true), initialImage(iImage), pparams(pp), fast(ff) { iImage->increaseRef(); } diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index fc793dd71..4cb672e15 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -468,7 +468,7 @@ public: * @param isRaw shall be true if it is a raw file * @param pparams is a struct containing the processing parameters * @return an object containing the data above. It can be passed to the functions that do the actual image processing. */ - static ProcessingJob* create (const Glib::ustring& fname, bool isRaw, const procparams::ProcParams& pparams); + static ProcessingJob* create (const Glib::ustring& fname, bool isRaw, const procparams::ProcParams& pparams, bool fast=false); /** Creates a processing job from a file name. This function always succeeds. It only stores the data into the ProcessingJob class, it does not load * the image thus it returns immediately. This function increases the reference count of the initialImage. If you decide not the process the image you @@ -477,7 +477,7 @@ public: * @param initialImage is a loaded and pre-processed initial image * @param pparams is a struct containing the processing parameters * @return an object containing the data above. It can be passed to the functions that do the actual image processing. */ - static ProcessingJob* create (InitialImage* initialImage, const procparams::ProcParams& pparams); + static ProcessingJob* create (InitialImage* initialImage, const procparams::ProcParams& pparams, bool fast=false); /** Cancels and destroys a processing job. The reference count of the corresponding initialImage (if any) is decreased. After the call of this function the ProcessingJob instance * gets invalid, you must not use it any more. Dont call this function while the job is being processed. diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index e027968a5..677f912fc 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -41,7 +41,7 @@ class ImageProcessor { public: ImageProcessor(ProcessingJob* pjob, int& errorCode, ProgressListener* pl, bool tunnelMetaData, bool flush): - pjob(pjob), + job(static_cast(pjob)), errorCode(errorCode), pl(pl), tunnelMetaData(tunnelMetaData), @@ -55,9 +55,9 @@ public: { } - Image16 *operator()(bool fast) + Image16 *operator()() { - if (!fast) { + if (!job->fast) { return normal_pipeline(); } else { return fast_pipeline(); @@ -81,21 +81,28 @@ private: Image16 *fast_pipeline() { - ProcessingJobImpl* job = static_cast(pjob); if (!job->pparams.resize.enabled) { return normal_pipeline(); } + + pl = nullptr; if (!stage_1()) { return nullptr; } + stage_calc_denoise(); + printf("after calc denoise\n"); fflush(stdout); stage_2(); stage_4(); + printf("after 4\n"); fflush(stdout); stage_early_resize(); - stage_calc_denoise(); + printf("after early resize\n"); fflush(stdout); stage_3(); + printf("after 3\n"); fflush(stdout); stage_5(); + printf("after 5\n"); fflush(stdout); stage_6(); + printf("after 6\n"); fflush(stdout); return stage_7(); } @@ -103,8 +110,6 @@ private: { errorCode = 0; - ProcessingJobImpl* job = static_cast(pjob); - if (pl) { pl->setProgressStr ("PROGRESSBAR_PROCESSING"); pl->setProgress (0.0); @@ -235,7 +240,6 @@ private: void stage_calc_denoise() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -714,7 +718,6 @@ private: void stage_2() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -753,7 +756,6 @@ private: void stage_3() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -826,7 +828,6 @@ private: void stage_4() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -849,7 +850,6 @@ private: void stage_5() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -994,7 +994,6 @@ private: void stage_6() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -1192,7 +1191,6 @@ private: Image16 *stage_7() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -1389,7 +1387,6 @@ private: void stage_early_resize() { - ProcessingJobImpl* job = static_cast(pjob); procparams::ProcParams& params = job->pparams; ImProcFunctions ipf (¶ms, true); @@ -1435,14 +1432,16 @@ private: tmplab = resized; params.resize.enabled = false; - if (params.prsharpening.enabled) { - params.sharpening = params.prsharpening; - } - + params.sharpening = params.prsharpening; params.wavelet.strength = int(float(params.wavelet.strength) * tmpScale); params.dirpyrDenoise.luma *= tmpScale; - // params.dirpyrDenoise.smethod = "shal"; + params.dirpyrDenoise.smethod = "shal"; + + for (int i = 0; i < 6; ++i) { + auto &n = params.dirpyrequalizer.mult[i]; + n = 1.0 + (n - 1.0) * tmpScale; + } fw = imw; fh = imh; @@ -1455,7 +1454,7 @@ private: } private: - ProcessingJob* pjob; + ProcessingJobImpl* job; int& errorCode; ProgressListener* pl; bool tunnelMetaData; @@ -1534,7 +1533,7 @@ private: IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* pl, bool tunnelMetaData, bool flush) { ImageProcessor proc(pjob, errorCode, pl, tunnelMetaData, flush); - return proc(true); + return proc(); } void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl, bool tunnelMetaData) diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 7bd53c444..1f2dac51d 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -34,6 +34,9 @@ #include "guiutils.h" #include "rtimage.h" #include + +#include "../rtengine/processingjob.h" + using namespace std; using namespace rtengine; @@ -227,7 +230,7 @@ bool BatchQueue::saveBatchQueue () // The column's header is mandatory (the first line will be skipped when loaded) file << "input image full path|param file full path|output image full path|file format|jpeg quality|jpeg subsampling|" - << "png bit depth|png compression|tiff bit depth|uncompressed tiff|save output params|force format options|" + << "png bit depth|png compression|tiff bit depth|uncompressed tiff|save output params|force format options|fast export|" << std::endl; // method is already running with entryLock, so no need to lock again @@ -242,6 +245,7 @@ bool BatchQueue::saveBatchQueue () << saveFormat.pngBits << '|' << saveFormat.pngCompression << '|' << saveFormat.tiffBits << '|' << saveFormat.tiffUncompressed << '|' << saveFormat.saveParams << '|' << entry->forceFormatOpts << '|' + << static_cast(entry->job)->fast << '|' << std::endl; } } @@ -308,6 +312,7 @@ bool BatchQueue::loadBatchQueue () const auto tiffUncompressed = nextIntOr (options.saveFormat.tiffUncompressed); const auto saveParams = nextIntOr (options.saveFormat.saveParams); const auto forceFormatOpts = nextIntOr (options.forceFormatOpts); + const auto fast = nextIntOr(false); rtengine::procparams::ProcParams pparams; @@ -319,7 +324,7 @@ bool BatchQueue::loadBatchQueue () if (!thumb) continue; - auto job = rtengine::ProcessingJob::create (source, thumb->getType () == FT_Raw, pparams); + auto job = rtengine::ProcessingJob::create (source, thumb->getType () == FT_Raw, pparams, fast); auto prevh = getMaxThumbnailHeight (); auto prevw = prevh; diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 5cbb5255b..24d1d8541 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -389,6 +389,7 @@ FileBrowser::FileBrowser () untrash->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_Delete, Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE); open->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_Return, (Gdk::ModifierType)0, Gtk::ACCEL_VISIBLE); develop->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_B, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); + developfast->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_B, Gdk::CONTROL_MASK | Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE); copyprof->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_C, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); pasteprof->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_V, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); partpasteprof->add_accelerator ("activate", pmenu->get_accel_group(), GDK_KEY_V, Gdk::CONTROL_MASK | Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE); @@ -1139,9 +1140,12 @@ bool FileBrowser::keyPressed (GdkEventKey* event) } else if (event->keyval == GDK_KEY_Delete && shift) { menuItemActivated (untrash); return true; - } else if ((event->keyval == GDK_KEY_B || event->keyval == GDK_KEY_b) && ctrl) { + } else if ((event->keyval == GDK_KEY_B || event->keyval == GDK_KEY_b) && ctrl && !shift) { menuItemActivated (develop); return true; + } else if ((event->keyval == GDK_KEY_B || event->keyval == GDK_KEY_b) && ctrl && shift) { + menuItemActivated (developfast); + return true; } else if ((event->keyval == GDK_KEY_A || event->keyval == GDK_KEY_a) && ctrl) { menuItemActivated (selall); return true; diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index a876dd54e..99c190cde 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -1094,7 +1094,7 @@ void FileCatalog::developRequested (std::vector tbe, bool fas // controlling time and resource consuming tasks // and also those which effect is not pronounced after reducing the image size // TODO!!! could expose selections below via preferences - if (fastmode) { + if (fastmode && false) { if (options.fastexport_bypass_sharpening ) { params.sharpening.enabled = false; } @@ -1187,7 +1187,7 @@ void FileCatalog::developRequested (std::vector tbe, bool fas params.resize.height = options.fastexport_resize_height ; } - rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (fbe->filename, th->getType() == FT_Raw, params); + rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (fbe->filename, th->getType() == FT_Raw, params, fastmode); int pw; int ph = BatchQueue::calcMaxThumbnailHeight(); diff --git a/rtgui/main.cc b/rtgui/main.cc index ee3d3210e..7e11825a2 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -83,6 +83,8 @@ Glib::ustring fname_to_utf8 (const char* fname) #endif } +bool fast_export = false; + } // This recursive mutex will be used by gdk_threads_enter/leave instead of a simple mutex @@ -537,6 +539,10 @@ int processLineParams( int argc, char **argv ) compression = -1; break; + case 'f': + fast_export = true; + break; + case 'c': // MUST be last option while (iArg + 1 < argc) { iArg++; @@ -845,7 +851,7 @@ int processLineParams( int argc, char **argv ) continue; } - job = rtengine::ProcessingJob::create (ii, currentParams); + job = rtengine::ProcessingJob::create (ii, currentParams, fast_export); if( !job ) { errors++;