Fix issue #3411 + revert some code to the old one for better readability
This commit is contained in:
parent
bdf4665c16
commit
a69c631f22
@ -519,11 +519,12 @@ cmsHPROFILE ICCStore::createGammaProfile (const procparams::ColorManagementParam
|
||||
// 7 parameters for smoother curves
|
||||
cmsFloat64Number Parameters[7] = { ga[0], ga[1], ga[2], ga[3], ga[4], ga[5], ga[6] } ;
|
||||
|
||||
lcmsMutex->lock ();
|
||||
cmsWhitePointFromTemp(&xyD, (double)temp);
|
||||
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(NULL, 5, Parameters); //5 = smoother than 4
|
||||
cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile
|
||||
|
||||
cmsFreeToneCurve(GammaTRC[0]);
|
||||
lcmsMutex->unlock ();
|
||||
|
||||
return oprofdef;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ Image16::tofloat()
|
||||
}
|
||||
|
||||
// Parallized transformation; create transform with cmsFLAGS_NOCACHE!
|
||||
void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage)
|
||||
void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy)
|
||||
{
|
||||
// LittleCMS cannot parallelize planar Lab float images
|
||||
// so build temporary buffers to allow multi processor execution
|
||||
@ -341,15 +341,15 @@ void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImag
|
||||
#pragma omp for schedule(static)
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int y = cy; y < cy + height; y++)
|
||||
{
|
||||
unsigned short *pRGB, *pR, *pG, *pB;
|
||||
float *pLab, *pL, *pa, *pb;
|
||||
|
||||
pLab= bufferLab.data;
|
||||
pL = labImage.L[y];
|
||||
pa = labImage.a[y];
|
||||
pb = labImage.b[y];
|
||||
pL = labImage.L[y] + cx;
|
||||
pa = labImage.a[y] + cx;
|
||||
pb = labImage.b[y] + cx;
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*(pLab++) = *(pL++) / 327.68f;
|
||||
@ -360,9 +360,9 @@ void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImag
|
||||
cmsDoTransform (hTransform, bufferLab.data, bufferRGB.data, width);
|
||||
|
||||
pRGB = bufferRGB.data;
|
||||
pR = r(y);
|
||||
pG = g(y);
|
||||
pB = b(y);
|
||||
pR = r(y - cy);
|
||||
pG = g(y - cy);
|
||||
pB = b(y - cy);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*(pR++) = *(pRGB++);
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage);
|
||||
void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -238,14 +238,14 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
|
||||
float* rL = lab->L[i];
|
||||
float* ra = lab->a[i];
|
||||
float* rb = lab->b[i];
|
||||
uint8_t* dest = image->r(i - cy) + cx;
|
||||
int ix = 3 * i * cw;
|
||||
|
||||
for (int j = cx; j < cx + cw; j++) {
|
||||
|
||||
float fy = (0.0086206897f * (*rL)) / 327.68f + 0.1379310345f; // (L+16)/116
|
||||
float fx = (0.002f * *(ra++)) / 327.68f + fy;
|
||||
float fz = fy - (0.005f * *(rb++)) / 327.68f;
|
||||
float LL = *(rL++) / 327.68f;
|
||||
float fy = (0.0086206897f * rL[j]) / 327.68f + 0.1379310345f; // (L+16)/116
|
||||
float fx = (0.002f * ra[j]) / 327.68f + fy;
|
||||
float fz = fy - (0.005f * rb[j]) / 327.68f;
|
||||
float LL = rL[j] / 327.68f;
|
||||
|
||||
float x_ = 65535.0f * Color::f2xyz(fx) * Color::D50x;
|
||||
//float y_ = 65535.0f * Color::f2xyz(fy);
|
||||
@ -254,9 +254,9 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
|
||||
|
||||
Color::xyz2rgb(x_, y_, z_, R, G, B, xyz_rgb);
|
||||
|
||||
*(dest++) = (int)Color::gamma2curve[CLIP(R)] >> 8;
|
||||
*(dest++) = (int)Color::gamma2curve[CLIP(G)] >> 8;
|
||||
*(dest++) = (int)Color::gamma2curve[CLIP(B)] >> 8;
|
||||
image->data[ix++] = (int)Color::gamma2curve[R] >> 8;
|
||||
image->data[ix++] = (int)Color::gamma2curve[G] >> 8;
|
||||
image->data[ix++] = (int)Color::gamma2curve[B] >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,63 +314,6 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
|
||||
}
|
||||
|
||||
if (oprof) {
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16) if (multiThread)
|
||||
#endif
|
||||
|
||||
for (int i = cy; i < cy + ch; i++) {
|
||||
float* rL = lab->L[i];
|
||||
float* ra = lab->a[i];
|
||||
float* rb = lab->b[i];
|
||||
short* xa = (short*)image->r(i - cy) + cx;
|
||||
short* ya = (short*)image->g(i - cy) + cx;
|
||||
short* za = (short*)image->b(i - cy) + cx;
|
||||
|
||||
for (int j = 0; j < cw; j++) {
|
||||
|
||||
float fy = (0.0086206897f * *rL) / 327.68f + 0.1379310345f; // (L+16)/116
|
||||
float fx = (0.002f * *(ra++)) / 327.68f + fy;
|
||||
float fz = fy - (0.005f * *(rb++)) / 327.68f;
|
||||
float LL = *(rL++) / 327.68f;
|
||||
|
||||
float x_ = 65535.0f * Color::f2xyz(fx) * Color::D50x;
|
||||
//float y_ = 65535.0f * Color::f2xyz(fy);
|
||||
float z_ = 65535.0f * Color::f2xyz(fz) * Color::D50z;
|
||||
float y_ = (LL > (float)Color::epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / (float)Color::kappa;
|
||||
|
||||
*xa = CLIP((int) round(x_)) ;
|
||||
*(ya++) = CLIP((int) round(y_));
|
||||
*za = CLIP((int) round(z_));
|
||||
|
||||
if(bw && y_ < 65535.f) { //force Bw value and take highlight into account
|
||||
*xa = (int) round(y_ * Color::D50x);
|
||||
*za = (int) round(y_ * Color::D50z);
|
||||
}
|
||||
++xa;
|
||||
++za;
|
||||
}
|
||||
}
|
||||
|
||||
cmsHPROFILE iprof = iccStore->getXYZProfile ();
|
||||
|
||||
|
||||
*/
|
||||
|
||||
cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr);
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
|
||||
if (icm.outputBPC) {
|
||||
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
|
||||
@ -378,12 +321,11 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
|
||||
}
|
||||
else printf("lab2rgb16 / icm.outputBPC=false / outputIntent=%d\n", icm.outputIntent);
|
||||
lcmsMutex->lock ();
|
||||
//cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprof, TYPE_RGB_16, icm.outputIntent, flags);
|
||||
cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr);
|
||||
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, oprof, TYPE_RGB_16, icm.outputIntent, flags);
|
||||
lcmsMutex->unlock ();
|
||||
|
||||
//image->ExecCMSTransform(hTransform);
|
||||
image->ExecCMSTransform(hTransform, *lab);
|
||||
image->ExecCMSTransform(hTransform, *lab, cx, cy);
|
||||
cmsDeleteTransform(hTransform);
|
||||
} else {
|
||||
//
|
||||
@ -395,16 +337,13 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
|
||||
float* rL = lab->L[i];
|
||||
float* ra = lab->a[i];
|
||||
float* rb = lab->b[i];
|
||||
uint16_t* rR = image->r(i - cy) + cx;
|
||||
uint16_t* rG = image->g(i - cy) + cx;
|
||||
uint16_t* rB = image->b(i - cy) + cx;
|
||||
|
||||
for (int j = 0; j < cw; j++) {
|
||||
for (int j = cx; j < cx + cw; j++) {
|
||||
|
||||
float fy = (0.0086206897f * *rL) / 327.68f + 0.1379310345f; // (L+16)/116
|
||||
float fx = (0.002f * *(ra++)) / 327.68f + fy;
|
||||
float fz = fy - (0.005f * *(rb++)) / 327.68f;
|
||||
float LL = *(rL++) / 327.68f;
|
||||
float fy = (0.0086206897f * rL[j]) / 327.68f + 0.1379310345f; // (L+16)/116
|
||||
float fx = (0.002f * ra[j]) / 327.68f + fy;
|
||||
float fz = fy - (0.005f * rb[j]) / 327.68f;
|
||||
float LL = rL[j] / 327.68f;
|
||||
|
||||
float x_ = 65535.0f * Color::f2xyz(fx) * Color::D50x;
|
||||
//float y_ = 65535.0 * Color::f2xyz(fy);
|
||||
@ -413,9 +352,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
|
||||
|
||||
Color::xyz2srgb(x_, y_, z_, R, G, B);
|
||||
|
||||
*(rR++) = (int)Color::gamma2curve[CLIP(R)];
|
||||
*(rG++) = (int)Color::gamma2curve[CLIP(G)];
|
||||
*(rB++) = (int)Color::gamma2curve[CLIP(B)];
|
||||
image->r(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(R)];
|
||||
image->g(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(G)];
|
||||
image->b(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(B)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5930,7 +5930,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited)
|
||||
icm.outputBPC = keyFile.get_boolean ("Color Management", "OutputBPC");
|
||||
|
||||
if (pedited) {
|
||||
pedited->icm.gamfree = true;
|
||||
pedited->icm.outputBPC = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
Glib::ustring monitorProfile; ///< ICC profile name used for the monitor
|
||||
RenderingIntent monitorIntent; ///< Colorimetric intent used with the above profile
|
||||
bool monitorBPC; ///< Black Point Compensation for the WCS->Monitor transform (directly, i.e. not soft-proofing)
|
||||
bool monitorBPC; ///< Black Point Compensation for the Labimage->Monitor transform (directly, i.e. not soft-proofing and no WCS in between)
|
||||
bool autoMonitorProfile; ///< Try to auto-determine the correct monitor color profile
|
||||
bool autocielab;
|
||||
bool rgbcurveslumamode_gamut;// controls gamut enforcement for RGB curves in lumamode
|
||||
|
@ -2216,8 +2216,6 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
|
||||
toEdit.icm.outputBPC = mods.icm.outputBPC;
|
||||
}
|
||||
|
||||
//if (icm.gampos) toEdit.icm.gampos = mods.icm.gampos;
|
||||
//if (icm.slpos) toEdit.icm.slpos = mods.icm.slpos;
|
||||
if (icm.gampos) {
|
||||
toEdit.icm.gampos = dontforceSet && options.baBehav[ADDSET_FREE_OUPUT_GAMMA] ? toEdit.icm.gampos + mods.icm.gampos : mods.icm.gampos;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user