Merge rec2020 into master

This commit is contained in:
Desmis
2016-04-30 15:39:59 +02:00
7 changed files with 360 additions and 301 deletions

Binary file not shown.

View File

@@ -83,6 +83,26 @@ const double prophoto_xyz[3][3] = {{1.3459433, -0.2556075, -0.0511118},
{ -0.5445989, 1.5081673, 0.0205351}, { -0.5445989, 1.5081673, 0.0205351},
{0.0000000, 0.0000000, 1.2118128} {0.0000000, 0.0000000, 1.2118128}
}; };
/*
const double xyz_rec2020[3][3] = {{0.636958, 0.144617, 0.168881},
{0.262700, 0.677998, 0.059302},
{0.0000000, 0.028073, 1.060985}
};
const double rec2020_xyz[3][3] = {{1.716651, -0.355671, -0.253366},
{ -0.666684, 1.616481, 0.015769},
{0.017640, -0.042771, 0.942103}
};
*/
const double xyz_rec2020[3][3] = {{0.6734241, 0.1656411, 0.1251286},
{0.2790177, 0.6753402, 0.0456377},
{ -0.0019300, 0.0299784, 0.7973330}
};
const double rec2020_xyz[3][3] = {{1.6473376, -0.3935675, -0.2359961},
{ -0.6826036, 1.6475887, 0.0128190},
{0.0296524, -0.0628993, 1.2531279}
};
const double xyz_widegamut[3][3] = {{0.7161046, 0.1009296, 0.1471858}, const double xyz_widegamut[3][3] = {{0.7161046, 0.1009296, 0.1471858},
{0.2581874, 0.7249378, 0.0168748}, {0.2581874, 0.7249378, 0.0168748},

View File

@@ -41,8 +41,9 @@ void loadProfiles (const Glib::ustring& dirName,
std::map<Glib::ustring, Glib::ustring>* profileNames, std::map<Glib::ustring, Glib::ustring>* profileNames,
bool nameUpper, bool onlyRgb) bool nameUpper, bool onlyRgb)
{ {
if (dirName.empty ()) if (dirName.empty ()) {
return; return;
}
try { try {
@@ -52,23 +53,27 @@ void loadProfiles (const Glib::ustring& dirName,
const Glib::ustring fileName = *entry; const Glib::ustring fileName = *entry;
if (fileName.size () < 4) if (fileName.size () < 4) {
continue; continue;
}
const Glib::ustring extension = fileName.substr (fileName.size () - 4).casefold (); 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; continue;
}
const Glib::ustring filePath = Glib::build_filename (dirName, fileName); 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; continue;
}
Glib::ustring name = fileName.substr (0, fileName.size() - 4); Glib::ustring name = fileName.substr (0, fileName.size() - 4);
if (nameUpper) if (nameUpper) {
name = name.uppercase (); name = name.uppercase ();
}
if (profiles) { if (profiles) {
const rtengine::ProfileContent content (filePath); const rtengine::ProfileContent content (filePath);
@@ -77,28 +82,31 @@ void loadProfiles (const Glib::ustring& dirName,
if (profile && (!onlyRgb || cmsGetColorSpace (profile) == cmsSigRgbData)) { if (profile && (!onlyRgb || cmsGetColorSpace (profile) == cmsSigRgbData)) {
profiles->insert (std::make_pair (name, profile)); profiles->insert (std::make_pair (name, profile));
if (profileContents) if (profileContents) {
profileContents->insert (std::make_pair (name, content)); profileContents->insert (std::make_pair (name, content));
} }
} }
}
if (profileNames) if (profileNames) {
profileNames->insert (std::make_pair (name, filePath)); 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) 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; result |= 1 << intent;
}
} }
inline std::uint8_t getSupportedIntents (cmsHPROFILE profile, cmsUInt32Number direction) inline std::uint8_t getSupportedIntents (cmsHPROFILE profile, cmsUInt32Number direction)
{ {
if (!profile) if (!profile) {
return 0; return 0;
}
std::uint8_t result = 0; std::uint8_t result = 0;
@@ -116,9 +124,9 @@ inline cmsHPROFILE createXYZProfile ()
return rtengine::ICCStore::createFromMatrix (mat, false, "XYZ"); return rtengine::ICCStore::createFromMatrix (mat, false, "XYZ");
} }
const double (*wprofiles[])[3] = {xyz_sRGB, xyz_adobe, xyz_prophoto, xyz_widegamut, xyz_bruce, xyz_beta, xyz_best}; const double (*wprofiles[])[3] = {xyz_sRGB, xyz_adobe, xyz_prophoto, xyz_widegamut, xyz_bruce, xyz_beta, xyz_best, xyz_rec2020};
const double (*iwprofiles[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz, bruce_xyz, beta_xyz, best_xyz}; const double (*iwprofiles[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz, bruce_xyz, beta_xyz, best_xyz, rec2020_xyz};
const char* wpnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB"}; const char* wpnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB", "Rec2020"};
const char* wpgamma[] = {"default", "BT709_g2.2_s4.5", "sRGB_g2.4_s12.92", "linear_g1.0", "standard_g2.2", "standard_g1.8", "High_g1.3_s3.35", "Low_g2.6_s6.9"}; //gamma free const char* wpgamma[] = {"default", "BT709_g2.2_s4.5", "sRGB_g2.4_s12.92", "linear_g1.0", "standard_g2.2", "standard_g1.8", "High_g1.3_s3.35", "Low_g2.6_s6.9"}; //gamma free
//default = gamma inside profile //default = gamma inside profile
//BT709 g=2.22 s=4.5 sRGB g=2.4 s=12.92 //BT709 g=2.22 s=4.5 sRGB g=2.4 s=12.92
@@ -163,8 +171,9 @@ std::vector<Glib::ustring> ICCStore::getProfiles () const
std::vector<Glib::ustring> res; 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); res.push_back (profile->first);
}
return res; return res;
} }
@@ -181,8 +190,9 @@ std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& di
loadProfiles (profilesDir, &profiles, NULL, NULL, false, true); loadProfiles (profilesDir, &profiles, NULL, NULL, false, true);
loadProfiles (dirName, &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); res.push_back (profile->first);
}
return res; return res;
} }
@@ -388,22 +398,25 @@ cmsHPROFILE ICCStore::getStdProfile (const Glib::ustring& name) const
const ProfileMap::const_iterator r = fileStdProfiles.find (nameUpper); const ProfileMap::const_iterator r = fileStdProfiles.find (nameUpper);
// return profile from store // return profile from store
if (r != fileStdProfiles.end ()) if (r != fileStdProfiles.end ()) {
return r->second; return r->second;
}
// profile is not yet in store // profile is not yet in store
const NameMap::const_iterator f = fileStdProfilesFileNames.find (nameUpper); const NameMap::const_iterator f = fileStdProfilesFileNames.find (nameUpper);
// profile does not exist // profile does not exist
if (f == fileStdProfilesFileNames.end ()) if (f == fileStdProfilesFileNames.end ()) {
return NULL; return NULL;
}
// but there exists one => load it // but there exists one => load it
const ProfileContent content (f->second); const ProfileContent content (f->second);
const cmsHPROFILE profile = content.toProfile (); const cmsHPROFILE profile = content.toProfile ();
if (profile) if (profile) {
const_cast<ProfileMap&>(fileStdProfiles).insert (std::make_pair (f->first, 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 // 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);
@@ -481,6 +494,7 @@ void ICCStore::findDefaultMonitorProfile ()
defaultMonitorProfile = Glib::ustring(profileName); defaultMonitorProfile = Glib::ustring(profileName);
defaultMonitorProfile = Glib::path_get_basename(defaultMonitorProfile); defaultMonitorProfile = Glib::path_get_basename(defaultMonitorProfile);
size_t pos = defaultMonitorProfile.rfind("."); size_t pos = defaultMonitorProfile.rfind(".");
if (pos != Glib::ustring::npos) { if (pos != Glib::ustring::npos) {
defaultMonitorProfile = defaultMonitorProfile.substr(0, pos); defaultMonitorProfile = defaultMonitorProfile.substr(0, pos);
} }

View File

@@ -429,6 +429,14 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
p5 = 0.1300; p5 = 0.1300;
p6 = 0.0350; p6 = 0.0350;
select_temp = 1; select_temp = 1;
} else if (profi == "Rec2020") {
p1 = 0.7080; // Rec2020 primaries
p2 = 0.2920;
p3 = 0.1700;
p4 = 0.7970;
p5 = 0.1310;
p6 = 0.0460;
select_temp = 2;
} else { } else {
p1 = 0.7347; //ProPhoto and default primaries p1 = 0.7347; //ProPhoto and default primaries
p2 = 0.2653; p2 = 0.2653;
@@ -511,7 +519,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 t50 = 5003; // for Widegamut, Prophoto Best, Beta D50
} else if (select_temp == 2) { } else if (select_temp == 2) {
t50 = 6504; // for sRGB, AdobeRGB, Bruce D65 t50 = 6504; // for sRGB, AdobeRGB, Bruce Rec2020 D65
} }
cmsCIExyY xyD; cmsCIExyY xyD;

View File

@@ -56,6 +56,7 @@ public:
Glib::ustring bruce; // default name of Bruce Glib::ustring bruce; // default name of Bruce
Glib::ustring srgb; // default name of SRGB space profile Glib::ustring srgb; // default name of SRGB space profile
Glib::ustring srgb10; // default name of SRGB space profile Glib::ustring srgb10; // default name of SRGB space profile
Glib::ustring rec2020; // default name of rec2020
bool gamutICC; // no longer used bool gamutICC; // no longer used
bool gamutLch; bool gamutLch;

View File

@@ -293,6 +293,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
adjustr = 1.f / 1.3f; adjustr = 1.f / 1.3f;
} else if (params.icm.working == "WideGamut") { } else if (params.icm.working == "WideGamut") {
adjustr = 1.f / 1.1f; adjustr = 1.f / 1.1f;
} else if (params.icm.working == "Rec2020") {
adjustr = 1.f / 1.1f;
} else if (params.icm.working == "Beta RGB") { } else if (params.icm.working == "Beta RGB") {
adjustr = 1.f / 1.2f; adjustr = 1.f / 1.2f;
} else if (params.icm.working == "BestRGB") { } else if (params.icm.working == "BestRGB") {
@@ -532,6 +534,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
adjustr = 1.f / 1.3f; adjustr = 1.f / 1.3f;
} else if (params.icm.working == "WideGamut") { } else if (params.icm.working == "WideGamut") {
adjustr = 1.f / 1.1f; adjustr = 1.f / 1.1f;
} else if (params.icm.working == "Rec2020") {
adjustr = 1.f / 1.1f;
} else if (params.icm.working == "Beta RGB") { } else if (params.icm.working == "Beta RGB") {
adjustr = 1.f / 1.2f; adjustr = 1.f / 1.2f;
} else if (params.icm.working == "BestRGB") { } else if (params.icm.working == "BestRGB") {
@@ -1177,11 +1181,11 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
useLCMS = false; useLCMS = false;
bool pro = false; bool pro = false;
Glib::ustring chpro, outProfile; Glib::ustring chpro, outProfile;
bool present_space[9] = {false, false, false, false, false, false, false, false, false}; bool present_space[10] = {false, false, false, false, false, false, false, false, false, false};
std::vector<Glib::ustring> opnames = iccStore->getProfiles (); std::vector<Glib::ustring> opnames = iccStore->getProfiles ();
//test if files are in system //test if files are in system
for (int j = 0; j < 9; j++) { for (int j = 0; j < 10; j++) {
// one can modify "option" [Color Management] to adapt the profile's name if they are different for windows, MacOS, Linux ?? // one can modify "option" [Color Management] to adapt the profile's name if they are different for windows, MacOS, Linux ??
// some of them are actually provided by RT, thanks to Jacques Desmis // some of them are actually provided by RT, thanks to Jacques Desmis
if (j == 0) { if (j == 0) {
@@ -1202,6 +1206,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
chpro = options.rtSettings.srgb10; //gamma 1.0 chpro = options.rtSettings.srgb10; //gamma 1.0
} else if(j == 8) { } else if(j == 8) {
chpro = options.rtSettings.prophoto10; //gamma 1.0 chpro = options.rtSettings.prophoto10; //gamma 1.0
} else if(j == 9) {
chpro = options.rtSettings.rec2020;
} }
for (unsigned int i = 0; i < opnames.size(); i++) { for (unsigned int i = 0; i < opnames.size(); i++) {
@@ -1241,6 +1247,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
outProfile = options.rtSettings.srgb10; outProfile = options.rtSettings.srgb10;
} else if (params.icm.working == "ProPhoto" && present_space[8] && pro) { } else if (params.icm.working == "ProPhoto" && present_space[8] && pro) {
outProfile = options.rtSettings.prophoto10; outProfile = options.rtSettings.prophoto10;
} else if (params.icm.working == "Rec2020" && present_space[9]) {
outProfile = options.rtSettings.rec2020;
} else { } else {
// Should not occurs // Should not occurs
if (settings->verbose) { if (settings->verbose) {

View File

@@ -644,6 +644,7 @@ void Options::setDefaults ()
rtSettings.bruce = "Bruce"; rtSettings.bruce = "Bruce";
rtSettings.beta = "BetaRGB"; rtSettings.beta = "BetaRGB";
rtSettings.best = "BestRGB"; rtSettings.best = "BestRGB";
rtSettings.rec2020 = "Rec2020";
rtSettings.verbose = false; rtSettings.verbose = false;
rtSettings.gamutICC = true; rtSettings.gamutICC = true;
rtSettings.gamutLch = true; rtSettings.gamutLch = true;
@@ -1542,6 +1543,10 @@ int Options::readFromFile (Glib::ustring fname)
rtSettings.best = keyFile.get_string("Color Management", "Best"); rtSettings.best = keyFile.get_string("Color Management", "Best");
} }
if( keyFile.has_key ("Color Management", "Rec2020")) {
rtSettings.rec2020 = keyFile.get_string("Color Management", "Rec2020");
}
if( keyFile.has_key ("Color Management", "Bruce")) { if( keyFile.has_key ("Color Management", "Bruce")) {
rtSettings.bruce = keyFile.get_string("Color Management", "Bruce"); rtSettings.bruce = keyFile.get_string("Color Management", "Bruce");
} }
@@ -1776,11 +1781,13 @@ int Options::readFromFile (Glib::ustring fname)
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str()); printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
} }
setDefaults (); setDefaults ();
} catch (...) { } catch (...) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str()); printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
} }
setDefaults (); setDefaults ();
} }
@@ -2033,6 +2040,7 @@ int Options::saveToFile (Glib::ustring fname)
keyFile.set_string ("Color Management", "sRGB10", rtSettings.srgb10); keyFile.set_string ("Color Management", "sRGB10", rtSettings.srgb10);
keyFile.set_string ("Color Management", "Beta", rtSettings.beta); keyFile.set_string ("Color Management", "Beta", rtSettings.beta);
keyFile.set_string ("Color Management", "Best", rtSettings.best); keyFile.set_string ("Color Management", "Best", rtSettings.best);
keyFile.set_string ("Color Management", "Rec2020", rtSettings.rec2020);
keyFile.set_string ("Color Management", "Bruce", rtSettings.bruce); keyFile.set_string ("Color Management", "Bruce", rtSettings.bruce);
keyFile.set_integer ("Color Management", "WhiteBalanceSpotSize", whiteBalanceSpotSize); keyFile.set_integer ("Color Management", "WhiteBalanceSpotSize", whiteBalanceSpotSize);
keyFile.set_boolean ("Color Management", "GamutICC", rtSettings.gamutICC); keyFile.set_boolean ("Color Management", "GamutICC", rtSettings.gamutICC);