Skip to content

Commit

Permalink
Fixed a lot of issues reported by cppcheck 1.78
Browse files Browse the repository at this point in the history
  • Loading branch information
heckflosse committed Apr 8, 2017
1 parent 73e1470 commit 6e55f6b
Show file tree
Hide file tree
Showing 41 changed files with 228 additions and 256 deletions.
7 changes: 3 additions & 4 deletions rtengine/CA_correct_RT.cc
Expand Up @@ -45,15 +45,14 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution)
//
//==============================================================================

double fMaxElem;
double fAcc;

int i, j, k, m;
int i, j, k;

for(k = 0; k < (nDim - 1); k++) { // base row of matrix
// search of line with max element
fMaxElem = fabs( pfMatr[k * nDim + k] );
m = k;
double fMaxElem = fabs( pfMatr[k * nDim + k] );
int m = k;

for (i = k + 1; i < nDim; i++) {
if(fMaxElem < fabs(pfMatr[i * nDim + k]) ) {
Expand Down
3 changes: 3 additions & 0 deletions rtengine/EdgePreservingDecomposition.cc
Expand Up @@ -395,6 +395,9 @@ SSEFUNCTION void MultiDiagonalSymmetricMatrix::VectorProduct(float* RESTRICT Pro
}
}
}
#ifdef _OPENMP
static_cast<void>(chunkSize); // to silence cppcheck warning
#endif
}

bool MultiDiagonalSymmetricMatrix::CreateIncompleteCholeskyFactorization(int MaxFillAbove)
Expand Down
111 changes: 53 additions & 58 deletions rtengine/PF_correct_RT.cc
Expand Up @@ -663,12 +663,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d

const int width = src->W, height = src->H;
const float piid = 3.14159265f / 180.f;
float shfabs, shmed;

int i1, j1, tot;
int i1, j1;
const float eps = 1.0f;
const float eps2 = 0.01f;
float shsum, dirsh, norm, sum;

float** sraa;
sraa = new float*[height];
Expand Down Expand Up @@ -848,13 +846,13 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
__m128 onev = F2V(1.0f);
#endif // __SSE2__
#ifdef _OPENMP
#pragma omp for private(shfabs, shmed,i1,j1)
#pragma omp for private(i1,j1)
#endif

