astyle on files edited by rec2020 branch

This commit is contained in:
Beep6581
2016-04-30 16:20:45 +02:00
parent 56af7e88ce
commit 59a9d2dc2f
4 changed files with 791 additions and 775 deletions

View File

@@ -41,8 +41,9 @@ void loadProfiles (const Glib::ustring& dirName,
std::map<Glib::ustring, Glib::ustring>* profileNames,
bool nameUpper, bool onlyRgb)
{
if (dirName.empty ())
if (dirName.empty ()) {
return;
}
try {
@@ -52,23 +53,27 @@ void loadProfiles (const Glib::ustring& dirName,
const Glib::ustring fileName = *entry;
if (fileName.size () < 4)
if (fileName.size () < 4) {
continue;
}
const Glib::ustring extension = fileName.substr (fileName.size () - 4).casefold ();
if (extension.compare (".icc") != 0 && extension.compare (".icm") != 0)
if (extension.compare (".icc") != 0 && extension.compare (".icm") != 0) {
continue;
}
const Glib::ustring filePath = Glib::build_filename (dirName, fileName);
if (!Glib::file_test (filePath, Glib::FILE_TEST_IS_REGULAR))
if (!Glib::file_test (filePath, Glib::FILE_TEST_IS_REGULAR)) {
continue;
}
Glib::ustring name = fileName.substr (0, fileName.size() - 4);
if (nameUpper)
if (nameUpper) {
name = name.uppercase ();
}
if (profiles) {
const rtengine::ProfileContent content (filePath);
@@ -77,28 +82,31 @@ void loadProfiles (const Glib::ustring& dirName,
if (profile && (!onlyRgb || cmsGetColorSpace (profile) == cmsSigRgbData)) {
profiles->insert (std::make_pair (name, profile));
if (profileContents)
if (profileContents) {
profileContents->insert (std::make_pair (name, content));
}
}
}
if (profileNames)
if (profileNames) {
profileNames->insert (std::make_pair (name, filePath));
}
}
}
catch (Glib::Exception&) {}
} catch (Glib::Exception&) {}
}
inline void getSupportedIntent (cmsHPROFILE profile, cmsUInt32Number intent, cmsUInt32Number direction, std::uint8_t& result)
{
if (cmsIsIntentSupported (profile, intent, direction))
if (cmsIsIntentSupported (profile, intent, direction)) {
result |= 1 << intent;
}
}
inline std::uint8_t getSupportedIntents (cmsHPROFILE profile, cmsUInt32Number direction)
{
if (!profile)
if (!profile) {
return 0;
}
std::uint8_t result = 0;
@@ -137,7 +145,7 @@ std::vector<Glib::ustring> getGamma ()
std::vector<Glib::ustring> res;
for (unsigned int i = 0; i < sizeof(wpgamma) / sizeof(wpgamma[0]); i++) {
for (unsigned int i = 0; i < sizeof (wpgamma) / sizeof (wpgamma[0]); i++) {
res.push_back (wpgamma[i]);
}
@@ -149,7 +157,7 @@ std::vector<Glib::ustring> getWorkingProfiles ()
std::vector<Glib::ustring> res;
for (unsigned int i = 0; i < sizeof(wpnames) / sizeof(wpnames[0]); i++) {
for (unsigned int i = 0; i < sizeof (wpnames) / sizeof (wpnames[0]); i++) {
res.push_back (wpnames[i]);
}
@@ -159,12 +167,13 @@ std::vector<Glib::ustring> getWorkingProfiles ()
std::vector<Glib::ustring> ICCStore::getProfiles () const
{
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
std::vector<Glib::ustring> res;
for (ProfileMap::const_iterator profile = fileProfiles.begin (); profile != fileProfiles.end (); ++profile)
for (ProfileMap::const_iterator profile = fileProfiles.begin (); profile != fileProfiles.end (); ++profile) {
res.push_back (profile->first);
}
return res;
}
@@ -172,7 +181,7 @@ std::vector<Glib::ustring> ICCStore::getProfiles () const
std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& dirName) const
{
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
std::vector<Glib::ustring> res;
@@ -181,8 +190,9 @@ std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& di
loadProfiles (profilesDir, &profiles, NULL, NULL, false, true);
loadProfiles (dirName, &profiles, NULL, NULL, false, true);
for (ProfileMap::const_iterator profile = profiles.begin (); profile != profiles.end (); ++profile)
for (ProfileMap::const_iterator profile = profiles.begin (); profile != profiles.end (); ++profile) {
res.push_back (profile->first);
}
return res;
}
@@ -195,19 +205,19 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
}
cmsUInt32Number bytesNeeded = 0;
cmsSaveProfileToMem(iprof, 0, &bytesNeeded);
cmsSaveProfileToMem (iprof, 0, &bytesNeeded);
if (bytesNeeded == 0) {
return NULL;
}
uint8_t *data = new uint8_t[bytesNeeded + 1];
cmsSaveProfileToMem(iprof, data, &bytesNeeded);
cmsSaveProfileToMem (iprof, data, &bytesNeeded);
const uint8_t *p = &data[128]; // skip 128 byte header
uint32_t tag_count;
memcpy(&tag_count, p, 4);
memcpy (&tag_count, p, 4);
p += 4;
tag_count = ntohl(tag_count);
tag_count = ntohl (tag_count);
struct icctag {
uint32_t sig;
@@ -220,10 +230,10 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
int data_size = (gamma_size + 3) & ~3;
for (uint32_t i = 0; i < tag_count; i++) {
memcpy(&tags[i], p, 12);
tags[i].sig = ntohl(tags[i].sig);
tags[i].offset = ntohl(tags[i].offset);
tags[i].size = ntohl(tags[i].size);
memcpy (&tags[i], p, 12);
tags[i].sig = ntohl (tags[i].sig);
tags[i].offset = ntohl (tags[i].offset);
tags[i].size = ntohl (tags[i].size);
p += 12;
if (tags[i].sig != 0x62545243 && // bTRC
@@ -236,16 +246,16 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
uint32_t sz = 128 + 4 + tag_count * 12 + data_size;
uint8_t *nd = new uint8_t[sz];
memset(nd, 0, sz);
memcpy(nd, data, 128 + 4);
sz = htonl(sz);
memcpy(nd, &sz, 4);
memset (nd, 0, sz);
memcpy (nd, data, 128 + 4);
sz = htonl (sz);
memcpy (nd, &sz, 4);
uint32_t offset = 128 + 4 + tag_count * 12;
uint32_t gamma_offset = 0;
for (uint32_t i = 0; i < tag_count; i++) {
struct icctag tag;
tag.sig = htonl(tags[i].sig);
tag.sig = htonl (tags[i].sig);
if (tags[i].sig == 0x62545243 || // bTRC
tags[i].sig == 0x67545243 || // gTRC
@@ -253,30 +263,30 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
tags[i].sig == 0x6B545243) { // kTRC
if (gamma_offset == 0) {
gamma_offset = offset;
uint32_t pcurve[] = { htonl(0x63757276), htonl(0), htonl(gamma_size == 12 ? 0 : 1) };
memcpy(&nd[offset], pcurve, 12);
uint32_t pcurve[] = { htonl (0x63757276), htonl (0), htonl (gamma_size == 12 ? 0 : 1) };
memcpy (&nd[offset], pcurve, 12);
if (gamma_size == 14) {
uint16_t gm = htons(gamma);
memcpy(&nd[offset + 12], &gm, 2);
uint16_t gm = htons (gamma);
memcpy (&nd[offset + 12], &gm, 2);
}
offset += (gamma_size + 3) & ~3;
}
tag.offset = htonl(gamma_offset);
tag.size = htonl(gamma_size);
tag.offset = htonl (gamma_offset);
tag.size = htonl (gamma_size);
} else {
tag.offset = htonl(offset);
tag.size = htonl(tags[i].size);
memcpy(&nd[offset], &data[tags[i].offset], tags[i].size);
tag.offset = htonl (offset);
tag.size = htonl (tags[i].size);
memcpy (&nd[offset], &data[tags[i].offset], tags[i].size);
offset += (tags[i].size + 3) & ~3;
}
memcpy(&nd[128 + 4 + i * 12], &tag, 12);
memcpy (&nd[128 + 4 + i * 12], &tag, 12);
}
cmsHPROFILE oprof = cmsOpenProfileFromMem (nd, ntohl(sz));
cmsHPROFILE oprof = cmsOpenProfileFromMem (nd, ntohl (sz));
delete [] nd;
delete [] data;
return oprof;
@@ -294,7 +304,7 @@ ICCStore::ICCStore () :
{
//cmsErrorAction (LCMS_ERROR_SHOW);
int N = sizeof(wpnames) / sizeof(wpnames[0]);
int N = sizeof (wpnames) / sizeof (wpnames[0]);
for (int i = 0; i < N; i++) {
wProfiles[wpnames[i]] = createFromMatrix (wprofiles[i]);
@@ -355,7 +365,7 @@ cmsHPROFILE ICCStore::workingSpaceGamma (const Glib::ustring& name) const
cmsHPROFILE ICCStore::getProfile (const Glib::ustring& name) const
{
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
const ProfileMap::const_iterator r = fileProfiles.find (name);
@@ -368,8 +378,8 @@ cmsHPROFILE ICCStore::getProfile (const Glib::ustring& name) const
const cmsHPROFILE profile = content.toProfile ();
if (profile) {
const_cast<ProfileMap&>(fileProfiles).insert(std::make_pair(name, profile));
const_cast<ContentMap&>(fileProfileContents).insert(std::make_pair(name, content));
const_cast<ProfileMap&> (fileProfiles).insert (std::make_pair (name, profile));
const_cast<ContentMap&> (fileProfileContents).insert (std::make_pair (name, content));
return profile;
}
@@ -383,37 +393,40 @@ cmsHPROFILE ICCStore::getStdProfile (const Glib::ustring& name) const
const Glib::ustring nameUpper = name.uppercase ();
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
const ProfileMap::const_iterator r = fileStdProfiles.find (nameUpper);
// return profile from store
if (r != fileStdProfiles.end ())
if (r != fileStdProfiles.end ()) {
return r->second;
}
// profile is not yet in store
const NameMap::const_iterator f = fileStdProfilesFileNames.find (nameUpper);
// profile does not exist
if (f == fileStdProfilesFileNames.end ())
if (f == fileStdProfilesFileNames.end ()) {
return NULL;
}
// but there exists one => load it
const ProfileContent content (f->second);
const cmsHPROFILE profile = content.toProfile ();
if (profile)
const_cast<ProfileMap&>(fileStdProfiles).insert (std::make_pair (f->first, profile));
if (profile) {
const_cast<ProfileMap&> (fileStdProfiles).insert (std::make_pair (f->first, profile));
}
// profile is not valid or it is now stored => remove entry from fileStdProfilesFileNames
const_cast<NameMap&>(fileStdProfilesFileNames).erase (f);
const_cast<NameMap&> (fileStdProfilesFileNames).erase (f);
return profile;
}
ProfileContent ICCStore::getContent (const Glib::ustring& name) const
{
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
const ContentMap::const_iterator r = fileProfileContents.find (name);
@@ -445,7 +458,7 @@ std::uint8_t ICCStore::getProofIntents (cmsHPROFILE profile) const
void ICCStore::init (const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir)
{
MyMutex::MyLock lock(mutex_);
MyMutex::MyLock lock (mutex_);
// RawTherapee's profiles take precedence if a user's profile of the same name exists
profilesDir = Glib::build_filename (rtICCDir, "output");
@@ -470,26 +483,27 @@ void ICCStore::findDefaultMonitorProfile ()
#ifdef WIN32
// Get current main monitor. Could be fine tuned to get the current windows monitor (multi monitor setup),
// but problem is that we live in RTEngine with no GUI window to query around
HDC hDC = GetDC(NULL);
HDC hDC = GetDC (NULL);
if (hDC != NULL) {
if (SetICMMode(hDC, ICM_ON)) {
if (SetICMMode (hDC, ICM_ON)) {
char profileName[MAX_PATH + 1];
DWORD profileLength = MAX_PATH;
if (GetICMProfileA(hDC, &profileLength, profileName)) {
defaultMonitorProfile = Glib::ustring(profileName);
defaultMonitorProfile = Glib::path_get_basename(defaultMonitorProfile);
size_t pos = defaultMonitorProfile.rfind(".");
if (GetICMProfileA (hDC, &profileLength, profileName)) {
defaultMonitorProfile = Glib::ustring (profileName);
defaultMonitorProfile = Glib::path_get_basename (defaultMonitorProfile);
size_t pos = defaultMonitorProfile.rfind (".");
if (pos != Glib::ustring::npos) {
defaultMonitorProfile = defaultMonitorProfile.substr(0, pos);
defaultMonitorProfile = defaultMonitorProfile.substr (0, pos);
}
}
// might fail if e.g. the monitor has no profile
}
ReleaseDC(NULL, hDC);
ReleaseDC (NULL, hDC);
}
#else
@@ -497,11 +511,11 @@ void ICCStore::findDefaultMonitorProfile ()
#endif
if (options.rtSettings.verbose) {
printf("Default monitor profile is: %s\n", defaultMonitorProfile.c_str());
printf ("Default monitor profile is: %s\n", defaultMonitorProfile.c_str());
}
}
ProfileContent::ProfileContent (const Glib::ustring& fileName) : data(NULL), length(0)
ProfileContent::ProfileContent (const Glib::ustring& fileName) : data (NULL), length (0)
{
FILE* f = g_fopen (fileName.c_str (), "rb");
@@ -532,16 +546,16 @@ ProfileContent::ProfileContent (const ProfileContent& other)
}
}
ProfileContent::ProfileContent (cmsHPROFILE hProfile) : data(NULL), length(0)
ProfileContent::ProfileContent (cmsHPROFILE hProfile) : data (NULL), length (0)
{
if (hProfile != NULL) {
cmsUInt32Number bytesNeeded = 0;
cmsSaveProfileToMem(hProfile, 0, &bytesNeeded);
cmsSaveProfileToMem (hProfile, 0, &bytesNeeded);
if (bytesNeeded > 0) {
data = new char[bytesNeeded + 1];
cmsSaveProfileToMem(hProfile, data, &bytesNeeded);
cmsSaveProfileToMem (hProfile, data, &bytesNeeded);
length = (int)bytesNeeded;
}
}
@@ -618,9 +632,9 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
}
// constructing profile header
unsigned* oprof = new unsigned [phead[0] / sizeof(unsigned)];
unsigned* oprof = new unsigned [phead[0] / sizeof (unsigned)];
memset (oprof, 0, phead[0]);
memcpy (oprof, phead, sizeof(phead));
memcpy (oprof, phead, sizeof (phead));
oprof[0] = 132 + 12 * pbody[0];
@@ -633,14 +647,14 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
oprof[0] += (pbody[i * 3 + 3] + 3) & -4;
}
memcpy (oprof + 32, pbody, sizeof(pbody));
memcpy (oprof + 32, pbody, sizeof (pbody));
// wtpt
memcpy ((char *)oprof + pbody[8] + 8, pwhite, sizeof(pwhite));
memcpy ((char *)oprof + pbody[8] + 8, pwhite, sizeof (pwhite));
// r/g/b TRC
for (int i = 4; i < 7; i++) {
memcpy ((char *)oprof + pbody[i * 3 + 2], pcurve, sizeof(pcurve));
memcpy ((char *)oprof + pbody[i * 3 + 2], pcurve, sizeof (pcurve));
}
// r/g/b XYZ
@@ -654,7 +668,7 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
// convert to network byte order
for (unsigned int i = 0; i < phead[0] / 4; i++) {
oprof[i] = htonl(oprof[i]);
oprof[i] = htonl (oprof[i]);
}
// cprt
@@ -665,7 +679,7 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
strcpy ((char *)oprof + pbody[5] + 12, name.c_str());
cmsHPROFILE p = cmsOpenProfileFromMem (oprof, ntohl(oprof[0]));
cmsHPROFILE p = cmsOpenProfileFromMem (oprof, ntohl (oprof[0]));
delete [] oprof;
return p;
}

View File

@@ -45,7 +45,7 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
#pragma omp parallel firstprivate(lab, data, W, H)
#endif
{
AlignedBuffer<float> pBuf(3 * lab->W);
AlignedBuffer<float> pBuf (3 * lab->W);
float *buffer = pBuf.data;
#ifdef _OPENMP
@@ -70,7 +70,7 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
}
if (!settings->HistogramWorking && output2monitorTransform && lab2outputTransform) {
AlignedBuffer<float> buf(3 * W);
AlignedBuffer<float> buf (3 * W);
cmsDoTransform (lab2outputTransform, buffer, buf.data, W);
cmsDoTransform (output2monitorTransform, buf.data, data + ix, W);
} else {
@@ -108,18 +108,18 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
fz = fy - (0.005 * rb[j]) / 327.68;
LL = rL[j] / 327.68;
x_ = 65535.0 * Color::f2xyz(fx) * Color::D50x;
x_ = 65535.0 * Color::f2xyz (fx) * Color::D50x;
// y_ = 65535.0 * Color::f2xyz(fy);
z_ = 65535.0 * Color::f2xyz(fz) * Color::D50z;
z_ = 65535.0 * Color::f2xyz (fz) * Color::D50z;
y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B);
Color::xyz2srgb (x_, y_, z_, R, G, B);
/* copy RGB */
//int R1=((int)gamma2curve[(R)])
data[ix++] = ((int)Color::gamma2curve[CLIP(R)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP(G)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP(B)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP (R)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP (G)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP (B)]) >> 8;
}
}
}
@@ -153,14 +153,14 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
cmsHPROFILE oprofG = oprof;
if (standard_gamma) {
oprofG = ICCStore::makeStdGammaProfile(oprof);
oprofG = ICCStore::makeStdGammaProfile (oprof);
}
lcmsMutex->lock ();
cmsHPROFILE hLab = cmsCreateLab4Profile(NULL);
cmsHPROFILE hLab = cmsCreateLab4Profile (NULL);
cmsHTRANSFORM hTransform = cmsCreateTransform (hLab, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, intent,
cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety
cmsCloseProfile(hLab);
cmsCloseProfile (hLab);
lcmsMutex->unlock ();
unsigned char *data = image->data;
@@ -170,7 +170,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
#pragma omp parallel
#endif
{
AlignedBuffer<double> pBuf(3 * cw);
AlignedBuffer<double> pBuf (3 * cw);
double *buffer = pBuf.data;
int condition = cy + ch;
@@ -195,10 +195,10 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
}
} // End of parallelization
cmsDeleteTransform(hTransform);
cmsDeleteTransform (hTransform);
if (oprofG != oprof) {
cmsCloseProfile(oprofG);
cmsCloseProfile (oprofG);
}
} else {
@@ -222,16 +222,16 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
float fz = fy - (0.005 * rb[j]) / 327.68;
float LL = rL[j] / 327.68;
float x_ = 65535.0 * Color::f2xyz(fx) * Color::D50x;
float x_ = 65535.0 * Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0 * Color::f2xyz(fz) * Color::D50z;
float z_ = 65535.0 * Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa;
Color::xyz2rgb(x_, y_, z_, R, G, B, rgb_xyz);
Color::xyz2rgb (x_, y_, z_, R, G, B, rgb_xyz);
image->data[ix++] = (int)Color::gamma2curve[CLIP(R)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP(G)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP(B)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP (R)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP (G)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP (B)] >> 8;
}
}
}
@@ -272,9 +272,9 @@ 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];
short* xa = (short*)image->r(i - cy);
short* ya = (short*)image->g(i - cy);
short* za = (short*)image->b(i - cy);
short* xa = (short*)image->r (i - cy);
short* ya = (short*)image->g (i - cy);
short* za = (short*)image->b (i - cy);
for (int j = cx; j < cx + cw; j++) {
@@ -283,18 +283,18 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x;
float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z;
float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa;
xa[j - cx] = CLIP((int) round(x_));
ya[j - cx] = CLIP((int) round(y_));
za[j - cx] = CLIP((int) round(z_));
xa[j - cx] = CLIP ((int) round (x_));
ya[j - cx] = CLIP ((int) round (y_));
za[j - cx] = CLIP ((int) round (z_));
if(bw && y_ < 65535.f ) { //force Bw value and take highlight into account
xa[j - cx] = (int) round(y_ * Color::D50x );
za[j - cx] = (int) round(y_ * Color::D50z);
if (bw && y_ < 65535.f ) { //force Bw value and take highlight into account
xa[j - cx] = (int) round (y_ * Color::D50x );
za[j - cx] = (int) round (y_ * Color::D50z);
}
}
@@ -305,9 +305,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprof, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE);
lcmsMutex->unlock ();
image->ExecCMSTransform(hTransform);
image->ExecCMSTransform (hTransform);
cmsDeleteTransform(hTransform);
cmsDeleteTransform (hTransform);
} else {
#pragma omp parallel for if (multiThread)
@@ -324,16 +324,16 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x;
float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z;
float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B);
Color::xyz2srgb (x_, y_, z_, R, G, 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)];
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)];
}
}
}
@@ -441,7 +441,7 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
if (!freegamma) {//if Free gamma not selected
// gamma : ga0,ga1,ga2,ga3,ga4,ga5 by calcul
if(gam == "BT709_g2.2_s4.5") {
if (gam == "BT709_g2.2_s4.5") {
ga0 = 2.22; //BT709 2.2 4.5 - my prefered as D.Coffin
ga1 = 0.909995;
ga2 = 0.090005;
@@ -492,11 +492,11 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
ga5 = 0.0;
}
} else { //free gamma selected
if(slpos == 0) {
if (slpos == 0) {
slpos = eps;
}
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
Color::calcGamma (pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
ga4 = g_a3 * ts;
//printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4);
ga0 = gampos;
@@ -508,7 +508,7 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
}
if(select_temp == 1) {
if (select_temp == 1) {
t50 = 5003; // for Widegamut, Prophoto Best, Beta D50
} else if (select_temp == 2) {
t50 = 6504; // for sRGB, AdobeRGB, Bruce D65
@@ -529,11 +529,11 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
Parameters[5] = ga5;
Parameters[6] = ga6;
// 7 parameters for smoother curves
cmsWhitePointFromTemp(&xyD, t50);
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(NULL, 5, Parameters);//5 = more smoother than 4
cmsHPROFILE oprofdef = cmsCreateRGBProfileTHR(NULL, &xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile
cmsWhitePointFromTemp (&xyD, t50);
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve (NULL, 5, Parameters); //5 = more smoother than 4
cmsHPROFILE oprofdef = cmsCreateRGBProfileTHR (NULL, &xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile
cmsFreeToneCurve(GammaTRC[0]);
cmsFreeToneCurve (GammaTRC[0]);
if (oprofdef) {
@@ -543,9 +543,9 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float* rL = lab->L[i];
float* ra = lab->a[i];
float* rb = lab->b[i];
short* xa = (short*)image->r(i - cy);
short* ya = (short*)image->g(i - cy);
short* za = (short*)image->b(i - cy);
short* xa = (short*)image->r (i - cy);
short* ya = (short*)image->g (i - cy);
short* za = (short*)image->b (i - cy);
for (int j = cx; j < cx + cw; j++) {
@@ -554,18 +554,18 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float)Color::f2xyz(fx) * Color::D50x;
float x_ = 65535.0f * (float)Color::f2xyz (fx) * Color::D50x;
// float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float)Color::f2xyz(fz) * Color::D50z;
float z_ = 65535.0f * (float)Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa;
xa[j - cx] = CLIP((int) round(x_)) ;
ya[j - cx] = CLIP((int) round(y_));
za[j - cx] = CLIP((int) round(z_));
xa[j - cx] = CLIP ((int) round (x_)) ;
ya[j - cx] = CLIP ((int) round (y_));
za[j - cx] = CLIP ((int) round (z_));
if(bw && y_ < 65535.f) { //force Bw value and take highlight into account
xa[j - cx] = (int) round(y_ * Color::D50x);
za[j - cx] = (int) round(y_ * Color::D50z);
if (bw && y_ < 65535.f) { //force Bw value and take highlight into account
xa[j - cx] = (int) round (y_ * Color::D50x);
za[j - cx] = (int) round (y_ * Color::D50z);
}
}
@@ -576,8 +576,8 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprofdef, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE);
lcmsMutex->unlock ();
image->ExecCMSTransform(hTransform);
cmsDeleteTransform(hTransform);
image->ExecCMSTransform (hTransform);
cmsDeleteTransform (hTransform);
} else {
//
#pragma omp parallel for if (multiThread)
@@ -594,16 +594,16 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x;
float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z;
float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B);
Color::xyz2srgb (x_, y_, z_, R, G, 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)];
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)];
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff