merge with dev - all warnings are not delete - come soon

This commit is contained in:
Desmis
2017-04-08 19:28:04 +02:00
144 changed files with 5970 additions and 5235 deletions

View File

@@ -37,8 +37,6 @@
#include "../rtgui/ppversion.h"
#include "improccoordinator.h"
#include <locale.h>
//#define BENCHMARK
#include "StopWatch.h"
namespace
@@ -50,7 +48,7 @@ namespace
return false;
}
const std::size_t length =
const ssize_t length =
fdata(raw_image.get_thumbOffset(), raw_image.get_file())[1] != 0xD8 && raw_image.is_ppmThumb()
? raw_image.get_thumbWidth() * raw_image.get_thumbHeight() * (raw_image.get_thumbBPS() / 8) * 3
: raw_image.get_thumbLength();
@@ -58,6 +56,74 @@ namespace
return raw_image.get_thumbOffset() + length <= raw_image.get_file()->size;
}
void scale_colors(rtengine::RawImage *ri, float scale_mul[4], float cblack[4])
{
DCraw::dcrawImage_t image = ri->get_image();
if(ri->isBayer()) {
const int height = ri->get_iheight();
const int width = ri->get_iwidth();
for(int row = 0; row < height; ++row) {
unsigned c0 = ri->FC(row,0);
unsigned c1 = ri->FC(row,1);
int col = 0;
for(; col < width - 1; col += 2) {
float val0 = image[row * width + col][c0];
float val1 = image[row * width + col + 1][c1];
val0 -= cblack[c0];
val1 -= cblack[c1];
val0 *= scale_mul[c0];
val1 *= scale_mul[c1];
image[row * width + col][c0] = rtengine::CLIP(val0);
image[row * width + col + 1][c1] = rtengine::CLIP(val1);
}
if(col < width) { // in case width is odd
float val0 = image[row * width + col][c0];
val0 -= cblack[c0];
val0 *= scale_mul[c0];
image[row * width + col][c0] = rtengine::CLIP(val0);
}
}
} else if(ri->isXtrans()) {
const int height = ri->get_iheight();
const int width = ri->get_iwidth();
unsigned c[6];
for(int row = 0; row < height; ++row) {
for(int i = 0; i < 6; ++i) {
c[i] = ri->XTRANSFC(row,i);
}
int col = 0;
for(; col < width - 5; col += 6) {
for(int i = 0; i < 6; ++i) {
const unsigned ccol = c[i];
float val = image[row * width + col + i][ccol];
val -= cblack[ccol];
val *= scale_mul[ccol];
image[row * width + col + i][ccol] = rtengine::CLIP(val);
}
}
for(; col < width; ++col) { // remaining columns
const unsigned ccol = ri->XTRANSFC(row,col);
float val = image[row * width + col][ccol];
val -= cblack[ccol];
val *= scale_mul[ccol];
image[row * width + col][ccol] = rtengine::CLIP(val);
}
}
} else {
const int size = ri->get_iheight() * ri->get_iwidth();
for (int i = 0; i < size; ++i) {
for (int j = 0; j < 4; ++j) {
float val = image[i][j];
val -= cblack[j];
val *= scale_mul[j];
image[i][j] = rtengine::CLIP(val);
}
}
}
}
}
extern Options options;
@@ -254,7 +320,7 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL
std::string fname = ri->get_filename();
std::string suffix = fname.length() > 4 ? fname.substr(fname.length() - 3) : "";
for (int i = 0; i < suffix.length(); i++) {
for (unsigned int i = 0; i < suffix.length(); i++) {
suffix[i] = std::tolower(suffix[i]);
}
@@ -333,17 +399,23 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
tpp->greenMultiplier = ri->get_pre_mul(1);
tpp->blueMultiplier = ri->get_pre_mul(2);
ri->scale_colors();
//ri->scale_colors();
float pre_mul[4], scale_mul[4], cblack[4];
ri->get_colorsCoeff(pre_mul, scale_mul, cblack, false);
scale_colors(ri, scale_mul, cblack);
ri->pre_interpolate();
rml.exifBase = ri->get_exifBase();
rml.ciffBase = ri->get_ciffBase();
rml.ciffLength = ri->get_ciffLen();
tpp->camwbRed = tpp->redMultiplier / ri->get_pre_mul(0);
tpp->camwbGreen = tpp->greenMultiplier / ri->get_pre_mul(1);
tpp->camwbBlue = tpp->blueMultiplier / ri->get_pre_mul(2);
tpp->defGain = 1.0 / min(ri->get_pre_mul(0), ri->get_pre_mul(1), ri->get_pre_mul(2));
tpp->camwbRed = tpp->redMultiplier / pre_mul[0]; //ri->get_pre_mul(0);
tpp->camwbGreen = tpp->greenMultiplier / pre_mul[1]; //ri->get_pre_mul(1);
tpp->camwbBlue = tpp->blueMultiplier / pre_mul[2]; //ri->get_pre_mul(2);
//tpp->defGain = 1.0 / min(ri->get_pre_mul(0), ri->get_pre_mul(1), ri->get_pre_mul(2));
tpp->defGain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]);
tpp->gammaCorrected = true;
unsigned filter = ri->get_filters();
@@ -500,8 +572,8 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
for (int row = 0; row < high; row++)
for (int col = 0; col < wide; col++) {
unsigned ur = r = fw + (row - col) * step;
unsigned uc = c = (row + col) * step;
int ur = r = fw + (row - col) * step;
int uc = c = (row + col) * step;
if (ur > tmph - 2 || uc > tmpw - 2) {
continue;
@@ -779,17 +851,33 @@ void Thumbnail::init ()
}
Thumbnail::Thumbnail () :
iColorMatrix{}, cam2xyz{}, scale(1.0), colorMatrix{}, isRaw(true),
camProfile(nullptr), thumbImg(nullptr),
camwbRed(1.0), camwbGreen(1.0), camwbBlue(1.0),
redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0),
autoWBTemp(2700), autoWBGreen(1.0), wbEqual(-1.0), wbTempBias(0.0),
embProfileLength(0), embProfileData(nullptr), embProfile(nullptr),
redMultiplier(1.0), greenMultiplier(1.0), blueMultiplier(1.0),
camProfile(nullptr),
iColorMatrix{},
cam2xyz{},
thumbImg(nullptr),
camwbRed(1.0),
camwbGreen(1.0),
camwbBlue(1.0),
redAWBMul(-1.0),
greenAWBMul(-1.0),
blueAWBMul(-1.0),
autoWBTemp(2700),
autoWBGreen(1.0),
wbEqual(-1.0),
wbTempBias(0.0),
aeHistCompression(3),
embProfileLength(0),
embProfileData(nullptr),
embProfile(nullptr),
redMultiplier(1.0),
greenMultiplier(1.0),
blueMultiplier(1.0),
scale(1.0),
defGain(1.0),
scaleForSave(8192),
gammaCorrected(false),
aeHistCompression(3)
colorMatrix{},
isRaw(true)
{
}
@@ -843,8 +931,6 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int
IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rheight, TypeInterpolation interp, std::string camName,
double focalLen, double focalLen35mm, float focusDist, float shutter, float fnumber, float iso, std::string expcomp_, double& myscale)
{
BENCHFUN
// check if the WB's equalizer value has changed
if (wbEqual < (params.wb.equal - 5e-4) || wbEqual > (params.wb.equal + 5e-4) || wbTempBias < (params.wb.tempBias - 5e-4) || wbTempBias > (params.wb.tempBias + 5e-4)) {
wbEqual = params.wb.equal;
@@ -959,7 +1045,6 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
LUTu hist16 (65536);
double gamma = isRaw ? Color::sRGBGamma : 0; // usually in ImageSource, but we don't have that here
ipf.firstAnalysis (baseImg, params, hist16);
// perform transform
@@ -967,7 +1052,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
Imagefloat* trImg = new Imagefloat (fw, fh);
int origFW;
int origFH;
double tscale;
double tscale = 0.0;
getDimensions(origFW, origFH, tscale);
ipf.transform (baseImg, trImg, 0, 0, 0, 0, fw, fh, origFW * tscale + 0.5, origFH * tscale + 0.5, focalLen, focalLen35mm, focusDist, 0, true); // Raw rotate degree not detectable here
delete baseImg;
@@ -1194,7 +1279,6 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
LUTf CAMBrightCurveQ;
float CAMMean;
int sk;
int scale;
sk = 16;
int rtt = 0;
CieImage* cieView = new CieImage (fw, fh);