From e137ccd15181b2ca6f15de393fa9ff1a2aa54a7b Mon Sep 17 00:00:00 2001 From: ffsup2 Date: Thu, 28 Oct 2010 23:40:40 +0200 Subject: [PATCH] Speedup in opening an image --- rtengine/dcrop.cc | 18 +++++--- rtengine/dcrop.h | 1 + rtengine/improccoordinator.cc | 81 ++++++++++------------------------- rtengine/improccoordinator.h | 3 +- rtgui/crophandler.cc | 2 +- rtgui/cropwindow.cc | 2 +- 6 files changed, 41 insertions(+), 66 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 03d4ee25c..7c0f5b8fd 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -32,7 +32,7 @@ Crop::Crop (ImProcCoordinator* parent) : resizeCrop(NULL), transCrop(NULL), updating(false), cropw(-1), croph(-1), trafw(-1), trafh(-1), borderRequested(32), cropAllocated(false), - cropImageListener(NULL), parent(parent) + cropImageListener(NULL), parent(parent),skip(10) { parent->crops.push_back (this); } @@ -78,17 +78,26 @@ void Crop::update (int todo, bool internal) { int wx, wy, ww, wh, ws; bool overrideWindow = false; if (cropImageListener) - overrideWindow = cropImageListener->getWindow (wx, wy, ww, wh, ws); + overrideWindow = cropImageListener->getWindow (wx, wy, ww, wh, ws); + + bool regenHighDetail=false; + if( ws==1 && skip>1 && !parent->fineDetailsProcessed ){ + regenHighDetail=true; + } + // re-allocate sub-images and arrays if their dimensions changed bool needsinitupdate = false; if (!overrideWindow) needsinitupdate = setCropSizes (rqcropx, rqcropy, rqcropw, rqcroph, skip, true); else - needsinitupdate = setCropSizes (wx, wy, ww, wh, ws, true); + needsinitupdate = setCropSizes (wx, wy, ww, wh, ws, true); // this set skip=ws // it something has been reallocated, all processing steps have to be performed if (needsinitupdate) todo = ALL; - + + if( regenHighDetail ) + parent->updatePreviewImage (ALL,this); // We have just set skip to 1 + if (resizeCrop) baseCrop = resizeCrop; else @@ -172,7 +181,6 @@ void Crop::update (int todo, bool internal) { parent->ipf.colordenoise (labnCrop, cbuffer); parent->ipf.dirpyrdenoise (labnCrop); parent->ipf.sharpening (labnCrop, (unsigned short**)cbuffer); - //parent->ipf.impulsedenoise (labnCrop); parent->ipf.dirpyrequalizer (labnCrop); parent->ipf.waveletEqualizer(labnCrop, true, true); } diff --git a/rtengine/dcrop.h b/rtengine/dcrop.h index 65115825c..3112f0529 100644 --- a/rtengine/dcrop.h +++ b/rtengine/dcrop.h @@ -69,6 +69,7 @@ class Crop : public DetailedCrop { void fullUpdate (); void setListener (DetailedCropListener* il); void destroy () { delete this; } + int get_skip () { return skip;} }; } #endif diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index f2d06a950..ea54a78d4 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -28,8 +28,8 @@ namespace rtengine { extern Settings* settings; ImProcCoordinator::ImProcCoordinator () - : awbComputed(false), ipf(¶ms, true), scale(-1), allocated(false), - pW(-1), pH(-1), plistener(NULL), imageListener(NULL), + : awbComputed(false), ipf(¶ms, true), scale(10), allocated(false), + pW(-1), pH(-1), plistener(NULL), imageListener(NULL),fineDetailsProcessed(false), aeListener(NULL), hListener(NULL), resultValid(false), changeSinceLast(0), updaterRunning(false), destroying(false) { } @@ -61,7 +61,7 @@ DetailedCrop* ImProcCoordinator::createCrop () { return new Crop (this); } -void ImProcCoordinator::updatePreviewImage (int todo) { +void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { mProcessing.lock (); @@ -77,11 +77,28 @@ void ImProcCoordinator::updatePreviewImage (int todo) { ipf.setScale (scale); + bool highDetailNeeded=false; + for (int i=0; iget_skip() == 1 ){ + highDetailNeeded=true; + break; + } + + progress ("Applying white balance, color correction & sRBG conversion...",100*readyphase/numofphases); if ( todo & M_PREPROC) imgsrc->preprocess( params.raw ); - if( todo & M_RAW) - imgsrc->demosaic( params.raw ); + if( todo & M_RAW){ + RAWParams rp = params.raw; + if( !highDetailNeeded ){ + rp.dmethod = RAWParams::methodstring[RAWParams::fast]; + rp.ca_autocorrect = false; + rp.ccSteps = 0; + fineDetailsProcessed = false; + }else + fineDetailsProcessed = true; + imgsrc->demosaic( rp ); + } if (todo & M_INIT) { minit.lock (); if (settings->verbose) printf ("Applying white balance, color correction & sRBG conversion...\n"); @@ -161,54 +178,6 @@ void ImProcCoordinator::updatePreviewImage (int todo) { if (todo & M_LUMACURVE) CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.lumaCurve.brightness, params.lumaCurve.contrast, 0.0, 0.0, false, params.lumaCurve.curve, lhist16, lumacurve, bcLhist, scale==1 ? 1 : 16); -/* - if (todo & M_LUMINANCE) { - progress ("Applying Luminance Curve...",100*readyphase/numofphases); - ipf.luminanceCurve (oprevl, nprevl, lumacurve, 0, pH); - readyphase++; - if (scale==1) { - progress ("Denoising luminance impulse...",100*readyphase/numofphases); - ipf.impulsedenoise (nprevl); - } - if (scale==1) { - progress ("Denoising luminance...",100*readyphase/numofphases); - ipf.lumadenoise (nprevl, buffer); - } - readyphase++; - if (scale==1) { - progress ("Sharpening...",100*readyphase/numofphases); - ipf.sharpening (nprevl, (unsigned short**)buffer); - } - if (scale==1) { - progress ("Wavelet...",100*readyphase/numofphases); - ipf.waveletEqualizer (nprevl, true, false); - } - readyphase++; - } - - - if (todo & M_COLOR) { - progress ("Applying Color Boost...",100*readyphase/numofphases); - ipf.colorCurve (oprevl, nprevl); - readyphase++; - if (scale==1) { - progress ("Denoising color...",100*readyphase/numofphases); - ipf.colordenoise (nprevl, buffer); - } - if (scale==1) { - progress ("Denoising luma/chroma...",100*readyphase/numofphases); - ipf.dirpyrdenoise (nprevl); - } - if (scale==1) { - progress ("Wavelet...",100*readyphase/numofphases); - ipf.waveletEqualizer (nprevl, false, true); - } - readyphase++; - } -*/ - - - if (todo & (M_LUMINANCE+M_COLOR) ) { progress ("Applying Luminance Curve...",100*readyphase/numofphases); ipf.luminanceCurve (oprevl, nprevl, lumacurve, 0, pH); @@ -238,10 +207,6 @@ void ImProcCoordinator::updatePreviewImage (int todo) { ipf.sharpening (nprevl, (unsigned short**)buffer); } readyphase++; - //if (scale==1) { - // progress ("Denoising luminance impulse...",100*readyphase/numofphases); - // ipf.impulsedenoise (nprevl); - //} if (scale==1) { progress ("Pyramid equalizer...",100*readyphase/numofphases); ipf.dirpyrequalizer (nprevl); @@ -256,7 +221,7 @@ void ImProcCoordinator::updatePreviewImage (int todo) { // process crop, if needed for (int i=0; ihasListener ()) + if (crops[i]->hasListener () && cropCall != crops[i] ) crops[i]->update (todo, true); progress ("Conversion to RGB...",100*readyphase/numofphases); diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 01be6df96..cf81c20b4 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -57,6 +57,7 @@ class ImProcCoordinator : public StagedImageProcessor { ImProcFunctions ipf; int scale; + bool fineDetailsProcessed; bool allocated; void freeAll (); @@ -88,7 +89,7 @@ class ImProcCoordinator : public StagedImageProcessor { void reallocAll (); void updateHistograms (int x1, int y1, int x2, int y2); void setScale (int prevscale, bool internal=false); - void updatePreviewImage (int todo); + void updatePreviewImage (int todo, Crop* cropCall= NULL); Glib::Mutex mProcessing; ProcParams params; diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index b30474cec..257f037fe 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -22,7 +22,7 @@ using namespace rtengine; CropHandler::CropHandler () - : zoom(1000), cx(0), cy(0), cw(0), ch(0), + : zoom(10), cx(0), cy(0), cw(0), ch(0), cropX(0), cropY(0), cropW(0), cropH(0), enabled(false), cropimg(NULL), ipc(NULL), crop(NULL), listener(NULL) { diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index c0988ccae..e0d569f5b 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -54,7 +54,7 @@ CropWindow::CropWindow (ImageArea* parent, rtengine::StagedImageProcessor* ipc_) backColor(0), decorated(true), titleHeight(30), sideBorderWidth(3), lowerBorderWidth(3), upperBorderWidth(1), sepWidth(2), imgX(0), imgY(0), imgW(1), imgH(1), xpos(30), ypos(30), iarea(parent), - cropZoom(ZOOM11INDEX), cropgl(NULL), pmlistener(NULL), observedCropWin(NULL) { + cropZoom(0), cropgl(NULL), pmlistener(NULL), observedCropWin(NULL) { Glib::RefPtr context = parent->get_pango_context () ; Pango::FontDescription fontd = context->get_font_description ();