Performance improvements, espc. using monitor profiles

see issue 1310
This commit is contained in:
Oliver Duis
2012-04-07 11:10:16 +02:00
parent 37ae5773b7
commit 6f26d26abb
7 changed files with 20 additions and 19 deletions

View File

@@ -145,7 +145,7 @@ public:
}
// use with float indices
T operator[](float index) {
int idx = floor(index);
int idx = (int)index; // don't use floor! The difference in negative space is no problems here
if (((unsigned int)idx) > maxs) {
if (idx<0)
{

View File

@@ -182,9 +182,9 @@ void Crop::update (int todo) {
}
// switch back to rgb
parent->ipf.lab2rgb (labnCrop, cropImg);
parent->ipf.lab2monitorRgb (labnCrop, cropImg);
//parent->ipf.lab2rgb (laboCrop, cropImg);
//parent->ipf.lab2monitorRgb (laboCrop, cropImg);
//cropImg = baseCrop->to8();
/*

View File

@@ -335,7 +335,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
previmg->getMutex().lock();
try
{
ipf.lab2rgb (nprevl, previmg);
ipf.lab2monitorRgb (nprevl, previmg);
delete workimg;
workimg = ipf.lab2rgb (nprevl, 0,0,pW,pH, params.icm.working);
}

View File

@@ -157,8 +157,8 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par
if (monitor) {
cmsHPROFILE iprof = iccStore->getXYZProfile ();
lcmsMutex->lock ();
monitorTransform = cmsCreateTransform (iprof, TYPE_RGB_FLT, monitor, TYPE_RGB_8, settings->colorimetricIntent,
cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety
monitorTransform = cmsCreateTransform (iprof, TYPE_RGB_16, monitor, TYPE_RGB_8, settings->colorimetricIntent,
cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is for thread safety, NOOPTIMIZE for precision
lcmsMutex->unlock ();
}

View File

@@ -121,7 +121,7 @@ class ImProcFunctions {
void colorCurve (LabImage* lold, LabImage* lnew);
void sharpening (LabImage* lab, float** buffer);
void transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH);
void lab2rgb (LabImage* lab, Image8* image);
void lab2monitorRgb (LabImage* lab, Image8* image);
void resize (Image16* src, Image16* dst, float dScale);
void deconvsharpening (LabImage* lab, float** buffer);
void MLsharpen (LabImage* lab);// Manuel's clarity / sharpening

View File

@@ -54,7 +54,7 @@ const double (*iwprof[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz,
const char* wprofnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB"};
const int numprof = 7;
void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) {
void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image) {
//MyTime tBeg,tEnd;
// tBeg.set();
//gamutmap(lab);
@@ -64,7 +64,8 @@ void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) {
// cmsDoTransform is relatively expensive
#pragma omp parallel for
for (int i=0; i<lab->H; i++) {
float buffer[3*lab->W];
// pre-conversion to integer, since the output is 8 bit anyway, but LCMS is MUCH faster not converting from float
unsigned short buffer[3*lab->W];
const int ix = i * 3 * lab->W;
int iy = 0;
@@ -85,9 +86,9 @@ void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) {
y_ = f2xyz(fy);
z_ = f2xyz(fz)*D50z;
buffer[iy++] = CLIP01(x_);
buffer[iy++] = CLIP01(y_);
buffer[iy++] = CLIP01(z_);
buffer[iy++] = (unsigned short)CLIP(x_* CMAXVAL+0.5);
buffer[iy++] = (unsigned short)CLIP(y_* CMAXVAL+0.5);
buffer[iy++] = (unsigned short)CLIP(z_* CMAXVAL+0.5);
}
cmsDoTransform (monitorTransform, buffer, image->data + ix, lab->W);
@@ -174,9 +175,9 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
float y_ = 65535.0 * f2xyz(fy);
float z_ = 65535.0 * f2xyz(fz)*D50z;
buffer[iy++] = CLIP((int)x_);
buffer[iy++] = CLIP((int)y_);
buffer[iy++] = CLIP((int)z_);
buffer[iy++] = CLIP((int)(x_+0.5));
buffer[iy++] = CLIP((int)(y_+0.5));
buffer[iy++] = CLIP((int)(z_+0.5));
}
cmsDoTransform (hTransform, buffer, image->data + ix, cw);
@@ -258,9 +259,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float y_ = 65535.0 * f2xyz(fy);
float z_ = 65535.0 * f2xyz(fz)*D50z;
xa[j-cx] = CLIP((int)x_);
ya[j-cx] = CLIP((int)y_);
za[j-cx] = CLIP((int)z_);
xa[j-cx] = CLIP((int)(x_+0.5));
ya[j-cx] = CLIP((int)(y_+0.5));
za[j-cx] = CLIP((int)(z_+0.5));
}
}

View File

@@ -775,7 +775,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
// obtain final image
Image8* readyImg = new Image8 (fw, fh);
ipf.lab2rgb (labView, readyImg);
ipf.lab2monitorRgb (labView, readyImg);
delete labView;
delete baseImg;