code cleanup after feedback by @Floessie
This commit is contained in:
parent
4d3503b795
commit
a3adf8fb07
@ -461,6 +461,7 @@ class ProcessingJob
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~ProcessingJob() {}
|
||||
|
||||
/** Creates a processing job from a file name. This function always succeeds. It only stores the data into the ProcessingJob class, it does not load
|
||||
* the image thus it returns immediately.
|
||||
|
@ -37,6 +37,14 @@ extern const Settings* settings;
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
void adjust_radius(const T &default_param, double scale_factor, T ¶m)
|
||||
{
|
||||
const double delta = (param - default_param) * scale_factor;
|
||||
param = default_param + delta;
|
||||
}
|
||||
|
||||
|
||||
class ImageProcessor {
|
||||
public:
|
||||
ImageProcessor(ProcessingJob* pjob, int& errorCode,
|
||||
@ -1338,20 +1346,18 @@ private:
|
||||
ImProcFunctions ipf (¶ms, true);
|
||||
|
||||
int imw, imh;
|
||||
double tmpScale = ipf.resizeScale(¶ms, fw, fh, imw, imh);
|
||||
double scale_factor = ipf.resizeScale(¶ms, fw, fh, imw, imh);
|
||||
|
||||
LabImage *tmplab = new LabImage(fw, fh);
|
||||
std::unique_ptr<LabImage> tmplab(new LabImage(fw, fh));
|
||||
ipf.rgb2lab(*baseImg, *tmplab, params.icm.working);
|
||||
|
||||
int cx = 0, cy = 0, cw = fw, ch = fh;
|
||||
|
||||
if (params.crop.enabled) {
|
||||
cx = params.crop.x;
|
||||
cy = params.crop.y;
|
||||
cw = params.crop.w;
|
||||
ch = params.crop.h;
|
||||
int cx = params.crop.x;
|
||||
int cy = params.crop.y;
|
||||
int cw = params.crop.w;
|
||||
int ch = params.crop.h;
|
||||
|
||||
LabImage *cropped = new LabImage(cw, ch);
|
||||
std::unique_ptr<LabImage> cropped(new LabImage(cw, ch));
|
||||
|
||||
for(int row = 0; row < ch; row++) {
|
||||
for(int col = 0; col < cw; col++) {
|
||||
@ -1361,23 +1367,20 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
delete tmplab;
|
||||
tmplab = cropped;
|
||||
cx = 0;
|
||||
cy = 0;
|
||||
|
||||
tmplab.swap(cropped);
|
||||
params.crop.enabled = false;
|
||||
}
|
||||
|
||||
assert(params.resize.enabled);
|
||||
|
||||
// resize image
|
||||
LabImage *resized = new LabImage(imw, imh);
|
||||
ipf.Lanczos(tmplab, resized, tmpScale);
|
||||
delete tmplab;
|
||||
tmplab = resized;
|
||||
{
|
||||
std::unique_ptr<LabImage> resized(new LabImage(imw, imh));
|
||||
ipf.Lanczos(tmplab.get(), resized.get(), scale_factor);
|
||||
tmplab.swap(resized);
|
||||
}
|
||||
|
||||
adjust_procparams(tmpScale);
|
||||
adjust_procparams(scale_factor);
|
||||
|
||||
fw = imw;
|
||||
fh = imh;
|
||||
@ -1385,34 +1388,26 @@ private:
|
||||
delete baseImg;
|
||||
baseImg = new Imagefloat(fw, fh);
|
||||
ipf.lab2rgb(*tmplab, *baseImg, params.icm.working);
|
||||
delete tmplab;
|
||||
}
|
||||
|
||||
void adjust_procparams(double scale_factor)
|
||||
{
|
||||
procparams::ProcParams& params = job->pparams;
|
||||
procparams::ProcParams ¶ms = job->pparams;
|
||||
procparams::ProcParams defaultparams;
|
||||
|
||||
#define ADJUST_RADIUS_(n, f) \
|
||||
do { \
|
||||
auto delta = (params. n - defaultparams. n) * f; \
|
||||
params. n = defaultparams. n + delta; \
|
||||
} while (false)
|
||||
|
||||
params.resize.enabled = false;
|
||||
|
||||
if (params.prsharpening.enabled) {
|
||||
params.sharpening = params.prsharpening;
|
||||
} else {
|
||||
ADJUST_RADIUS_(sharpening.radius, scale_factor);
|
||||
adjust_radius(defaultparams.sharpening.radius, scale_factor,
|
||||
params.sharpening.radius);
|
||||
}
|
||||
params.impulseDenoise.thresh =
|
||||
int(float(params.impulseDenoise.thresh) * scale_factor);
|
||||
params.impulseDenoise.thresh *= scale_factor;
|
||||
if (scale_factor < 0.5) {
|
||||
params.impulseDenoise.enabled = false;
|
||||
}
|
||||
params.wavelet.strength =
|
||||
int(float(params.wavelet.strength) * scale_factor);
|
||||
params.wavelet.strength *= scale_factor;
|
||||
params.dirpyrDenoise.luma *= scale_factor;
|
||||
//params.dirpyrDenoise.smethod = "shal";
|
||||
for (auto &p : params.dirpyrDenoise.lcurve) {
|
||||
@ -1427,13 +1422,13 @@ private:
|
||||
|
||||
const double dirpyreq_scale = min(scale_factor * 1.5, 1.0);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
ADJUST_RADIUS_(dirpyrequalizer.mult[i], dirpyreq_scale);
|
||||
// auto &n = params.dirpyrequalizer.mult[i];
|
||||
// n = 1.0 + (n - 1.0) * dirpyreq_scale;
|
||||
adjust_radius(defaultparams.dirpyrequalizer.mult[i], dirpyreq_scale,
|
||||
params.dirpyrequalizer.mult[i]);
|
||||
}
|
||||
|
||||
ADJUST_RADIUS_(defringe.radius, scale_factor);
|
||||
ADJUST_RADIUS_(sh.radius, scale_factor);
|
||||
adjust_radius(defaultparams.defringe.radius, scale_factor,
|
||||
params.defringe.radius);
|
||||
adjust_radius(defaultparams.sh.radius, scale_factor, params.sh.radius);
|
||||
|
||||
if (params.raw.xtranssensor.method ==
|
||||
procparams::RAWParams::XTransSensor::methodstring[
|
||||
@ -1442,8 +1437,6 @@ private:
|
||||
procparams::RAWParams::XTransSensor::methodstring[
|
||||
procparams::RAWParams::XTransSensor::onePass];
|
||||
}
|
||||
|
||||
#undef ADJUST_RADIUS_
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1096,46 +1096,46 @@ void FileCatalog::developRequested (std::vector<FileBrowserEntry*> tbe, bool fas
|
||||
// TODO!!! could expose selections below via preferences
|
||||
if (fastmode) {
|
||||
if (!options.fastexport_use_fast_pipeline) {
|
||||
if (options.fastexport_bypass_sharpening ) {
|
||||
if (options.fastexport_bypass_sharpening) {
|
||||
params.sharpening.enabled = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_sharpenEdge ) {
|
||||
if (options.fastexport_bypass_sharpenEdge) {
|
||||
params.sharpenEdge.enabled = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_sharpenMicro ) {
|
||||
if (options.fastexport_bypass_sharpenMicro) {
|
||||
params.sharpenMicro.enabled = false;
|
||||
}
|
||||
|
||||
//if (options.fastexport_bypass_lumaDenoise ) params.lumaDenoise.enabled = false;
|
||||
//if (options.fastexport_bypass_colorDenoise ) params.colorDenoise.enabled = false;
|
||||
if (options.fastexport_bypass_defringe ) {
|
||||
//if (options.fastexport_bypass_lumaDenoise) params.lumaDenoise.enabled = false;
|
||||
//if (options.fastexport_bypass_colorDenoise) params.colorDenoise.enabled = false;
|
||||
if (options.fastexport_bypass_defringe) {
|
||||
params.defringe.enabled = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_dirpyrDenoise ) {
|
||||
if (options.fastexport_bypass_dirpyrDenoise) {
|
||||
params.dirpyrDenoise.enabled = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_sh_hq ) {
|
||||
if (options.fastexport_bypass_sh_hq) {
|
||||
params.sh.hq = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_dirpyrequalizer ) {
|
||||
if (options.fastexport_bypass_dirpyrequalizer) {
|
||||
params.dirpyrequalizer.enabled = false;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_wavelet ) {
|
||||
if (options.fastexport_bypass_wavelet) {
|
||||
params.wavelet.enabled = false;
|
||||
}
|
||||
|
||||
//if (options.fastexport_bypass_raw_bayer_all_enhance ) params.raw.bayersensor.all_enhance = false;
|
||||
if (options.fastexport_bypass_raw_bayer_dcb_iterations ) {
|
||||
//if (options.fastexport_bypass_raw_bayer_all_enhance) params.raw.bayersensor.all_enhance = false;
|
||||
if (options.fastexport_bypass_raw_bayer_dcb_iterations) {
|
||||
params.raw.bayersensor.dcb_iterations = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_bayer_dcb_enhance ) {
|
||||
if (options.fastexport_bypass_raw_bayer_dcb_enhance) {
|
||||
params.raw.bayersensor.dcb_enhance = false;
|
||||
}
|
||||
|
||||
@ -1143,58 +1143,57 @@ void FileCatalog::developRequested (std::vector<FileBrowserEntry*> tbe, bool fas
|
||||
params.raw.bayersensor.lmmse_iterations = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_bayer_linenoise ) {
|
||||
if (options.fastexport_bypass_raw_bayer_linenoise) {
|
||||
params.raw.bayersensor.linenoise = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_bayer_greenthresh ) {
|
||||
if (options.fastexport_bypass_raw_bayer_greenthresh) {
|
||||
params.raw.bayersensor.greenthresh = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_ccSteps ) {
|
||||
if (options.fastexport_bypass_raw_ccSteps) {
|
||||
params.raw.bayersensor.ccSteps = params.raw.xtranssensor.ccSteps = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_ca ) {
|
||||
if (options.fastexport_bypass_raw_ca) {
|
||||
params.raw.ca_autocorrect = false;
|
||||
params.raw.cared = 0;
|
||||
params.raw.cablue = 0;
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_df ) {
|
||||
if (options.fastexport_bypass_raw_df) {
|
||||
params.raw.df_autoselect = false;
|
||||
params.raw.dark_frame = "";
|
||||
}
|
||||
|
||||
if (options.fastexport_bypass_raw_ff ) {
|
||||
if (options.fastexport_bypass_raw_ff) {
|
||||
params.raw.ff_AutoSelect = false;
|
||||
params.raw.ff_file = "";
|
||||
}
|
||||
|
||||
|
||||
params.raw.bayersensor.method = options.fastexport_raw_bayer_method ;
|
||||
params.raw.bayersensor.method = options.fastexport_raw_bayer_method;
|
||||
params.raw.xtranssensor.method = options.fastexport_raw_xtrans_method;
|
||||
params.icm.input = options.fastexport_icm_input ;
|
||||
params.icm.working = options.fastexport_icm_working ;
|
||||
params.icm.output = options.fastexport_icm_output ;
|
||||
params.icm.outputIntent = options.fastexport_icm_outputIntent ;
|
||||
params.icm.outputBPC = options.fastexport_icm_outputBPC ;
|
||||
params.icm.gamma = options.fastexport_icm_gamma ;
|
||||
params.icm.input = options.fastexport_icm_input;
|
||||
params.icm.working = options.fastexport_icm_working;
|
||||
params.icm.output = options.fastexport_icm_output;
|
||||
params.icm.outputIntent = options.fastexport_icm_outputIntent;
|
||||
params.icm.outputBPC = options.fastexport_icm_outputBPC;
|
||||
params.icm.gamma = options.fastexport_icm_gamma;
|
||||
}
|
||||
|
||||
if (params.resize.enabled) {
|
||||
params.resize.width = rtengine::min(params.resize.width, options.fastexport_resize_width) ;
|
||||
params.resize.height = rtengine::min(params.resize.height, options.fastexport_resize_height) ;
|
||||
params.resize.width = rtengine::min(params.resize.width, options.fastexport_resize_width);
|
||||
params.resize.height = rtengine::min(params.resize.height, options.fastexport_resize_height);
|
||||
} else {
|
||||
params.resize.width = options.fastexport_resize_width;
|
||||
params.resize.height = options.fastexport_resize_height;
|
||||
}
|
||||
|
||||
params.resize.enabled = options.fastexport_resize_enabled ;
|
||||
params.resize.scale = options.fastexport_resize_scale ;
|
||||
params.resize.appliesTo = options.fastexport_resize_appliesTo ;
|
||||
params.resize.method = options.fastexport_resize_method ;
|
||||
params.resize.dataspec = options.fastexport_resize_dataspec ;
|
||||
params.resize.enabled = options.fastexport_resize_enabled;
|
||||
params.resize.scale = options.fastexport_resize_scale;
|
||||
params.resize.appliesTo = options.fastexport_resize_appliesTo;
|
||||
params.resize.method = options.fastexport_resize_method;
|
||||
params.resize.dataspec = options.fastexport_resize_dataspec;
|
||||
}
|
||||
|
||||
rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (fbe->filename, th->getType() == FT_Raw, params, fastmode && options.fastexport_use_fast_pipeline);
|
||||
|
Loading…
x
Reference in New Issue
Block a user