Speedup in opening an image

This commit is contained in:
ffsup2
2010-10-28 23:40:40 +02:00
parent 8c6bfa22ad
commit e137ccd151
6 changed files with 41 additions and 66 deletions

View File

@@ -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);
}

View File

@@ -69,6 +69,7 @@ class Crop : public DetailedCrop {
void fullUpdate ();
void setListener (DetailedCropListener* il);
void destroy () { delete this; }
int get_skip () { return skip;}
};
}
#endif

View File

@@ -28,8 +28,8 @@ namespace rtengine {
extern Settings* settings;
ImProcCoordinator::ImProcCoordinator ()
: awbComputed(false), ipf(&params, true), scale(-1), allocated(false),
pW(-1), pH(-1), plistener(NULL), imageListener(NULL),
: awbComputed(false), ipf(&params, 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; i<crops.size(); i++)
if (crops[i]->get_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; i<crops.size(); i++)
if (crops[i]->hasListener ())
if (crops[i]->hasListener () && cropCall != crops[i] )
crops[i]->update (todo, true);
progress ("Conversion to RGB...",100*readyphase/numofphases);

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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<Pango::Context> context = parent->get_pango_context () ;
Pango::FontDescription fontd = context->get_font_description ();