diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index 35e36ce05..0a53ba469 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -111,7 +111,19 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution) using namespace std; using namespace rtengine; -float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterations, const double cared, const double cablue, const double caautostrength, array2D &rawData, double *fitParamsTransfer, bool fitParamsIn, bool fitParamsOut, float *buffer, bool freeBuffer) +float* RawImageSource::CA_correct_RT( + bool autoCA, + size_t autoIterations, + double cared, + double cablue, + double caautostrength, + const array2D &rawData, + double* fitParamsTransfer, + bool fitParamsIn, + bool fitParamsOut, + float* buffer, + bool freeBuffer +) { // multithreaded and vectorized by Ingo Weyrich constexpr int ts = 128; @@ -120,14 +132,16 @@ float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterati constexpr int v1 = ts, v2 = 2 * ts, v3 = 3 * ts, v4 = 4 * ts; //, p1=-ts+1, p2=-2*ts+2, p3=-3*ts+3, m1=ts+1, m2=2*ts+2, m3=3*ts+3; // Test for RGB cfa - for(int i = 0; i < 2; i++) - for(int j = 0; j < 2; j++) + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 2; j++) { if(FC(i, j) == 3) { printf("CA correction supports only RGB Colour filter arrays\n"); return buffer; } + } + } - volatile double progress = 0.0; + double progress = 0.0; if(plistener) { plistener->setProgress (progress); @@ -159,9 +173,16 @@ float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterati bool processpasstwo = true; double fitparams[2][2][16]; - const size_t iterations = autoCA ? std::max(autoIterations, static_cast(1)) : 1; + const size_t iterations = + autoCA + ? std::max(autoIterations, 1) + : 1; + for (size_t it = 0; it < iterations && processpasstwo; ++it) { - float blockave[2][2] = {{0, 0}, {0, 0}}, blocksqave[2][2] = {{0, 0}, {0, 0}}, blockdenom[2][2] = {{0, 0}, {0, 0}}, blockvar[2][2]; + float blockave[2][2] = {}; + float blocksqave[2][2] = {}; + float blockdenom[2][2] = {}; + float blockvar[2][2]; const bool fitParamsSet = fitParamsTransfer && fitParamsIn; if(autoCA && fitParamsSet && iterations < 2) { // use stored parameters diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 47fc756a9..b9729555b 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -239,7 +239,19 @@ protected: inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i); inline void interpolate_row_rb_mul_pp (const array2D &rawData, float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip); - float* CA_correct_RT (const bool autoCA, const size_t autoIterations, const double cared, const double cablue, const double caautostrength, array2D &rawData, double *fitParamsTransfer, bool fitParamsIn, bool fitParamsOut, float * buffer, bool freeBuffer); + float* CA_correct_RT( + bool autoCA, + size_t autoIterations, + double cared, + double cablue, + double caautostrength, + const array2D &rawData, + double* fitParamsTransfer, + bool fitParamsIn, + bool fitParamsOut, + float* buffer, + bool freeBuffer + ); void ddct8x8s(int isgn, float a[8][8]); void processRawWhitepoint (float expos, float preser, array2D &rawData); // exposure before interpolation diff --git a/rtgui/rawcacorrection.cc b/rtgui/rawcacorrection.cc index 7e75682e0..8c917c910 100644 --- a/rtgui/rawcacorrection.cc +++ b/rtgui/rawcacorrection.cc @@ -37,7 +37,7 @@ RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROM caAutocorrect = Gtk::manage (new CheckBox(M("TP_RAWCACORR_AUTO"), multiImage)); caAutocorrect->setCheckBoxListener (this); - caAutoiterations = Gtk::manage(new Adjuster (M("TP_RAWCACORR_AUTOIT"), 1, 3, 1, 1)); + caAutoiterations = Gtk::manage(new Adjuster (M("TP_RAWCACORR_AUTOIT"), 1, 5, 1, 1)); caAutoiterations->setAdjusterListener (this); if (caAutoiterations->delay < options.adjusterMaxDelay) {