Camconst stuff: now case insensitive matching; print levels and where they come from if verbose; Phase One camconst.json minor fixes and comments

This commit is contained in:
torger
2013-10-23 18:19:46 +02:00
parent 1990132042
commit 9ef10d741a
3 changed files with 38 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
* This file is part of RawTherapee. * This file is part of RawTherapee.
*/ */
#include "camconst.h" #include "camconst.h"
#include "settings.h"
#include "safegtk.h" #include "safegtk.h"
#include "rt_math.h" #include "rt_math.h"
#include <cstdio> #include <cstdio>
@@ -16,6 +17,8 @@
namespace rtengine { namespace rtengine {
extern const Settings* settings;
CameraConst::CameraConst() CameraConst::CameraConst()
{ {
memset(dcraw_matrix, 0, sizeof(dcraw_matrix)); memset(dcraw_matrix, 0, sizeof(dcraw_matrix));
@@ -438,12 +441,16 @@ CameraConstantsStore::parse_camera_constants_file(Glib::ustring filename_)
goto parse_error; goto parse_error;
} }
Glib::ustring make_model(ji->valuestring); Glib::ustring make_model(ji->valuestring);
make_model = make_model.uppercase();
std::map<Glib::ustring, CameraConst *>::iterator existingccIter = mCameraConstants.find(make_model); std::map<Glib::ustring, CameraConst *>::iterator existingccIter = mCameraConstants.find(make_model);
if (existingccIter == mCameraConstants.end()) if (existingccIter == mCameraConstants.end()) {
// add the new CamConst to the map // add the new CamConst to the map
mCameraConstants.insert(std::pair<Glib::ustring,CameraConst *>(make_model, cc)); mCameraConstants.insert(std::pair<Glib::ustring,CameraConst *>(make_model, cc));
else { if (settings->verbose) {
printf("Add camera constants for \"%s\"\n", make_model.c_str());
}
} 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 = existingccIter->second; CameraConst *existingcc = existingccIter->second;
@@ -451,6 +458,9 @@ CameraConstantsStore::parse_camera_constants_file(Glib::ustring filename_)
existingcc->update_dcrawMatrix(cc->get_dcrawMatrix()); existingcc->update_dcrawMatrix(cc->get_dcrawMatrix());
// deleting all the existing levels, replaced by the new ones // deleting all the existing levels, replaced by the new ones
existingcc->update_Levels(cc); existingcc->update_Levels(cc);
if (settings->verbose) {
printf("Merging camera constants for \"%s\"\n", make_model.c_str());
}
} }
if (is_array) { if (is_array) {
ji = ji->next; ji = ji->next;
@@ -501,6 +511,7 @@ CameraConstantsStore::get(const char make[], const char model[])
Glib::ustring key(make); Glib::ustring key(make);
key += " "; key += " ";
key += model; key += model;
key = key.uppercase();
std::map<Glib::ustring, CameraConst *>::iterator it; std::map<Glib::ustring, CameraConst *>::iterator it;
it = mCameraConstants.find(key); it = mCameraConstants.find(key);
if (it == mCameraConstants.end()) { if (it == mCameraConstants.end()) {

View File

@@ -383,14 +383,17 @@ Quality X: unknown, ie we knowing to little about the camera properties to know
"ranges": { "black": 512, "white": 16350 } "ranges": { "black": 512, "white": 16350 }
}, },
// Phase One: color matrices borrowed from Adobe DNG Converter, black/white levels tested on actual raw files /* Phase One: color matrices borrowed from Adobe DNG Converter, black/white levels tested on actual raw files.
Note: the dcraw decoder makes black level subtraction when decoding from metadata in the IIQ format, so
what we see here is the result after that, ie black level is 0. (The actual black level is about 1024 with
white level at 0xfffc=65532) */
{ // quality A { // quality A
"make_model": [ "Phase One P40+", "Phase One IQ140", "Phase One P65+", "Phase One IQ160" ], "make_model": [ "Phase One P40+", "Phase One IQ140", "Phase One P65+", "Phase One IQ160" ],
"dcraw_matrix": [ 8035,435,-962,-6001,13872,2320,-1159,3065,5434 ], "dcraw_matrix": [ 8035,435,-962,-6001,13872,2320,-1159,3065,5434 ],
"ranges": { "black": 0, "white": 64400 } "ranges": { "black": 0, "white": 64400 }
}, },
{ // quality A { // quality A
"make_model": "Phase One IQ180", "make_model": [ "Phase One IQ180", "Phase One IQ280" ],
"dcraw_matrix": [ 6294,686,-712,-5435,13417,2211,-1006,2435,5042 ], "dcraw_matrix": [ 6294,686,-712,-5435,13417,2211,-1006,2435,5042 ],
"ranges": { "black": 0, "white": 64400 } "ranges": { "black": 0, "white": 64400 }
}, },
@@ -410,7 +413,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know
"ranges": { "black": 0, "white": 64400 } "ranges": { "black": 0, "white": 64400 }
}, },
{ // quality A { // quality A
"make_model": [ "Phase One 45", "Phase One 45+" ], "make_model": [ "Phase One P45", "Phase One P45+" ],
"dcraw_matrix": [ 5053,-24,-117,-5685,14077,1703,-2619,4491,5850 ], "dcraw_matrix": [ 5053,-24,-117,-5685,14077,1703,-2619,4491,5850 ],
"ranges": { "black": 0, "white": 64400 } "ranges": { "black": 0, "white": 64400 }
}, },

