"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "rtengine/dcp.cc" between
rawtherapee-5.6.tar.xz and rawtherapee-5.7.tar.xz

About: RawTherapee is a powerful cross-platform raw image processing program.

dcp.cc  (rawtherapee-5.6.tar.xz):dcp.cc  (rawtherapee-5.7.tar.xz)
skipping to change at line 17 skipping to change at line 17
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* RawTherapee is distributed in the hope that it will be useful, * RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. * along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include "dcp.h" #include "dcp.h"
#include "cJSON.h" #include "cJSON.h"
skipping to change at line 337 skipping to change at line 337
}; };
double res = 0; double res = 0;
// Convert to uv space. // Convert to uv space.
double u = 2.0 * white_xy[0] / (1.5 - white_xy[0] + 6.0 * white_xy[1]); double u = 2.0 * white_xy[0] / (1.5 - white_xy[0] + 6.0 * white_xy[1]);
double v = 3.0 * white_xy[1] / (1.5 - white_xy[0] + 6.0 * white_xy[1]); double v = 3.0 * white_xy[1] / (1.5 - white_xy[0] + 6.0 * white_xy[1]);
// Search for line pair coordinate is between. // Search for line pair coordinate is between.
double last_dt = 0.0; double last_dt = 0.0;
double last_dv = 0.0;
double last_du = 0.0;
for (uint32_t index = 1; index <= 30; ++index) { for (uint32_t index = 1; index <= 30; ++index) {
// Convert slope to delta-u and delta-v, with length 1. // Convert slope to delta-u and delta-v, with length 1.
double du = 1.0; double du = 1.0;
double dv = temp_table[index].t; double dv = temp_table[index].t;
double len = sqrt(1.0 + dv * dv); double len = sqrt(1.0 + dv * dv);
du /= len; du /= len;
dv /= len; dv /= len;
// Find delta from black body point to test coordinate. // Find delta from black body point to test coordinate.
skipping to change at line 374 skipping to change at line 372
double f; double f;
if (index == 1) { if (index == 1) {
f = 0.0; f = 0.0;
} else { } else {
f = dt / (last_dt + dt); f = dt / (last_dt + dt);
} }
// Interpolate the temperature. // Interpolate the temperature.
res = 1.0e6 / (temp_table[index - 1].r * f + temp_table[index].r * ( 1.0 - f)); res = 1.0e6 / (temp_table[index - 1].r * f + temp_table[index].r * ( 1.0 - f));
// Find delta from black body point to test coordinate.
uu = u - (temp_table [index - 1].u * f + temp_table [index].u * (1.0
- f));
vv = v - (temp_table [index - 1].v * f + temp_table [index].v * (1.0
- f));
// Interpolate vectors along slope.
du = du * (1.0 - f) + last_du * f;
dv = dv * (1.0 - f) + last_dv * f;
len = sqrt (du * du + dv * dv);
du /= len;
dv /= len;
break; break;
} }
// Try next line pair. // Try next line pair.
last_dt = dt; last_dt = dt;
last_du = du;
last_dv = dv;
} }
return res; return res;
} }
std::map<std::string, std::string> getAliases(const Glib::ustring& profile_dir) std::map<std::string, std::string> getAliases(const Glib::ustring& profile_dir)
{ {
const std::unique_ptr<std::FILE, std::function<void (std::FILE*)>> file( const std::unique_ptr<std::FILE, std::function<void (std::FILE*)>> file(
g_fopen(Glib::build_filename(profile_dir, "camera_model_aliases.json").c _str(), "rb"), g_fopen(Glib::build_filename(profile_dir, "camera_model_aliases.json").c _str(), "rb"),
[](std::FILE* file) [](std::FILE* file)
skipping to change at line 1836 skipping to change at line 1822
if (!Glib::file_test(fname, Glib::FILE_TEST_IS_DIR)) { if (!Glib::file_test(fname, Glib::FILE_TEST_IS_DIR)) {
// File // File
const auto lastdot = sname.rfind('.'); const auto lastdot = sname.rfind('.');
if ( if (
lastdot != Glib::ustring::npos lastdot != Glib::ustring::npos
&& lastdot <= sname.size() - 4 && lastdot <= sname.size() - 4
&& !sname.casefold().compare(lastdot, 4, ".dcp") && !sname.casefold().compare(lastdot, 4, ".dcp")
) { ) {
const Glib::ustring cam_short_name = sname.substr(0, lastdot file_std_profiles[sname.substr(0, lastdot).casefold_collate_
).uppercase(); key()] = fname; // They will be loaded and cached on demand
file_std_profiles[cam_short_name] = fname; // They will be l
oaded and cached on demand
} }
} else { } else {
// Directory // Directory
dirs.push_front(fname); dirs.push_front(fname);
} }
} }
} }
for (const auto& alias : getAliases(rt_profile_dir)) { for (const auto& alias : getAliases(rt_profile_dir)) {
const Glib::ustring alias_name = Glib::ustring(alias.first).uppercas e(); const Glib::ustring alias_name = Glib::ustring(alias.first).uppercas e();
const Glib::ustring real_name = Glib::ustring(alias.second).uppercas const std::map<std::string, Glib::ustring>::const_iterator real = fi
e(); le_std_profiles.find(Glib::ustring(alias.second).casefold_collate_key());
const std::map<Glib::ustring, Glib::ustring>::const_iterator real =
file_std_profiles.find(real_name);
if (real != file_std_profiles.end()) { if (real != file_std_profiles.end()) {
file_std_profiles[alias_name] = real->second; file_std_profiles[alias_name.casefold_collate_key()] = real->sec ond;
} }
} }
} }
bool DCPStore::isValidDCPFileName(const Glib::ustring& filename) const bool DCPStore::isValidDCPFileName(const Glib::ustring& filename) const
{ {
if (!Glib::file_test(filename, Glib::FILE_TEST_EXISTS) || Glib::file_test(fi lename, Glib::FILE_TEST_IS_DIR)) { if (!Glib::file_test(filename, Glib::FILE_TEST_EXISTS) || Glib::file_test(fi lename, Glib::FILE_TEST_IS_DIR)) {
return false; return false;
} }
skipping to change at line 1874 skipping to change at line 1858
return return
pos > 0 pos > 0
&& ( && (
!filename.casefold().compare(pos, 4, ".dcp") !filename.casefold().compare(pos, 4, ".dcp")
|| !filename.casefold().compare(pos, 4, ".dng") || !filename.casefold().compare(pos, 4, ".dng")
); );
} }
DCPProfile* DCPStore::getProfile(const Glib::ustring& filename) const DCPProfile* DCPStore::getProfile(const Glib::ustring& filename) const
{ {
const auto key = filename.casefold_collate_key();
MyMutex::MyLock lock(mutex); MyMutex::MyLock lock(mutex);
const std::map<std::string, DCPProfile*>::const_iterator iter = profile_cach e.find(key);
const std::map<Glib::ustring, DCPProfile*>::iterator r = profile_cache.find( if (iter != profile_cache.end()) {
filename); return iter->second;
if (r != profile_cache.end()) {
return r->second;
} }
DCPProfile* const res = new DCPProfile(filename); DCPProfile* const res = new DCPProfile(filename);
if (res->isValid()) { if (res->isValid()) {
// Add profile // Add profile
profile_cache[filename] = res; profile_cache[key] = res;
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("DCP profile '%s' loaded from disk\n", filename.c_str()); printf("DCP profile '%s' loaded from disk\n", filename.c_str());
} }
return res; return res;
} }
delete res; delete res;
return nullptr; return nullptr;
} }
DCPProfile* DCPStore::getStdProfile(const Glib::ustring& requested_cam_short_nam e) const DCPProfile* DCPStore::getStdProfile(const Glib::ustring& requested_cam_short_nam e) const
{ {
const Glib::ustring name = requested_cam_short_name.uppercase(); const std::map<std::string, Glib::ustring>::const_iterator iter = file_std_p
rofiles.find(requested_cam_short_name.casefold_collate_key());
// Warning: do NOT use map.find(), since it does not seem to work reliably h if (iter != file_std_profiles.end()) {
ere return getProfile(iter->second);
for (const auto& file_std_profile : file_std_profiles) {
if (file_std_profile.first == name) {
return getProfile(file_std_profile.second);
}
} }
// profile not found, looking if we're in loadAll=false mode // profile not found, looking if we're in loadAll=false mode
for (const auto &dir : profileDir) { for (const auto &dir : profileDir) {
if (!dir.empty()) { if (!dir.empty()) {
const Glib::ustring fname = Glib::build_filename(dir, requested_cam_ short_name + Glib::ustring(".dcp")); const Glib::ustring fname = Glib::build_filename(dir, requested_cam_ short_name + Glib::ustring(".dcp"));
if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) { if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
return getProfile(fname); return getProfile(fname);
} }
 End of changes. 12 change blocks. 
40 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)