for (int i = 0; i < height; i++) {
for (j = 0; j < 2; j++) {
shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = 0; j1 <= j + 2; j1++ ) {
Expand All @@ -879,8 +877,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
}

for (; j < width - 2; j++) {
shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -893,8 +891,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
#else

for (; j < width - 2; j++) {
shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -907,8 +905,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
#endif

for (; j < width; j++) {
shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 < width; j1++ ) {
Expand All @@ -927,7 +925,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
{
int j;
#ifdef _OPENMP
#pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16)
#pragma omp for private(i1,j1) schedule(dynamic,16)
#endif

for (int i = 0; i < height; i++) {
Expand All @@ -936,10 +934,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = 0; j1 <= j + 2; j1++ ) {
Expand All @@ -953,7 +951,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d

sum += src->sh_p[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
shsum += dirsh * src->sh_p[i1][j1];
norm += dirsh;
}
Expand All @@ -972,10 +970,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -989,7 +987,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d

sum += src->sh_p[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
shsum += dirsh * src->sh_p[i1][j1];
norm += dirsh;
}
Expand All @@ -1008,10 +1006,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 < width; j1++ ) {
Expand All @@ -1025,7 +1023,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d

sum += src->sh_p[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps);
shsum += dirsh * src->sh_p[i1][j1];
norm += dirsh;
}
Expand Down Expand Up @@ -1272,13 +1270,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
t1.set();

const int width = src->W, height = src->H;
// const float piid=3.14159265f/180.f;
float shfabs, shmed;

int i1, j1, tot;
int i1, j1;
const float eps = 1.0f;
const float eps2 = 0.01f;
float shsum, dirsh, norm, sum;

float** sraa;
sraa = new float*[height];
Expand Down Expand Up @@ -1455,13 +1450,13 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
__m128 onev = F2V(1.0f);
#endif // __SSE2__
#ifdef _OPENMP
#pragma omp for private(shfabs, shmed,i1,j1)
#pragma omp for private(i1,j1)
#endif

for (int i = 0; i < height; i++) {
for (j = 0; j < 2; j++) {
shfabs = fabs(src->L[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->L[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = 0; j1 <= j + 2; j1++ ) {
Expand All @@ -1474,7 +1469,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
#ifdef __SSE2__

for (; j < width - 5; j += 4) {
shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j]));
vfloat shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j]));
shmedv = ZEROV;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
Expand All @@ -1486,8 +1481,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
}

for (; j < width - 2; j++) {
shfabs = fabs(src->L[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->L[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -1500,8 +1495,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
#else

for (; j < width - 2; j++) {
shfabs = fabs(src->L[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->L[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -1514,8 +1509,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
#endif

for (; j < width; j++) {
shfabs = fabs(src->L[i][j] - tmL[i][j]);
shmed = 0.0f;
float shfabs = fabs(src->L[i][j] - tmL[i][j]);
float shmed = 0.0f;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 < width; j1++ ) {
Expand All @@ -1534,7 +1529,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
{
int j;
#ifdef _OPENMP
#pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16)
#pragma omp for private(i1,j1) schedule(dynamic,16)
#endif

for (int i = 0; i < height; i++) {
Expand All @@ -1543,10 +1538,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = 0; j1 <= j + 2; j1++ ) {
Expand All @@ -1560,7 +1555,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d

sum += src->L[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
shsum += dirsh * src->L[i1][j1];
norm += dirsh;
}
Expand All @@ -1579,10 +1574,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 <= j + 2; j1++ ) {
Expand All @@ -1596,7 +1591,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d

sum += src->L[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
shsum += dirsh * src->L[i1][j1];
norm += dirsh;
}
Expand All @@ -1615,10 +1610,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d
continue;
}

norm = 0.0f;
shsum = 0.0f;
sum = 0.0f;
tot = 0;
float norm = 0.0f;
float shsum = 0.0f;
float sum = 0.0f;
int tot = 0;

for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ )
for (j1 = j - 2; j1 < width; j1++ ) {
Expand All @@ -1632,7 +1627,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d

sum += src->L[i1][j1];
tot++;
dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps);
shsum += dirsh * src->L[i1][j1];
norm += dirsh;
}
Expand Down
2 changes: 1 addition & 1 deletion rtengine/cfa_linedn_RT.cc
Expand Up @@ -46,7 +46,7 @@ void RawImageSource::CLASS cfa_linedn(float noise)

const float clip_pt = 0.8 * initialGain * 65535.0;

float eps = 1e-5; //tolerance to avoid dividing by zero
const float eps = 1e-5; //tolerance to avoid dividing by zero

const float gauss[5] = {0.20416368871516755, 0.18017382291138087, 0.1238315368057753, 0.0662822452863612, 0.02763055063889883};
const float rolloff[8] = {0, 0.135335, 0.249352, 0.411112, 0.606531, 0.800737, 0.945959, 1}; //gaussian with sigma=3
Expand Down
2 changes: 1 addition & 1 deletion rtengine/color.cc
Expand Up @@ -1817,7 +1817,7 @@ void Color::Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v)
v = 9.0 * Y / (X + 15 * Y + 3 * Z) - v0;
}

void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, double wp[3][3])
void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, const double wp[3][3])
{
float u1 = u + u0;
float v1 = v + v0;
Expand Down
2 changes: 1 addition & 1 deletion rtengine/color.h
Expand Up @@ -498,7 +498,7 @@ class Color
* @param a channel [-42000 ; +42000] ; can be more than 42000 (return value)
* @param b channel [-42000 ; +42000] ; can be more than 42000 (return value)
*/
static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, double wp[3][3]);
static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, const double wp[3][3]);


/**
Expand Down
2 changes: 1 addition & 1 deletion rtengine/curves.h
Expand Up @@ -273,7 +273,7 @@ class CurveFactory
}

float R = hlrange / (val * comp);
return log(1.0 + Y) * R;
return log1p(Y) * R;
} else {
return exp_scale;
}
Expand Down
3 changes: 1 addition & 2 deletions rtengine/diagonalcurves.cc
Expand Up @@ -33,7 +33,6 @@ DiagonalCurve::DiagonalCurve (const std::vector<double>& p, int poly_pn)
{

ppn = poly_pn > 65500 ? 65500 : poly_pn;
bool identity = true;

if (ppn < 500) {
hashSize = 100; // Arbitrary cut-off value, but mutliple of 10
Expand All @@ -46,6 +45,7 @@ DiagonalCurve::DiagonalCurve (const std::vector<double>& p, int poly_pn)
if (p.size() < 3) {
kind = DCT_Empty;
} else {
bool identity = true;
kind = (DiagonalCurveType)p[0];

if (kind == DCT_Linear || kind == DCT_Spline || kind == DCT_NURBS) {
Expand Down Expand Up @@ -364,7 +364,6 @@ double DiagonalCurve::getVal (double t) const
}

return poly_y[k_lo] + (t - poly_x[k_lo]) * dyByDx[k_lo];
break;
}

case DCT_Empty :
Expand Down

0 comments on commit 6e55f6b

Please sign in to comment.