From 1d51016bdde96e08be9c553967eae87c41f3e223 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Wed, 30 Oct 2019 14:07:49 +0100 Subject: [PATCH] Fix some lgtm issues --- rtengine/CA_correct_RT.cc | 2 +- rtengine/array2D.h | 2 +- rtengine/capturesharpening.cc | 4 ++-- rtengine/cfa_linedn_RT.cc | 2 +- rtengine/demosaic_algos.cc | 16 ++++++++-------- rtengine/pixelshift.cc | 4 ++-- rtengine/tmo_fattal02.cc | 4 ++-- rtengine/vng4_demosaic_RT.cc | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index a2d68402f..05fd806ca 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -198,7 +198,7 @@ float* RawImageSource::CA_correct_RT( //block CA shift values and weight assigned to block float* const blockwt = buffer + (height * width); - memset(blockwt, 0, vblsz * hblsz * (2 * 2 + 1) * sizeof(float)); + memset(blockwt, 0, static_cast(vblsz) * hblsz * (2 * 2 + 1) * sizeof(float)); float (*blockshifts)[2][2] = (float (*)[2][2])(blockwt + vblsz * hblsz); // Because we can't break parallel processing, we need a switch do handle the errors diff --git a/rtengine/array2D.h b/rtengine/array2D.h index 7713cd55c..d25e20a83 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -249,7 +249,7 @@ public: ar_realloc(w, h, offset); if (flags & ARRAY2D_CLEAR_DATA) { - memset(data + offset, 0, w * h * sizeof(T)); + memset(data + offset, 0, static_cast(w) * h * sizeof(T)); } } diff --git a/rtengine/capturesharpening.cc b/rtengine/capturesharpening.cc index 4eeca1f15..bbc0be50b 100644 --- a/rtengine/capturesharpening.cc +++ b/rtengine/capturesharpening.cc @@ -583,10 +583,10 @@ BENCHFUN } else { if (sigmaCornerOffset != 0.0) { const float distance = sqrt(rtengine::SQR(i + tileSize / 2 - H / 2) + rtengine::SQR(j + tileSize / 2 - W / 2)); - const float sigmaTile = sigma + distanceFactor * distance; + const float sigmaTile = static_cast(sigma) + distanceFactor * distance; if (sigmaTile >= 0.4f) { float lkernel7[7][7]; - compute7x7kernel(sigma + distanceFactor * distance, lkernel7); + compute7x7kernel(static_cast(sigma) + distanceFactor * distance, lkernel7); for (int k = 0; k < iterations - 1; ++k) { // apply 7x7 gaussian blur and divide luminance by result of gaussian blur gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, lkernel7); diff --git a/rtengine/cfa_linedn_RT.cc b/rtengine/cfa_linedn_RT.cc index 3aef79133..ba26740c1 100644 --- a/rtengine/cfa_linedn_RT.cc +++ b/rtengine/cfa_linedn_RT.cc @@ -62,7 +62,7 @@ void RawImageSource::CLASS cfa_linedn(float noise, bool horizontal, bool vertica // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% float noisevar = SQR(3 * noise * 65535); // _noise_ (as a fraction of saturation) is input to the algorithm float noisevarm4 = 4.0f * noisevar; - float* RawDataTmp = (float*)malloc( width * height * sizeof(float)); + float* RawDataTmp = (float*)malloc(static_cast(width) * height * sizeof(float)); #ifdef _OPENMP #pragma omp parallel #endif diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 52e15be54..f1b9cb5e8 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -77,7 +77,7 @@ void RawImageSource::ppg_demosaic() plistener->setProgress (0.0); } - image = (float (*)[4]) calloc (H * W, sizeof * image); + image = (float (*)[4]) calloc (static_cast(H) * W, sizeof * image); for (int ii = 0; ii < H; ii++) for (int jj = 0; jj < W; jj++) { @@ -375,9 +375,9 @@ void RawImageSource::jdl_interpolate_omp() // from "Lassus" int row, col, c, d, i, u = width, v = 2 * u, w = 3 * u, x = 4 * u, y = 5 * u, z = 6 * u, indx, (*dif)[2], (*chr)[2]; float f[4], g[4]; float (*image)[4]; - image = (float (*)[4]) calloc (width * height, sizeof * image); - dif = (int (*)[2]) calloc(width * height, sizeof * dif); - chr = (int (*)[2]) calloc(width * height, sizeof * chr); + image = (float (*)[4]) calloc (static_cast(width) * height, sizeof * image); + dif = (int (*)[2]) calloc(static_cast(width) * height, sizeof * dif); + chr = (int (*)[2]) calloc(static_cast(width) * height, sizeof * chr); if (plistener) { // this function seems to be unused @@ -542,14 +542,14 @@ void RawImageSource::lmmse_interpolate_omp(int winw, int winh, array2D &r float *rix[5]; float *qix[5]; - float *buffer = (float *)calloc(rr1 * cc1 * 5 * sizeof(float), 1); + float *buffer = (float *)calloc(static_cast(rr1) * cc1 * 5 * sizeof(float), 1); if(buffer == nullptr) { // allocation of big block of memory failed, try to get 5 smaller ones printf("lmmse_interpolate_omp: allocation of big memory block failed, try to get 5 smaller ones now...\n"); bool allocationFailed = false; for(int i = 0; i < 5; i++) { - qix[i] = (float *)calloc(rr1 * cc1 * sizeof(float), 1); + qix[i] = (float *)calloc(static_cast(rr1) * cc1 * sizeof(float), 1); if(!qix[i]) { // allocation of at least one small block failed allocationFailed = true; @@ -1144,7 +1144,7 @@ void RawImageSource::igv_interpolate(int winw, int winh) vdif = (float (*)) calloc( width * height / 2, sizeof * vdif ); hdif = (float (*)) calloc( width * height / 2, sizeof * hdif ); - chrarray = (float (*)) calloc( width * height, sizeof( float ) ); + chrarray = (float (*)) calloc(static_cast(width) * height, sizeof( float ) ); chr[0] = chrarray; chr[1] = chrarray + (width * height) / 2; @@ -2039,7 +2039,7 @@ void RawImageSource::refinement_lassus(int PassCount) t1e.set(); int u = W, v = 2 * u, w = 3 * u, x = 4 * u, y = 5 * u; float (*image)[3]; - image = (float(*)[3]) calloc(W * H, sizeof * image); + image = (float(*)[3]) calloc(static_cast(W) * H, sizeof * image); #ifdef _OPENMP #pragma omp parallel shared(image) #endif diff --git a/rtengine/pixelshift.cc b/rtengine/pixelshift.cc index ca5e742fb..9cb5844c2 100644 --- a/rtengine/pixelshift.cc +++ b/rtengine/pixelshift.cc @@ -114,9 +114,9 @@ void xorMasks(int xStart, int xEnd, int yStart, int yEnd, const array2D } } -void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, array2D &mask, std::stack, std::vector>> &coordStack) +void floodFill4Impl(int yin, int xin, int xStart, int xEnd, int yStart, int yEnd, array2D &mask, std::stack, std::vector>> &coordStack) { - coordStack.emplace(x, y); + coordStack.emplace(xin, yin); while(!coordStack.empty()) { auto coord = coordStack.top(); diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index f1822b486..31671bd0c 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -1094,7 +1094,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb) float oldMedian; const float percentile = float(LIM(params->fattal.anchor, 1, 100)) / 100.f; - findMinMaxPercentile (Yr.data(), Yr.getRows() * Yr.getCols(), percentile, oldMedian, percentile, oldMedian, multiThread); + findMinMaxPercentile (Yr.data(), static_cast(Yr.getRows()) * Yr.getCols(), percentile, oldMedian, percentile, oldMedian, multiThread); // median filter on the deep shadows, to avoid boosting noise // because w2 >= w and h2 >= h, we can use the L buffer as temporary buffer for Median_Denoise() int w2 = find_fast_dim (w) + 1; @@ -1136,7 +1136,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb) const float wr = float(w2) / float(w); float newMedian; - findMinMaxPercentile (L.data(), L.getRows() * L.getCols(), percentile, newMedian, percentile, newMedian, multiThread); + findMinMaxPercentile (L.data(), static_cast(L.getRows()) * L.getCols(), percentile, newMedian, percentile, newMedian, multiThread); const float scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan #ifdef _OPENMP diff --git a/rtengine/vng4_demosaic_RT.cc b/rtengine/vng4_demosaic_RT.cc index 384ec3219..aaaa1b9a6 100644 --- a/rtengine/vng4_demosaic_RT.cc +++ b/rtengine/vng4_demosaic_RT.cc @@ -103,7 +103,7 @@ void RawImageSource::vng4_demosaic (const array2D &rawData, array2D(height) * width, sizeof * image); int lcode[16][16][32]; float mul[16][16][8];