Fix some lgtm issues

This commit is contained in:
Ingo Weyrich 2019-10-30 14:07:49 +01:00
parent d7ec033829
commit 1d51016bdd
8 changed files with 18 additions and 18 deletions

View File

@ -198,7 +198,7 @@ float* RawImageSource::CA_correct_RT(
//block CA shift values and weight assigned to block //block CA shift values and weight assigned to block
float* const blockwt = buffer + (height * width); float* const blockwt = buffer + (height * width);
memset(blockwt, 0, vblsz * hblsz * (2 * 2 + 1) * sizeof(float)); memset(blockwt, 0, static_cast<unsigned long>(vblsz) * hblsz * (2 * 2 + 1) * sizeof(float));
float (*blockshifts)[2][2] = (float (*)[2][2])(blockwt + vblsz * hblsz); 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 // Because we can't break parallel processing, we need a switch do handle the errors

View File

@ -249,7 +249,7 @@ public:
ar_realloc(w, h, offset); ar_realloc(w, h, offset);
if (flags & ARRAY2D_CLEAR_DATA) { if (flags & ARRAY2D_CLEAR_DATA) {
memset(data + offset, 0, w * h * sizeof(T)); memset(data + offset, 0, static_cast<unsigned long>(w) * h * sizeof(T));
} }
} }

View File

