Implement dcpprofiles/camera_model_aliases.json
(#4500)
This commit is contained in:
4
rtdata/dcpprofiles/camera_model_aliases.json
Normal file
4
rtdata/dcpprofiles/camera_model_aliases.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Canon EOS 600D": ["Canon EOS Kiss X5", "Canon EOS Rebel T3i"],
|
||||||
|
"Canon EOS 1300D": ["Canon EOS Kiss X80", "Canon EOS Rebel T6"]
|
||||||
|
}
|
@@ -1,3 +0,0 @@
|
|||||||
Canon EOS 600D;Canon EOS Kiss X5;Canon EOS Rebel T3i
|
|
||||||
Canon EOS 1300D;Canon EOS Kiss X80;Canon EOS Rebel T6
|
|
||||||
MINOLTA DYNAX 7D;MINOLTA MAXXUM 7D;MINOLTA ALPHA 7D;MINOLTA ALPHA SWEET
|
|
@@ -18,13 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "dcp.h"
|
#include "dcp.h"
|
||||||
|
|
||||||
|
#include "cJSON.h"
|
||||||
#include "iccmatrices.h"
|
#include "iccmatrices.h"
|
||||||
#include "iccstore.h"
|
#include "iccstore.h"
|
||||||
#include "rawimagesource.h"
|
|
||||||
#include "improcfun.h"
|
#include "improcfun.h"
|
||||||
|
#include "rawimagesource.h"
|
||||||
#include "rt_math.h"
|
#include "rt_math.h"
|
||||||
|
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
@@ -382,6 +386,53 @@ double xyCoordToTemperature(const std::array<double, 2>& white_xy)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::string> getAliases(const Glib::ustring& profile_dir)
|
||||||
|
{
|
||||||
|
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"),
|
||||||
|
[](std::FILE* file)
|
||||||
|
{
|
||||||
|
std::fclose(file);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fseek(file.get(), 0, SEEK_END);
|
||||||
|
const long length = std::ftell(file.get());
|
||||||
|
if (length <= 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<char[]> buffer(new char[length + 1]);
|
||||||
|
std::fseek(file.get(), 0, SEEK_SET);
|
||||||
|
std::fread(buffer.get(), 1, length, file.get());
|
||||||
|
buffer[length] = 0;
|
||||||
|
|
||||||
|
std::unique_ptr<cJSON> root(cJSON_Parse(buffer.get()));
|
||||||
|
if (!root || !root->child) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::string> res;
|
||||||
|
|
||||||
|
for (cJSON* camera = root->child; camera; camera = camera->next) {
|
||||||
|
if (cJSON_IsArray(camera)) {
|
||||||
|
const std::size_t array_size = cJSON_GetArraySize(camera);
|
||||||
|
for (std::size_t index = 0; index < array_size; ++index) {
|
||||||
|
const cJSON* const alias = cJSON_GetArrayItem(camera, index);
|
||||||
|
if (cJSON_IsString(alias)) {
|
||||||
|
res[alias->valuestring] = camera->string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DCPProfile::ApplyState::Data {
|
struct DCPProfile::ApplyState::Data {
|
||||||
@@ -953,9 +1004,7 @@ DCPProfile::DCPProfile(const Glib::ustring& filename) :
|
|||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCPProfile::~DCPProfile()
|
DCPProfile::~DCPProfile() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DCPProfile::operator bool() const
|
DCPProfile::operator bool() const
|
||||||
{
|
{
|
||||||
@@ -1721,7 +1770,6 @@ DCPStore* DCPStore::getInstance()
|
|||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DCPStore::~DCPStore()
|
DCPStore::~DCPStore()
|
||||||
{
|
{
|
||||||
for (auto &p : profile_cache) {
|
for (auto &p : profile_cache) {
|
||||||
@@ -1729,7 +1777,6 @@ DCPStore::~DCPStore()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
||||||
{
|
{
|
||||||
MyMutex::MyLock lock(mutex);
|
MyMutex::MyLock lock(mutex);
|
||||||
@@ -1748,7 +1795,7 @@ void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
|||||||
|
|
||||||
while (!dirs.empty()) {
|
while (!dirs.empty()) {
|
||||||
// Process directory
|
// Process directory
|
||||||
Glib::ustring dirname = dirs.back();
|
const Glib::ustring dirname = dirs.back();
|
||||||
dirs.pop_back();
|
dirs.pop_back();
|
||||||
|
|
||||||
std::unique_ptr<Glib::Dir> dir;
|
std::unique_ptr<Glib::Dir> dir;
|
||||||
@@ -1784,6 +1831,16 @@ void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& alias : getAliases(rt_profile_dir)) {
|
||||||
|
const Glib::ustring alias_name = Glib::ustring(alias.first).uppercase();
|
||||||
|
const Glib::ustring real_name = Glib::ustring(alias.second).uppercase();
|
||||||
|
const std::map<Glib::ustring, Glib::ustring>::const_iterator real = file_std_profiles.find(real_name);
|
||||||
|
|
||||||
|
if (real != file_std_profiles.end()) {
|
||||||
|
file_std_profiles[alias_name] = real->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user