View File

@@ -239,6 +239,8 @@ int RawImage::loadRaw (bool loadData, bool closeFile)
CameraConstantsStore* ccs = CameraConstantsStore::getInstance(); CameraConstantsStore* ccs = CameraConstantsStore::getInstance();
CameraConst *cc = ccs->get(make, model); CameraConst *cc = ccs->get(make, model);
bool white_from_cc = false;
bool black_from_cc = false;
if (cc) { if (cc) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (RT_blacklevel_from_constant) { if (RT_blacklevel_from_constant) {
@@ -253,12 +255,29 @@ int RawImage::loadRaw (bool loadData, bool closeFile)
if (black_c4[0] == -1) { if (black_c4[0] == -1) {
// RT constants not set, bring in the DCRAW single channel black constant // RT constants not set, bring in the DCRAW single channel black constant
for (int c=0; c < 4; c++) black_c4[c] = black; for (int c=0; c < 4; c++) black_c4[c] = black;
} else {
black_from_cc = true;
}
if (maximum_c4[0] > 0) {
white_from_cc = true;
} }
for (int c=0; c < 4; c++) { for (int c=0; c < 4; c++) {
if (cblack[c] < black_c4[c]) { if (cblack[c] < black_c4[c]) {
cblack[c] = black_c4[c]; cblack[c] = black_c4[c];
} }
} }
if (settings->verbose) {
if (cc) {
printf("constants exists for \"%s %s\" in camconst.json\n", make, model);
} else {
printf("no constants in camconst.json exists for \"%s %s\" (relying only on dcraw defaults)\n", make, model);
}
printf("black levels: R:%d G1:%d B:%d G2:%d (%s)\n", get_cblack(0), get_cblack(1), get_cblack(2), get_cblack(3),
black_from_cc ? "provided by camconst.json" : "provided by dcraw");
printf("white levels: R:%d G1:%d B:%d G2:%d (%s)\n", get_white(0), get_white(1), get_white(2), get_white(3),
white_from_cc ? "provided by camconst.json" : "provided by dcraw");
printf("color matrix provided by %s\n", (cc && cc->has_dcrawMatrix()) ? "camconst.json" : "dcraw");
}
} }
if ( closeFile ) { if ( closeFile ) {