From bf30ca6c05ef134852b84013c6706bb10edd2479 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Sun, 24 May 2020 19:28:56 +0200 Subject: [PATCH] dual_demosaic: added Amaze+bilinear and Vng4+biliner, also made a small speedup, #5748 --- rtdata/languages/default | 2 ++ rtengine/dual_demosaic_RT.cc | 61 +++++++++++++++--------------------- rtengine/procparams.cc | 2 ++ rtengine/procparams.h | 2 ++ rtengine/rawimagesource.cc | 4 ++- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index e4c3a3a08..b30e7dd32 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1909,11 +1909,13 @@ TP_RAW_3PASSBEST;3-pass (Markesteijn) TP_RAW_4PASS;3-pass+fast TP_RAW_AHD;AHD TP_RAW_AMAZE;AMaZE +TP_RAW_AMAZEBILINEAR;AMaZE+Bilinear TP_RAW_AMAZEVNG4;AMaZE+VNG4 TP_RAW_BORDER;Border TP_RAW_DCB;DCB TP_RAW_DCBENHANCE;DCB enhancement TP_RAW_DCBITERATIONS;Number of DCB iterations +TP_RAW_DCBBILINEAR;DCB+Bilinear TP_RAW_DCBVNG4;DCB+VNG4 TP_RAW_DMETHOD;Method TP_RAW_DMETHOD_PROGRESSBAR;%1 demosaicing... diff --git a/rtengine/dual_demosaic_RT.cc b/rtengine/dual_demosaic_RT.cc index bbf4e621a..f7a403c16 100644 --- a/rtengine/dual_demosaic_RT.cc +++ b/rtengine/dual_demosaic_RT.cc @@ -48,17 +48,18 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams if (contrast == 0.0 && !autoContrast) { // contrast == 0.0 means only first demosaicer will be used if(isBayer) { - if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) ) { + if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4)) { amaze_demosaic_RT(0, 0, winw, winh, rawData, red, green, blue, options.chunkSizeAMAZE, options.measure); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4) ) { + } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4)) { dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) { - rcd_demosaic(options.chunkSizeRCD, options.measure); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4) ) { + } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4)) { rcd_demosaic(options.chunkSizeRCD, options.measure); } } else { - if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS) ) { + if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS)) { xtrans_interpolate (3, true, options.chunkSizeXT, options.measure); } else { xtrans_interpolate (1, false, options.chunkSizeXT, options.measure); @@ -71,17 +72,19 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams array2D L(winw, winh); if (isBayer) { - if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) || raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::PIXELSHIFT)) { + if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::PIXELSHIFT)) { amaze_demosaic_RT(0, 0, winw, winh, rawData, red, green, blue, options.chunkSizeAMAZE, options.measure); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4) ) { + } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBVNG4)) { dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) { - rcd_demosaic(options.chunkSizeRCD, options.measure); - } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4) ) { + } else if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDVNG4)) { rcd_demosaic(options.chunkSizeRCD, options.measure); } } else { - if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS) ) { + if (raw.xtranssensor.method == procparams::RAWParams::XTransSensor::getMethodString(procparams::RAWParams::XTransSensor::Method::FOUR_PASS)) { xtrans_interpolate (3, true, options.chunkSizeXT, options.measure); } else { xtrans_interpolate (1, false, options.chunkSizeXT, options.measure); @@ -95,17 +98,13 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams }; #ifdef _OPENMP - #pragma omp parallel + #pragma omp parallel for schedule(dynamic,16) #endif - { -#ifdef _OPENMP - #pragma omp for -#endif - for(int i = 0; i < winh; ++i) { - Color::RGB2L(red[i], green[i], blue[i], L[i], xyz_rgb, winw); - } + for(int i = 0; i < winh; ++i) { + Color::RGB2L(red[i], green[i], blue[i], L[i], xyz_rgb, winw); } - // calculate contrast based blend factors to use vng4 in regions with low contrast + + // calculate contrast based blend factors to use flat demosaicer in regions with low contrast JaggedArray blend(winw, winh); float contrastf = contrast / 100.0; @@ -117,7 +116,9 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams array2D blueTmp(winw, winh); if (isBayer) { - if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) ) { + if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::RCDBILINEAR) || + raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::DCBBILINEAR)) { bayer_bilinear_demosaic(rawData, redTmp, greenTmp, blueTmp); } else { vng4_demosaic(rawData, redTmp, greenTmp, blueTmp); @@ -126,32 +127,20 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams fast_xtrans_interpolate(rawData, redTmp, greenTmp, blueTmp); } - - // the following is split into 3 loops intentionally to avoid cache conflicts on CPUs with only 4-way cache #ifdef _OPENMP - #pragma omp parallel for + #pragma omp parallel for schedule(dynamic,16) #endif for(int i = 0; i < winh; ++i) { + // the following is split into 3 loops intentionally to avoid cache conflicts on CPUs with only 4-way cache for(int j = 0; j < winw; ++j) { red[i][j] = intp(blend[i][j], red[i][j], redTmp[i][j]); } - } -#ifdef _OPENMP - #pragma omp parallel for -#endif - for(int i = 0; i < winh; ++i) { for(int j = 0; j < winw; ++j) { green[i][j] = intp(blend[i][j], green[i][j], greenTmp[i][j]); } - } -#ifdef _OPENMP - #pragma omp parallel for -#endif - for(int i = 0; i < winh; ++i) { for(int j = 0; j < winw; ++j) { blue[i][j] = intp(blend[i][j], blue[i][j], blueTmp[i][j]); } } - } } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 56cccb4bb..57bcf604a 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2764,11 +2764,13 @@ const std::vector& RAWParams::BayerSensor::getMethodStrings() { static const std::vector method_strings { "amaze", + "amazebilinear", "amazevng4", "rcd", "rcdbilinear", "rcdvng4", "dcb", + "dcbbilinear", "dcbvng4", "lmmse", "igv", diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 4e7f6d3ff..0c0631624 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1408,11 +1408,13 @@ struct RAWParams { struct BayerSensor { enum class Method { AMAZE, + AMAZEBILINEAR, AMAZEVNG4, RCD, RCDBILINEAR, RCDVNG4, DCB, + DCBBILINEAR, DCBVNG4, LMMSE, IGV, diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 4f78dfbdb..7d3f5ab2c 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1578,7 +1578,9 @@ void RawImageSource::demosaic(const RAWParams &raw, bool autoContrast, double &c ahd_demosaic (); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZE)) { amaze_demosaic_RT (0, 0, W, H, rawData, red, green, blue, options.chunkSizeAMAZE, options.measure); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZEVNG4) + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZEBILINEAR) + || raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZEVNG4) + || raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCBBILINEAR) || raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCBVNG4) || raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCDBILINEAR) || raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCDVNG4)) {