@ -583,10 +583,10 @@ BENCHFUN
} else { } else {
if (sigmaCornerOffset != 0.0) { if (sigmaCornerOffset != 0.0) {
const float distance = sqrt(rtengine::SQR(i + tileSize / 2 - H / 2) + rtengine::SQR(j + tileSize / 2 - W / 2)); 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<float>(sigma) + distanceFactor * distance;
if (sigmaTile >= 0.4f) { if (sigmaTile >= 0.4f) {
float lkernel7[7][7]; float lkernel7[7][7];
compute7x7kernel(sigma + distanceFactor * distance, lkernel7); compute7x7kernel(static_cast<float>(sigma) + distanceFactor * distance, lkernel7);
for (int k = 0; k < iterations - 1; ++k) { for (int k = 0; k < iterations - 1; ++k) {
// apply 7x7 gaussian blur and divide luminance by result of gaussian blur // apply 7x7 gaussian blur and divide luminance by result of gaussian blur
gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, lkernel7); gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, lkernel7);

View File

@ -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 noisevar = SQR(3 * noise * 65535); // _noise_ (as a fraction of saturation) is input to the algorithm
float noisevarm4 = 4.0f * noisevar; float noisevarm4 = 4.0f * noisevar;
float* RawDataTmp = (float*)malloc( width * height * sizeof(float)); float* RawDataTmp = (float*)malloc(static_cast<unsigned long>(width) * height * sizeof(float));
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel #pragma omp parallel
#endif #endif

View File

@ -77,7 +77,7 @@ void RawImageSource::ppg_demosaic()
plistener->setProgress (0.0); plistener->setProgress (0.0);
} }
image = (float (*)[4]) calloc (H * W, sizeof * image); image = (float (*)[4]) calloc (static_cast<size_t>(H) * W, sizeof * image);
for (int ii = 0; ii < H; ii++) for (int ii = 0; ii < H; ii++)
for (int jj = 0; jj < W; jj++) { 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]; 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 f[4], g[4];
float (*image)[4]; float (*image)[4];
image = (float (*)[4]) calloc (width * height, sizeof * image); image = (float (*)[4]) calloc (static_cast<size_t>(width) * height, sizeof * image);
dif = (int (*)[2]) calloc(width * height, sizeof * dif); dif = (int (*)[2]) calloc(static_cast<size_t>(width) * height, sizeof * dif);
chr = (int (*)[2]) calloc(width * height, sizeof * chr); chr = (int (*)[2]) calloc(static_cast<size_t>(width) * height, sizeof * chr);
if (plistener) { if (plistener) {
// this function seems to be unused // this function seems to be unused
@ -542,14 +542,14 @@ void RawImageSource::lmmse_interpolate_omp(int winw, int winh, array2D<float> &r
float *rix[5]; float *rix[5];
float *qix[5]; float *qix[5];
float *buffer = (float *)calloc(rr1 * cc1 * 5 * sizeof(float), 1); float *buffer = (float *)calloc(static_cast<size_t>(rr1) * cc1 * 5 * sizeof(float), 1);
if(buffer == nullptr) { // allocation of big block of memory failed, try to get 5 smaller ones 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"); printf("lmmse_interpolate_omp: allocation of big memory block failed, try to get 5 smaller ones now...\n");
bool allocationFailed = false; bool allocationFailed = false;
for(int i = 0; i < 5; i++) { for(int i = 0; i < 5; i++) {
qix[i] = (float *)calloc(rr1 * cc1 * sizeof(float), 1); qix[i] = (float *)calloc(static_cast<size_t>(rr1) * cc1 * sizeof(float), 1);
if(!qix[i]) { // allocation of at least one small block failed if(!qix[i]) { // allocation of at least one small block failed
allocationFailed = true; allocationFailed = true;
@ -1144,7 +1144,7 @@ void RawImageSource::igv_interpolate(int winw, int winh)
vdif = (float (*)) calloc( width * height / 2, sizeof * vdif ); vdif = (float (*)) calloc( width * height / 2, sizeof * vdif );
hdif = (float (*)) calloc( width * height / 2, sizeof * hdif ); hdif = (float (*)) calloc( width * height / 2, sizeof * hdif );
chrarray = (float (*)) calloc( width * height, sizeof( float ) ); chrarray = (float (*)) calloc(static_cast<size_t>(width) * height, sizeof( float ) );
chr[0] = chrarray; chr[0] = chrarray;
chr[1] = chrarray + (width * height) / 2; chr[1] = chrarray + (width * height) / 2;
@ -2039,7 +2039,7 @@ void RawImageSource::refinement_lassus(int PassCount)
t1e.set(); t1e.set();
int u = W, v = 2 * u, w = 3 * u, x = 4 * u, y = 5 * u; int u = W, v = 2 * u, w = 3 * u, x = 4 * u, y = 5 * u;
float (*image)[3]; float (*image)[3];
image = (float(*)[3]) calloc(W * H, sizeof * image); image = (float(*)[3]) calloc(static_cast<size_t>(W) * H, sizeof * image);
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel shared(image) #pragma omp parallel shared(image)
#endif #endif

View File

@ -114,9 +114,9 @@ void xorMasks(int xStart, int xEnd, int yStart, int yEnd, const array2D<uint8_t>
} }
} }
void floodFill4Impl(int y, int x, int xStart, int xEnd, int yStart, int yEnd, array2D<uint8_t> &mask, std::stack<std::pair<uint16_t, uint16_t>, std::vector<std::pair<uint16_t, uint16_t>>> &coordStack) void floodFill4Impl(int yin, int xin, int xStart, int xEnd, int yStart, int yEnd, array2D<uint8_t> &mask, std::stack<std::pair<uint16_t, uint16_t>, std::vector<std::pair<uint16_t, uint16_t>>> &coordStack)
{ {
coordStack.emplace(x, y); coordStack.emplace(xin, yin);
while(!coordStack.empty()) { while(!coordStack.empty()) {
auto coord = coordStack.top(); auto coord = coordStack.top();

View File

@ -1094,7 +1094,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb)
float oldMedian; float oldMedian;
const float percentile = float(LIM(params->fattal.anchor, 1, 100)) / 100.f; 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<size_t>(Yr.getRows()) * Yr.getCols(), percentile, oldMedian, percentile, oldMedian, multiThread);
// median filter on the deep shadows, to avoid boosting noise // 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() // 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; int w2 = find_fast_dim (w) + 1;
@ -1136,7 +1136,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb)
const float wr = float(w2) / float(w); const float wr = float(w2) / float(w);
float newMedian; float newMedian;
findMinMaxPercentile (L.data(), L.getRows() * L.getCols(), percentile, newMedian, percentile, newMedian, multiThread); findMinMaxPercentile (L.data(), static_cast<size_t>(L.getRows()) * L.getCols(), percentile, newMedian, percentile, newMedian, multiThread);
const float scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan const float scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan
#ifdef _OPENMP #ifdef _OPENMP

View File

@ -103,7 +103,7 @@ void RawImageSource::vng4_demosaic (const array2D<float> &rawData, array2D<float
const int width = W, height = H; const int width = W, height = H;
constexpr unsigned int colors = 4; constexpr unsigned int colors = 4;
float (*image)[4] = (float (*)[4]) calloc (height * width, sizeof * image); float (*image)[4] = (float (*)[4]) calloc (static_cast<size_t>(height) * width, sizeof * image);
int lcode[16][16][32]; int lcode[16][16][32];
float mul[16][16][8]; float mul[16][16][8];