cppcheck: further fixes
This commit is contained in:
parent
4fedfb2b26
commit
4c99c9cf01
@ -334,8 +334,6 @@ double xyCoordToTemperature(const std::array<double, 2>& white_xy)
|
|||||||
|
|
||||||
// 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.
|
||||||
@ -371,23 +369,11 @@ double xyCoordToTemperature(const std::array<double, 2>& white_xy)
|
|||||||
|
|
||||||
// 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;
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of RawTherapee.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
|
||||||
*
|
|
||||||
* RawTherapee is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RawTherapee is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "rtengine.h"
|
|
||||||
#include <iostream>
|
|
||||||
//#include <giomm.h>
|
|
||||||
#include <helpers.h>
|
|
||||||
|
|
||||||
class PListener :
|
|
||||||
public rtengine::ProgressListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void setProgressStr(const Glib::ustring& str)
|
|
||||||
{
|
|
||||||
std::cout << str << std::endl;
|
|
||||||
}
|
|
||||||
void setProgress (double p)
|
|
||||||
{
|
|
||||||
std::cout << p << std::endl;
|
|
||||||
}
|
|
||||||
void setProgressState(bool inProcessing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void error(const Glib::ustring& descr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
|
||||||
{
|
|
||||||
if (argc < 4) {
|
|
||||||
std::cout << "Usage: rtcmd <infile> <paramfile> <outfile>" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Glib::thread_init ();
|
|
||||||
|
|
||||||
// create and fill settings
|
|
||||||
rtengine::Settings* s = rtengine::Settings::create ();
|
|
||||||
s->demosaicMethod = "hphd";
|
|
||||||
s->colorCorrectionSteps = 2;
|
|
||||||
s->iccDirectory = "";
|
|
||||||
s->colorimetricIntent = 1;
|
|
||||||
s->monitorProfile = "";
|
|
||||||
// init rtengine
|
|
||||||
rtengine::init (s);
|
|
||||||
// the settings can be modified later through the "s" pointer without calling any api function
|
|
||||||
|
|
||||||
// Create a listener object. Any class is appropriate that inherits from rtengine::ProgressListener
|
|
||||||
PListener pl;
|
|
||||||
|
|
||||||
// Load the image given in the first command line parameter
|
|
||||||
rtengine::InitialImage* ii;
|
|
||||||
int errorCode;
|
|
||||||
ii = rtengine::InitialImage::load (argv[1], true, errorCode, &pl);
|
|
||||||
|
|
||||||
if (!ii) {
|
|
||||||
ii = rtengine::InitialImage::load (argv[1], false, errorCode, &pl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ii) {
|
|
||||||
std::cout << "Input file not supported." << std::endl;
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create an instance of ProcParams structure that holds the image processing settings. You find the memory map in a separate file and the non-basic types like strings and vectors can be manipulated through helper functions
|
|
||||||
rtengine::procparams::ProcParams params;
|
|
||||||
params.load (argv[2]);
|
|
||||||
|
|
||||||
/* First, simplest scenario. Develop image and save it in a file */
|
|
||||||
// create a processing job with the loaded image and the current processing parameters
|
|
||||||
rtengine::ProcessingJob* job = ProcessingJob::create (i, params);
|
|
||||||
// process image. The error is given back in errorcode.
|
|
||||||
rtengine::IImage16* res = rtengine::processImage (job, errorCode, &pl);
|
|
||||||
// save image to disk
|
|
||||||
res->saveToFile (argv[3]);
|
|
||||||
// through "res" you can access width/height and pixel data, too
|
|
||||||
}
|
|
||||||
|
|
@ -970,8 +970,8 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue
|
|||||||
for (int c = 0; c < 3; ++c) {
|
for (int c = 0; c < 3; ++c) {
|
||||||
lab[i2][c] = 0;
|
lab[i2][c] = 0;
|
||||||
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j2 = 0; j2 < 3; ++j2) {
|
||||||
lab[i2][c] += trans[c][j] * cam[i2][j];
|
lab[i2][c] += trans[c][j2] * cam[i2][j2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,8 +996,8 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue
|
|||||||
for (int c = 0; c < 3; ++c) {
|
for (int c = 0; c < 3; ++c) {
|
||||||
cam[0][c] = 0.f;
|
cam[0][c] = 0.f;
|
||||||
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j2 = 0; j2 < 3; ++j2) {
|
||||||
cam[0][c] += itrans[c][j] * lab[0][j];
|
cam[0][c] += itrans[c][j2] * lab[0][j2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,12 +1081,11 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue
|
|||||||
//now correct clipped channels
|
//now correct clipped channels
|
||||||
if (pixel[0] > max_f[0] && pixel[1] > max_f[1] && pixel[2] > max_f[2]) {
|
if (pixel[0] > max_f[0] && pixel[1] > max_f[1] && pixel[2] > max_f[2]) {
|
||||||
//all channels clipped
|
//all channels clipped
|
||||||
const float Y = 0.299f * clipfix[0] + 0.587f * clipfix[1] + 0.114f * clipfix[2];
|
|
||||||
|
|
||||||
const float factor = whitept / Y;
|
const float mult = whitept / (0.299f * clipfix[0] + 0.587f * clipfix[1] + 0.114f * clipfix[2]);
|
||||||
red[i + miny][j + minx] = clipfix[0] * factor;
|
red[i + miny][j + minx] = clipfix[0] * mult;
|
||||||
green[i + miny][j + minx] = clipfix[1] * factor;
|
green[i + miny][j + minx] = clipfix[1] * mult;
|
||||||
blue[i + miny][j + minx] = clipfix[2] * factor;
|
blue[i + miny][j + minx] = clipfix[2] * mult;
|
||||||
} else {//some channels clipped
|
} else {//some channels clipped
|
||||||
const float notclipped[3] = {
|
const float notclipped[3] = {
|
||||||
pixel[0] <= max_f[0] ? 1.f : 0.f,
|
pixel[0] <= max_f[0] ? 1.f : 0.f,
|
||||||
@ -1113,11 +1112,11 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue
|
|||||||
Y = 0.299f * red[i + miny][j + minx] + 0.587f * green[i + miny][j + minx] + 0.114f * blue[i + miny][j + minx];
|
Y = 0.299f * red[i + miny][j + minx] + 0.587f * green[i + miny][j + minx] + 0.114f * blue[i + miny][j + minx];
|
||||||
|
|
||||||
if (Y > whitept) {
|
if (Y > whitept) {
|
||||||
const float factor = whitept / Y;
|
const float mult = whitept / Y;
|
||||||
|
|
||||||
red[i + miny][j + minx] *= factor;
|
red[i + miny][j + minx] *= mult;
|
||||||
green[i + miny][j + minx] *= factor;
|
green[i + miny][j + minx] *= mult;
|
||||||
blue[i + miny][j + minx] *= factor;
|
blue[i + miny][j + minx] *= mult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ void ImProcFunctions::Lanczos (const Imagefloat* src, Imagefloat* dst, float sca
|
|||||||
void ImProcFunctions::Lanczos (const LabImage* src, LabImage* dst, float scale)
|
void ImProcFunctions::Lanczos (const LabImage* src, LabImage* dst, float scale)
|
||||||
{
|
{
|
||||||
const float delta = 1.0f / scale;
|
const float delta = 1.0f / scale;
|
||||||
const float a = 3.0f;
|
constexpr float a = 3.0f;
|
||||||
const float sc = min(scale, 1.0f);
|
const float sc = min(scale, 1.0f);
|
||||||
const int support = static_cast<int> (2.0f * a / sc) + 1;
|
const int support = static_cast<int> (2.0f * a / sc) + 1;
|
||||||
|
|
||||||
@ -268,18 +268,18 @@ void ImProcFunctions::Lanczos (const LabImage* src, LabImage* dst, float scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do vertical interpolation. Store results.
|
// Do vertical interpolation. Store results.
|
||||||
|
int j = 0;
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
int j;
|
|
||||||
__m128 Lv, av, bv, wkv;
|
__m128 Lv, av, bv, wkv;
|
||||||
|
|
||||||
for (j = 0; j < src->W - 3; j += 4) {
|
for (j = 0; j < src->W - 3; j += 4) {
|
||||||
Lv = _mm_setzero_ps();
|
Lv = ZEROV;
|
||||||
av = _mm_setzero_ps();
|
av = ZEROV;
|
||||||
bv = _mm_setzero_ps();
|
bv = ZEROV;
|
||||||
|
|
||||||
for (int ii = ii0; ii < ii1; ii++) {
|
for (int ii = ii0; ii < ii1; ii++) {
|
||||||
int k = ii - ii0;
|
int k = ii - ii0;
|
||||||
wkv = _mm_set1_ps (w[k]);
|
wkv = F2V(w[k]);
|
||||||
Lv += wkv * LVFU(src->L[ii][j]);
|
Lv += wkv * LVFU(src->L[ii][j]);
|
||||||
av += wkv * LVFU(src->a[ii][j]);
|
av += wkv * LVFU(src->a[ii][j]);
|
||||||
bv += wkv * LVFU(src->b[ii][j]);
|
bv += wkv * LVFU(src->b[ii][j]);
|
||||||
@ -289,45 +289,40 @@ void ImProcFunctions::Lanczos (const LabImage* src, LabImage* dst, float scale)
|
|||||||
STVF(la[j], av);
|
STVF(la[j], av);
|
||||||
STVF(lb[j], bv);
|
STVF(lb[j], bv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
int j = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; j < src->W; j++) {
|
for (; j < src->W; ++j) {
|
||||||
float L = 0.0f, a = 0.0f, b = 0.0f;
|
float Ll = 0.0f, La = 0.0f, Lb = 0.0f;
|
||||||
|
|
||||||
for (int ii = ii0; ii < ii1; ii++) {
|
for (int ii = ii0; ii < ii1; ++ii) {
|
||||||
int k = ii - ii0;
|
int k = ii - ii0;
|
||||||
|
|
||||||
L += w[k] * src->L[ii][j];
|
Ll += w[k] * src->L[ii][j];
|
||||||
a += w[k] * src->a[ii][j];
|
La += w[k] * src->a[ii][j];
|
||||||
b += w[k] * src->b[ii][j];
|
Lb += w[k] * src->b[ii][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
lL[j] = L;
|
lL[j] = Ll;
|
||||||
la[j] = a;
|
la[j] = La;
|
||||||
lb[j] = b;
|
lb[j] = Lb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do horizontal interpolation
|
// Do horizontal interpolation
|
||||||
for (int j = 0; j < dst->W; j++) {
|
for (int x = 0; x < dst->W; ++x) {
|
||||||
|
float * wh = wwh + support * x;
|
||||||
|
float Ll = 0.0f, La = 0.0f, Lb = 0.0f;
|
||||||
|
|
||||||
float * wh = wwh + support * j;
|
for (int jj = jj0[x]; jj < jj1[x]; ++jj) {
|
||||||
|
int k = jj - jj0[x];
|
||||||
|
|
||||||
float L = 0.0f, a = 0.0f, b = 0.0f;
|
Ll += wh[k] * lL[jj];
|
||||||
|
La += wh[k] * la[jj];
|
||||||
for (int jj = jj0[j]; jj < jj1[j]; jj++) {
|
Lb += wh[k] * lb[jj];
|
||||||
int k = jj - jj0[j];
|
|
||||||
|
|
||||||
L += wh[k] * lL[jj];
|
|
||||||
a += wh[k] * la[jj];
|
|
||||||
b += wh[k] * lb[jj];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dst->L[i][j] = L;
|
dst->L[i][x] = Ll;
|
||||||
dst->a[i][j] = a;
|
dst->a[i][x] = La;
|
||||||
dst->b[i][j] = b;
|
dst->b[i][x] = Lb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of RawTherapee.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
|
||||||
*
|
|
||||||
* RawTherapee is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RawTherapee is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "rtengine.h"
|
|
||||||
#include <iostream>
|
|
||||||
//#include <giomm.h>
|
|
||||||
#include <helpers.h>
|
|
||||||
|
|
||||||
class PListener :
|
|
||||||
public rtengine::ProgressListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void setProgressStr(const Glib::ustring& str)
|
|
||||||
{
|
|
||||||
std::cout << str << std::endl;
|
|
||||||
}
|
|
||||||
void setProgress(double p)
|
|
||||||
{
|
|
||||||
std::cout << p << std::endl;
|
|
||||||
}
|
|
||||||
void setProgressState(bool inProcessing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void error(const Glib::ustring& descr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
|
||||||
{
|
|
||||||
if (argc < 4) {
|
|
||||||
std::cout << "Usage: rtcmd <infile> <paramfile> <outfile>" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
rtengine::Settings s;
|
|
||||||
s.demosaicMethod = "hphd";
|
|
||||||
s.colorCorrectionSteps = 2;
|
|
||||||
s.iccDirectory = "";
|
|
||||||
s.colorimetricIntent = 1;
|
|
||||||
s.monitorProfile = "";
|
|
||||||
|
|
||||||
Glib::thread_init ();
|
|
||||||
rtengine::init (s, "");
|
|
||||||
PListener pl;
|
|
||||||
|
|
||||||
rtengine::InitialImage* ii;
|
|
||||||
int errorCode;
|
|
||||||
ii = rtengine::InitialImage::load (argv[1], true, errorCode, &pl);
|
|
||||||
|
|
||||||
if (!ii) {
|
|
||||||
ii = rtengine::InitialImage::load (argv[1], false, errorCode, &pl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ii) {
|
|
||||||
std::cout << "Input file not supported." << std::endl;
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
rtengine::procparams::ProcParams params;
|
|
||||||
params.load (argv[2]);
|
|
||||||
|
|
||||||
rtengine::ProcessingJob* job = ProcessingJob::create (ii, params);
|
|
||||||
rtengine::IImage16* res = rtengine::processImage (job, errorCode, &pl);
|
|
||||||
res->saveToFile (argv[3]);
|
|
||||||
}
|
|
||||||
|
|
@ -476,14 +476,14 @@ void tmo_fattal02 (size_t width,
|
|||||||
|
|
||||||
Array2Df* H = new Array2Df (width, height);
|
Array2Df* H = new Array2Df (width, height);
|
||||||
float temp = 100.f / maxLum;
|
float temp = 100.f / maxLum;
|
||||||
float eps = 1e-4f;
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel if(multithread)
|
#pragma omp parallel if(multithread)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
const float eps = 1e-4f;
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
vfloat epsv = F2V (eps);
|
const vfloat epsv = F2V(eps);
|
||||||
vfloat tempv = F2V (temp);
|
const vfloat tempv = F2V(temp);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp for schedule(dynamic,16)
|
#pragma omp for schedule(dynamic,16)
|
||||||
@ -926,13 +926,13 @@ void solve_pde_fft (Array2Df *F, Array2Df *U, Array2Df *buf, bool multithread)/*
|
|||||||
// a solution which has no positive values: U_new(x,y)=U(x,y)-max
|
// a solution which has no positive values: U_new(x,y)=U(x,y)-max
|
||||||
// (not really needed but good for numerics as we later take exp(U))
|
// (not really needed but good for numerics as we later take exp(U))
|
||||||
//DEBUG_STR << "solve_pde_fft: removing constant from solution" << std::endl;
|
//DEBUG_STR << "solve_pde_fft: removing constant from solution" << std::endl;
|
||||||
float max = 0.f;
|
float maxVal = 0.f;
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(max:max) if(multithread)
|
#pragma omp parallel for reduction(max:maxVal) if(multithread)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
max = std::max (max, (*U) (i));
|
maxVal = std::max(maxVal, (*U)(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
@ -940,7 +940,7 @@ void solve_pde_fft (Array2Df *F, Array2Df *U, Array2Df *buf, bool multithread)/*
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
(*U) (i) -= max;
|
(*U) (i) -= maxVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user