Merge pull request #5684 from Beep6581/camconst_review (with @heckflosse's permission)

camconst.cc/h : code review
This commit is contained in:
Floessie 2020-03-09 13:13:55 +01:00 committed by GitHub
commit 5e4dc51c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 186 additions and 344 deletions

View File

@ -2,20 +2,25 @@
* This file is part of RawTherapee. * This file is part of RawTherapee.
*/ */
#include "camconst.h" #include "camconst.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <cassert>
#include <memory>
#include <vector>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include "settings.h" #include "settings.h"
#include "rt_math.h" #include "rt_math.h"
#include <cstdio>
#include <cstring>
// cJSON is a very minimal JSON parser lib in C, not for threaded stuff etc, so if we're going to use JSON more than just // cJSON is a very minimal JSON parser lib in C, not for threaded stuff etc, so if we're going to use JSON more than just
// here we should probably replace cJSON with something beefier. // here we should probably replace cJSON with something beefier.
#include "cJSON.h" #include "cJSON.h"
#include <errno.h>
#include <assert.h>
#include <inttypes.h>
namespace rtengine namespace rtengine
{ {
@ -30,66 +35,70 @@ CameraConst::CameraConst() : pdafOffset(0)
} }
bool bool CameraConst::parseApertureScaling(CameraConst *cc, const void *ji_)
CameraConst::parseApertureScaling(CameraConst *cc, void *ji_)
{ {
cJSON *ji = (cJSON *)ji_; const cJSON *ji = static_cast<const cJSON *>(ji_);
if (ji->type != cJSON_Array) { if (ji->type != cJSON_Array) {
fprintf(stderr, "\"ranges\":\"aperture_scaling\" must be an array\n"); fprintf(stderr, "\"ranges\":\"aperture_scaling\" must be an array\n");
return false; return false;
} }
for (ji = ji->child; ji != nullptr; ji = ji->next) { for (ji = ji->child; ji; ji = ji->next) {
cJSON *js = cJSON_GetObjectItem(ji, "aperture"); const cJSON *js = cJSON_GetObjectItem(ji, "aperture");
if (!js) { if (!js) {
fprintf(stderr, "missing \"ranges\":\"aperture_scaling\":\"aperture\" object item.\n"); fprintf(stderr, "missing \"ranges\":\"aperture_scaling\":\"aperture\" object item.\n");
return false; return false;
} else if (js->type != cJSON_Number) { }
if (js->type != cJSON_Number) {
fprintf(stderr, "\"ranges\":\"aperture_scaling\":\"aperture\" must be a number.\n"); fprintf(stderr, "\"ranges\":\"aperture_scaling\":\"aperture\" must be a number.\n");
return false; return false;
} }
float aperture = (float)js->valuedouble; const float aperture = js->valuedouble;
js = cJSON_GetObjectItem(ji, "scale_factor"); js = cJSON_GetObjectItem(ji, "scale_factor");
if (!js) { if (!js) {
fprintf(stderr, "missing \"ranges\":\"aperture_scaling\":\"scale_factor\" object item.\n"); fprintf(stderr, "missing \"ranges\":\"aperture_scaling\":\"scale_factor\" object item.\n");
return false; return false;
} else if (js->type != cJSON_Number) { }
if (js->type != cJSON_Number) {
fprintf(stderr, "\"ranges\":\"aperture_scaling\":\"scale_factor\" must be a number.\n"); fprintf(stderr, "\"ranges\":\"aperture_scaling\":\"scale_factor\" must be a number.\n");
return false; return false;
} }
float scale_factor = (float)js->valuedouble; const float scale_factor = js->valuedouble;
cc->mApertureScaling.insert(std::pair<float, float>(aperture, scale_factor)); cc->mApertureScaling.emplace(aperture, scale_factor);
} }
return true; return true;
} }
bool bool CameraConst::parseLevels(CameraConst *cc, int bw, const void *ji_)
CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_)
{ {
cJSON *ji = (cJSON *)ji_; const cJSON *ji = static_cast<const cJSON *>(ji_);
if (ji->type == cJSON_Number) { if (ji->type == cJSON_Number) {
struct camera_const_levels lvl; camera_const_levels lvl;
lvl.levels[0] = lvl.levels[1] = lvl.levels[2] = lvl.levels[3] = ji->valueint; lvl.levels[0] = lvl.levels[1] = lvl.levels[2] = lvl.levels[3] = ji->valueint;
cc->mLevels[bw].insert(std::pair<int, struct camera_const_levels>(0, lvl)); cc->mLevels[bw].emplace(0, lvl);
return true; return true;
} else if (ji->type != cJSON_Array) { }
if (ji->type != cJSON_Array) {
fprintf(stderr, "\"ranges\":\"%s\" must be a number or an array\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\" must be a number or an array\n", bw ? "white" : "black");
return false; return false;
} }
if (ji->child->type == cJSON_Number) { if (ji->child->type == cJSON_Number) {
struct camera_const_levels lvl; camera_const_levels lvl;
int i; int i;
cJSON *js; const cJSON *js;
for (js = ji->child, i = 0; js != nullptr && i < 4; js = js->next, i++) { for (js = ji->child, i = 0; js && i < 4; js = js->next, i++) {
lvl.levels[i] = js->valueint; lvl.levels[i] = js->valueint;
} }
@ -97,39 +106,36 @@ CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_)
lvl.levels[3] = lvl.levels[1]; // G2 = G1 lvl.levels[3] = lvl.levels[1]; // G2 = G1
} else if (i == 1) { } else if (i == 1) {
lvl.levels[3] = lvl.levels[2] = lvl.levels[1] = lvl.levels[0]; lvl.levels[3] = lvl.levels[2] = lvl.levels[1] = lvl.levels[0];
} else if (i != 4 || js != nullptr) { } else if (i != 4 || js) {
fprintf(stderr, "\"ranges\":\"%s\" array must have 1, 3 or 4 numbers.\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\" array must have 1, 3 or 4 numbers.\n", bw ? "white" : "black");
return false; return false;
} }
cc->mLevels[bw].insert(std::pair<int, struct camera_const_levels>(0, lvl)); cc->mLevels[bw].emplace(0, lvl);
return true; return true;
} }
for (ji = ji->child; ji != nullptr; ji = ji->next) { for (ji = ji->child; ji; ji = ji->next) {
int iso[1000] = { 0 }; const cJSON *js = cJSON_GetObjectItem(ji, "iso");
int iso_count = 0;
cJSON *js = cJSON_GetObjectItem(ji, "iso");
if (!js) { if (!js) {
fprintf(stderr, "missing \"ranges\":\"%s\":\"iso\" object item.\n", bw ? "white" : "black"); fprintf(stderr, "missing \"ranges\":\"%s\":\"iso\" object item.\n", bw ? "white" : "black");
return false; return false;
} else if (js->type == cJSON_Number) { }
iso[0] = js->valueint;
iso_count = 1;
} else if (js->type == cJSON_Array) {
int i;
for (js = js->child, i = 0; js != nullptr && i < 1000; js = js->next, i++) { std::vector<int> isos;
if (js->type == cJSON_Number) {
isos.push_back(js->valueint);
} else if (js->type == cJSON_Array) {
for (js = js->child; js; js = js->next) {
if (js->type != cJSON_Number) { if (js->type != cJSON_Number) {
fprintf(stderr, "\"ranges\":\"%s\":\"iso\" must be a number or an array of numbers.\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\":\"iso\" must be a number or an array of numbers.\n", bw ? "white" : "black");
return false; return false;
} }
iso[i] = js->valueint; isos.push_back(js->valueint);
} }
iso_count = i;
} else { } else {
fprintf(stderr, "\"ranges\":\"%s\":\"iso\" must be an array or a number.\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\":\"iso\" must be an array or a number.\n", bw ? "white" : "black");
return false; return false;
@ -142,14 +148,14 @@ CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_)
return false; return false;
} }
struct camera_const_levels lvl; camera_const_levels lvl;
if (js->type == cJSON_Number) { if (js->type == cJSON_Number) {
lvl.levels[0] = lvl.levels[1] = lvl.levels[2] = lvl.levels[3] = js->valueint; lvl.levels[0] = lvl.levels[1] = lvl.levels[2] = lvl.levels[3] = js->valueint;
} else if (js->type == cJSON_Array) { } else if (js->type == cJSON_Array) {
int i; int i;
for (js = js->child, i = 0; js != nullptr && i < 4; js = js->next, i++) { for (js = js->child, i = 0; js && i < 4; js = js->next, i++) {
if (js->type != cJSON_Number) { if (js->type != cJSON_Number) {
fprintf(stderr, "\"ranges\":\"%s\":\"levels\" must be a number or an array of numbers.\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\":\"levels\" must be a number or an array of numbers.\n", bw ? "white" : "black");
return false; return false;
@ -162,7 +168,7 @@ CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_)
lvl.levels[3] = lvl.levels[1]; // G2 = G1 lvl.levels[3] = lvl.levels[1]; // G2 = G1
} else if (i == 1) { } else if (i == 1) {
lvl.levels[3] = lvl.levels[2] = lvl.levels[1] = lvl.levels[0]; lvl.levels[3] = lvl.levels[2] = lvl.levels[1] = lvl.levels[0];
} else if (i != 4 || js != nullptr) { } else if (i != 4 || js) {
fprintf(stderr, "\"ranges\":\"%s\":\"levels\" array must have 1, 3 or 4 numbers.\n", bw ? "white" : "black"); fprintf(stderr, "\"ranges\":\"%s\":\"levels\" array must have 1, 3 or 4 numbers.\n", bw ? "white" : "black");
return false; return false;
} }
@ -171,40 +177,38 @@ CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_)
return false; return false;
} }
for (int i = 0; i < iso_count; i++) { for (auto iso : isos) {
cc->mLevels[bw].insert(std::pair<int, struct camera_const_levels>(iso[i], lvl)); cc->mLevels[bw].emplace(iso, lvl);
} }
} }
return true; return true;
} }
CameraConst * CameraConst* CameraConst::parseEntry(const void *cJSON_, const char *make_model)
CameraConst::parseEntry(void *cJSON_, const char *make_model)
{ {
cJSON *js, *ji, *jranges; const cJSON *js = static_cast<const cJSON*>(cJSON_);
js = (cJSON *)cJSON_;
CameraConst *cc = new CameraConst; std::unique_ptr<CameraConst> cc(new CameraConst);
cc->make_model = make_model; cc->make_model = make_model;
ji = cJSON_GetObjectItem(js, "dcraw_matrix"); const cJSON *ji = cJSON_GetObjectItem(js, "dcraw_matrix");
if (ji) { if (ji) {
if (ji->type != cJSON_Array) { if (ji->type != cJSON_Array) {
fprintf(stderr, "\"dcraw_matrix\" must be an array\n"); fprintf(stderr, "\"dcraw_matrix\" must be an array\n");
goto parse_error; return nullptr;
} }
int i; int i;
for (i = 0, ji = ji->child; i < 12 && ji != nullptr; i++, ji = ji->next) { for (i = 0, ji = ji->child; i < 12 && ji; i++, ji = ji->next) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"dcraw_matrix\" array must contain numbers\n"); fprintf(stderr, "\"dcraw_matrix\" array must contain numbers\n");
goto parse_error; return nullptr;
} }
cc->dcraw_matrix[i] = (short)ji->valueint; cc->dcraw_matrix[i] = ji->valueint;
} }
} }
@ -213,23 +217,23 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_Array) { if (ji->type != cJSON_Array) {
fprintf(stderr, "\"raw_crop\" must be an array\n"); fprintf(stderr, "\"raw_crop\" must be an array\n");
goto parse_error; return nullptr;
} }
int i; int i;
for (i = 0, ji = ji->child; i < 4 && ji != nullptr; i++, ji = ji->next) { for (i = 0, ji = ji->child; i < 4 && ji; i++, ji = ji->next) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"raw_crop\" array must contain numbers\n"); fprintf(stderr, "\"raw_crop\" array must contain numbers\n");
goto parse_error; return nullptr;
} }
cc->raw_crop[i] = ji->valueint; cc->raw_crop[i] = ji->valueint;
} }
if (i != 4 || ji != nullptr) { if (i != 4 || ji) {
fprintf(stderr, "\"raw_crop\" must contain 4 numbers\n"); fprintf(stderr, "\"raw_crop\" must contain 4 numbers\n");
goto parse_error; return nullptr;
} }
} }
@ -238,15 +242,15 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_Array) { if (ji->type != cJSON_Array) {
fprintf(stderr, "\"masked_areas\" must be an array\n"); fprintf(stderr, "\"masked_areas\" must be an array\n");
goto parse_error; return nullptr;
} }
int i; int i;
for (i = 0, ji = ji->child; i < 8 * 4 && ji != nullptr; i++, ji = ji->next) { for (i = 0, ji = ji->child; i < 2 * 4 && ji; i++, ji = ji->next) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"masked_areas\" array must contain numbers\n"); fprintf(stderr, "\"masked_areas\" array must contain numbers\n");
goto parse_error; return nullptr;
} }
cc->raw_mask[i / 4][i % 4] = ji->valueint; cc->raw_mask[i / 4][i % 4] = ji->valueint;
@ -254,27 +258,23 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (i % 4 != 0) { if (i % 4 != 0) {
fprintf(stderr, "\"masked_areas\" array length must be divisible by 4\n"); fprintf(stderr, "\"masked_areas\" array length must be divisible by 4\n");
goto parse_error; return nullptr;
} }
} }
jranges = cJSON_GetObjectItem(js, "ranges"); const cJSON *jranges = cJSON_GetObjectItem(js, "ranges");
if (jranges) { if (jranges) {
ji = cJSON_GetObjectItem(jranges, "black"); ji = cJSON_GetObjectItem(jranges, "black");
if (ji) { if (ji && !parseLevels(cc.get(), 0, ji)) {
if (!parseLevels(cc, 0, ji)) { return nullptr;
goto parse_error;
}
} }
ji = cJSON_GetObjectItem(jranges, "white"); ji = cJSON_GetObjectItem(jranges, "white");
if (ji) { if (ji && !parseLevels(cc.get(), 1, ji)) {
if (!parseLevels(cc, 1, ji)) { return nullptr;
goto parse_error;
}
} }
ji = cJSON_GetObjectItem(jranges, "white_max"); ji = cJSON_GetObjectItem(jranges, "white_max");
@ -282,32 +282,28 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"ranges\":\"white_max\" must be a number\n"); fprintf(stderr, "\"ranges\":\"white_max\" must be a number\n");
goto parse_error; return nullptr;
} }
cc->white_max = (int)ji->valueint; cc->white_max = ji->valueint;
} }
ji = cJSON_GetObjectItem(jranges, "aperture_scaling"); ji = cJSON_GetObjectItem(jranges, "aperture_scaling");
if (ji) { if (ji && !parseApertureScaling(cc.get(), ji)) {
if (!parseApertureScaling(cc, ji)) { return nullptr;
goto parse_error;
}
} }
} }
for (int bw = 0; bw < 2; bw++) { for (int bw = 0; bw < 2; bw++) {
struct camera_const_levels lvl; camera_const_levels lvl;
if (!cc->get_Levels(lvl, bw, 0, 0)) { if (!cc->get_Levels(lvl, bw, 0, 0)) {
std::map<int, struct camera_const_levels>::iterator it; const auto it = cc->mLevels[bw].cbegin();
it = cc->mLevels[bw].begin();
if (it != cc->mLevels[bw].end()) { if (it != cc->mLevels[bw].cend()) {
// insert levels with lowest iso as the default (iso 0) // insert levels with lowest iso as the default (iso 0)
struct camera_const_levels lvl = it->second; cc->mLevels[bw].emplace(0, it->second);
cc->mLevels[bw].insert(std::pair<int, struct camera_const_levels>(0, lvl));
} }
} }
} }
@ -317,13 +313,13 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_Array) { if (ji->type != cJSON_Array) {
fprintf(stderr, "\"pdaf_pattern\" must be an array\n"); fprintf(stderr, "\"pdaf_pattern\" must be an array\n");
goto parse_error; return nullptr;
} }
for (ji = ji->child; ji != nullptr; ji = ji->next) { for (ji = ji->child; ji; ji = ji->next) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"pdaf_pattern\" array must contain numbers\n"); fprintf(stderr, "\"pdaf_pattern\" array must contain numbers\n");
goto parse_error; return nullptr;
} }
cc->pdafPattern.push_back(ji->valueint); cc->pdafPattern.push_back(ji->valueint);
@ -335,7 +331,7 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_Number) { if (ji->type != cJSON_Number) {
fprintf(stderr, "\"pdaf_offset\" must contain a number\n"); fprintf(stderr, "\"pdaf_offset\" must contain a number\n");
goto parse_error; return nullptr;
} }
cc->pdafOffset = ji->valueint; cc->pdafOffset = ji->valueint;
@ -346,27 +342,21 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
if (ji) { if (ji) {
if (ji->type != cJSON_False && ji->type != cJSON_True) { if (ji->type != cJSON_False && ji->type != cJSON_True) {
fprintf(stderr, "\"global_green_equilibration\" must be a boolean\n"); fprintf(stderr, "\"global_green_equilibration\" must be a boolean\n");
goto parse_error; return nullptr;
} }
cc->globalGreenEquilibration = (ji->type == cJSON_True); cc->globalGreenEquilibration = (ji->type == cJSON_True);
} }
return cc; return cc.release();
parse_error:
delete cc;
return nullptr;
} }
bool bool CameraConst::has_dcrawMatrix() const
CameraConst::has_dcrawMatrix()
{ {
return dcraw_matrix[0] != 0; return dcraw_matrix[0] != 0;
} }
void void CameraConst::update_dcrawMatrix(const short *other)
CameraConst::update_dcrawMatrix(const short *other)
{ {
if (!other) { if (!other) {
return; return;
@ -377,8 +367,7 @@ CameraConst::update_dcrawMatrix(const short *other)
} }
} }
const short * const short* CameraConst::get_dcrawMatrix() const
CameraConst::get_dcrawMatrix()
{ {
if (!has_dcrawMatrix()) { if (!has_dcrawMatrix()) {
return nullptr; return nullptr;
@ -387,44 +376,35 @@ CameraConst::get_dcrawMatrix()
return dcraw_matrix; return dcraw_matrix;
} }
bool const std::vector<int>& CameraConst::get_pdafPattern() const
CameraConst::has_pdafPattern()
{
return pdafPattern.size() > 0;
}
std::vector<int>
CameraConst::get_pdafPattern()
{ {
return pdafPattern; return pdafPattern;
} }
void void CameraConst::update_pdafPattern(const std::vector<int> &other)
CameraConst::update_pdafPattern(const std::vector<int> &other)
{ {
if (other.empty()) { if (other.empty()) {
return; return;
} }
pdafPattern = other; pdafPattern = other;
} }
void void CameraConst::update_pdafOffset(int other)
CameraConst::update_pdafOffset(int other)
{ {
if (other == 0) { if (other == 0) {
return; return;
} }
pdafOffset = other; pdafOffset = other;
} }
bool bool CameraConst::has_rawCrop() const
CameraConst::has_rawCrop()
{ {
return raw_crop[0] != 0 || raw_crop[1] != 0 || raw_crop[2] != 0 || raw_crop[3] != 0; return raw_crop[0] != 0 || raw_crop[1] != 0 || raw_crop[2] != 0 || raw_crop[3] != 0;
} }
void void CameraConst::get_rawCrop(int& left_margin, int& top_margin, int& width, int& height) const
CameraConst::get_rawCrop(int& left_margin, int& top_margin, int& width, int& height)
{ {
left_margin = raw_crop[0]; left_margin = raw_crop[0];
top_margin = raw_crop[1]; top_margin = raw_crop[1];
@ -432,22 +412,20 @@ CameraConst::get_rawCrop(int& left_margin, int& top_margin, int& width, int& hei
height = raw_crop[3]; height = raw_crop[3];
} }
bool bool CameraConst::has_rawMask(int idx) const
CameraConst::has_rawMask(int idx)
{ {
if (idx < 0 || idx > 7) { if (idx < 0 || idx > 1) {
return false; return false;
} }
return (raw_mask[idx][0] | raw_mask[idx][1] | raw_mask[idx][2] | raw_mask[idx][3]) != 0; return (raw_mask[idx][0] | raw_mask[idx][1] | raw_mask[idx][2] | raw_mask[idx][3]) != 0;
} }
void void CameraConst::get_rawMask(int idx, int& top, int& left, int& bottom, int& right) const
CameraConst::get_rawMask(int idx, int& top, int& left, int& bottom, int& right)
{ {
top = left = bottom = right = 0; top = left = bottom = right = 0;
if (idx < 0 || idx > 7) { if (idx < 0 || idx > 1) {
return; return;
} }
@ -457,38 +435,30 @@ CameraConst::get_rawMask(int idx, int& top, int& left, int& bottom, int& right)
right = raw_mask[idx][3]; right = raw_mask[idx][3];
} }
void void CameraConst::update_Levels(const CameraConst *other)
CameraConst::update_Levels(const CameraConst *other)
{ {
if (!other) { if (!other) {
return; return;
} }
if (other->mLevels[0].size()) { if (!other->mLevels[0].empty()) {
mLevels[0].clear();
mLevels[0] = other->mLevels[0]; mLevels[0] = other->mLevels[0];
} }
if (other->mLevels[1].size()) { if (!other->mLevels[1].empty()) {
mLevels[1].clear();
mLevels[1] = other->mLevels[1]; mLevels[1] = other->mLevels[1];
} }
if (other->mApertureScaling.size()) { if (!other->mApertureScaling.empty()) {
mApertureScaling.clear();
mApertureScaling = other->mApertureScaling; mApertureScaling = other->mApertureScaling;
} }
if (other->white_max) { if (other->white_max) {
white_max = other->white_max; white_max = other->white_max;
} }
// for (std::map<int, struct camera_const_levels>::iterator i=other->mLevels[0].begin(); i!=other->mLevels[0].end(); i++) {
// }
} }
void void CameraConst::update_Crop(CameraConst *other)
CameraConst::update_Crop(CameraConst *other)
{ {
if (!other) { if (!other) {
return; return;
@ -499,18 +469,16 @@ CameraConst::update_Crop(CameraConst *other)
} }
} }
bool bool CameraConst::get_Levels(camera_const_levels & lvl, int bw, int iso, float fnumber) const
CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float fnumber)
{ {
std::map<int, struct camera_const_levels>::iterator it; std::map<int, camera_const_levels>::const_iterator it = mLevels[bw].find(iso);
it = mLevels[bw].find(iso);
if (it == mLevels[bw].end()) { if (it == mLevels[bw].end()) {
std::map<int, struct camera_const_levels>::iterator best_it = mLevels[bw].begin(); auto best_it = mLevels[bw].cbegin();
if (iso > 0) { if (iso > 0) {
for (it = mLevels[bw].begin(); it != mLevels[bw].end(); ++it) { for (it = mLevels[bw].begin(); it != mLevels[bw].end(); ++it) {
if (abs(it->first - iso) <= abs(best_it->first - iso)) { if (std::abs(it->first - iso) <= std::abs(best_it->first - iso)) {
best_it = it; best_it = it;
} else { } else {
break; break;
@ -527,35 +495,34 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float
lvl = it->second; lvl = it->second;
if (bw == 1 && fnumber > 0 && mApertureScaling.size() > 0) { if (bw == 1 && fnumber > 0 && !mApertureScaling.empty()) {
std::map<float, float>::iterator it; std::map<float, float>::const_iterator scaleIt = mApertureScaling.find(fnumber);
it = mApertureScaling.find(fnumber);
if (it == mApertureScaling.end()) { if (scaleIt == mApertureScaling.end()) {
// fnumber may be an exact aperture, eg 1.414, or a rounded eg 1.4. In our map we // fnumber may be an exact aperture, eg 1.414, or a rounded eg 1.4. In our map we
// should have rounded numbers so we translate and retry the lookup // should have rounded numbers so we translate and retry the lookup
// table with traditional 1/3 stop f-number rounding used by most cameras, we only // table with traditional 1/3 stop f-number rounding used by most cameras, we only
// have in the range 0.7 - 10.0, but aperture scaling rarely happen past f/4.0 // have in the range 0.7 - 10.0, but aperture scaling rarely happen past f/4.0
const float fn_tab[8][3] = { constexpr float fn_tab[8][3] = {
{ 0.7, 0.8, 0.9 }, { 0.7f, 0.8f, 0.9f },
{ 1.0, 1.1, 1.2 }, { 1.f, 1.1f, 1.2f },
{ 1.4, 1.6, 1.8 }, { 1.4f, 1.6f, 1.8f },
{ 2.0, 2.2, 2.5 }, { 2.f, 2.2f, 2.5f },
{ 2.8, 3.2, 3.5 }, { 2.8f, 3.2f, 3.5f },
{ 4.0, 4.5, 5.0 }, { 4.f, 4.5f, 5.f },
{ 5.6, 6.3, 7.1 }, { 5.6f, 6.3f, 7.1f },
{ 8.0, 9.0, 10.0 } { 8.f, 9.f, 10.f }
}; };
for (int avh = 0; avh < 8; avh++) { for (int avh = 0; avh < 8; avh++) {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
float av = (avh - 1) + (float)k / 3; const float av = (avh - 1) + k / 3.f;
float aperture = sqrtf(powf(2, av)); const float aperture = std::sqrt(std::pow(2.f, av));
if (fnumber > aperture * 0.97f && fnumber < aperture / 0.97f) { if (fnumber > aperture * 0.97f && fnumber < aperture / 0.97f) {
fnumber = fn_tab[avh][k]; fnumber = fn_tab[avh][k];
it = mApertureScaling.find(fnumber); scaleIt = mApertureScaling.find(fnumber);
avh = 7; avh = 7;
break; break;
} }
@ -563,20 +530,18 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float
} }
} }
float scaling = 1.0; float scaling = 1.f;
if (it == mApertureScaling.end()) { if (scaleIt == mApertureScaling.end()) {
std::map<float, float>::reverse_iterator it; for (auto entry = mApertureScaling.crbegin(); entry != mApertureScaling.crend(); ++entry) {
if (entry->first > fnumber) {
for (it = mApertureScaling.rbegin(); it != mApertureScaling.rend(); ++it) { scaling = entry->second;
if (it->first > fnumber) {
scaling = it->second;
} else { } else {
break; break;
} }
} }
} else { } else {
scaling = it->second; scaling = scaleIt->second;
} }
if (scaling > 1.f) { if (scaling > 1.f) {
@ -593,24 +558,22 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float
return true; return true;
} }
int int CameraConst::get_BlackLevel(const int idx, const int iso_speed) const
CameraConst::get_BlackLevel(const int idx, const int iso_speed)
{ {
assert(idx >= 0 && idx <= 3); assert(idx >= 0 && idx <= 3);
struct camera_const_levels lvl; camera_const_levels lvl;
if (!get_Levels(lvl, 0, iso_speed, 0.0)) { if (!get_Levels(lvl, 0, iso_speed, 0.f)) {
return -1; return -1;
} }
return lvl.levels[idx]; return lvl.levels[idx];
} }
int int CameraConst::get_WhiteLevel(const int idx, const int iso_speed, const float fnumber) const
CameraConst::get_WhiteLevel(const int idx, const int iso_speed, const float fnumber)
{ {
assert(idx >= 0 && idx <= 3); assert(idx >= 0 && idx <= 3);
struct camera_const_levels lvl; camera_const_levels lvl;
if (!get_Levels(lvl, 1, iso_speed, fnumber)) { if (!get_Levels(lvl, 1, iso_speed, fnumber)) {
return -1; return -1;
@ -619,48 +582,44 @@ CameraConst::get_WhiteLevel(const int idx, const int iso_speed, const float fnum
return lvl.levels[idx]; return lvl.levels[idx];
} }
bool bool CameraConst::has_globalGreenEquilibration() const
CameraConst::has_globalGreenEquilibration()
{ {
return globalGreenEquilibration >= 0; return globalGreenEquilibration >= 0;
} }
bool bool CameraConst::get_globalGreenEquilibration() const
CameraConst::get_globalGreenEquilibration()
{ {
return globalGreenEquilibration > 0; return globalGreenEquilibration > 0;
} }
void void CameraConst::update_globalGreenEquilibration(bool other)
CameraConst::update_globalGreenEquilibration(bool other)
{ {
globalGreenEquilibration = (other ? 1 : 0); globalGreenEquilibration = (other ? 1 : 0);
} }
bool bool CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_)
CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_)
{ {
// read the file into a single long string // read the file into a single long string
const char *filename = filename_.c_str(); const char *filename = filename_.c_str();
FILE *stream = fopen(filename, "rt"); FILE *stream = fopen(filename, "rt");
if (stream == nullptr) { if (!stream) {
fprintf(stderr, "Could not open camera constants file \"%s\": %s\n", filename, strerror(errno)); fprintf(stderr, "Could not open camera constants file \"%s\": %s\n", filename, strerror(errno));
return false; return false;
} }
size_t bufsize = 16384; size_t bufsize = 262144;
size_t increment = 2 * bufsize; size_t increment = bufsize;
size_t datasize = 0, ret; size_t datasize = 0, ret;
char *buf = (char *)malloc(bufsize); char *buf = (char *)malloc(bufsize);
while ((ret = fread(&buf[datasize], 1, bufsize - datasize, stream)) != 0) { while ((ret = fread(&buf[datasize], 1, bufsize - datasize - 1, stream)) != 0) {
datasize += ret; datasize += ret;
if (datasize == bufsize) { // we need more memory if (datasize == bufsize - 1) { // we need more memory
bufsize += increment; bufsize += increment;
void *temp = realloc(buf, bufsize); // try to realloc buffer with new size void *temp = realloc(buf, bufsize); // try to realloc buffer with new size
if(!temp) { // realloc failed if (!temp) { // realloc failed
temp = malloc(bufsize); // alloc now buffer temp = malloc(bufsize); // alloc now buffer
if (temp) { // alloc worked if (temp) { // alloc worked
memcpy(temp, buf, bufsize - increment); // copy old buffer content to new buffer memcpy(temp, buf, bufsize - increment); // copy old buffer content to new buffer
@ -683,17 +642,13 @@ CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_
fclose(stream); fclose(stream);
if(datasize == bufsize) {
buf = (char *)realloc(buf, datasize + 1);
}
buf[datasize] = '\0'; buf[datasize] = '\0';
// remove comments // remove comments
cJSON_Minify(buf); cJSON_Minify(buf);
// parse // parse
cJSON *jsroot = cJSON_Parse(buf); cJSON* const jsroot = cJSON_Parse(buf);
if (!jsroot) { if (!jsroot) {
char str[128]; char str[128];
@ -711,20 +666,16 @@ CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_
} }
free(buf); free(buf);
/*{
char *js_str = cJSON_Print(jsroot); const cJSON *js = cJSON_GetObjectItem(jsroot, "camera_constants");
printf("%s\n", js_str);
free(js_str);
}*/
cJSON *js = cJSON_GetObjectItem(jsroot, "camera_constants");
if (!js) { if (!js) {
fprintf(stderr, "missing \"camera_constants\" object item\n"); fprintf(stderr, "missing \"camera_constants\" object item\n");
goto parse_error; goto parse_error;
} }
for (js = js->child; js != nullptr; js = js->next) { for (js = js->child; js; js = js->next) {
cJSON *ji = cJSON_GetObjectItem(js, "make_model"); const cJSON *ji = cJSON_GetObjectItem(js, "make_model");
if (!ji) { if (!ji) {
fprintf(stderr, "missing \"make_model\" object item\n"); fprintf(stderr, "missing \"make_model\" object item\n");
@ -738,30 +689,30 @@ CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_
is_array = true; is_array = true;
} }
while (ji != nullptr) { while (ji) {
if (ji->type != cJSON_String) { if (ji->type != cJSON_String) {
fprintf(stderr, "\"make_model\" must be a string or an array of strings\n"); fprintf(stderr, "\"make_model\" must be a string or an array of strings\n");
goto parse_error; goto parse_error;
} }
CameraConst *cc = CameraConst::parseEntry((void *)js, ji->valuestring); CameraConst* const cc = CameraConst::parseEntry((const void *)js, ji->valuestring);
if (!cc) { if (!cc) {
goto parse_error; goto parse_error;
} }
Glib::ustring make_model(ji->valuestring); std::string make_model(ji->valuestring);
make_model = make_model.uppercase(); std::transform(make_model.begin(), make_model.end(), make_model.begin(), ::toupper);
const auto ret = mCameraConstants.emplace(make_model, cc); const auto entry = mCameraConstants.emplace(make_model, cc);
if(ret.second) { // entry inserted into map if (entry.second) { // entry inserted into map
if (settings->verbose) { if (settings->verbose) {
printf("Add camera constants for \"%s\"\n", make_model.c_str()); printf("Add camera constants for \"%s\"\n", make_model.c_str());
} }
} else { } else {
// The CameraConst already exist for this camera make/model -> we merge the values // The CameraConst already exist for this camera make/model -> we merge the values
CameraConst *existingcc = ret.first->second; CameraConst* const existingcc = entry.first->second;
// updating the dcraw matrix // updating the dcraw matrix
existingcc->update_dcrawMatrix(cc->get_dcrawMatrix()); existingcc->update_dcrawMatrix(cc->get_dcrawMatrix());
@ -813,29 +764,26 @@ void CameraConstantsStore::init(const Glib::ustring& baseDir, const Glib::ustrin
{ {
parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json"));
Glib::ustring userFile(Glib::build_filename(userSettingsDir, "camconst.json")); const Glib::ustring userFile(Glib::build_filename(userSettingsDir, "camconst.json"));
if (Glib::file_test(userFile, Glib::FILE_TEST_EXISTS)) { if (Glib::file_test(userFile, Glib::FILE_TEST_EXISTS)) {
parse_camera_constants_file(userFile); parse_camera_constants_file(userFile);
} }
} }
CameraConstantsStore * CameraConstantsStore* CameraConstantsStore::getInstance()
CameraConstantsStore::getInstance()
{ {
static CameraConstantsStore instance_; static CameraConstantsStore instance_;
return &instance_; return &instance_;
} }
CameraConst * const CameraConst* CameraConstantsStore::get(const char make[], const char model[]) const
CameraConstantsStore::get(const char make[], const char model[])
{ {
Glib::ustring key(make); std::string key(make);
key += " "; key += " ";
key += model; key += model;
key = key.uppercase(); std::transform(key.begin(), key.end(), key.begin(), ::toupper);
std::map<std::string, CameraConst *>::iterator it; const auto it = mCameraConstants.find(key);
it = mCameraConstants.find(key);
if (it == mCameraConstants.end()) { if (it == mCameraConstants.end()) {
return nullptr; return nullptr;

View File

@ -27,35 +27,34 @@ private:
std::string make_model; std::string make_model;
short dcraw_matrix[12]; short dcraw_matrix[12];
int raw_crop[4]; int raw_crop[4];
int raw_mask[8][4]; int raw_mask[2][4];
int white_max; int white_max;
std::map<int, struct camera_const_levels> mLevels[2]; std::map<int, camera_const_levels> mLevels[2];
std::map<float, float> mApertureScaling; std::map<float, float> mApertureScaling;
std::vector<int> pdafPattern; std::vector<int> pdafPattern;
int pdafOffset; int pdafOffset;
int globalGreenEquilibration; int globalGreenEquilibration;
CameraConst(); CameraConst();
static bool parseLevels(CameraConst *cc, int bw, void *ji); static bool parseLevels(CameraConst *cc, int bw, const void *ji);
static bool parseApertureScaling(CameraConst *cc, void *ji); static bool parseApertureScaling(CameraConst *cc, const void *ji);
bool get_Levels(struct camera_const_levels & lvl, int bw, int iso, float fnumber); bool get_Levels(camera_const_levels & lvl, int bw, int iso, float fnumber) const;
public: public:
static CameraConst *parseEntry(void *cJSON, const char *make_model); static CameraConst *parseEntry(const void *cJSON, const char *make_model);
bool has_dcrawMatrix(void); bool has_dcrawMatrix(void) const;
bool has_pdafPattern(void);
void update_dcrawMatrix(const short *other); void update_dcrawMatrix(const short *other);
const short *get_dcrawMatrix(void); const short *get_dcrawMatrix(void) const;
std::vector<int> get_pdafPattern(); const std::vector<int>& get_pdafPattern() const;
int get_pdafOffset() {return pdafOffset;} int get_pdafOffset() const {return pdafOffset;};
bool has_rawCrop(void); bool has_rawCrop(void) const;
void get_rawCrop(int& left_margin, int& top_margin, int& width, int& height); void get_rawCrop(int& left_margin, int& top_margin, int& width, int& height) const;
bool has_rawMask(int idx); bool has_rawMask(int idx) const;
void get_rawMask(int idx, int& top, int& left, int& bottom, int& right); void get_rawMask(int idx, int& top, int& left, int& bottom, int& right) const;
int get_BlackLevel(int idx, int iso_speed); int get_BlackLevel(int idx, int iso_speed) const;
int get_WhiteLevel(int idx, int iso_speed, float fnumber); int get_WhiteLevel(int idx, int iso_speed, float fnumber) const;
bool has_globalGreenEquilibration(); bool has_globalGreenEquilibration() const;
bool get_globalGreenEquilibration(); bool get_globalGreenEquilibration() const;
void update_Levels(const CameraConst *other); void update_Levels(const CameraConst *other);
void update_Crop(CameraConst *other); void update_Crop(CameraConst *other);
void update_pdafPattern(const std::vector<int> &other); void update_pdafPattern(const std::vector<int> &other);
@ -75,7 +74,7 @@ public:
~CameraConstantsStore(); ~CameraConstantsStore();
void init(const Glib::ustring& baseDir, const Glib::ustring& userSettingsDir); void init(const Glib::ustring& baseDir, const Glib::ustring& userSettingsDir);
static CameraConstantsStore *getInstance(void); static CameraConstantsStore *getInstance(void);
CameraConst *get(const char make[], const char model[]); const CameraConst *get(const char make[], const char model[]) const;
}; };
} }

View File

@ -177,7 +177,7 @@ PDAFLinesFilter::PDAFLinesFilter(RawImage *ri):
gthresh_ = new PDAFGreenEqulibrateThreshold(W_, H_); gthresh_ = new PDAFGreenEqulibrateThreshold(W_, H_);
CameraConstantsStore* ccs = CameraConstantsStore::getInstance(); CameraConstantsStore* ccs = CameraConstantsStore::getInstance();
CameraConst *cc = ccs->get(ri_->get_maker().c_str(), ri_->get_model().c_str()); const CameraConst *cc = ccs->get(ri_->get_maker().c_str(), ri_->get_model().c_str());
if (cc) { if (cc) {
pattern_ = cc->get_pdafPattern(); pattern_ = cc->get_pdafPattern();

View File

@ -524,7 +524,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
} }
CameraConstantsStore* ccs = CameraConstantsStore::getInstance(); CameraConstantsStore* ccs = CameraConstantsStore::getInstance();
CameraConst *cc = ccs->get(make, model); const CameraConst *cc = ccs->get(make, model);
if (raw_image) { if (raw_image) {
if (cc && cc->has_rawCrop()) { if (cc && cc->has_rawCrop()) {
@ -850,42 +850,18 @@ DCraw::dcraw_coeff_overrides(const char make[], const char model[], const int is
short trans[12]; // set first value to 0 for no change short trans[12]; // set first value to 0 for no change
} table[] = { } table[] = {
{
"Canon EOS 5D Mark III", -1, 0x3a98, /* RT */
{ 6722, -635, -963, -4287, 12460, 2028, -908, 2162, 5668 }
},
{ {
"Canon EOS 5D", -1, 0xe6c, /* RT */ "Canon EOS 5D", -1, 0xe6c, /* RT */
{ 6319, -793, -614, -5809, 13342, 2738, -1132, 1559, 7971 } { 6319, -793, -614, -5809, 13342, 2738, -1132, 1559, 7971 }
}, },
{
"Canon EOS 6D", -1, 0x3c82,
{ 7034, -804, -1014, -4420, 12564, 2058, -851, 1994, 5758 }
},
{
"Canon EOS 7D", -1, 0x3510, /* RT - Colin Walker */
{ 5962, -171, -732, -4189, 12307, 2099, -911, 1981, 6304 }
},
{ {
"Canon EOS 20D", -1, 0xfff, /* RT */ "Canon EOS 20D", -1, 0xfff, /* RT */
{ 7590, -1646, -673, -4697, 12411, 2568, -627, 1118, 7295 } { 7590, -1646, -673, -4697, 12411, 2568, -627, 1118, 7295 }
}, },
{
"Canon EOS 40D", -1, 0x3f60, /* RT */
{ 6070, -531, -883, -5763, 13647, 2315, -1533, 2582, 6801 }
},
{
"Canon EOS 60D", -1, 0x2ff7, /* RT - Colin Walker */
{ 5678, -179, -718, -4389, 12381, 2243, -869, 1819, 6380 }
},
{ {
"Canon EOS 450D", -1, 0x390d, /* RT */ "Canon EOS 450D", -1, 0x390d, /* RT */
{ 6246, -1272, -523, -5075, 12357, 3075, -1035, 1825, 7333 } { 6246, -1272, -523, -5075, 12357, 3075, -1035, 1825, 7333 }
}, },
{
"Canon EOS 550D", -1, 0x3dd7, /* RT - Lebedev*/
{ 6519, -772, -703, -4994, 12737, 2519, -1387, 2492, 6175 }
},
{ {
"Canon EOS-1D Mark III", 0, 0x3bb0, /* RT */ "Canon EOS-1D Mark III", 0, 0x3bb0, /* RT */
{ 7406, -1592, -646, -4856, 12457, 2698, -432, 726, 7921 } { 7406, -1592, -646, -4856, 12457, 2698, -432, 726, 7921 }
@ -894,18 +870,10 @@ DCraw::dcraw_coeff_overrides(const char make[], const char model[], const int is
"Canon PowerShot G10", -1, -1, /* RT */ "Canon PowerShot G10", -1, -1, /* RT */
{ 12535, -5030, -796, -2711, 10134, 3006, -413, 1605, 5264 } { 12535, -5030, -796, -2711, 10134, 3006, -413, 1605, 5264 }
}, },
{
"Canon PowerShot G12", -1, -1, /* RT */
{ 12222, -4097, -1380, -2876, 11016, 2130, -888, 1630, 4434 }
},
{ {
"Fujifilm X100", -1, -1, /* RT - Colin Walker */ "Fujifilm X100", -1, -1, /* RT - Colin Walker */
{ 10841, -3288, -807, -4652, 12552, 2344, -642, 1355, 7206 } { 10841, -3288, -807, -4652, 12552, 2344, -642, 1355, 7206 }
}, },
{ {
"Nikon D200", -1, 0xfbc, /* RT */ "Nikon D200", -1, 0xfbc, /* RT */
{ 8498, -2633, -295, -5423, 12869, 2860, -777, 1077, 8124 } { 8498, -2633, -295, -5423, 12869, 2860, -777, 1077, 8124 }
@ -918,32 +886,14 @@ DCraw::dcraw_coeff_overrides(const char make[], const char model[], const int is
"Nikon D3100", -1, -1, /* RT */ "Nikon D3100", -1, -1, /* RT */
{ 7729, -2212, -481, -5709, 13148, 2858, -1295, 1908, 8936 } { 7729, -2212, -481, -5709, 13148, 2858, -1295, 1908, 8936 }
}, },
{
"Nikon D3S", -1, -1, /* RT */
{ 8792, -2663, -344, -5221, 12764, 2752, -1491, 2165, 8121 }
},
{ {
"Nikon D5200", -1, -1, // color matrix copied from D5200 DNG D65 matrix "Nikon D5200", -1, -1, // color matrix copied from D5200 DNG D65 matrix
{ 8322, -3112, -1047, -6367, 14342, 2179, -988, 1638, 6394 } { 8322, -3112, -1047, -6367, 14342, 2179, -988, 1638, 6394 }
}, },
{
"Nikon D7000", -1, -1, /* RT - Tanveer(tsk1979) */
{ 7530, -1942, -255, -4318, 11390, 3362, -926, 1694, 7649 }
},
{ {
"Nikon D7100", -1, -1, // color matrix and WP copied from D7100 DNG D65 matrix "Nikon D7100", -1, -1, // color matrix and WP copied from D7100 DNG D65 matrix
{ 8322, -3112, -1047, -6367, 14342, 2179, -988, 1638, 6394 } { 8322, -3112, -1047, -6367, 14342, 2179, -988, 1638, 6394 }
}, },
{
"Nikon D700", -1, -1, /* RT */
{ 8364, -2503, -352, -6307, 14026, 2492, -1134, 1512, 8156 }
},
{
"Nikon COOLPIX A", -1, 0x3e00, // color matrix and WP copied from "COOLPIX A" DNG D65 matrix
{ 8198, -2239, -724, -4871, 12389, 2798, -1043, 205, 7181 }
},
{ {
"Olympus E-30", -1, 0xfbc, /* RT - Colin Walker */ "Olympus E-30", -1, 0xfbc, /* RT - Colin Walker */
{ 8510, -2355, -693, -4819, 12520, 2578, -1029, 2067, 7752 } { 8510, -2355, -693, -4819, 12520, 2578, -1029, 2067, 7752 }
@ -984,69 +934,14 @@ DCraw::dcraw_coeff_overrides(const char make[], const char model[], const int is
"Olympus XZ-1", -1, -1, /* RT - Colin Walker */ "Olympus XZ-1", -1, -1, /* RT - Colin Walker */
{ 8665, -2247, -762, -2424, 10372, 2382, -1011, 2286, 5189 } { 8665, -2247, -762, -2424, 10372, 2382, -1011, 2286, 5189 }
}, },
/* since Dcraw_v9.21 Panasonic BlackLevel is read from exif (tags 0x001c BlackLevelRed, 0x001d BlackLevelGreen, 0x001e BlackLevelBlue
and we define here the needed offset of around 15. The total BL is BL + BLoffset (cblack + black) */
{
"Panasonic DMC-FZ150", 15, 0xfd2, /* RT */
{ 10435, -3208, -72, -2293, 10506, 2067, -486, 1725, 4682 }
},
{
"Panasonic DMC-G10", 15, 0xf50, /* RT - Colin Walker - variable WL 3920 - 4080 */
{ 8310, -1811, -960, -4941, 12990, 2151, -1378, 2468, 6860 }
},
{
"Panasonic DMC-G1", 15, 0xf50, /* RT - Colin Walker - variable WL 3920 - 4080 */
{ 7477, -1615, -651, -5016, 12769, 2506, -1380, 2475, 7240 }
},
{
"Panasonic DMC-G2", 15, 0xf50, /* RT - Colin Walker - variable WL 3920 - 4080 */
{ 8310, -1811, -960, -4941, 12990, 2151, -1378, 2468, 6860 }
},
{
"Panasonic DMC-G3", 15, 0xfdc, /* RT - Colin Walker - WL 4060 */
{ 6051, -1406, -671, -4015, 11505, 2868, -1654, 2667, 6219 }
},
{
"Panasonic DMC-G5", 15, 0xfdc, /* RT - WL 4060 */
{ 7122, -2092, -419, -4643, 11769, 3283, -1363, 2413, 5944 }
},
{
"Panasonic DMC-GF1", 15, 0xf50, /* RT - Colin Walker - Variable WL 3920 - 4080 */
{ 7863, -2080, -668, -4623, 12331, 2578, -1020, 2066, 7266 }
},
{
"Panasonic DMC-GF2", 15, 0xfd2, /* RT - Colin Walker - WL 4050 */
{ 7694, -1791, -745, -4917, 12818, 2332, -1221, 2322, 7197 }
},
{
"Panasonic DMC-GF3", 15, 0xfd2, /* RT - Colin Walker - WL 4050 */
{ 8074, -1846, -861, -5026, 12999, 2239, -1320, 2375, 7422 }
},
{
"Panasonic DMC-GH1", 15, 0xf5a, /* RT - Colin Walker - variable WL 3930 - 4080 */
{ 6360, -1557, -375, -4201, 11504, 3086, -1378, 2518, 5843 }
},
{
"Panasonic DMC-GH2", 15, 0xf5a, /* RT - Colin Walker - variable WL 3930 - 4080 */
// { 6855,-1765,-456,-4223,11600,2996,-1450,2602,5761 } }, disabled due to problems with underwater WB
{ 7780, -2410, -806, -3913, 11724, 2484, -1018, 2390, 5298 }
}, // dcraw original
{ {
"Pentax K200D", -1, -1, /* RT */ "Pentax K200D", -1, -1, /* RT */
{ 10962, -4428, -542, -5486, 13023, 2748, -569, 842, 8390 } { 10962, -4428, -542, -5486, 13023, 2748, -569, 842, 8390 }
}, },
{ {
"Leica Camera AG M9 Digital Camera", -1, -1, /* RT */ "Leica Camera AG M9 Digital Camera", -1, -1, /* RT */
{ 7181, -1706, -55, -3557, 11409, 2450, -621, 2072, 7533 } { 7181, -1706, -55, -3557, 11409, 2450, -621, 2072, 7533 }
}, },
{ {
"SONY NEX-3", 128 << dcraw_arw2_scaling_bugfix_shift, -1, /* RT - Colin Walker */ "SONY NEX-3", 128 << dcraw_arw2_scaling_bugfix_shift, -1, /* RT - Colin Walker */
{ 5145, -741, -123, -4915, 12310, 2945, -794, 1489, 6906 } { 5145, -741, -123, -4915, 12310, 2945, -794, 1489, 6906 }
@ -1104,7 +999,7 @@ DCraw::dcraw_coeff_overrides(const char make[], const char model[], const int is
{ {
// test if we have any information in the camera constants store, if so we take that. // test if we have any information in the camera constants store, if so we take that.
rtengine::CameraConstantsStore* ccs = rtengine::CameraConstantsStore::getInstance(); rtengine::CameraConstantsStore* ccs = rtengine::CameraConstantsStore::getInstance();
rtengine::CameraConst *cc = ccs->get(make, model); const rtengine::CameraConst *cc = ccs->get(make, model);
if (cc) { if (cc) {
if (RT_blacklevel_from_constant == ThreeValBool::T) { if (RT_blacklevel_from_constant == ThreeValBool::T) {

View File

@ -1453,7 +1453,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
[&]() -> bool [&]() -> bool
{ {
CameraConstantsStore *ccs = CameraConstantsStore::getInstance(); CameraConstantsStore *ccs = CameraConstantsStore::getInstance();
CameraConst *cc = ccs->get(ri->get_maker().c_str(), ri->get_model().c_str()); const CameraConst *cc = ccs->get(ri->get_maker().c_str(), ri->get_model().c_str());
return cc && cc->get_globalGreenEquilibration(); return cc && cc->get_globalGreenEquilibration();
}; };