diff --git a/rtengine/vng4_demosaic_RT.cc b/rtengine/vng4_demosaic_RT.cc index 62f5018c5..0e7d8e0f9 100644 --- a/rtengine/vng4_demosaic_RT.cc +++ b/rtengine/vng4_demosaic_RT.cc @@ -71,9 +71,8 @@ void RawImageSource::vng4_demosaic (const array2D &rawData, array2Dprefilters; const int width = W, height = H; constexpr unsigned int colors = 4; - float (*image)[4]; - image = (float (*)[4]) calloc (height * width, sizeof * image); + float (*image)[4] = (float (*)[4]) calloc (height * width, sizeof * image); #ifdef _OPENMP #pragma omp parallel for @@ -87,7 +86,7 @@ void RawImageSource::vng4_demosaic (const array2D &rawData, array2D &rawData, array2D &rawData, array2D &rawData, array2D &rawData, array2D gval[g]) { - gmin = gval[g]; - } - - if (gmax < gval[g]) { - gmax = gval[g]; - } + gmin = std::min(gmin, gval[g]); + gmax = std::max(gmax, gval[g]); } thold = gmin + (gmax / 2); } memset (sum, 0, sizeof sum); - float t1, t2; - t1 = t2 = pix[color]; + float t1p2 = pix[color]; if(color & 1) { int num = 0; @@ -273,7 +266,7 @@ void RawImageSource::vng4_demosaic (const array2D &rawData, array2D &rawData, array2D &rawData, array2D firstRow) { @@ -321,23 +313,12 @@ void RawImageSource::vng4_demosaic (const array2D &rawData, array2D 2 && firstRow < H - 3) { + interpolate_row_rb_mul_pp (rawData, red[firstRow], blue[firstRow], green[firstRow - 1], green[firstRow], green[firstRow + 1], firstRow, 1.0, 1.0, 1.0, 0, W, 1); } - if (lastRow != -1) { - if (lastRow == 0) { - interpolate_row_rb_mul_pp (rawData, red[0], blue[0], nullptr, green[0], green[1], 0, 1.0, 1.0, 1.0, 0, W, 1); - } else if (lastRow == H - 1) { - interpolate_row_rb_mul_pp (rawData, red[lastRow], blue[lastRow], green[lastRow - 1], green[lastRow], nullptr, lastRow, 1.0, 1.0, 1.0, 0, W, 1); - } else { - interpolate_row_rb_mul_pp (rawData, red[lastRow], blue[lastRow], green[lastRow - 1], green[lastRow], green[lastRow + 1], lastRow, 1.0, 1.0, 1.0, 0, W, 1); - } + + if (lastRow > 2 && lastRow < H - 3) { + interpolate_row_rb_mul_pp (rawData, red[lastRow], blue[lastRow], green[lastRow - 1], green[lastRow], green[lastRow + 1], lastRow, 1.0, 1.0, 1.0, 0, W, 1); } } free (code[0][0]);