From c16115cdde0b0a63aae75de2a23bc113ad35adae Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 30 Aug 2017 14:49:27 +0200 Subject: [PATCH 01/52] Speedup for loading of Phase One files --- rtengine/dcraw.cc | 253 ++++++++++++++++++++++++++++++++++------------ rtengine/dcraw.h | 31 +++++- 2 files changed, 218 insertions(+), 66 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index d6bac40de..784c6f9d8 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -25,6 +25,8 @@ /*RT*/#include "jpeg.h" #include "opthelper.h" +#define BENCHMARK +#include "StopWatch.h" /* dcraw.c -- Dave Coffin's raw photo decoder @@ -1435,56 +1437,69 @@ int CLASS raw (unsigned row, unsigned col) void CLASS phase_one_flat_field (int is_float, int nc) { - ushort head[8]; - unsigned wide, high, y, x, c, rend, cend, row, col; - float *mrow, num, mult[4]; + ushort uhead[8]; - read_shorts (head, 8); - if (head[2] * head[3] * head[4] * head[5] == 0) return; - wide = head[2] / head[4] + (head[2] % head[4] != 0); - high = head[3] / head[5] + (head[3] % head[5] != 0); - mrow = (float *) calloc (nc*wide, sizeof *mrow); - merror (mrow, "phase_one_flat_field()"); - for (y=0; y < high; y++) { - for (x=0; x < wide; x++) - for (c=0; c < nc; c+=2) { - num = is_float ? getreal(11) : get2()/32768.0; - if (y==0) mrow[c*wide+x] = num; - else mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) / head[5]; - } - if (y==0) continue; - rend = head[1] + y*head[5]; - for (row = rend-head[5]; - row < raw_height && row < rend && - row < head[1]+head[3]-head[5]; row++) { - for (x=1; x < wide; x++) { - for (c=0; c < nc; c+=2) { - mult[c] = mrow[c*wide+x-1]; - mult[c+1] = (mrow[c*wide+x] - mult[c]) / head[4]; - } - cend = head[0] + x*head[4]; - for (col = cend-head[4]; - col < raw_width && - col < cend && col < head[0]+head[2]-head[4]; col++) { - c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0; - if (!(c & 1)) { - c = RAW(row,col) * mult[c]; - RAW(row,col) = LIM(c,0,65535); - } - for (c=0; c < nc; c+=2) - mult[c] += mult[c+1]; - } - } - for (x=0; x < wide; x++) - for (c=0; c < nc; c+=2) - mrow[c*wide+x] += mrow[(c+1)*wide+x]; + read_shorts (uhead, 8); + if (uhead[2] * uhead[3] * uhead[4] * uhead[5] == 0) { + return; } - } - free (mrow); + const unsigned wide = uhead[2] / uhead[4] + (uhead[2] % uhead[4] != 0); + const unsigned high = uhead[3] / uhead[5] + (uhead[3] % uhead[5] != 0); + const unsigned colLimit = std::min(uhead[0] + uhead[2] - uhead[4], (int)raw_width); + + const float head4 = 1.0 / uhead[4]; + const float head5 = 1.0 / uhead[5]; + + float* mrow = (float *) calloc(nc * wide, sizeof *mrow); + merror(mrow, "phase_one_flat_field()"); + for (unsigned x=0; x < wide; x++) { + for (unsigned c=0; c < nc; c+=2) { + float num = is_float ? getreal(11) : get2() / 32768.f; + mrow[c * wide + x] = num; + } + } + for (unsigned y=1; y < high; y++) { + for (unsigned x=0; x < wide; x++) { + for (unsigned c=0; c < nc; c+=2) { + float num = is_float ? getreal(11) : get2() / 32768.f; + mrow[(c + 1) * wide + x] = (num - mrow[c * wide + x]) * head5; + } + } + const unsigned rend = uhead[1] + y * uhead[5]; + for (unsigned row = rend - uhead[5]; row < raw_height && row < rend && row < uhead[1] + uhead[3] - uhead[5]; row++) { + unsigned cend = uhead[0] + uhead[4]; + const unsigned c0 = FC(row - top_margin, cend - uhead[4] - left_margin); + const unsigned c = nc > 2 ? (c0 & 1) ? FC(row - top_margin, cend - uhead[4] - left_margin + 1) : c0 : 0; + for (unsigned x=1; x < wide; x++, cend += uhead[4]) { + float mult0 = mrow[c * wide + x - 1]; + float mult1 = (mrow[c * wide + x] - mult0) * head4; + if (nc > 2) { + mult0 += (c0 & 1) ? mult1 : 0; + for (unsigned col = cend - uhead[4] + (c0 & 1); col < std::min(colLimit, cend); col += 2) { + RAW(row, col) *= mult0; + mult0 += mult1; + mult0 += mult1; // <= this could be reduced to one addition inside the loop, but then the result is not exactly the same as with old code, though it should be even more accurate then + } + } else { + for (unsigned col = cend - uhead[4]; col < std::min(colLimit, cend); col++) { + RAW(row, col) *= mult0; + mult0 += mult1; + } + } + } + for (unsigned x=0; x < wide; x++) { + for (unsigned c=0; c < nc; c+=2) { + mrow[c * wide + x] += mrow[(c + 1) * wide + x]; + } + } + } + } + free(mrow); } void CLASS phase_one_correct() { + BENCHFUN unsigned entries, tag, data, save, col, row, type; int len, i, j, k, cip, val[4], dev[4], sum, max; int head[9], diff, mindiff=INT_MAX, off_412=0; @@ -1725,11 +1740,38 @@ unsigned CLASS ph1_bithuff_t::operator() (int nbits, ushort *huff) vbits -= nbits; return c; } -#define ph1_bits(n) ph1_bithuff(n,0) + +inline unsigned CLASS ph1_bithuff_t::operator() (int nbits) +{ +/*RT static UINT64 bitbuf=0; */ +/*RT static int vbits=0; */ + + if (vbits < nbits) { + bitbuf = bitbuf << 32 | get4(); + vbits += 32; + } + unsigned c = bitbuf << (64-vbits) >> (64-nbits); + vbits -= nbits; + return c; +} + +inline unsigned CLASS ph1_bithuff_t::operator() () +{ +/*RT static UINT64 bitbuf=0; */ +/*RT static int vbits=0; */ + return bitbuf = vbits = 0; +} + + +#define ph1_init() ph1_bithuff() +#define ph1_bits(n) ph1_bithuff(n) +#define hb_bits(n) ph1_bithuff(n,0) #define ph1_huff(h) ph1_bithuff(*h,h+1) +#ifndef MYFILE_MMAP void CLASS phase_one_load_raw_c() { + BENCHFUN static const int length[] = { 8,7,6,9,11,10,5,12,14,13 }; int *offset, len[2], pred[2], row, col, i, j; ushort *pixel; @@ -1753,7 +1795,7 @@ void CLASS phase_one_load_raw_c() curve[i] = i*i / 3.969 + 0.5; for (row=0; row < raw_height; row++) { fseek (ifp, data_offset + offset[row], SEEK_SET); - ph1_bits(-1); + ph1_init(); pred[0] = pred[1] = 0; for (col=0; col < raw_width; col++) { if (col >= (raw_width & -8)) @@ -1781,7 +1823,91 @@ void CLASS phase_one_load_raw_c() free (pixel); maximum = 0xfffc - ph1.black; } +#else +void CLASS phase_one_load_raw_c() +{ +BENCHFUN + static const int length[] = { 8,7,6,9,11,10,5,12,14,13 }; + short (*cblack)[2], (*rblack)[2]; + int *offset = (int *) calloc(raw_width * 2 + raw_height * 4, 2); + fseek(ifp, strip_offset, SEEK_SET); + for (int row=0; row < raw_height; row++) { + offset[row] = get4(); + } + cblack = (short (*)[2]) (offset + raw_height); + fseek(ifp, ph1.black_col, SEEK_SET); + if (ph1.black_col) { + read_shorts ((ushort *) cblack[0], raw_height * 2); + } + rblack = cblack + raw_height; + fseek(ifp, ph1.black_row, SEEK_SET); + if (ph1.black_row) { + read_shorts ((ushort *) rblack[0], raw_width * 2); + } + for (int i=0; i < 256; i++) { + curve[i] = i * i / 3.969 + 0.5; + } + +#pragma omp parallel +{ + int len[2], pred[2]; + IMFILE *ifpthr = new IMFILE; + ifpthr->fd = ifp->fd; + ifpthr->pos = ifp->pos; + ifpthr->size = ifp->size; + ifpthr->data = ifp->data; + ifpthr->eof = ifp->eof; + ifpthr->plistener = nullptr; + ifpthr->progress_range = ifp->progress_range; + ifpthr->progress_next = ifp->progress_next; + ifpthr->progress_current = ifp->progress_current; + + ph1_bithuff_t ph1_bithuff(this, ifpthr, order); + ushort pixel; + + #pragma omp for schedule(dynamic,16) + for (int row=0; row < raw_height; row++) { + int shift = 2*(ph1.format != 8); + fseek(ifpthr, data_offset + offset[row], SEEK_SET); + ph1_init(); + pred[0] = pred[1] = 0; + for (int col=0; col < raw_width; col++) { + if (col >= (raw_width & -8)) { + len[0] = len[1] = 14; + } else if ((col & 7) == 0) { + for (int i=0; i < 2; i++) { + int j; + for (j=0; j < 5 && !ph1_bits(1); j++); + if (j--) { + len[i] = length[j*2 + ph1_bits(1)]; + } + } + } + int i; + if ((i = len[col & 1]) == 14) { + pixel = pred[col & 1] = ph1_bits(16); + } else { + pixel = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1)); + } + if (UNLIKELY(pred[col & 1] >> 16)) { + derror(); + } + if (ph1.format == 5 && pixel < 256) { + pixel = curve[pixel]; + } + int rawVal = (pixel << shift) - ph1.black + + cblack[row][col >= ph1.split_col] + + rblack[col][row >= ph1.split_row]; + RAW(row,col) = std::max(rawVal, 0); + } + } + delete ifpthr; +} + free(offset); + maximum = 0xfffc - ph1.black; +} +#endif void CLASS parse_hasselblad_gain() { /* @@ -2122,7 +2248,7 @@ void CLASS hasselblad_load_raw() if (!ljpeg_start (&jh, 0)) return; order = 0x4949; - ph1_bits(-1); + hb_bits(-1); back[4] = (int *) calloc (raw_width, 3*sizeof **back); merror (back[4], "hasselblad_load_raw()"); FORC3 back[c] = back[4] + c*raw_width; @@ -2134,7 +2260,7 @@ void CLASS hasselblad_load_raw() for (s=0; s < tiff_samples*2; s+=2) { FORC(2) len[c] = ph1_huff(jh.huff[0]); FORC(2) { - diff[s+c] = ph1_bits(len[c]); + diff[s+c] = hb_bits(len[c]); if ((diff[s+c] & (1 << (len[c]-1))) == 0) diff[s+c] -= (1 << len[c]) - 1; if (diff[s+c] == 65535) diff[s+c] = -32768; @@ -3088,19 +3214,19 @@ void CLASS samsung_load_raw() for (row=0; row < raw_height; row++) { fseek (ifp, strip_offset+row*4, SEEK_SET); fseek (ifp, data_offset+get4(), SEEK_SET); - ph1_bits(-1); + hb_bits(-1); FORC4 len[c] = row < 2 ? 7:4; for (col=0; col < raw_width; col+=16) { - dir = ph1_bits(1); - FORC4 op[c] = ph1_bits(2); + dir = hb_bits(1); + FORC4 op[c] = hb_bits(2); FORC4 switch (op[c]) { - case 3: len[c] = ph1_bits(4); break; + case 3: len[c] = hb_bits(4); break; case 2: len[c]--; break; case 1: len[c]++; } for (c=0; c < 16; c+=2) { i = len[((c & 1) << 1) | (c >> 3)]; - RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) + + RAW(row,col+c) = ((signed) hb_bits(i) << (32-i) >> (32-i)) + (dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128); if (c == 14) c = -1; } @@ -3144,25 +3270,25 @@ void CLASS samsung3_load_raw() init = (get2(),get2()); for (row=0; row < raw_height; row++) { fseek (ifp, (data_offset-ftell(ifp)) & 15, SEEK_CUR); - ph1_bits(-1); + hb_bits(-1); mag = 0; pmode = 7; FORC(6) ((ushort *)lent)[c] = row < 2 ? 7:4; prow[ row & 1] = &RAW(row-1,1-((row & 1) << 1)); // green prow[~row & 1] = &RAW(row-2,0); // red and blue for (tab=0; tab+15 < raw_width; tab+=16) { if (~opt & 4 && !(tab & 63)) { - i = ph1_bits(2); - mag = i < 3 ? mag-'2'+"204"[i] : ph1_bits(12); + i = hb_bits(2); + mag = i < 3 ? mag-'2'+"204"[i] : hb_bits(12); } if (opt & 2) - pmode = 7 - 4*ph1_bits(1); - else if (!ph1_bits(1)) - pmode = ph1_bits(3); - if (opt & 1 || !ph1_bits(1)) { - FORC4 len[c] = ph1_bits(2); + pmode = 7 - 4*hb_bits(1); + else if (!hb_bits(1)) + pmode = hb_bits(3); + if (opt & 1 || !hb_bits(1)) { + FORC4 len[c] = hb_bits(2); FORC4 { i = ((row & 1) << 1 | (c & 1)) % 3; - len[c] = len[c] < 3 ? lent[i][0]-'1'+"120"[len[c]] : ph1_bits(4); + len[c] = len[c] < 3 ? lent[i][0]-'1'+"120"[len[c]] : hb_bits(4); lent[i][0] = lent[i][1]; lent[i][1] = len[c]; } @@ -3173,7 +3299,7 @@ void CLASS samsung3_load_raw() ? (tab ? RAW(row,tab-2+(col & 1)) : init) : (prow[col & 1][col-'4'+"0224468"[pmode]] + prow[col & 1][col-'4'+"0244668"[pmode]] + 1) >> 1; - diff = ph1_bits (i = len[c >> 2]); + diff = hb_bits (i = len[c >> 2]); if (diff >> (i-1)) diff -= 1 << i; diff = diff * (mag*2+1) + mag; RAW(row,col) = pred + diff; @@ -4103,7 +4229,6 @@ void CLASS crop_masked_pixels() } } } else { - #pragma omp parallel for for (int row=0; row < height; row++) for (int col=0; col < width; col++) diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index a109b43c2..0fa0f2175 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -318,10 +318,37 @@ class ph1_bithuff_t { public: ph1_bithuff_t(DCraw *p,IMFILE *&i,short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){} unsigned operator()(int nbits, ushort *huff); + unsigned operator()(int nbits); + unsigned operator()(); + ushort get2() { + uchar str[2] = { 0xff,0xff }; + fread (str, 1, 2, ifp); + if (order == 0x4949) { /* "II" means little-endian */ + return str[0] | str[1] << 8; + } else { /* "MM" means big-endian */ + return str[0] << 8 | str[1]; + } + } private: - unsigned get4(){ - return parent->get4(); + inline unsigned get4() { + unsigned val = 0xffffff; + uchar* str = (uchar*)&val; + fread (str, 1, 4, ifp); + if (order == 0x4949) { +#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ + return val; +#else + return str[0] | str[1] << 8 | str[2] << 16 | str[3] << 24; +#endif + } else { +#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ + return str[0] << 24 | str[1] << 16 | str[2] << 8 | str[3]; +#else + return val; +#endif + } } + DCraw *parent; short ℴ IMFILE *&ifp; From 61a69ba1930ed5400cacde1323409cd83956d331 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 30 Aug 2017 16:44:46 +0200 Subject: [PATCH 02/52] Fixed artifacts in clipped highlights of phase one files I introduced with recent commit --- rtengine/dcraw.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 784c6f9d8..3f4c1736c 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1476,13 +1476,15 @@ void CLASS phase_one_flat_field (int is_float, int nc) if (nc > 2) { mult0 += (c0 & 1) ? mult1 : 0; for (unsigned col = cend - uhead[4] + (c0 & 1); col < std::min(colLimit, cend); col += 2) { - RAW(row, col) *= mult0; + int val = RAW(row, col) * mult0; + RAW(row, col) = LIM(val, 0, 65535); mult0 += mult1; mult0 += mult1; // <= this could be reduced to one addition inside the loop, but then the result is not exactly the same as with old code, though it should be even more accurate then } } else { for (unsigned col = cend - uhead[4]; col < std::min(colLimit, cend); col++) { - RAW(row, col) *= mult0; + int val = RAW(row, col) * mult0; + RAW(row, col) = LIM(val, 0, 65535); mult0 += mult1; } } From fd1909e4da39f0730786ad1a57abab87b81a75a5 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 30 Aug 2017 18:55:30 +0200 Subject: [PATCH 03/52] Additional optimizations for Phase One P45+ and P65+ --- rtengine/dcraw.cc | 403 ++++++++++++++++++++++++---------------------- 1 file changed, 207 insertions(+), 196 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 3f4c1736c..ec06afee6 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1501,204 +1501,215 @@ void CLASS phase_one_flat_field (int is_float, int nc) void CLASS phase_one_correct() { - BENCHFUN - unsigned entries, tag, data, save, col, row, type; - int len, i, j, k, cip, val[4], dev[4], sum, max; - int head[9], diff, mindiff=INT_MAX, off_412=0; - static const signed char dir[12][2] = - { {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0}, - {-2,-2}, {-2,2}, {2,-2}, {2,2} }; - float poly[8], num, cfrac, frac, mult[2], *yval[2]; - ushort *xval[2]; - int qmult_applied = 0, qlin_applied = 0; +BENCHFUN + unsigned entries, tag, data, save, col, row, type; + int len, i, j, k, cip, val[4], dev[4], sum, max; + int head[9], diff, mindiff=INT_MAX, off_412=0; + static const signed char dir[12][2] = { {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0}, {-2,-2}, {-2,2}, {2,-2}, {2,2} }; + float poly[8], num, cfrac, frac, mult[2], *yval[2]; + ushort *xval[2]; + int qmult_applied = 0, qlin_applied = 0; - if (half_size || !meta_length) return; - if (verbose) fprintf (stderr,_("Phase One correction...\n")); - fseek (ifp, meta_offset, SEEK_SET); - order = get2(); - fseek (ifp, 6, SEEK_CUR); - fseek (ifp, meta_offset+get4(), SEEK_SET); - entries = get4(); get4(); - while (entries--) { - tag = get4(); - len = get4(); - data = get4(); - save = ftell(ifp); - fseek (ifp, meta_offset+data, SEEK_SET); - if (tag == 0x419) { /* Polynomial curve */ - for (get4(), i=0; i < 8; i++) - poly[i] = getreal(11); - poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1; - for (i=0; i < 0x10000; i++) { - num = (poly[5]*i + poly[3])*i + poly[1]; - curve[i] = LIM(num,0,65535); - } goto apply; /* apply to right half */ - } else if (tag == 0x41a) { /* Polynomial curve */ - for (i=0; i < 4; i++) - poly[i] = getreal(11); - for (i=0; i < 0x10000; i++) { - for (num=0, j=4; j--; ) - num = num * i + poly[j]; - curve[i] = LIM(num+i,0,65535); - } apply: /* apply to whole image */ - for (row=0; row < raw_height; row++) - for (col = (tag & 1)*ph1.split_col; col < raw_width; col++) - RAW(row,col) = curve[RAW(row,col)]; - } else if (tag == 0x400) { /* Sensor defects */ - while ((len -= 8) >= 0) { - col = get2(); - row = get2(); - type = get2(); get2(); - if (col >= raw_width) continue; - if (type == 131 || type == 137) /* Bad column */ - for (row=0; row < raw_height; row++) - if (FC(row-top_margin,col-left_margin) == 1) { - for (sum=i=0; i < 4; i++) - sum += val[i] = raw (row+dir[i][0], col+dir[i][1]); - for (max=i=0; i < 4; i++) { - dev[i] = abs((val[i] << 2) - sum); - if (dev[max] < dev[i]) max = i; - } - RAW(row,col) = (sum - val[max])/3.0 + 0.5; - } else { - for (sum=0, i=8; i < 12; i++) - sum += raw (row+dir[i][0], col+dir[i][1]); - RAW(row,col) = 0.5 + sum * 0.0732233 + - (raw(row,col-2) + raw(row,col+2)) * 0.3535534; - } - else if (type == 129) { /* Bad pixel */ - if (row >= raw_height) continue; - j = (FC(row-top_margin,col-left_margin) != 1) * 4; - for (sum=0, i=j; i < j+8; i++) - sum += raw (row+dir[i][0], col+dir[i][1]); - RAW(row,col) = (sum + 4) >> 3; - } - } - } else if (tag == 0x401) { /* All-color flat fields */ - phase_one_flat_field (1, 2); - } else if (tag == 0x416 || tag == 0x410) { - phase_one_flat_field (0, 2); - } else if (tag == 0x40b) { /* Red+blue flat field */ - phase_one_flat_field (0, 4); - } else if (tag == 0x412) { - fseek (ifp, 36, SEEK_CUR); - diff = abs (get2() - ph1.tag_21a); - if (mindiff > diff) { - mindiff = diff; - off_412 = ftell(ifp) - 38; - } - } else if (tag == 0x41f && !qlin_applied) { /* Quadrant linearization */ - ushort lc[2][2][16], ref[16]; - int qr, qc; - for (qr = 0; qr < 2; qr++) - for (qc = 0; qc < 2; qc++) - for (i = 0; i < 16; i++) - lc[qr][qc][i] = get4(); - for (i = 0; i < 16; i++) { - int v = 0; - for (qr = 0; qr < 2; qr++) - for (qc = 0; qc < 2; qc++) - v += lc[qr][qc][i]; - ref[i] = (v + 2) >> 2; - } - for (qr = 0; qr < 2; qr++) { - for (qc = 0; qc < 2; qc++) { - int cx[19], cf[19]; - for (i = 0; i < 16; i++) { - cx[1+i] = lc[qr][qc][i]; - cf[1+i] = ref[i]; - } - cx[0] = cf[0] = 0; - cx[17] = cf[17] = ((unsigned) ref[15] * 65535) / lc[qr][qc][15]; - cx[18] = cf[18] = 65535; - cubic_spline(cx, cf, 19); - for (row = (qr ? ph1.split_row : 0); - row < (qr ? raw_height : ph1.split_row); row++) - for (col = (qc ? ph1.split_col : 0); - col < (qc ? raw_width : ph1.split_col); col++) - RAW(row,col) = curve[RAW(row,col)]; - } - } - qlin_applied = 1; - } else if (tag == 0x41e && !qmult_applied) { /* Quadrant multipliers */ - float qmult[2][2] = { { 1, 1 }, { 1, 1 } }; - get4(); get4(); get4(); get4(); - qmult[0][0] = 1.0 + getreal(11); - get4(); get4(); get4(); get4(); get4(); - qmult[0][1] = 1.0 + getreal(11); - get4(); get4(); get4(); - qmult[1][0] = 1.0 + getreal(11); - get4(); get4(); get4(); - qmult[1][1] = 1.0 + getreal(11); - for (row=0; row < raw_height; row++) - for (col=0; col < raw_width; col++) { - i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col); - RAW(row,col) = LIM(i,0,65535); - } - qmult_applied = 1; - } else if (tag == 0x431 && !qmult_applied) { /* Quadrant combined */ - ushort lc[2][2][7], ref[7]; - int qr, qc; - for (i = 0; i < 7; i++) - ref[i] = get4(); - for (qr = 0; qr < 2; qr++) - for (qc = 0; qc < 2; qc++) - for (i = 0; i < 7; i++) - lc[qr][qc][i] = get4(); - for (qr = 0; qr < 2; qr++) { - for (qc = 0; qc < 2; qc++) { - int cx[9], cf[9]; - for (i = 0; i < 7; i++) { - cx[1+i] = ref[i]; - cf[1+i] = ((unsigned) ref[i] * lc[qr][qc][i]) / 10000; - } - cx[0] = cf[0] = 0; - cx[8] = cf[8] = 65535; - cubic_spline(cx, cf, 9); - for (row = (qr ? ph1.split_row : 0); - row < (qr ? raw_height : ph1.split_row); row++) - for (col = (qc ? ph1.split_col : 0); - col < (qc ? raw_width : ph1.split_col); col++) - RAW(row,col) = curve[RAW(row,col)]; - } - } - qmult_applied = 1; - qlin_applied = 1; + if (half_size || !meta_length) { + return; + } + if (verbose) { + fprintf (stderr,_("Phase One correction...\n")); + } + fseek (ifp, meta_offset, SEEK_SET); + order = get2(); + fseek (ifp, 6, SEEK_CUR); + fseek (ifp, meta_offset+get4(), SEEK_SET); + entries = get4(); get4(); + while (entries--) { + tag = get4(); + len = get4(); + data = get4(); + save = ftell(ifp); + fseek (ifp, meta_offset+data, SEEK_SET); + if (tag == 0x419) { /* Polynomial curve */ + for (get4(), i=0; i < 8; i++) { + poly[i] = getreal(11); + } + poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1; + for (i=0; i < 0x10000; i++) { + num = (poly[5]*i + poly[3])*i + poly[1]; + curve[i] = LIM(num,0,65535); + } + goto apply; /* apply to right half */ + } else if (tag == 0x41a) { /* Polynomial curve */ + for (i=0; i < 4; i++) { + poly[i] = getreal(11); + } + for (i=0; i < 0x10000; i++) { + for (num=0, j=4; j--;) { + num = num * i + poly[j]; + } + curve[i] = LIM(num+i,0,65535); + } + apply: /* apply to whole image */ + #pragma omp parallel for schedule(dynamic,16) + for (int row=0; row < raw_height; row++) { + for (int col = (tag & 1)*ph1.split_col; col < raw_width; col++) { + RAW(row,col) = curve[RAW(row,col)]; + } + } + } else if (tag == 0x400) { /* Sensor defects */ + while ((len -= 8) >= 0) { + col = get2(); + row = get2(); + type = get2(); + get2(); + if (col >= raw_width) continue; + if (type == 131 || type == 137) { /* Bad column */ + for (row=0; row < raw_height; row++) { + if (FC(row-top_margin,col-left_margin) == 1) { + for (sum=i=0; i < 4; i++) + sum += val[i] = raw (row+dir[i][0], col+dir[i][1]); + for (max=i=0; i < 4; i++) { + dev[i] = abs((val[i] << 2) - sum); + if (dev[max] < dev[i]) max = i; + } + RAW(row,col) = (sum - val[max])/3.0 + 0.5; + } else { + for (sum=0, i=8; i < 12; i++) + sum += raw (row+dir[i][0], col+dir[i][1]); + RAW(row,col) = 0.5 + sum * 0.0732233 + (raw(row,col-2) + raw(row,col+2)) * 0.3535534; + } + } + } else if (type == 129) { /* Bad pixel */ + if (row >= raw_height) continue; + j = (FC(row-top_margin,col-left_margin) != 1) * 4; + for (sum=0, i=j; i < j+8; i++) + sum += raw (row+dir[i][0], col+dir[i][1]); + RAW(row,col) = (sum + 4) >> 3; + } + } + } else if (tag == 0x401) { /* All-color flat fields */ + phase_one_flat_field (1, 2); + } else if (tag == 0x416 || tag == 0x410) { + phase_one_flat_field (0, 2); + } else if (tag == 0x40b) { /* Red+blue flat field */ + phase_one_flat_field (0, 4); + } else if (tag == 0x412) { + fseek (ifp, 36, SEEK_CUR); + diff = abs (get2() - ph1.tag_21a); + if (mindiff > diff) { + mindiff = diff; + off_412 = ftell(ifp) - 38; + } + } else if (tag == 0x41f && !qlin_applied) { /* Quadrant linearization */ + ushort lc[2][2][16], ref[16]; + int qr, qc; + for (qr = 0; qr < 2; qr++) + for (qc = 0; qc < 2; qc++) + for (i = 0; i < 16; i++) + lc[qr][qc][i] = get4(); + for (i = 0; i < 16; i++) { + int v = 0; + for (qr = 0; qr < 2; qr++) + for (qc = 0; qc < 2; qc++) + v += lc[qr][qc][i]; + ref[i] = (v + 2) >> 2; + } + for (qr = 0; qr < 2; qr++) { + for (qc = 0; qc < 2; qc++) { + int cx[19], cf[19]; + for (i = 0; i < 16; i++) { + cx[1+i] = lc[qr][qc][i]; + cf[1+i] = ref[i]; + } + cx[0] = cf[0] = 0; + cx[17] = cf[17] = ((unsigned) ref[15] * 65535) / lc[qr][qc][15]; + cx[18] = cf[18] = 65535; + cubic_spline(cx, cf, 19); + #pragma omp parallel for schedule(dynamic,16) + for (int row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++) + for (int col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++) + RAW(row,col) = curve[RAW(row,col)]; + } + } + qlin_applied = 1; + } else if (tag == 0x41e && !qmult_applied) { /* Quadrant multipliers */ + float qmult[2][2] = { { 1, 1 }, { 1, 1 } }; + get4(); get4(); get4(); get4(); + qmult[0][0] = 1.0 + getreal(11); + get4(); get4(); get4(); get4(); get4(); + qmult[0][1] = 1.0 + getreal(11); + get4(); get4(); get4(); + qmult[1][0] = 1.0 + getreal(11); + get4(); get4(); get4(); + qmult[1][1] = 1.0 + getreal(11); + #pragma omp parallel for schedule(dynamic,16) + for (int row=0; row < raw_height; row++) { + for (int col=0; col < raw_width; col++) { + int i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col); + RAW(row,col) = LIM(i,0,65535); + } + } + qmult_applied = 1; + } else if (tag == 0x431 && !qmult_applied) { /* Quadrant combined */ + ushort lc[2][2][7], ref[7]; + int qr, qc; + for (i = 0; i < 7; i++) + ref[i] = get4(); + for (qr = 0; qr < 2; qr++) + for (qc = 0; qc < 2; qc++) + for (i = 0; i < 7; i++) + lc[qr][qc][i] = get4(); + for (qr = 0; qr < 2; qr++) { + for (qc = 0; qc < 2; qc++) { + int cx[9], cf[9]; + for (i = 0; i < 7; i++) { + cx[1+i] = ref[i]; + cf[1+i] = ((unsigned) ref[i] * lc[qr][qc][i]) / 10000; + } + cx[0] = cf[0] = 0; + cx[8] = cf[8] = 65535; + cubic_spline(cx, cf, 9); + for (row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++) + for (col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++) + RAW(row,col) = curve[RAW(row,col)]; + } + } + qmult_applied = 1; + qlin_applied = 1; + } + fseek (ifp, save, SEEK_SET); + } + if (off_412) { + fseek (ifp, off_412, SEEK_SET); + for (i=0; i < 9; i++) + head[i] = get4() & 0x7fff; + yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6); + merror (yval[0], "phase_one_correct()"); + yval[1] = (float *) (yval[0] + head[1]*head[3]); + xval[0] = (ushort *) (yval[1] + head[2]*head[4]); + xval[1] = (ushort *) (xval[0] + head[1]*head[3]); + get2(); + for (i=0; i < 2; i++) + for (j=0; j < head[i+1]*head[i+3]; j++) + yval[i][j] = getreal(11); + for (i=0; i < 2; i++) + for (j=0; j < head[i+1]*head[i+3]; j++) + xval[i][j] = get2(); + for (row=0; row < raw_height; row++) + for (col=0; col < raw_width; col++) { + cfrac = (float) col * head[3] / raw_width; + cfrac -= cip = cfrac; + num = RAW(row,col) * 0.5; + for (i=cip; i < cip+2; i++) { + for (k=j=0; j < head[1]; j++) + if (num < xval[0][k = head[1]*i+j]) + break; + frac = (j == 0 || j == head[1]) ? 0 : (xval[0][k] - num) / (xval[0][k] - xval[0][k-1]); + mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac); + } + i = ((mult[0] * (1-cfrac) + mult[1] * cfrac) * row + num) * 2; + RAW(row,col) = LIM(i,0,65535); + } + free (yval[0]); } - fseek (ifp, save, SEEK_SET); - } - if (off_412) { - fseek (ifp, off_412, SEEK_SET); - for (i=0; i < 9; i++) head[i] = get4() & 0x7fff; - yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6); - merror (yval[0], "phase_one_correct()"); - yval[1] = (float *) (yval[0] + head[1]*head[3]); - xval[0] = (ushort *) (yval[1] + head[2]*head[4]); - xval[1] = (ushort *) (xval[0] + head[1]*head[3]); - get2(); - for (i=0; i < 2; i++) - for (j=0; j < head[i+1]*head[i+3]; j++) - yval[i][j] = getreal(11); - for (i=0; i < 2; i++) - for (j=0; j < head[i+1]*head[i+3]; j++) - xval[i][j] = get2(); - for (row=0; row < raw_height; row++) - for (col=0; col < raw_width; col++) { - cfrac = (float) col * head[3] / raw_width; - cfrac -= cip = cfrac; - num = RAW(row,col) * 0.5; - for (i=cip; i < cip+2; i++) { - for (k=j=0; j < head[1]; j++) - if (num < xval[0][k = head[1]*i+j]) break; - frac = (j == 0 || j == head[1]) ? 0 : - (xval[0][k] - num) / (xval[0][k] - xval[0][k-1]); - mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac); - } - i = ((mult[0] * (1-cfrac) + mult[1] * cfrac) * row + num) * 2; - RAW(row,col) = LIM(i,0,65535); - } - free (yval[0]); - } } void CLASS phase_one_load_raw() From 6a67dd350012c117550fa007ae1ae6e439573b36 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 30 Aug 2017 19:47:26 +0200 Subject: [PATCH 04/52] Additional speedup for phase_one_flat_field() --- rtengine/dcraw.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index ec06afee6..9b4015d43 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1476,15 +1476,15 @@ void CLASS phase_one_flat_field (int is_float, int nc) if (nc > 2) { mult0 += (c0 & 1) ? mult1 : 0; for (unsigned col = cend - uhead[4] + (c0 & 1); col < std::min(colLimit, cend); col += 2) { - int val = RAW(row, col) * mult0; - RAW(row, col) = LIM(val, 0, 65535); + unsigned val = RAW(row, col) * mult0; + RAW(row, col) = rtengine::min(val, 65535u); mult0 += mult1; mult0 += mult1; // <= this could be reduced to one addition inside the loop, but then the result is not exactly the same as with old code, though it should be even more accurate then } } else { for (unsigned col = cend - uhead[4]; col < std::min(colLimit, cend); col++) { - int val = RAW(row, col) * mult0; - RAW(row, col) = LIM(val, 0, 65535); + unsigned val = RAW(row, col) * mult0; + RAW(row, col) = rtengine::min(val, 65535u); mult0 += mult1; } } From 51804a15a0aa2bfde65b18269a68b9be55a35e97 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 23 Sep 2017 11:03:07 +0200 Subject: [PATCH 05/52] phase_one_load_raw_c() cleanup --- rtengine/dcraw.cc | 73 +++++++++++++++++++++++++---------------------- rtengine/dcraw.h | 2 +- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index d02dfa99e..623547962 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1489,8 +1489,8 @@ void CLASS phase_one_flat_field (int is_float, int nc) } } } - for (unsigned x=0; x < wide; x++) { - for (unsigned c=0; c < nc; c+=2) { + for (unsigned x = 0; x < wide; x++) { + for (unsigned c = 0; c < nc; c += 2) { mrow[c * wide + x] += mrow[(c + 1) * wide + x]; } } @@ -1841,81 +1841,86 @@ void CLASS phase_one_load_raw_c() { BENCHFUN static const int length[] = { 8,7,6,9,11,10,5,12,14,13 }; - short (*cblack)[2], (*rblack)[2]; - int *offset = (int *) calloc(raw_width * 2 + raw_height * 4, 2); + int *offset = (int *)calloc(raw_width * 2 + raw_height * 4, 2); fseek(ifp, strip_offset, SEEK_SET); - for (int row=0; row < raw_height; row++) { + for (int row = 0; row < raw_height; row++) { offset[row] = get4(); } - cblack = (short (*)[2]) (offset + raw_height); + + short (*cblack)[2] = (short (*)[2]) (offset + raw_height); fseek(ifp, ph1.black_col, SEEK_SET); if (ph1.black_col) { read_shorts ((ushort *) cblack[0], raw_height * 2); } - rblack = cblack + raw_height; + + short (*rblack)[2] = cblack + raw_height; fseek(ifp, ph1.black_row, SEEK_SET); if (ph1.black_row) { read_shorts ((ushort *) rblack[0], raw_width * 2); } - for (int i=0; i < 256; i++) { + + for (int i = 0; i < 256; i++) { curve[i] = i * i / 3.969 + 0.5; } +#ifdef _OPENMP #pragma omp parallel +#endif { int len[2], pred[2]; - IMFILE *ifpthr = new IMFILE; - ifpthr->fd = ifp->fd; - ifpthr->pos = ifp->pos; - ifpthr->size = ifp->size; - ifpthr->data = ifp->data; - ifpthr->eof = ifp->eof; - ifpthr->plistener = nullptr; - ifpthr->progress_range = ifp->progress_range; - ifpthr->progress_next = ifp->progress_next; - ifpthr->progress_current = ifp->progress_current; + IMFILE ifpthr = *ifp; + ifpthr.plistener = nullptr; - ph1_bithuff_t ph1_bithuff(this, ifpthr, order); - ushort pixel; +#ifdef _OPENMP +#pragma omp master +#endif +{ + ifpthr.plistener = ifp->plistener; +} + ph1_bithuff_t ph1_bithuff(this, &ifpthr, order); + +#ifdef _OPENMP #pragma omp for schedule(dynamic,16) - for (int row=0; row < raw_height; row++) { - int shift = 2*(ph1.format != 8); - fseek(ifpthr, data_offset + offset[row], SEEK_SET); +#endif + + for (int row = 0; row < raw_height; row++) { + const int shift = 2 * (ph1.format != 8); + fseek(&ifpthr, data_offset + offset[row], SEEK_SET); ph1_init(); pred[0] = pred[1] = 0; - for (int col=0; col < raw_width; col++) { + for (int col = 0; col < raw_width; col++) { if (col >= (raw_width & -8)) { len[0] = len[1] = 14; } else if ((col & 7) == 0) { - for (int i=0; i < 2; i++) { + for (int i = 0; i < 2; i++) { int j; - for (j=0; j < 5 && !ph1_bits(1); j++); + for (j = 0; j < 5 && !ph1_bits(1); j++) + ; if (j--) { - len[i] = length[j*2 + ph1_bits(1)]; + len[i] = length[j * 2 + ph1_bits(1)]; } } } - int i; - if ((i = len[col & 1]) == 14) { + + int i = len[col & 1]; + ushort pixel; + if (i == 14) { pixel = pred[col & 1] = ph1_bits(16); } else { pixel = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1)); } - if (UNLIKELY(pred[col & 1] >> 16)) { + if (UNLIKELY(pixel >> 16)) { derror(); } if (ph1.format == 5 && pixel < 256) { pixel = curve[pixel]; } - int rawVal = (pixel << shift) - ph1.black - + cblack[row][col >= ph1.split_col] - + rblack[col][row >= ph1.split_row]; + int rawVal = (pixel << shift) - ph1.black + cblack[row][col >= ph1.split_col] + rblack[col][row >= ph1.split_row]; RAW(row,col) = std::max(rawVal, 0); } } - delete ifpthr; } free(offset); maximum = 0xfffc - ph1.black; diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index 0fa0f2175..569b3cebc 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -316,7 +316,7 @@ void parse_qt (int end); // ph1_bithuff(int nbits, ushort *huff); class ph1_bithuff_t { public: - ph1_bithuff_t(DCraw *p,IMFILE *&i,short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){} + ph1_bithuff_t(DCraw *p,IMFILE *i,short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){} unsigned operator()(int nbits, ushort *huff); unsigned operator()(int nbits); unsigned operator()(); From e776f32033be232e1916f1a861145c403ea06a5f Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 25 Sep 2017 01:55:36 +0200 Subject: [PATCH 06/52] Fixed warning in ImProcFunctions::ciecam_02float() --- rtengine/improcfun.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 3bc154446..1676dc433 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -1891,12 +1891,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } } - float meanQ; if (std::isnan (mean)) { mean = (sum / ((height) * width)) / 327.68f; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone - meanQ = (sumQ / ((height) * width));//in case of - } } From 9e812bb25b30ace7c21f50192a43f78643bf623a Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 21 Oct 2017 17:43:02 +0200 Subject: [PATCH 07/52] Make compilation unit rtengine/FTblockDN.cc -Wextra clean --- rtengine/FTblockDN.cc | 38 +++++++++++--------------------------- rtengine/dcrop.cc | 4 ++-- rtengine/improcfun.h | 12 ++++++------ rtengine/simpleprocess.cc | 4 ++-- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 50b178388..2344c9f30 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -424,7 +424,7 @@ void ImProcFunctions::Tile_calc(int tilesize, int overlap, int kall, int imwidth int denoiseNestedLevels = 1; enum nrquality {QUALITY_STANDARD, QUALITY_HIGH}; -SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &chaut, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &nresi, float &highresi) +SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &nresi, float &highresi) { //#ifdef _DEBUG MyTime t1e, t2e; @@ -2797,10 +2797,10 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllAB(wavelet_decomposition &WaveletCoef } -SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float ** WavCoeffs_b, int level, - int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, - float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, - float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread) +SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float ** WavCoeffs_b, + int W_ab, int H_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, + float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, + float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb) { //simple wavelet shrinkage @@ -2916,8 +2916,8 @@ SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float ** void ImProcFunctions::WaveletDenoiseAll_info(int levwav, wavelet_decomposition &WaveletCoeffs_a, - wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, bool autoch, - float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread) + wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, + float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb) { int maxlvl = levwav; @@ -2927,14 +2927,12 @@ void ImProcFunctions::WaveletDenoiseAll_info(int levwav, wavelet_decomposition & int Wlvl_ab = WaveletCoeffs_a.level_W(lvl); int Hlvl_ab = WaveletCoeffs_a.level_H(lvl); - int skip_ab = WaveletCoeffs_a.level_stride(lvl); - float ** WavCoeffs_a = WaveletCoeffs_a.level_coeffs(lvl); float ** WavCoeffs_b = WaveletCoeffs_b.level_coeffs(lvl); - ShrinkAll_info(WavCoeffs_a, WavCoeffs_b, lvl, Wlvl_ab, Hlvl_ab, - skip_ab, noisevarlum, noisevarchrom, noisevarhue, width, height, noisevar_abr, noisevar_abb, noi, chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, - autoch, schoice, lvl, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, maxchred, maxchblue, minchred, minchblue, nb, chau, chred, chblue, denoiseMethodRgb, multiThread); + ShrinkAll_info(WavCoeffs_a, WavCoeffs_b, Wlvl_ab, Hlvl_ab, + noisevarlum, noisevarchrom, noisevarhue, chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, + schoice, lvl, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, maxchred, maxchblue, minchred, minchblue, nb, chau, chred, chblue, denoiseMethodRgb); } } @@ -3235,9 +3233,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat noisevarhue[i] = new float[(width + 1) / 2]; } - // init luma noisevarL - float noisevarab_b, noisevarab_r; - float realred, realblue; float interm_med = static_cast( dnparams.chroma) / 10.0; float intermred, intermblue; @@ -3467,8 +3462,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat //and whether to subsample the image after wavelet filtering. Subsampling is coded as //binary 1 or 0 for each level, eg subsampling = 0 means no subsampling, 1 means subsample //the first level only, 7 means subsample the first three levels, etc. - noisevarab_r = SQR(realred) + 0.01f; - noisevarab_b = SQR(realblue) + 0.01f; wavelet_decomposition* adecomp; wavelet_decomposition* bdecomp; @@ -3497,8 +3490,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat bdecomp = new wavelet_decomposition (labdn->data + 2 * datalen, labdn->W, labdn->H, levwav, 1); } } - const bool autoch = (settings->leveldnautsimpl == 1 && (dnparams.Cmethod == "AUT" || dnparams.Cmethod == "PRE")) || (settings->leveldnautsimpl == 0 && (dnparams.C2method == "AUTO" || dnparams.C2method == "PREV")); - if (comptlevel == 0) { WaveletDenoiseAll_info( @@ -3508,11 +3499,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat noisevarlum, noisevarchrom, noisevarhue, - width, - height, - noisevarab_r, - noisevarab_b, - labdn, chaut, Nb, redaut, @@ -3522,7 +3508,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat minredaut, minblueaut, schoice, - autoch, chromina, sigma, lumema, @@ -3538,8 +3523,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat chau, chred, chblue, - denoiseMethodRgb, - multiThread + denoiseMethodRgb ); // Enhance mode } diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 0738e48b0..5918d167a 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -653,8 +653,8 @@ void Crop::update (int todo) if (skip == 1 && denoiseParams.enabled) { int kall = 0; - float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi; - parent->ipf.RGB_denoise (kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); + float nresi, highresi; + parent->ipf.RGB_denoise (kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, nresi, highresi); if (parent->adnListener) { parent->adnListener->noiseChanged (nresi, highresi); diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 6c5ded3b6..f9ed02a85 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -305,7 +305,7 @@ public: void Median_Denoise ( float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr); - void RGB_denoise (int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &chaut, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &nresi, float &highresi); + void RGB_denoise (int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &nresi, float &highresi); void RGB_denoise_infoGamCurve (const procparams::DirPyrDenoiseParams & dnparams, const bool isRAW, LUTf &gamcurve, float &gam, float &gamthresh, float &gamslope); void RGB_denoise_info (Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false); void RGBtile_denoise (float * fLblox, int hblproc, float noisevar_Ldetail, float * nbrwt, float * blurbuffer ); //for DCT @@ -313,8 +313,8 @@ public: bool WaveletDenoiseAllL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge); bool WaveletDenoiseAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb); void WaveletDenoiseAll_info (int levwav, wavelet_decomposition &WaveletCoeffs_a, - wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, bool autoch, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, - float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); + wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, + float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb); bool WaveletDenoiseAll_BiShrinkL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3]); bool WaveletDenoiseAll_BiShrinkAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab, @@ -322,9 +322,9 @@ public: void ShrinkAllL (wavelet_decomposition &WaveletCoeffs_L, float **buffer, int level, int dir, float *noisevarlum, float * madL, float * vari, int edge); void ShrinkAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float **buffer, int level, int dir, float *noisevarchrom, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, float * madL, float * madaab = nullptr, bool madCalculated = false); - void ShrinkAll_info (float ** WavCoeffs_a, float ** WavCoeffs_b, int level, - int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, - float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); + void ShrinkAll_info (float ** WavCoeffs_a, float ** WavCoeffs_b, + int W_ab, int H_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, + float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb); void Noise_residualAB (wavelet_decomposition &WaveletCoeffs_ab, float &chresid, float &chmaxresid, bool denoiseMethodRgb); void calcautodn_info (float &chaut, float &delta, int Nb, int levaut, float maxmax, float lumema, float chromina, int mode, int lissage, float redyel, float skinc, float nsknc); float MadMax (float * DataList, int &max, int datalen); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index cc199389a..384f427b7 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -778,9 +778,9 @@ private: // CurveFactory::denoiseLL(lldenoiseutili, denoiseParams.lcurve, Noisecurve,1); //denoiseParams.getCurves(noiseLCurve); // ipf.RGB_denoise(baseImg, baseImg, calclum, imgsrc->isRAW(), denoiseParams, params.defringe, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, lldenoiseutili); - float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi; + float nresi, highresi; int kall = 2; - ipf.RGB_denoise (kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); + ipf.RGB_denoise (kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, nresi, highresi); } From 06f07820bdaaac52f5144770206a21fd787fd084 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 21 Oct 2017 19:52:41 +0200 Subject: [PATCH 08/52] Make compilation unit rtengine/ipwavelet.cc -Wextra clean, #4155 --- rtengine/dcrop.cc | 3 +-- rtengine/improccoordinator.cc | 2 +- rtengine/improcfun.h | 22 +++++++++--------- rtengine/ipwavelet.cc | 44 ++++++++++++++++------------------- rtengine/simpleprocess.cc | 2 +- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 5918d167a..57d8f9309 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -801,7 +801,6 @@ void Crop::update (int todo) bool ccutili = parent->ccutili; bool clcutili = parent->clcutili; bool cclutili = parent->cclutili; - bool wavcontlutili = parent->wavcontlutili; LUTu dummy; // parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1); @@ -921,7 +920,7 @@ void Crop::update (int todo) params.wavelet.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); - parent->ipf.ip_wavelet (labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, wavcontlutili, skip); + parent->ipf.ip_wavelet (labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, skip); } // } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9d265f90b..96787c257 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -706,7 +706,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int kall = 0; progress ("Wavelet...", 100 * readyphase / numofphases); // ipf.ip_wavelet(nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, scale); - ipf.ip_wavelet (nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, scale); + ipf.ip_wavelet (nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, scale); } diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index f9ed02a85..e683d0e19 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -263,9 +263,9 @@ public: void EPDToneMapResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0); - float *CompressDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed); - void ContrastResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx); - float *ContrastDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast = nullptr); + float *CompressDR (float *Source, int W_L, int H_L, float Compression, float DetailBoost, float *Compressed); + void ContrastResid (float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0); + float *ContrastDR (float *Source, int W_L, int H_L, float *Contrast = nullptr); void EPDToneMap (LabImage *lab, unsigned int Iterates = 0, int skip = 1); void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); @@ -278,25 +278,25 @@ public: int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/ ); void Tile_calc (int tilesize, int overlap, int kall, int imwidth, int imheight, int &numtiles_W, int &numtiles_H, int &tilewidth, int &tileheight, int &tileWskip, int &tileHskip); - void ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip); + void ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, int skip); void WaveletcontAllL (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, - struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili); + struct cont_params &cp, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili); void WaveletcontAllLfinal (wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); void WaveletcontAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, const WavOpacityCurveW & waOpacityCurveW, struct cont_params &cp, const bool useChannelA); - void WaveletAandBAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, - struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhcurve, bool hhutili); + void WaveletAandBAllAB (wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, + struct cont_params &cp, FlatCurve* hhcurve, bool hhutili); void ContAllL (float **koeLi, float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * lab, float **varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, - int W_L, int H_L, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili); + int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili); void finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); void ContAllAB (LabImage * lab, int maxlvl, float **varhue, float **varchrom, float ** WavCoeffs_a, float * WavCoeffs_a0, int level, int dir, const WavOpacityCurveW & waOpacityCurveW, struct cont_params &cp, int W_ab, int H_ab, const bool useChannelA); void Evaluate2 (wavelet_decomposition &WaveletCoeffs_L, - const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]); - void Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp, - int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL); + float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN); + void Eval2 (float ** WavCoeffs_L, int level, + int W_L, int H_L, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN); void Aver (float * HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min); void Sigma (float * HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index dd2a32e10..85b35ef18 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -140,7 +140,7 @@ struct cont_params { int wavNestedLevels = 1; -SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip) +SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, int skip) { @@ -883,7 +883,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } } - int ind = 0; bool ref = false; if((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) { @@ -899,7 +898,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } if(cp.val > 0 || ref || contr) {//edge - Evaluate2(*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); + Evaluate2(*Ldecomp, mean, meanN, sigma, sigmaN, MaxP, MaxN); } //init for edge and denoise @@ -921,7 +920,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge); } - ind = 1; //Flat curve for Contrast=f(H) in levels FlatCurve* ChCurve = new FlatCurve(params->wavelet.Chcurve); //curve C=f(H) bool Chutili = false; @@ -936,10 +934,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } - WaveletcontAllL(labco, varhue, varchro, *Ldecomp, cp, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveWL, ChCurve, Chutili); + WaveletcontAllL(labco, varhue, varchro, *Ldecomp, cp, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); if(cp.val > 0 || ref || contr || cp.diagcurv) {//edge - Evaluate2(*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); + Evaluate2(*Ldecomp, mean, meanN, sigma, sigmaN, MaxP, MaxN); } WaveletcontAllLfinal(*Ldecomp, cp, mean, sigma, MaxP, waOpacityCurveWL); @@ -1025,7 +1023,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int if(!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) { WaveletcontAllAB(labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true); WaveletcontAllAB(labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false); - WaveletAandBAllAB(labco, varhue, varchro, *adecomp, *bdecomp, cp, waOpacityCurveW, hhCurve, hhutili ); + WaveletAandBAllAB(*adecomp, *bdecomp, cp, hhCurve, hhutili ); adecomp->reconstruct(labco->data + datalen, cp.strength); bdecomp->reconstruct(labco->data + 2 * datalen, cp.strength); @@ -1366,7 +1364,7 @@ void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float aver } void ImProcFunctions::Evaluate2(wavelet_decomposition &WaveletCoeffs_L, - const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]) + float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN) { //StopWatch Stop1("Evaluate2"); int maxlvl = WaveletCoeffs_L.maxlevel(); @@ -1376,16 +1374,14 @@ void ImProcFunctions::Evaluate2(wavelet_decomposition &WaveletCoeffs_L, int Wlvl_L = WaveletCoeffs_L.level_W(lvl); int Hlvl_L = WaveletCoeffs_L.level_H(lvl); - int skip_L = WaveletCoeffs_L.level_stride(lvl); - float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); - Eval2 (WavCoeffs_L, lvl, cp, Wlvl_L, Hlvl_L, skip_L, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL[lvl]); + Eval2 (WavCoeffs_L, lvl, Wlvl_L, Hlvl_L, mean, meanN, sigma, sigmaN, MaxP, MaxN); } } -void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp, - int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL) +void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, + int W_L, int H_L, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN) { float avLP[4], avLN[4]; @@ -1429,7 +1425,7 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont MaxN[level] = maxLN; } -float *ImProcFunctions::ContrastDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast) +float *ImProcFunctions::ContrastDR(float *Source, int W_L, int H_L, float *Contrast) { int n = W_L * H_L; @@ -1449,7 +1445,7 @@ float *ImProcFunctions::ContrastDR(float *Source, int skip, struct cont_params & return Contrast; } -SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed) +SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int W_L, int H_L, float Compression, float DetailBoost, float *Compressed) { const float eps = 0.000001f; @@ -1485,7 +1481,7 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c #endif - float *ucr = ContrastDR(Source, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx); + float *ucr = ContrastDR(Source, W_L, H_L); if(Compressed == nullptr) { Compressed = ucr; @@ -1563,7 +1559,7 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c } -void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx) +void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0) { float stren = cp.tmstrength; float gamm = params->wavelet.gamma; @@ -1593,7 +1589,7 @@ void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, unsigned int Iterates } - CompressDR(WavCoeffs_L0, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx, WavCoeffs_L0); + CompressDR(WavCoeffs_L0, W_L, H_L, Compression, DetailBoost, WavCoeffs_L0); #ifdef _RT_NESTED_OPENMP @@ -1679,7 +1675,7 @@ void ImProcFunctions::WaveletcontAllLfinal(wavelet_decomposition &WaveletCoeffs_ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, - struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili) + struct cont_params &cp, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili) { int maxlvl = WaveletCoeffs_L.maxlevel(); int W_L = WaveletCoeffs_L.level_W(0); @@ -1824,7 +1820,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #ifdef _RT_NESTED_OPENMP #pragma omp single #endif - ContrastResid(WavCoeffs_L0, 5, skip, cp, W_L, H_L, maxp, minp, ave, ah, bh, al, bl, factorx ); + ContrastResid(WavCoeffs_L0, cp, W_L, H_L, maxp, minp); } #ifdef _RT_NESTED_OPENMP @@ -2032,7 +2028,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); - ContAllL (koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); + ContAllL (koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); } @@ -2045,8 +2041,8 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } } -void ImProcFunctions::WaveletAandBAllAB(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, - struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhCurve, bool hhutili) +void ImProcFunctions::WaveletAandBAllAB(wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, + struct cont_params &cp, FlatCurve* hhCurve, bool hhutili) { // StopWatch Stop1("WaveletAandBAllAB"); if (hhutili && cp.resena) { // H=f(H) @@ -2573,7 +2569,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * labco, float ** varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, - int W_L, int H_L, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili) + int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili) { assert (level >= 0); assert (maxlvl > level); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 384f427b7..49d15532a 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1078,7 +1078,7 @@ private: CurveFactory::curveWavContL (wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1); if (params.wavelet.enabled) { - ipf.ip_wavelet (labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1); + ipf.ip_wavelet (labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, 1); } wavCLVCurve.Reset(); From 04cdcca26cdc457779b8c3cce1128810e482b939 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 21 Oct 2017 21:26:07 +0200 Subject: [PATCH 09/52] Make compilation unit rtengine/improcfun.cc -Wextra clean, #4155 --- rtengine/dcrop.cc | 9 ++++----- rtengine/improccoordinator.cc | 6 ++---- rtengine/improcfun.cc | 33 +++++++++++++++------------------ rtengine/improcfun.h | 14 +++++++------- rtengine/rawimagesource.cc | 2 +- rtengine/rtthumbnail.cc | 9 ++++----- rtengine/simpleprocess.cc | 18 ++++++++---------- 7 files changed, 41 insertions(+), 50 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 57d8f9309..71b600ae5 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -943,7 +943,6 @@ void Crop::update (int todo) // end calculation adaptation scene luminosity } - int begh = 0, endh = labnCrop->H; bool execsharp = false; if (skip == 1) { @@ -956,13 +955,13 @@ void Crop::update (int todo) if (settings->ciecamfloat) { float d, dj, yb; // not used after this block - parent->ipf.ciecam_02float (cieCrop, float (adap), begh, endh, 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, + parent->ipf.ciecam_02float (cieCrop, float (adap), 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, d, dj, yb, 1); } else { - double dd, dj, yb; // not used after this block + double dd, dj; // not used after this block - parent->ipf.ciecam_02 (cieCrop, adap, begh, endh, 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, - dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, dd, dj, yb, 1); + parent->ipf.ciecam_02 (cieCrop, adap, 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, + dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, dd, dj, 1); } } else { // CIECAM is disbaled, we free up its image buffer to save some space diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 96787c257..1f043989d 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -443,7 +443,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) LUTu aehist; int aehistcompr; imgsrc->getAutoExpHistogram (aehist, aehistcompr); - ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, params.toneCurve.expcomp, + ipf.getAutoExp (aehist, aehistcompr, params.toneCurve.clip, params.toneCurve.expcomp, params.toneCurve.brightness, params.toneCurve.contrast, params.toneCurve.black, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh); if (aeListener) @@ -759,8 +759,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // end calculation adaptation scene luminosity } - int begh = 0; - int endh = pH; float d, dj, yb; bool execsharp = false; @@ -781,7 +779,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) CAMBrightCurveJ.dirty = true; CAMBrightCurveQ.dirty = true; - ipf.ciecam_02float (ncie, float (adap), begh, endh, pW, 2, nprevl, ¶ms, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, scale, execsharp, d, dj, yb, 1); + ipf.ciecam_02float (ncie, float (adap), pW, 2, nprevl, ¶ms, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, scale, execsharp, d, dj, yb, 1); if ((params.colorappearance.autodegree || params.colorappearance.autodegreeout) && acListener && params.colorappearance.enabled) { acListener->autoCamChanged (100.* (double)d, 100.* (double)dj); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 516e0ee9d..72928d77f 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -208,9 +208,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro } // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params, +void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, - LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, double &yb, int rtt) + LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, int rtt) { if (params->colorappearance.enabled) { //int lastskip; @@ -256,7 +256,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh int width = lab->W, height = lab->H; float minQ = 10000.f; float maxQ = -1000.f; - float w_h; float a_w; float c_; float f_l; @@ -607,7 +606,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh #ifndef _DEBUG - #pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,begh, endh,nc2,f2,c2, alg,algepd, gamu, highlight, rstprotection, pW, scale) + #pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,nc2,f2,c2, alg,algepd, gamu, highlight, rstprotection, pW, scale) #endif { //matrix for current working space @@ -661,7 +660,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh Qpro = Q; Mpro = M; spro = s; - w_h = wh + epsil; a_w = aw; c_ = c; f_l = fl; @@ -1347,14 +1345,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh || (params->colorappearance.badpixsl > 0 && settings->autocielab)) { if (params->epd.enabled && params->colorappearance.tonecie && algepd) { - ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); + ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale ); } //EPDToneMapCIE adapted to CIECAM #ifndef _DEBUG - #pragma omp parallel default(shared) firstprivate(lab,xw2,yw2,zw2,chr,yb,la2,yb2, height,width,begh, endh, nc2,f2,c2, gamu, highlight,pW) + #pragma omp parallel default(shared) firstprivate(lab,xw2,yw2,zw2,chr,yb,la2,yb2, height,width, nc2,f2,c2, gamu, highlight,pW) #endif { TMatrix wiprofa = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); @@ -1521,7 +1519,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params, +void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt) { @@ -1982,7 +1980,6 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int const float pow1n = pow_F ( 1.64f - pow_F ( 0.29f, nj ), 0.73f ); const float epsil = 0.0001f; - const float w_h = wh + epsil; const float coefQ = 32767.f / wh; const float a_w = aw; const float c_ = c; @@ -2810,7 +2807,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int if (epdEnabled && params->colorappearance.tonecie && algepd) { lab->deleteLab(); - ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); + ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale ); lab->reallocLab(); } @@ -4064,7 +4061,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b; float ro, go, bo; int mode = 0; - toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, preser, strProtect); + toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, strProtect); float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo; float preserv = 1.f; @@ -4743,7 +4740,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (lumbefore < 65000.f && lumbefore > 500.f) { //reduct artifacts for highlights an extrem shadows float ro, go, bo; int mode = 1; - toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, preser, strProtect); + toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, strProtect); float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo; float preserv = 1.f; @@ -5085,7 +5082,7 @@ void ImProcFunctions::secondeg_begin (float reducac, float vend, float &aam, flo * @param mode ? * @param preser whether to preserve luminance (if 1) or not **/ -void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, int preser, float strProtect) +void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, float strProtect) { float bmu = mode == 1 ? 0.5f : 0.4f; float RedL = 1.f + (RedLow - 1.f) * 0.4f; @@ -6378,8 +6375,8 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu //#include "cubic.cc" -void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) -{ +//void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) +//{ /* LUT cmultiplier(181021); @@ -6456,7 +6453,7 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) } */ //delete [] cmultiplier; -} +//} void ImProcFunctions::impulsedenoise (LabImage* lab) { @@ -6539,7 +6536,7 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); } } -void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates, int skip) +void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates, int skip) { if (!params->epd.enabled) { @@ -6752,7 +6749,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip } -void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double defgain, double clip, +void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh) { diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index e683d0e19..1065c5833 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -220,7 +220,7 @@ public: double expcomp, int hlcompr, int hlcomprthresh, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve); void labtoning (float r, float g, float b, float &ro, float &go, float &bo, int algm, int metchrom, int twoc, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, LUTf & clToningcurve, LUTf & cl2Toningcurve, float iplow, float iphigh, double wp[3][3], double wip[3][3] ); void toning2col (float r, float g, float b, float &ro, float &go, float &bo, float iplow, float iphigh, float rl, float gl, float bl, float rh, float gh, float bh, float SatLow, float SatHigh, float balanS, float balanH, float reducac, int mode, int preser, float strProtect); - void toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, int preser, float strProtect); + void toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, float strProtect); void toningsmh2 (float r, float g, float b, float &ro, float &go, float &bo, float low[3], float satLow, float med[3], float satMed, float high[3], float satHigh, float reducac, int mode, int preser); void secondeg_begin (float reducac, float vend, float &aam, float &bbm); void secondeg_end (float reducac, float vinf, float &aa, float &bb, float &cc); @@ -229,15 +229,15 @@ public: void moyeqt (Imagefloat* working, float &moyS, float &eqty); void luminanceCurve (LabImage* lold, LabImage* lnew, LUTf &curve); - void ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params, + void ciecam_02float (CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt); - void ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params, + void ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, - LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, double &yb, int rtt); + LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, int rtt); void chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, LUTf &acurve, LUTf &bcurve, LUTf & satcurve, LUTf & satclcurve, LUTf &clcurve, LUTf &curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLurve); void vibrance (LabImage* lab);//Jacques' vibrance - void colorCurve (LabImage* lold, LabImage* lnew); +// void colorCurve (LabImage* lold, LabImage* lnew); void sharpening (LabImage* lab, float** buffer, SharpeningParams &sharpenParam); void sharpeningcam (CieImage* ncie, float** buffer); void transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const FramesMetaData *metadata, int rawRotationDeg, bool fullImage); @@ -268,7 +268,7 @@ public: float *ContrastDR (float *Source, int W_L, int H_L, float *Contrast = nullptr); void EPDToneMap (LabImage *lab, unsigned int Iterates = 0, int skip = 1); - void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); + void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); // pyramid denoise procparams::DirPyrDenoiseParams dnparams; @@ -353,7 +353,7 @@ public: bool transCoord (int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr); bool transCoord (int W, int H, const std::vector &src, std::vector &red, std::vector &green, std::vector &blue, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr); - static void getAutoExp (const LUTu & histogram, int histcompr, double defgain, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh); + static void getAutoExp (const LUTu & histogram, int histcompr, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh); static double getAutoDistor (const Glib::ustring& fname, int thumb_size); double getTransformAutoFill (int oW, int oH, const LensCorrection *pLCPMap = nullptr); void rgb2lab (const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace); diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 6ab9076aa..820c64bec 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2003,7 +2003,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le double clip = 0; int brightness, contrast, black, hlcompr, hlcomprthresh; getAutoExpHistogram (aehist, aehistcompr); - ImProcFunctions::getAutoExp (aehist, aehistcompr, getDefGain(), clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh); + ImProcFunctions::getAutoExp (aehist, aehistcompr, clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh); } t2.set(); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 9bdee796b..c790c9378 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1126,8 +1126,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT int hlcomprthresh = params.toneCurve.hlcomprthresh; if (params.toneCurve.autoexp && aeHistogram) { - double logDefGain = 0.0; - ipf.getAutoExp (aeHistogram, aeHistCompression, logDefGain, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); + ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); } LUTf curve1 (65536); @@ -1290,7 +1289,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT customColCurve2, customColCurve3, 16); - int begh = 0, endh = labView->H; + bool execsharp = false; float d, dj, yb; float fnum = fnumber;// F number @@ -1323,7 +1322,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT CAMMean = NAN; CAMBrightCurveJ.dirty = true; CAMBrightCurveQ.dirty = true; - ipf.ciecam_02float (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, sk, execsharp, d, dj, yb, rtt); + ipf.ciecam_02float (cieView, adap, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, sk, execsharp, d, dj, yb, rtt); delete cieView; } @@ -1433,7 +1432,7 @@ void Thumbnail::applyAutoExp (procparams::ProcParams& params) if (params.toneCurve.autoexp && aeHistogram) { ImProcFunctions ipf (¶ms, false); - ipf.getAutoExp (aeHistogram, aeHistCompression, log (defGain) / log (2.0), params.toneCurve.clip, params.toneCurve.expcomp, + ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, params.toneCurve.expcomp, params.toneCurve.brightness, params.toneCurve.contrast, params.toneCurve.black, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh); } } diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 49d15532a..78608c24e 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -718,7 +718,7 @@ private: LUTu aehist; int aehistcompr; imgsrc->getAutoExpHistogram (aehist, aehistcompr); - ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); + ipf.getAutoExp (aehist, aehistcompr, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); } // at this stage, we can flush the raw data to free up quite an important amount of memory @@ -1086,7 +1086,6 @@ private: //Colorappearance and tone-mapping associated int f_w = 1, f_h = 1; - int begh = 0, endh = fh; if (params.colorappearance.tonecie || params.colorappearance.enabled) { f_w = fw; @@ -1094,8 +1093,7 @@ private: } CieImage *cieView = new CieImage (f_w, (f_h)); - begh = 0; - endh = fh; + CurveFactory::curveLightBrightColor ( params.colorappearance.curve, params.colorappearance.curve2, @@ -1137,18 +1135,18 @@ private: if (params.sharpening.enabled) { if (settings->ciecamfloat) { float d, dj, yb; - ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); + ipf.ciecam_02float (cieView, float (adap), 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); } else { - double dd, dj, yb; - ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, yb, 1); + double dd, dj; + ipf.ciecam_02 (cieView, adap, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, 1); } } else { if (settings->ciecamfloat) { float d, dj, yb; - ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); + ipf.ciecam_02float (cieView, float (adap), 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1); } else { - double dd, dj, yb; - ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, yb, 1); + double dd, dj; + ipf.ciecam_02 (cieView, adap, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, 1); } } } From c8ac93676e1af480880c59957ab629e3f0711740 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 21 Oct 2017 22:01:42 +0200 Subject: [PATCH 10/52] Make compilation unit rtengine/demosaic_algos.cc -Wextra clean, #4155 --- rtengine/demosaic_algos.cc | 2 +- rtengine/rawimagesource.cc | 2 +- rtengine/rawimagesource.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 6a5b8eba8..88d369969 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -2612,7 +2612,7 @@ void RawImageSource::igv_interpolate(int winw, int winh) #define FORC(cnt) for (c=0; c < cnt; c++) #define FORC3 FORC(3) -void RawImageSource::ahd_demosaic(int winx, int winy, int winw, int winh) +void RawImageSource::ahd_demosaic() { int i, j, k, top, left, row, col, tr, tc, c, d, val, hm[2]; float (*pix)[4], (*rix)[3]; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 820c64bec..bea20e64c 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2032,7 +2032,7 @@ void RawImageSource::demosaic(const RAWParams &raw) } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::vng4] ) { vng4_demosaic (); } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::ahd] ) { - ahd_demosaic (0, 0, W, H); + ahd_demosaic (); } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::amaze] ) { amaze_demosaic_RT (0, 0, W, H, rawData, red, green, blue); } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift] ) { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 99cc9af64..d512274bc 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -247,7 +247,7 @@ protected: void amaze_demosaic_RT(int winx, int winy, int winw, int winh, array2D &rawData, array2D &red, array2D &green, array2D &blue);//Emil's code for AMaZE void fast_demosaic(int winx, int winy, int winw, int winh );//Emil's code for fast demosaicing void dcb_demosaic(int iterations, bool dcb_enhance); - void ahd_demosaic(int winx, int winy, int winw, int winh); + void ahd_demosaic(); void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0); void border_interpolate2(int winw, int winh, int lborders); void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border); From 3570550ac915a076587c9303a87cebf57d920c00 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 21 Oct 2017 22:55:07 +0200 Subject: [PATCH 11/52] Make compilation unit rtengine/labimage.cc -Wextra clean, #4155 --- rtengine/labimage.cc | 63 ++++++++++++++++++++++++++++++++++++++++++-- rtengine/labimage.h | 42 +++-------------------------- 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/rtengine/labimage.cc b/rtengine/labimage.cc index 36d3e0f67..4cd5ce31a 100644 --- a/rtengine/labimage.cc +++ b/rtengine/labimage.cc @@ -1,9 +1,29 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2017 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ + #include "labimage.h" -#include +#include + namespace rtengine { -LabImage::LabImage (int w, int h) : fromImage(false), W(w), H(h) +LabImage::LabImage (int w, int h) : W(w), H(h) { allocLab(w, h); } @@ -42,4 +62,43 @@ void LabImage::getPipetteData (float &v1, float &v2, float &v3, int posX, int po v3 = n ? accumulator_b / float(n) : 0.f; } +void LabImage::allocLab(int w, int h) +{ + L = new float*[h]; + a = new float*[h]; + b = new float*[h]; + + data = new float [w * h * 3]; + float * index = data; + + for (int i = 0; i < h; i++) { + L[i] = index + i * w; + } + + index += w * h; + + for (int i = 0; i < h; i++) { + a[i] = index + i * w; + } + + index += w * h; + + for (int i = 0; i < h; i++) { + b[i] = index + i * w; + } +} + +void LabImage::deleteLab() +{ + delete [] L; + delete [] a; + delete [] b; + delete [] data; +} + +void LabImage::reallocLab() +{ + allocLab(W, H); +}; + } diff --git a/rtengine/labimage.h b/rtengine/labimage.h index 4b7db93c0..93f3887b6 100644 --- a/rtengine/labimage.h +++ b/rtengine/labimage.h @@ -25,32 +25,8 @@ namespace rtengine class LabImage { private: - bool fromImage; - void allocLab(int w, int h) - { - L = new float*[H]; - a = new float*[H]; - b = new float*[H]; + void allocLab(int w, int h); - data = new float [W * H * 3]; - float * index = data; - - for (int i = 0; i < H; i++) { - L[i] = index + i * W; - } - - index += W * H; - - for (int i = 0; i < H; i++) { - a[i] = index + i * W; - } - - index += W * H; - - for (int i = 0; i < H; i++) { - b[i] = index + i * W; - } - }; public: int W, H; float * data; @@ -64,20 +40,8 @@ public: //Copies image data in Img into this instance. void CopyFrom(LabImage *Img); void getPipetteData (float &L, float &a, float &b, int posX, int posY, int squareSize); - void deleteLab( ) - { - if (!fromImage) { - delete [] L; - delete [] a; - delete [] b; - delete [] data; - } - } - void reallocLab( ) - { - allocLab(W, H); - }; - + void deleteLab(); + void reallocLab(); }; } From 15108af3a7682d9bcbe82b625ce24f26fedea4fe Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 01:54:12 +0200 Subject: [PATCH 12/52] Make compilation unit rtengine/ciecam02.cc -Wextra clean, #4155 --- rtengine/ciecam02.cc | 10 +++++----- rtengine/ciecam02.h | 10 ++++------ rtengine/curves.cc | 2 +- rtengine/improcfun.cc | 13 +++++-------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/rtengine/ciecam02.cc b/rtengine/ciecam02.cc index 625b77f05..7b5ef63fe 100644 --- a/rtengine/ciecam02.cc +++ b/rtengine/ciecam02.cc @@ -780,7 +780,7 @@ void Ciecam02::initcam2float (float gamu, float yb, float pilotd, float f, float void Ciecam02::xyz2jchqms_ciecam02 ( double &J, double &C, double &h, double &Q, double &M, double &s, double &aw, double &fl, double &wh, double x, double y, double z, double xw, double yw, double zw, - double yb, double la, double f, double c, double nc, double pilotd, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d) + double c, double nc, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d) { double r, g, b; double rw, gw, bw; @@ -1040,8 +1040,8 @@ void Ciecam02::xyz2jch_ciecam02float ( float &J, float &C, float &h, float aw, f void Ciecam02::jch2xyz_ciecam02 ( double &x, double &y, double &z, double J, double C, double h, - double xw, double yw, double zw, double yb, double la, - double f, double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw ) + double xw, double yw, double zw, + double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw ) { double r, g, b; double rc, gc, bc; @@ -1075,7 +1075,7 @@ void Ciecam02::jch2xyz_ciecam02 ( double &x, double &y, double &z, double J, dou void Ciecam02::jch2xyz_ciecam02float ( float &x, float &y, float &z, float J, float C, float h, float xw, float yw, float zw, - float f, float c, float nc, int gamu, float pow1, float nbb, float ncb, float fl, float cz, float d, float aw) + float c, float nc, int gamu, float pow1, float nbb, float ncb, float fl, float cz, float d, float aw) { float r, g, b; float rc, gc, bc; @@ -1110,7 +1110,7 @@ void Ciecam02::jch2xyz_ciecam02float ( float &x, float &y, float &z, float J, fl #ifdef __SSE2__ void Ciecam02::jch2xyz_ciecam02float ( vfloat &x, vfloat &y, vfloat &z, vfloat J, vfloat C, vfloat h, vfloat xw, vfloat yw, vfloat zw, - vfloat f, vfloat nc, vfloat pow1, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz) + vfloat nc, vfloat pow1, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz) { vfloat r, g, b; vfloat rc, gc, bc; diff --git a/rtengine/ciecam02.h b/rtengine/ciecam02.h index 1e0f755c1..55d807b7e 100644 --- a/rtengine/ciecam02.h +++ b/rtengine/ciecam02.h @@ -82,19 +82,18 @@ public: static void jch2xyz_ciecam02 ( double &x, double &y, double &z, double J, double C, double h, double xw, double yw, double zw, - double yb, double la, - double f, double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw); + double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw); static void jch2xyz_ciecam02float ( float &x, float &y, float &z, float J, float C, float h, float xw, float yw, float zw, - float f, float c, float nc, int gamu, float n, float nbb, float ncb, float fl, float cz, float d, float aw ); + float c, float nc, int gamu, float n, float nbb, float ncb, float fl, float cz, float d, float aw ); #ifdef __SSE2__ static void jch2xyz_ciecam02float ( vfloat &x, vfloat &y, vfloat &z, vfloat J, vfloat C, vfloat h, vfloat xw, vfloat yw, vfloat zw, - vfloat f, vfloat nc, vfloat n, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz ); + vfloat nc, vfloat n, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz ); #endif /** * Forward transform from XYZ to CIECAM02 JCh. @@ -115,8 +114,7 @@ public: double &Q, double &M, double &s, double &aw, double &fl, double &wh, double x, double y, double z, double xw, double yw, double zw, - double yb, double la, - double f, double c, double nc, double pilotd, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d ); + double c, double nc, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d ); static void xyz2jch_ciecam02float ( float &J, float &C, float &h, float aw, float fl, diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 3096f19f4..ee589bc74 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -1986,7 +1986,7 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv Ciecam02::jch2xyz_ciecam02float( x, y, z, J, C, h, xw, yw, zw, - f, c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw ); + c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw ); if (!isfinite(x) || !isfinite(y) || !isfinite(z)) { // can happen for colors on the rim of being outside gamut, that worked without chroma scaling but not with. Then we return only the curve's result. diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 72928d77f..c87d4edd4 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -652,8 +652,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L Q, M, s, aw, fl, wh, x, y, z, xw1, yw1, zw1, - yb, la, - f, c, nc, pilot, gamu, n, nbb, ncb, pfl, cz, d ); + c, nc, gamu, n, nbb, ncb, pfl, cz, d ); Jpro = J; Cpro = C; hpro = h; @@ -1178,8 +1177,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz, J, C, h, xw2, yw2, zw2, - yb2, la2, - f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); + c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); x = (float)xx * 655.35; y = (float)yy * 655.35; z = (float)zz * 655.35; @@ -1447,8 +1445,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz, ncie->J_p[i][j], ncie->C_p[i][j], ncie->h_p[i][j], xw2, yw2, zw2, - yb2, la2, - f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); + c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); x = (float)xx * 655.35; y = (float)yy * 655.35; z = (float)zz * 655.35; @@ -2602,7 +2599,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw Ciecam02::jch2xyz_ciecam02float ( x, y, z, LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]), F2V (xw2), F2V (yw2), F2V (zw2), - F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); + F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); STVF (xbuffer[k], x * c655d35); STVF (ybuffer[k], y * c655d35); STVF (zbuffer[k], z * c655d35); @@ -2946,7 +2943,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw Ciecam02::jch2xyz_ciecam02float ( x, y, z, LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]), F2V (xw2), F2V (yw2), F2V (zw2), - F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); + F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); x *= c655d35; y *= c655d35; z *= c655d35; From d5ceb850f33618742e20055c299463d2d2f61629 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 13:43:28 +0200 Subject: [PATCH 13/52] Make compilation unit rtengine/rawimagesource.cc -Wextra clean, #4155 --- rtengine/clutstore.cc | 2 +- rtengine/dcrop.cc | 12 ++++++------ rtengine/imagesource.h | 6 +++--- rtengine/improccoordinator.cc | 6 +++--- rtengine/loadinitial.cc | 6 +----- rtengine/previewimage.cc | 4 ++-- rtengine/rawimagesource.cc | 10 +++++----- rtengine/rawimagesource.h | 6 +++--- rtengine/simpleprocess.cc | 8 ++++---- rtengine/stdimagesource.cc | 4 ++-- rtengine/stdimagesource.h | 4 ++-- 11 files changed, 32 insertions(+), 36 deletions(-) diff --git a/rtengine/clutstore.cc b/rtengine/clutstore.cc index 5731773a4..565db8faa 100644 --- a/rtengine/clutstore.cc +++ b/rtengine/clutstore.cc @@ -52,7 +52,7 @@ bool loadFile( rtengine::procparams::ColorManagementParams icm; icm.working = working_color_space; - img_src.getImage(curr_wb, TR_NONE, img_float.get(), pp, rtengine::procparams::ToneCurveParams(), icm, rtengine::procparams::RAWParams()); + img_src.getImage(curr_wb, TR_NONE, img_float.get(), pp, rtengine::procparams::ToneCurveParams(), rtengine::procparams::RAWParams()); if (!working_color_space.empty()) { img_src.convertColorSpace(img_float.get(), icm, curr_wb); diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 71b600ae5..19cb654ec 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -228,18 +228,18 @@ void Crop::update (int todo) if (settings->leveldnautsimpl == 1) { if (params.dirpyrDenoise.Cmethod == "MAN" || params.dirpyrDenoise.Cmethod == "PON" ) { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); - parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); + parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw ); } } else { if (params.dirpyrDenoise.C2method == "MANU") { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); - parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); + parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw ); } } if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PRE") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "PREV")) { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); - parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); + parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw ); if ((!isDetailWindow) && parent->adnListener && skip == 1 && params.dirpyrDenoise.enabled) { float lowdenoise = 1.f; @@ -451,7 +451,7 @@ void Crop::update (int todo) for (int wcr = 0; wcr <= 2; wcr++) { for (int hcr = 0; hcr <= 2; hcr++) { PreviewProps ppP (coordW[wcr], coordH[hcr], crW, crH, 1); - parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw ); + parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.raw ); // we only need image reduced to 1/4 here for (int ii = 0; ii < crH; ii += 2) { @@ -613,7 +613,7 @@ void Crop::update (int todo) // if(params.dirpyrDenoise.Cmethod=="AUT" || params.dirpyrDenoise.Cmethod=="PON") {//reinit origCrop after Auto if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { //reinit origCrop after Auto PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); - parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); + parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw ); } DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise; @@ -763,7 +763,7 @@ void Crop::update (int todo) if (todo & M_RGBCURVE) { double rrm, ggm, bbm; DCPProfile::ApplyState as; - DCPProfile *dcpProf = parent->imgsrc->getDCP (params.icm, parent->currWB, as); + DCPProfile *dcpProf = parent->imgsrc->getDCP (params.icm, as); LUTu histToneCurve; parent->ipf.rgbProc (baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, cshmap, diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 757e6f5a7..b76a962eb 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -66,7 +66,7 @@ public: embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(INFINITY) {} virtual ~ImageSource () {} - virtual int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false) = 0; + virtual int load (const Glib::ustring &fname) = 0; virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true) {}; virtual void demosaic (const RAWParams &raw) {}; virtual void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {}; @@ -85,7 +85,7 @@ public: // use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat* - virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const ColorManagementParams &cmp, const RAWParams &raw) = 0; + virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const RAWParams &raw) = 0; virtual eSensorType getSensorType () const = 0; // true is ready to provide the AutoWB, i.e. when the image has been demosaiced for RawImageSource virtual bool isWBProviderReady () = 0; @@ -110,7 +110,7 @@ public: virtual FrameData* getImageData (unsigned int frameNum) = 0; virtual ImageMatrices* getImageMatrices () = 0; virtual bool isRAW () const = 0; - virtual DCPProfile* getDCP (const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as) + virtual DCPProfile* getDCP (const ColorManagementParams &cmp, DCPProfile::ApplyState &as) { return nullptr; }; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 1f043989d..9366bec27 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -333,7 +333,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // Tells to the ImProcFunctions' tools what is the preview scale, which may lead to some simplifications ipf.setScale (scale); - imgsrc->getImage (currWB, tr, orig_prev, pp, params.toneCurve, params.icm, params.raw); + imgsrc->getImage (currWB, tr, orig_prev, pp, params.toneCurve, params.raw); denoiseInfoStore.valid = false; //ColorTemp::CAT02 (orig_prev, ¶ms) ; // printf("orig_prevW=%d\n scale=%d",orig_prev->width, scale); @@ -556,7 +556,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) double bbm = 33.; DCPProfile::ApplyState as; - DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as); + DCPProfile *dcpProf = imgsrc->getDCP (params.icm, as); ipf.rgbProc (oprevi, oprevl, nullptr, hltonecurve, shtonecurve, tonecurve, shmap, params.toneCurve.saturation, rCurve, gCurve, bCurve, colourToningSatLimit, colourToningSatLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, beforeToneCurveBW, afterToneCurveBW, rrm, ggm, bbm, bwAutoR, bwAutoG, bwAutoB, params.toneCurve.expcomp, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, dcpProf, as, histToneCurve); @@ -1223,7 +1223,7 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool currWB = ColorTemp(); // = no white balance } - imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.icm, ppar.raw); + imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.raw); ImProcFunctions ipf (&ppar, true); if (ipf.needsTransform()) { diff --git a/rtengine/loadinitial.cc b/rtengine/loadinitial.cc index c29d60621..6192ca6db 100644 --- a/rtengine/loadinitial.cc +++ b/rtengine/loadinitial.cc @@ -36,11 +36,7 @@ InitialImage* InitialImage::load (const Glib::ustring& fname, bool isRaw, int* e isrc->setProgressListener (pl); - if(isRaw && pl == nullptr) { - *errorCode = isrc->load (fname, true); - } else { - *errorCode = isrc->load (fname); - } + *errorCode = isrc->load (fname); if (*errorCode) { delete isrc; diff --git a/rtengine/previewimage.cc b/rtengine/previewimage.cc index e6703aed5..1bd72a354 100644 --- a/rtengine/previewimage.cc +++ b/rtengine/previewimage.cc @@ -97,7 +97,7 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext if ((mode == PIM_EmbeddedOrRaw && !tpp) || mode == PIM_ForceRaw) { RawImageSource rawImage; - int error = rawImage.load(fname, true); + int error = rawImage.load(fname); if (!error) { const unsigned char *data = nullptr; @@ -115,7 +115,7 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext rawImage.preprocess(params.raw, params.lensProf, params.coarse); rawImage.demosaic(params.raw); Imagefloat image(fw, fh); - rawImage.getImage (wb, TR_NONE, &image, pp, params.toneCurve, params.icm, params.raw); + rawImage.getImage (wb, TR_NONE, &image, pp, params.toneCurve, params.raw); rtengine::Image8 output(fw, fh); rawImage.convertColorSpace(&image, params.icm, wb); #pragma omp parallel for schedule(dynamic, 10) diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index bea20e64c..3e234bef5 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -87,7 +87,7 @@ void transLineStandard (const float* const red, const float* const green, const rotateLine (blue, image->b, tran, i, imwidth, imheight); } -void transLineFuji (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const int fw) +void transLineFuji (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imheight, const int fw) { // Fuji SuperCCD rotation + coarse rotation @@ -623,7 +623,7 @@ float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const flo return gain; } -void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw ) +void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw ) { MyMutex::MyLock lock(getImageMutex); @@ -824,7 +824,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima if(d1x) { transLineD1x (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd, doClip); } else if(fuji) { - transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, fw); + transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imheight, fw); } else { transLineStandard (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight); } @@ -910,7 +910,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima } } -DCPProfile *RawImageSource::getDCP(const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as) +DCPProfile *RawImageSource::getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as) { DCPProfile *dcpProf = nullptr; cmsHPROFILE dummy; @@ -1518,7 +1518,7 @@ void RawImageSource::vflip (Imagefloat* image) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int RawImageSource::load (const Glib::ustring &fname, int imageNum, bool batch) +int RawImageSource::load (const Glib::ustring &fname) { MyTime t1, t2; diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index d512274bc..9da7d44f4 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -116,7 +116,7 @@ public: RawImageSource (); ~RawImageSource (); - int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false); + int load (const Glib::ustring &fname); void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true); void demosaic (const RAWParams &raw); void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); @@ -138,7 +138,7 @@ public: void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW); void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D &rawData); // raw for cblack - void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw); + void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw); eSensorType getSensorType () const { return ri != nullptr ? ri->getSensorType() : ST_NONE; @@ -185,7 +185,7 @@ public: } void getAutoExpHistogram (LUTu & histogram, int& histcompr); void getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); - DCPProfile *getDCP(const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as); + DCPProfile *getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as); void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb); static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 78608c24e..e8bcb7054 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -318,7 +318,7 @@ private: int beg_tileW = wcr * tileWskip + tileWskip / 2.f - crW / 2.f; int beg_tileH = hcr * tileHskip + tileHskip / 2.f - crH / 2.f; PreviewProps ppP (beg_tileW, beg_tileH, crW, crH, skipP); - imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw ); + imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.raw ); //baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve); // we only need image reduced to 1/4 here @@ -538,7 +538,7 @@ private: for (int wcr = 0; wcr <= 2; wcr++) { for (int hcr = 0; hcr <= 2; hcr++) { PreviewProps ppP (coordW[wcr], coordH[hcr], crW, crH, 1); - imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw); + imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.raw); //baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve); @@ -698,7 +698,7 @@ private: } baseImg = new Imagefloat (fw, fh); - imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.icm, params.raw); + imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.raw); if (pl) { pl->setProgress (0.50); @@ -931,7 +931,7 @@ private: autor = -9000.f; // This will ask to compute the "auto" values for the B&W tool (have to be inferior to -5000) DCPProfile::ApplyState as; - DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as); + DCPProfile *dcpProf = imgsrc->getDCP (params.icm, as); LUTu histToneCurve; diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index d4e6a62f1..61bf90b31 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -102,7 +102,7 @@ void StdImageSource::getSampleFormat (const Glib::ustring &fname, IIOSampleForma * and RT's image data type (Image8, Image16 and Imagefloat), then it will * load the image into it */ -int StdImageSource::load (const Glib::ustring &fname, int imageNum, bool batch) +int StdImageSource::load (const Glib::ustring &fname) { fileName = fname; @@ -187,7 +187,7 @@ int StdImageSource::load (const Glib::ustring &fname, int imageNum, bool batch) return 0; } -void StdImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw) +void StdImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw) { // the code will use OpenMP as of now. diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 1450d745e..304bc3d8d 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -42,8 +42,8 @@ public: StdImageSource (); ~StdImageSource (); - int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false); - void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw); + int load (const Glib::ustring &fname); + void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw); ColorTemp getWB () const { return wb; From e489fc7bea243ba1964a610926aef06162c85497 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 14:01:07 +0200 Subject: [PATCH 14/52] Make compilation unit rtengine/rtthumbnail.cc -Wextra clean, #4155 --- rtengine/improcfun.cc | 2 +- rtengine/rtthumbnail.cc | 6 +++--- rtengine/rtthumbnail.h | 6 +++--- rtgui/thumbnail.cc | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index c87d4edd4..9cc3e7d28 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -7064,7 +7064,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si return 0.0; } - Thumbnail* raw = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, w_raw, h_raw, 1, 1.0, FALSE, 0); + Thumbnail* raw = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, w_raw, h_raw, 1, 1.0, FALSE); if (!raw) { delete thumb; diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index c790c9378..b458464b8 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -381,7 +381,7 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname) return rml; } -Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum) +Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate) { RawImage *ri = new RawImage (fname); unsigned int tempImageNum = 0; @@ -929,7 +929,7 @@ Thumbnail::~Thumbnail () } // Simple processing of RAW internal JPGs -IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int rheight, rtengine::TypeInterpolation interp, double& myscale) +IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int rheight, rtengine::TypeInterpolation interp) { int rwidth; @@ -1761,7 +1761,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width) return tmpdata; } -bool Thumbnail::writeImage (const Glib::ustring& fname, int format) +bool Thumbnail::writeImage (const Glib::ustring& fname) { if (!thumbImg) { diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index 4987cc88c..2ee08de50 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -72,12 +72,12 @@ public: void init (); IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale); - IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale); + IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp); int getImageWidth (const procparams::ProcParams& pparams, int rheight, float &ratio); void getDimensions (int& w, int& h, double& scaleFac); static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, rtengine::RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode = false); - static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum); + static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate); static Thumbnail* loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode = false); static RawMetaDataLocation loadMetaDataFromRaw (const Glib::ustring& fname); @@ -88,7 +88,7 @@ public: void applyAutoExp (procparams::ProcParams& pparams); unsigned char* getGrayscaleHistEQ (int trim_width); - bool writeImage (const Glib::ustring& fname, int format); + bool writeImage (const Glib::ustring& fname); bool readImage (const Glib::ustring& fname); bool readData (const Glib::ustring& fname); diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index de02be130..bfb1b8797 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -140,7 +140,7 @@ void Thumbnail::_generateThumbnailImage () if ( tpp == nullptr ) { quick = false; - tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, tw, th, 1, pparams.wb.equal, TRUE, pparams.raw.bayersensor.imageNum); + tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, tw, th, 1, pparams.wb.equal, TRUE); } cfs.sensortype = sensorType; @@ -612,7 +612,7 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro if ( cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL ) { // RAW internal thumbnail, no profile yet: just do some rotation etc. - image = tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest, scale); + image = tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest); } else { // Full thumbnail: apply profile // image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.getCamera(), cfs.focalLen, cfs.focalLen35mm, cfs.focusDist, cfs.shutter, cfs.fnumber, cfs.iso, cfs.expcomp, scale ); @@ -883,7 +883,7 @@ void Thumbnail::_saveThumbnail () } // save thumbnail image - tpp->writeImage (getCacheFileName ("images", ""), 1); + tpp->writeImage (getCacheFileName ("images", "")); // save aehistogram tpp->writeAEHistogram (getCacheFileName ("aehistograms", "")); From a75058546a1f6477548e215546ecd97f8c9e4ad9 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 14:36:56 +0200 Subject: [PATCH 15/52] Make compilation unit rtengine/color.cc -Wextra clean, #4155 --- rtengine/color.cc | 8 ++++---- rtengine/color.h | 6 +++--- rtengine/iccstore.cc | 4 ++-- rtengine/improcfun.cc | 10 +++------- rtengine/rawimagesource.cc | 8 ++++---- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/rtengine/color.cc b/rtengine/color.cc index 0957ac71e..edfe04528 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -1526,9 +1526,9 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, - bool chr, bool lum, float chromat, float luma, const float r1, const float g1, const float b1, + float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, - int toDo, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) + const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) { float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z, XL, YL, ZL; float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L, b_L; @@ -1620,7 +1620,7 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg Color::xyz2rgb(X, Y, Z, ro, go, bo, rgb_xyz);// ro go bo in gamut } -void Color::calcGamma (double pwr, double ts, int mode, int imax, GammaValues &gamma) +void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) { //from Dcraw (D.Coffin) int i; @@ -2604,7 +2604,7 @@ void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const * const double wip[3][3]: matrix for working profile * bool multiThread : parallelize the loop */ -SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3], bool multiThread ) +SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]) { #ifdef _DEBUG MyTime t1e, t2e; diff --git a/rtengine/color.h b/rtengine/color.h index 5889095ca..59e189810 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -733,7 +733,7 @@ public: * @param go green channel of output color [0 ; 65535] (return value) * @param bo blue channel of output color [0 ; 65535] (return value) */ - static void interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, bool chr, bool lum, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, int channels, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); + static void interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); /** @@ -898,7 +898,7 @@ public: * gamma4 used in ip2Lab2rgb [0 ; 1], usually near 0.03(return value) * gamma5 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value) */ - static void calcGamma (double pwr, double ts, int mode, int imax, GammaValues &gamma); + static void calcGamma (double pwr, double ts, int mode, GammaValues &gamma); /** @@ -1310,7 +1310,7 @@ public: * @param wip matrix for working profile * @param multiThread whether to parallelize the loop or not */ - static void LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3], bool multiThread ); + static void LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]); /* diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index dc4fe6ffb..891fb1600 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -809,8 +809,8 @@ void rtengine::ICCStore::getGammaArray(const procparams::ColorManagementParams & double ts = icm.slpos; double slope = icm.slpos == 0 ? eps : icm.slpos; - int mode = 0, imax = 0; - Color::calcGamma(pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2 + int mode = 0; + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2 ga[4] = g_a[3] * ts; //printf("g_a.gamma0=%f g_a.gamma1=%f g_a.gamma2=%f g_a.gamma3=%f g_a.gamma4=%f\n", g_a.gamma0,g_a.gamma1,g_a.gamma2,g_a.gamma3,g_a.gamma4); ga[0] = icm.gampos; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 9cc3e7d28..b0796702f 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5556,8 +5556,6 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go float opacity2 = (1.f - min (s / satLimit, 1.f) * (1.f - satLimitOpacity)); //float ro, go, bo; - bool chr = true; - bool lum = false; float lm = l; float chromat, luma; @@ -5573,12 +5571,10 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go luma = 1.f - SQR (SQR ((lm * 65535.f) / (cl2Toningcurve[ (lm) * 65535.f]))); //apply C2=f(L) acts only on 'b' } - int todo = 1; - if (algm == 1) { - Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); + Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity, twoc, metchrom, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, wp, wip, ro, go, bo); } else { - Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); + Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, wp, wip, ro, go, bo); } } @@ -5818,7 +5814,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu // only if user activate Lab adjustments if (autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) { - Color::LabGamutMunsell (lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip, multiThread); + Color::LabGamutMunsell (lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip); } #ifdef __SSE2__ diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 3e234bef5..78fa1f829 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2117,8 +2117,8 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, const Reti std::swap(pwr, gamm); } - int mode = 0, imax = 0; - Color::calcGamma(pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope + int mode = 0; + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope // printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4); double start; @@ -2384,13 +2384,13 @@ void RawImageSource::retinex(ColorManagementParams cmp, const RetinexParams &deh double gamm = deh.gam; double gamm2 = gamm; double ts = deh.slope; - int mode = 0, imax = 0; + int mode = 0; if(gamm2 < 1.) { std::swap(pwr, gamm); } - Color::calcGamma(pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope double mul = 1. + g_a[4]; double add; From 7c9d42827f314ba3dd5302380167d2c05ec2306e Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 14:49:45 +0200 Subject: [PATCH 16/52] Make compilation unit rtengine/colortemp.cc -Wextra clean, #4155 --- rtengine/colortemp.cc | 2 +- rtengine/colortemp.h | 2 +- rtengine/improcfun.cc | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index ea90f2735..08c58176c 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1025,7 +1025,7 @@ void ColorTemp::cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, dou } -void ColorTemp::temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz) +void ColorTemp::temp2mulxyz (double tem, const std::string &method, double &Xxyz, double &Zxyz) { double xD, yD, x_D, y_D, interm; double x, y, z; diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index 2d346dd81..6f8ed089e 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -95,7 +95,7 @@ public: } void mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const; - static void temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz); + static void temp2mulxyz (double tem, const std::string &method, double &Xxyz, double &Zxyz); static void cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, double &CAM02BB01, double &CAM02BB02, double &CAM02BB10, double &CAM02BB11, double &CAM02BB12, double &CAM02BB20, double &CAM02BB21, double &CAM02BB22, double adap ); //static void CAT02 (Imagefloat* baseImg, const ProcParams* params); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index b0796702f..3b5bd3275 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -275,9 +275,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L bool ciedata = params->colorappearance.datacie; - ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB - ColorTemp::temp2mulxyz (params->colorappearance.tempout, params->colorappearance.greenout, "Custom", Xwout, Zwout); - ColorTemp::temp2mulxyz (params->colorappearance.tempsc, params->colorappearance.greensc, "Custom", Xwsc, Zwsc); + ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB + ColorTemp::temp2mulxyz (params->colorappearance.tempout, "Custom", Xwout, Zwout); + ColorTemp::temp2mulxyz (params->colorappearance.tempsc, "Custom", Xwsc, Zwsc); //viewing condition for surrsrc if (params->colorappearance.surrsrc == "Average") { @@ -1558,9 +1558,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)); - ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB - ColorTemp::temp2mulxyz (params->colorappearance.tempout, params->colorappearance.greenout, "Custom", Xwout, Zwout); - ColorTemp::temp2mulxyz (params->colorappearance.tempsc, params->colorappearance.greensc, "Custom", Xwsc, Zwsc); + ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB + ColorTemp::temp2mulxyz (params->colorappearance.tempout, "Custom", Xwout, Zwout); + ColorTemp::temp2mulxyz (params->colorappearance.tempsc, "Custom", Xwsc, Zwsc); //viewing condition for surrsrc if (params->colorappearance.surrsrc == "Average") { From 8bd9f174dcdd2cc81283a1b0486073d1e27b5cbb Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 20:05:27 +0200 Subject: [PATCH 17/52] Reworked colortemp and pow_F defines --- rtengine/EdgePreservingDecomposition.cc | 1 - rtengine/ciecam02.cc | 1 - rtengine/color.cc | 2 - rtengine/colortemp.cc | 355 ++++++------------------ rtengine/colortemp.h | 23 +- rtengine/opthelper.h | 2 + 6 files changed, 99 insertions(+), 285 deletions(-) diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 1424af1b3..1c2d0219f 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -6,7 +6,6 @@ #endif #include "sleef.c" #include "opthelper.h" -#define pow_F(a,b) (xexpf(b*xlogf(a))) #define DIAGONALS 5 #define DIAGONALSP1 6 diff --git a/rtengine/ciecam02.cc b/rtengine/ciecam02.cc index 7b5ef63fe..77c57048a 100644 --- a/rtengine/ciecam02.cc +++ b/rtengine/ciecam02.cc @@ -30,7 +30,6 @@ #undef CLIPD #define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0) #define MAXR(a,b) ((a) > (b) ? (a) : (b)) -#define pow_F(a,b) (xexpf(b*xlogf(a))) namespace rtengine { diff --git a/rtengine/color.cc b/rtengine/color.cc index edfe04528..7964cc472 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -25,8 +25,6 @@ #include "opthelper.h" #include "iccstore.h" -#define pow_F(a,b) (xexpf(b*xlogf(a))) - using namespace std; namespace rtengine diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 08c58176c..ab318aa73 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -24,11 +24,6 @@ #include "sleef.c" #include "settings.h" -#undef CLIPD -#define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0) -#define CLIPQQ(a) ((a)>0?((a)<250?(a):250):0) -#define MAXR(a,b) ((a) > (b) ? (a) : (b)) - namespace rtengine { @@ -70,48 +65,22 @@ static const double cie_colour_match_jd[97][3] = {//350nm to 830nm 5 nm J.Desm {0.000001251141, 0.00000045181, 0.000000} }; -ColorTemp::ColorTemp (double t, double g, double e, const Glib::ustring &m) : temp(t), green(g), equal(e), method(m) +ColorTemp::ColorTemp (double t, double g, double e, const std::string &m) : temp(t), green(g), equal(e), method(m) { - clip (temp, green, equal); } void ColorTemp::clip (double &temp, double &green) { - - if (temp < MINTEMP) { - temp = MINTEMP; - } else if (temp > MAXTEMP) { - temp = MAXTEMP; - } - - if (green < MINGREEN) { - green = MINGREEN; - } else if (green > MAXGREEN) { - green = MAXGREEN; - } + temp = rtengine::LIM(temp, MINTEMP, MAXTEMP); + green = rtengine::LIM(green, MINGREEN, MAXGREEN); } void ColorTemp::clip (double &temp, double &green, double &equal) { - - if (temp < MINTEMP) { - temp = MINTEMP; - } else if (temp > MAXTEMP) { - temp = MAXTEMP; - } - - if (green < MINGREEN) { - green = MINGREEN; - } else if (green > MAXGREEN) { - green = MAXGREEN; - } - - if(equal < MINEQUAL) { - equal = MINEQUAL; - } else if(equal > MAXEQUAL) { - equal = MAXEQUAL; - } + temp = rtengine::LIM(temp, MINTEMP, MAXTEMP); + green = rtengine::LIM(green, MINGREEN, MAXGREEN); + equal = rtengine::LIM(equal, MINEQUAL, MAXEQUAL); } ColorTemp::ColorTemp (double mulr, double mulg, double mulb, double e) : equal(e), method("Custom") @@ -122,7 +91,7 @@ ColorTemp::ColorTemp (double mulr, double mulg, double mulb, double e) : equal(e void ColorTemp::mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const { - double maxtemp = double(MAXTEMP), mintemp = double(MINTEMP); + double maxtemp = MAXTEMP, mintemp = MINTEMP; double tmpr, tmpg, tmpb; temp = (maxtemp + mintemp) / 2; @@ -354,6 +323,37 @@ const double ColorTemp::Flash6500_spect[97] = { 55.72, 51.97, 54.72, 57.46, 58.89, 60.33 }; +const std::map ColorTemp::spectMap = { + {"Daylight", Daylight5300_spect}, + {"Cloudy", Cloudy6200_spect}, + {"Shade", Shade7600_spect}, + {"Tungsten", A2856_spect}, + {"Fluo F1", FluoF1_spect}, + {"Fluo F2", FluoF2_spect}, + {"Fluo F3", FluoF3_spect}, + {"Fluo F4", FluoF4_spect}, + {"Fluo F5", FluoF5_spect}, + {"Fluo F6", FluoF6_spect}, + {"Fluo F7", FluoF7_spect}, + {"Fluo F8", FluoF8_spect}, + {"Fluo F9", FluoF9_spect}, + {"Fluo F10", FluoF10_spect}, + {"Fluo F11", FluoF11_spect}, + {"Fluo F12", FluoF12_spect}, + {"HMI Lamp", HMI_spect}, + {"GTI Lamp", GTI_spect}, + {"JudgeIII Lamp", JudgeIII_spect}, + {"Solux Lamp 3500K", Solux3500_spect}, + {"Solux Lamp 4100K", Solux4100_spect}, + {"Solux Lamp 4700K", Solux4700_spect}, + {"NG Solux Lamp 4700K", NG_Solux4700_spect}, + {"LED LSI Lumelex 2040", NG_LEDLSI2040_spect}, + {"LED CRS SP12 WWMR16", NG_CRSSP12WWMR16_spect}, + {"Flash 5500K", Flash5500_spect}, + {"Flash 6000K", Flash6000_spect}, + {"Flash 6500K", Flash6500_spect} + }; + // Data for Color ==> CRI (Color Rendering Index and Palette // actually 20 color that must be good enough for CRI @@ -844,10 +844,7 @@ const double ColorTemp::ColabSky42_0_m24_spect[97] = { * Gunter Wyszecki and W. S. Stiles, John Wiley & Sons, 1982, pp. 227, 228. */ //adaptation to RT by J.Desmis -#include -/* LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0 */ -#define LERP(a,b,c) (((b) - (a)) * (c) + (a)) int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp) const { @@ -922,13 +919,13 @@ int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp) } if (i == 31) { - return(-1); /* bad XYZ input, color temp would be less than minimum of 1666.7 degrees, or too far towards blue */ + return -1; /* bad XYZ input, color temp would be less than minimum of 1666.7 degrees, or too far towards blue */ } di = di / sqrt(1.0 + uvt[i ].t * uvt[i ].t); dm = dm / sqrt(1.0 + uvt[i - 1].t * uvt[i - 1].t); p = dm / (dm - di); /* p = interpolation parameter, 0.0 : i-1, 1.0 : i */ - p = 1.0 / (LERP(rt[i - 1], rt[i], p)); + p = 1.0 / rtengine::intp(p, rt[i], rt[i - 1]); temp = p; return 0; /* success */ } @@ -1025,192 +1022,15 @@ void ColorTemp::cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, dou } -void ColorTemp::temp2mulxyz (double tem, const std::string &method, double &Xxyz, double &Zxyz) +void ColorTemp::temp2mulxyz (double temp, const std::string &method, double &Xxyz, double &Zxyz) { - double xD, yD, x_D, y_D, interm; double x, y, z; - if (method == "Daylight" ) { - spectrum_to_xyz_preset(Daylight5300_spect, x, y, z); - } else if(method == "Cloudy" ) { - spectrum_to_xyz_preset(Cloudy6200_spect, x, y, z); - } else if(method == "Shade" ) { - spectrum_to_xyz_preset(Shade7600_spect, x, y, z); - } else if(method == "Tungsten" ) { - spectrum_to_xyz_preset(A2856_spect, x, y, z); - } else if(method == "Fluo F1" ) { - spectrum_to_xyz_preset(FluoF1_spect, x, y, z); - } else if(method == "Fluo F2" ) { - spectrum_to_xyz_preset(FluoF2_spect, x, y, z); - } else if(method == "Fluo F3" ) { - spectrum_to_xyz_preset(FluoF3_spect, x, y, z); - } else if(method == "Fluo F4" ) { - spectrum_to_xyz_preset(FluoF4_spect, x, y, z); - } else if(method == "Fluo F5" ) { - spectrum_to_xyz_preset(FluoF5_spect, x, y, z); - } else if(method == "Fluo F6" ) { - spectrum_to_xyz_preset(FluoF6_spect, x, y, z); - } else if(method == "Fluo F7" ) { - spectrum_to_xyz_preset(FluoF7_spect, x, y, z); - } else if(method == "Fluo F8" ) { - spectrum_to_xyz_preset(FluoF8_spect, x, y, z); - } else if(method == "Fluo F9" ) { - spectrum_to_xyz_preset(FluoF9_spect, x, y, z); - } else if(method == "Fluo F10" ) { - spectrum_to_xyz_preset(FluoF10_spect, x, y, z); - } else if(method == "Fluo F11" ) { - spectrum_to_xyz_preset(FluoF11_spect, x, y, z); - } else if(method == "Fluo F12" ) { - spectrum_to_xyz_preset(FluoF12_spect, x, y, z); - } else if(method == "HMI Lamp" ) { - spectrum_to_xyz_preset(HMI_spect, x, y, z); - } else if(method == "GTI Lamp" ) { - spectrum_to_xyz_preset(GTI_spect, x, y, z); - } else if(method == "JudgeIII Lamp" ) { - spectrum_to_xyz_preset(JudgeIII_spect, x, y, z); - } else if(method == "Solux Lamp 3500K" ) { - spectrum_to_xyz_preset(Solux3500_spect, x, y, z); - } else if(method == "Solux Lamp 4100K" ) { - spectrum_to_xyz_preset(Solux4100_spect, x, y, z); - } else if(method == "Solux Lamp 4700K" ) { - spectrum_to_xyz_preset(Solux4700_spect, x, y, z); - } else if(method == "NG Solux Lamp 4700K" ) { - spectrum_to_xyz_preset(NG_Solux4700_spect, x, y, z); - } else if(method == "LED LSI Lumelex 2040") { - spectrum_to_xyz_preset(NG_LEDLSI2040_spect, x, y, z); - } else if(method == "LED CRS SP12 WWMR16" ) { - spectrum_to_xyz_preset(NG_CRSSP12WWMR16_spect, x, y, z); - } else if(method == "Flash 5500K" ) { - spectrum_to_xyz_preset(Flash5500_spect, x, y, z); - } else if(method == "Flash 6000K" ) { - spectrum_to_xyz_preset(Flash6000_spect, x, y, z); - } else if(method == "Flash 6500K" ) { - spectrum_to_xyz_preset(Flash6500_spect, x, y, z); - } else { - // otherwise we use the Temp+Green generic solution - if (tem <= INITIALBLACKBODY) { - // if temperature is between 2000K and 4000K we use blackbody, because there will be no Daylight reference below 4000K... - // of course, the previous version of RT used the "magical" but wrong formula of U.Fuchs (Ufraw). - spectrum_to_xyz_blackbody(tem, x, y, z); - } else { - // from 4000K up to 25000K: using the D illuminant (daylight) which is standard - double m1, m2; - - if (tem <= 7000) { - x_D = -4.6070e9 / (tem * tem * tem) + 2.9678e6 / (tem * tem) + 0.09911e3 / tem + 0.244063; - } else if (tem <= 25000) { - x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040; - } else /*if (tem > 25000)*/ { - x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040 - ((tem - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !) - } - - y_D = -3.0 * x_D * x_D + 2.87 * x_D - 0.275; - //calculate D -daylight in function of s0, s1, s2 and temp ==> x_D y_D - //S(lamda)=So(lambda)+m1*s1(lambda)+m2*s2(lambda) - interm = (0.0241 + 0.2562 * x_D - 0.734 * y_D); - m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm; - m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm; - spectrum_to_xyz_daylight(m1, m2, x, y, z); - xD = x; - yD = y; - } - - } - - xD = x; - yD = y; - - double X = xD / yD; - double Z = (1.0 - xD - yD) / yD; - Xxyz = X; - Zxyz = Z; - //printf("Xxyz=%f Zxyz=%f\n",Xxyz,Zxyz); -} - -void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const -{ - - clip (temp, green, equal); - - //printf("temp=%d green=%.3f equal=%.3f\n", (int)temp, (float) green, (float) equal); - - //variables for CRI and display Lab, and palette - double xD, yD, x_D, y_D, interm; - double m1, m2; - - double x, y, z; - double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette - double Xcam02[50], Ycam02[50], Zcam02[50]; - - double XchkLamp[50], YchkLamp[50], ZchkLamp[50]; - double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50]; - const double epsilon = 0.008856; //Lab - const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm - double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02 - - double xr[50], yr[50], zr[50]; - double fx[50], fy[50], fz[50]; - -// bool palette = false; - // double tempalet; // correlated temperature - // We first test for specially handled methods - if (method == "Daylight" ) { - spectrum_to_xyz_preset(Daylight5300_spect, x, y, z); - } else if(method == "Cloudy" ) { - spectrum_to_xyz_preset(Cloudy6200_spect, x, y, z); - } else if(method == "Shade" ) { - spectrum_to_xyz_preset(Shade7600_spect, x, y, z); - } else if(method == "Tungsten" ) { - spectrum_to_xyz_preset(A2856_spect, x, y, z); - } else if(method == "Fluo F1" ) { - spectrum_to_xyz_preset(FluoF1_spect, x, y, z); - } else if(method == "Fluo F2" ) { - spectrum_to_xyz_preset(FluoF2_spect, x, y, z); - } else if(method == "Fluo F3" ) { - spectrum_to_xyz_preset(FluoF3_spect, x, y, z); - } else if(method == "Fluo F4" ) { - spectrum_to_xyz_preset(FluoF4_spect, x, y, z); - } else if(method == "Fluo F5" ) { - spectrum_to_xyz_preset(FluoF5_spect, x, y, z); - } else if(method == "Fluo F6" ) { - spectrum_to_xyz_preset(FluoF6_spect, x, y, z); - } else if(method == "Fluo F7" ) { - spectrum_to_xyz_preset(FluoF7_spect, x, y, z); - } else if(method == "Fluo F8" ) { - spectrum_to_xyz_preset(FluoF8_spect, x, y, z); - } else if(method == "Fluo F9" ) { - spectrum_to_xyz_preset(FluoF9_spect, x, y, z); - } else if(method == "Fluo F10" ) { - spectrum_to_xyz_preset(FluoF10_spect, x, y, z); - } else if(method == "Fluo F11" ) { - spectrum_to_xyz_preset(FluoF11_spect, x, y, z); - } else if(method == "Fluo F12" ) { - spectrum_to_xyz_preset(FluoF12_spect, x, y, z); - } else if(method == "HMI Lamp" ) { - spectrum_to_xyz_preset(HMI_spect, x, y, z); - } else if(method == "GTI Lamp" ) { - spectrum_to_xyz_preset(GTI_spect, x, y, z); - } else if(method == "JudgeIII Lamp" ) { - spectrum_to_xyz_preset(JudgeIII_spect, x, y, z); - } else if(method == "Solux Lamp 3500K" ) { - spectrum_to_xyz_preset(Solux3500_spect, x, y, z); - } else if(method == "Solux Lamp 4100K" ) { - spectrum_to_xyz_preset(Solux4100_spect, x, y, z); - } else if(method == "Solux Lamp 4700K" ) { - spectrum_to_xyz_preset(Solux4700_spect, x, y, z); - } else if(method == "NG Solux Lamp 4700K" ) { - spectrum_to_xyz_preset(NG_Solux4700_spect, x, y, z); - } else if(method == "LED LSI Lumelex 2040") { - spectrum_to_xyz_preset(NG_LEDLSI2040_spect, x, y, z); - } else if(method == "LED CRS SP12 WWMR16" ) { - spectrum_to_xyz_preset(NG_CRSSP12WWMR16_spect, x, y, z); - } else if(method == "Flash 5500K" ) { - spectrum_to_xyz_preset(Flash5500_spect, x, y, z); - } else if(method == "Flash 6000K" ) { - spectrum_to_xyz_preset(Flash6000_spect, x, y, z); - } else if(method == "Flash 6500K" ) { - spectrum_to_xyz_preset(Flash6500_spect, x, y, z); + const auto iterator = spectMap.find(method); + + if (iterator != spectMap.end()) { + spectrum_to_xyz_preset(iterator->second, x, y, z); } else { // otherwise we use the Temp+Green generic solution if (temp <= INITIALBLACKBODY) { @@ -1219,48 +1039,42 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, spectrum_to_xyz_blackbody(temp, x, y, z); } else { // from 4000K up to 25000K: using the D illuminant (daylight) which is standard + double x_D, y_D; if (temp <= 7000) { x_D = -4.6070e9 / (temp * temp * temp) + 2.9678e6 / (temp * temp) + 0.09911e3 / temp + 0.244063; } else if (temp <= 25000) { x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040; - } else /*if (temp > 25000)*/ { // above 25000 it's unknown..then I have modified to adjust for underwater - x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040 - ((temp - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !) + } else /*if (temp > 25000)*/ { + x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040 - ((temp - 25000) / 25000) * 0.025; //Jacques empirical adjustment for very high temp (underwater !) } - y_D = (-3.0 * x_D * x_D + 2.87 * x_D - 0.275); //modify blue / red action + y_D = -3.0 * x_D * x_D + 2.87 * x_D - 0.275; //modify blue / red action //calculate D -daylight in function of s0, s1, s2 and temp ==> x_D y_D //S(lamda)=So(lambda)+m1*s1(lambda)+m2*s2(lambda) - interm = (0.0241 + 0.2562 * x_D - 0.734 * y_D); - m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm; - m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm; + double interm = 0.0241 + 0.2562 * x_D - 0.734 * y_D; + double m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm; + double m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm; spectrum_to_xyz_daylight(m1, m2, x, y, z); - xD = x; - yD = y; } } - xD = x; - yD = y; + Xxyz = x / y; + Zxyz = (1.0 - x - y) / y; +} + +void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const +{ + clip(temp, green, equal); + double Xwb, Zwb; + temp2mulxyz(temp, method, Xwb, Zwb); + float adj = 1.f; if(equal < 0.9999 || equal > 1.0001 ) { adj = (100.f + ( 1000.f - (1000.f * (float)equal) ) / 20.f) / 100.f; } - //printf("adj=%f\n",adj); - double Xwb = xD / yD; - double Ywb = 1.0; - double Zwb = (1.0 - xD - yD) / yD; - - if (settings->verbose) { - // double u=4*xD/(-2*xD+12*yD+3); - // double v=6*yD/(-2*xD+12*yD+3); - // printf("xD=%f yD=%f u=%f v=%f\n",xD,yD,u,v); - if(settings->CRI_color != 0) { - printf("xD=%f yD=%f === Xwb=%f Ywb=%f Zwb=%f\n", xD, yD, Xwb, Ywb, Zwb); - } - } /*if (isRaw) { rmul = sRGB_xyz[0][0]*X + sRGB_xyz[0][1]*Y + sRGB_xyz[0][2]*Z; @@ -1268,36 +1082,41 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, bmul = sRGB_xyz[2][0]*X + sRGB_xyz[2][1]*Y + sRGB_xyz[2][2]*Z; } else {*/ //recalculate channels multipliers with new values of XYZ tue to whitebalance - rmul = sRGBd65_xyz[0][0] * Xwb * adj + sRGBd65_xyz[0][1] * Ywb + sRGBd65_xyz[0][2] * Zwb / adj; // Jacques' empirical modification 5/2013 - gmul = sRGBd65_xyz[1][0] * Xwb + sRGBd65_xyz[1][1] * Ywb + sRGBd65_xyz[1][2] * Zwb; - bmul = sRGBd65_xyz[2][0] * Xwb * adj + sRGBd65_xyz[2][1] * Ywb + sRGBd65_xyz[2][2] * Zwb / adj; + rmul = sRGBd65_xyz[0][0] * Xwb * adj + sRGBd65_xyz[0][1] + sRGBd65_xyz[0][2] * Zwb / adj; // Jacques' empirical modification 5/2013 + gmul = sRGBd65_xyz[1][0] * Xwb + sRGBd65_xyz[1][1] + sRGBd65_xyz[1][2] * Zwb; + bmul = sRGBd65_xyz[2][0] * Xwb * adj + sRGBd65_xyz[2][1] + sRGBd65_xyz[2][2] * Zwb / adj; //}; gmul /= green; //printf("rmul=%f gmul=%f bmul=%f\n",rmul, gmul, bmul); - double max = rmul; - - if (gmul > max) { - max = gmul; - } - - if (bmul > max) { - max = bmul; - } + double max = rtengine::max(rmul, gmul, bmul); rmul /= max; gmul /= max; bmul /= max; - // begin CRI_RT : color rendering index RT - adaptation of CRI by J.Desmis - // CRI = 100 for Blackbody and Daylight - // calculate from spectral data values X, Y, Z , for color of colorchecker24 , SG, DC, JDC_468 - //only for lamp different of tungstene - //first calcul with illuminant (choice) - // and calcul with : blackbody at equivalent temp of lamp - if(settings->CRI_color != 0) //activate if CRi_color !=0 + if(settings->CRI_color != 0) { //activate if CRi_color !=0 + // begin CRI_RT : color rendering index RT - adaptation of CRI by J.Desmis + // CRI = 100 for Blackbody and Daylight + // calculate from spectral data values X, Y, Z , for color of colorchecker24 , SG, DC, JDC_468 + // only for lamp different of tungstene + // first calcul with illuminant (choice) + // and calcul with : blackbody at equivalent temp of lamp // CRI_color-1 = dispaly Lab values of color CRI_color -1 - { + const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm + double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02 + double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette + double Xcam02[50], Ycam02[50], Zcam02[50]; + + double XchkLamp[50], YchkLamp[50], ZchkLamp[50]; + double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50]; + const double epsilon = 0.008856; //Lab + + double xr[50], yr[50], zr[50]; + double fx[50], fy[50], fz[50]; + double x, y, z; + double Ywb = 1.0; + int illum; int numero_color = settings->CRI_color - 1; diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index 6f8ed089e..d96e6f5ce 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -19,22 +19,19 @@ #ifndef _COLORTEMP_ #define _COLORTEMP_ -#include #include - -#define pow_F(a,b) (xexpf(b*xlogf(a))) +#include namespace rtengine { -#define MINTEMP 1500 -#define MAXTEMP 60000 -#define MINGREEN 0.02 -#define MAXGREEN 10.0 -#define MINEQUAL 0.8 -#define MAXEQUAL 1.5 - -#define INITIALBLACKBODY 4000 +constexpr double MINTEMP = 1500.0; +constexpr double MAXTEMP = 60000.0; +constexpr double MINGREEN = 0.02; +constexpr double MAXGREEN = 10.0; +constexpr double MINEQUAL = 0.8; +constexpr double MAXEQUAL = 1.5; +constexpr double INITIALBLACKBODY = 4000.0; class ColorTemp @@ -49,12 +46,12 @@ private: static void clip (double &temp, double &green, double &equal); int XYZtoCorColorTemp(double x0, double y0 , double z0, double &temp) const; void temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const; - + const static std::map spectMap; public: ColorTemp () : temp(-1.), green(-1.), equal (1.), method("Custom") {} explicit ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {} - ColorTemp (double t, double g, double e, const Glib::ustring &m); + ColorTemp (double t, double g, double e, const std::string &m); ColorTemp (double mulr, double mulg, double mulb, double e); void update (const double rmul, const double gmul, const double bmul, const double equal, const double tempBias=0.0) diff --git a/rtengine/opthelper.h b/rtengine/opthelper.h index 5e9b97931..d6af9a745 100644 --- a/rtengine/opthelper.h +++ b/rtengine/opthelper.h @@ -22,6 +22,8 @@ #ifndef OPTHELPER_H #define OPTHELPER_H + #define pow_F(a,b) (xexpf(b*xlogf(a))) + #ifdef __SSE2__ #include "sleefsseavx.c" #ifdef __GNUC__ From 8de8775264791fc7ccf88db7a04a1344bfd05955 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 21:06:24 +0200 Subject: [PATCH 18/52] eliminate AlignedBufferMP, also eliminate some unsused functions in boxblur.h --- rtengine/FTblockDN.cc | 1 - rtengine/alignedbuffer.h | 52 ----- rtengine/boxblur.h | 494 --------------------------------------- rtengine/iimage.h | 1 + 4 files changed, 1 insertion(+), 547 deletions(-) diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 2344c9f30..bf79f5445 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -3261,7 +3261,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat realblue = 0.001f; } - //TODO: implement using AlignedBufferMP //fill tile from image; convert RGB to "luma/chroma" if (isRAW) {//image is raw; use channel differences for chroma channels diff --git a/rtengine/alignedbuffer.h b/rtengine/alignedbuffer.h index 44fd43e81..dd9d7b278 100644 --- a/rtengine/alignedbuffer.h +++ b/rtengine/alignedbuffer.h @@ -18,12 +18,8 @@ */ #ifndef _ALIGNEDBUFFER_ #define _ALIGNEDBUFFER_ -#include #include -#include #include -#include -#include "../rtgui/threadutils.h" // Aligned buffer that should be faster template class AlignedBuffer @@ -111,7 +107,6 @@ public: } if (real) { - //data = (T*)( (uintptr_t)real + (alignment-((uintptr_t)real)%alignment) ); data = (T*)( ( uintptr_t(real) + uintptr_t(alignment - 1)) / alignment * alignment); inUse = true; } else { @@ -142,51 +137,4 @@ public: } }; -// Multi processor version, use with OpenMP -template class AlignedBufferMP -{ -private: - MyMutex mtx; - std::vector*> buffers; - size_t size; - -public: - explicit AlignedBufferMP(size_t sizeP) - { - size = sizeP; - } - - ~AlignedBufferMP() - { - for (size_t i = 0; i < buffers.size(); i++) { - delete buffers[i]; - } - } - - AlignedBuffer* acquire() - { - MyMutex::MyLock lock(mtx); - - // Find available buffer - for (size_t i = 0; i < buffers.size(); i++) { - if (!buffers[i]->inUse) { - buffers[i]->inUse = true; - return buffers[i]; - } - } - - // Add new buffer if nothing is free - AlignedBuffer* buffer = new AlignedBuffer(size); - buffers.push_back(buffer); - - return buffer; - } - - void release(AlignedBuffer* buffer) - { - MyMutex::MyLock lock(mtx); - - buffer->inUse = false; - } -}; #endif diff --git a/rtengine/boxblur.h b/rtengine/boxblur.h index 0fa31fc2a..5475e8ffc 100644 --- a/rtengine/boxblur.h +++ b/rtengine/boxblur.h @@ -34,8 +34,6 @@ namespace rtengine template void boxblur (T** src, A** dst, int radx, int rady, int W, int H) { - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //box blur image; box range = (radx,rady) AlignedBuffer* buffer = new AlignedBuffer (W * H); @@ -125,8 +123,6 @@ template void boxblur (T** src, A** dst, int radx, int rady, i template SSEFUNCTION void boxblur (T** src, A** dst, T* buffer, int radx, int rady, int W, int H) { - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //box blur image; box range = (radx,rady) float* temp = buffer; @@ -313,13 +309,8 @@ template SSEFUNCTION void boxblur (T** src, A** dst, T* buffer } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - template SSEFUNCTION void boxblur (T* src, A* dst, A* buffer, int radx, int rady, int W, int H) { - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1) float* temp = buffer; @@ -505,489 +496,6 @@ template SSEFUNCTION void boxblur (T* src, A* dst, A* buffer, } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -template void boxvar (T* src, T* dst, int radx, int rady, int W, int H) -{ - - AlignedBuffer buffer1(W * H); - AlignedBuffer buffer2(W * H); - float* tempave = buffer1.data; - float* tempsqave = buffer2.data; - - AlignedBufferMP buffer3(H); - - //float image_ave = 0; - - //box blur image channel; box size = 2*box+1 - //horizontal blur -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) { - int len = radx + 1; - tempave[row * W + 0] = src[row * W + 0] / len; - tempsqave[row * W + 0] = SQR(src[row * W + 0]) / len; - - for (int j = 1; j <= radx; j++) { - tempave[row * W + 0] += src[row * W + j] / len; - tempsqave[row * W + 0] += SQR(src[row * W + j]) / len; - } - - for (int col = 1; col <= radx; col++) { - tempave[row * W + col] = (tempave[row * W + col - 1] * len + src[row * W + col + radx]) / (len + 1); - tempsqave[row * W + col] = (tempsqave[row * W + col - 1] * len + SQR(src[row * W + col + radx])) / (len + 1); - len ++; - } - - for (int col = radx + 1; col < W - radx; col++) { - tempave[row * W + col] = tempave[row * W + col - 1] + (src[row * W + col + radx] - src[row * W + col - radx - 1]) / len; - tempsqave[row * W + col] = tempsqave[row * W + col - 1] + (SQR(src[row * W + col + radx]) - SQR(src[row * W + col - radx - 1])) / len; - } - - for (int col = W - radx; col < W; col++) { - tempave[row * W + col] = (tempave[row * W + col - 1] * len - src[row * W + col - radx - 1]) / (len - 1); - tempsqave[row * W + col] = (tempsqave[row * W + col - 1] * len - SQR(src[row * W + col - radx - 1])) / (len - 1); - len --; - } - } - - //vertical blur -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int col = 0; col < W; col++) { - AlignedBuffer* pBuf3 = buffer3.acquire(); - T* tempave2 = (T*)pBuf3->data; - - int len = rady + 1; - tempave2[0] = tempave[0 * W + col] / len; - dst[0 * W + col] = tempsqave[0 * W + col] / len; - - for (int i = 1; i <= rady; i++) { - tempave2[0] += tempave[i * W + col] / len; - dst[0 * W + col] += tempsqave[i * W + col] / len; - } - - for (int row = 1; row <= rady; row++) { - tempave2[row] = (tempave2[(row - 1)] * len + tempave[(row + rady) * W + col]) / (len + 1); - dst[row * W + col] = (dst[(row - 1) * W + col] * len + tempsqave[(row + rady) * W + col]) / (len + 1); - len ++; - } - - for (int row = rady + 1; row < H - rady; row++) { - tempave2[row] = tempave2[(row - 1)] + (tempave[(row + rady) * W + col] - tempave[(row - rady - 1) * W + col]) / len; - dst[row * W + col] = dst[(row - 1) * W + col] + (tempsqave[(row + rady) * W + col] - tempsqave[(row - rady - 1) * W + col]) / len; - } - - for (int row = H - rady; row < H; row++) { - tempave2[row] = (tempave2[(row - 1)] * len - tempave[(row - rady - 1) * W + col]) / (len - 1); - dst[row * W + col] = (dst[(row - 1) * W + col] * len - tempsqave[(row - rady - 1) * W + col]) / (len - 1); - len --; - } - - //now finish off - for (int row = 0; row < H; row++) { - dst[row * W + col] = fabs(dst[row * W + col] - SQR(tempave2[row])); - //image_ave += src[row*W+col]; - } - - buffer3.release(pBuf3); - } - - //image_ave /= (W*H); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -template void boxdev (T* src, T* dst, int radx, int rady, int W, int H) -{ - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1) - - AlignedBuffer* buffer1 = new AlignedBuffer (W * H); - float* temp = buffer1->data; - - AlignedBuffer* buffer2 = new AlignedBuffer (W * H); - float* tempave = buffer2->data; - - if (radx == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - temp[row * W + col] = src[row * W + col]; - } - } else { - //horizontal blur -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) { - int len = radx + 1; - temp[row * W + 0] = (float)src[row * W + 0] / len; - - for (int j = 1; j <= radx; j++) { - temp[row * W + 0] += (float)src[row * W + j] / len; - } - - for (int col = 1; col <= radx; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len + src[row * W + col + radx]) / (len + 1); - len ++; - } - - for (int col = radx + 1; col < W - radx; col++) { - temp[row * W + col] = temp[row * W + col - 1] + ((float)(src[row * W + col + radx] - src[row * W + col - radx - 1])) / len; - } - - for (int col = W - radx; col < W; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len - src[row * W + col - radx - 1]) / (len - 1); - len --; - } - } - } - - if (rady == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) { - for (int col = 0; col < W; col++) { - tempave[row * W + col] = temp[row * W + col]; - } - } - } else { - //vertical blur -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int col = 0; col < W; col++) { - int len = rady + 1; - tempave[0 * W + col] = temp[0 * W + col] / len; - - for (int i = 1; i <= rady; i++) { - tempave[0 * W + col] += temp[i * W + col] / len; - } - - for (int row = 1; row <= rady; row++) { - tempave[row * W + col] = (tempave[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1); - len ++; - } - - for (int row = rady + 1; row < H - rady; row++) { - tempave[row * W + col] = tempave[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len; - } - - for (int row = H - rady; row < H; row++) { - tempave[row * W + col] = (tempave[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1); - len --; - } - } - } - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //box blur absolute deviation - - - if (radx == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - temp[row * W + col] = fabs(src[row * W + col] - tempave[row * W + col]); - } - } else { - //horizontal blur -//OpenMP here -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) { - int len = radx + 1; - temp[row * W + 0] = fabs(src[row * W + 0] - tempave[row * W + 0]) / len; - - for (int j = 1; j <= radx; j++) { - temp[row * W + 0] += fabs(src[row * W + j] - tempave[row * W + j]) / len; - } - - for (int col = 1; col <= radx; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len + fabs(src[row * W + col + radx] - tempave[row * W + col + radx])) / (len + 1); - len ++; - } - - for (int col = radx + 1; col < W - radx; col++) { - temp[row * W + col] = temp[row * W + col - 1] + (fabs(src[row * W + col + radx] - tempave[row * W + col + radx]) - \ - fabs(src[row * W + col - radx - 1] - tempave[row * W + col - radx - 1])) / len; - } - - for (int col = W - radx; col < W; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len - fabs(src[row * W + col - radx - 1] - tempave[row * W + col - radx - 1])) / (len - 1); - len --; - } - } - } - - if (rady == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - dst[row * W + col] = temp[row * W + col]; - } - } else { - //vertical blur -//OpenMP here -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int col = 0; col < W; col++) { - int len = rady + 1; - dst[0 * W + col] = temp[0 * W + col] / len; - - for (int i = 1; i <= rady; i++) { - dst[0 * W + col] += temp[i * W + col] / len; - } - - for (int row = 1; row <= rady; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1); - len ++; - } - - for (int row = rady + 1; row < H - rady; row++) { - dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len; - } - - for (int row = H - rady; row < H; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1); - len --; - } - } - } - - delete buffer1; - delete buffer2; - -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -template void boxsqblur (T* src, A* dst, int radx, int rady, int W, int H) -{ - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1) - - AlignedBuffer* buffer = new AlignedBuffer (W * H); - float* temp = buffer->data; - - if (radx == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - temp[row * W + col] = SQR(src[row * W + col]); - } - } else { - //horizontal blur -//OpenMP here -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) { - int len = radx + 1; - temp[row * W + 0] = SQR((float)src[row * W + 0]) / len; - - for (int j = 1; j <= radx; j++) { - temp[row * W + 0] += SQR((float)src[row * W + j]) / len; - } - - for (int col = 1; col <= radx; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len + SQR(src[row * W + col + radx])) / (len + 1); - len ++; - } - - for (int col = radx + 1; col < W - radx; col++) { - temp[row * W + col] = temp[row * W + col - 1] + ((float)(SQR(src[row * W + col + radx]) - SQR(src[row * W + col - radx - 1]))) / len; - } - - for (int col = W - radx; col < W; col++) { - temp[row * W + col] = (temp[row * W + col - 1] * len - SQR(src[row * W + col - radx - 1])) / (len - 1); - len --; - } - } - } - - if (rady == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - dst[row * W + col] = temp[row * W + col]; - } - } else { - //vertical blur -//OpenMP here -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int col = 0; col < W; col++) { - int len = rady + 1; - dst[0 * W + col] = temp[0 * W + col] / len; - - for (int i = 1; i <= rady; i++) { - dst[0 * W + col] += temp[i * W + col] / len; - } - - for (int row = 1; row <= rady; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1); - len ++; - } - - for (int row = rady + 1; row < H - rady; row++) { - dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len; - } - - for (int row = H - rady; row < H; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1); - len --; - } - } - } - - delete buffer; - -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -template void boxcorrelate (T* src, A* dst, int dx, int dy, int radx, int rady, int W, int H) -{ - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - //box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1) - - AlignedBuffer* buffer = new AlignedBuffer (W * H); - float* temp = buffer->data; - - if (radx == 0) { - for (int row = 0; row < H; row++) { - int rr = min(H - 1, max(0, row + dy)); - - for (int col = 0; col < W; col++) { - int cc = min(W - 1, max(0, col + dx)); - temp[row * W + col] = dy > 0 ? (src[row * W + col]) * (src[rr * W + cc]) : 0; - } - } - } else { - //horizontal blur - for (int row = 0; row < H; row++) { - int len = radx + 1; - int rr = min(H - 1, max(0, row + dy)); - int cc = min(W - 1, max(0, 0 + dx)); - temp[row * W + 0] = ((float)src[row * W + 0]) * (src[rr * W + cc]) / len; - - for (int j = 1; j <= radx; j++) { - int cc = min(W - 1, max(0, j + dx)); - temp[row * W + 0] += ((float)src[row * W + j]) * (src[rr * W + cc]) / len; - } - - for (int col = 1; col <= radx; col++) { - int cc = min(W - 1, max(0, col + dx + radx)); - temp[row * W + col] = (temp[row * W + col - 1] * len + (src[row * W + col + radx]) * (src[rr * W + cc])) / (len + 1); - len ++; - } - - for (int col = radx + 1; col < W - radx; col++) { - int cc = min(W - 1, max(0, col + dx + radx)); - int cc1 = min(W - 1, max(0, col + dx - radx - 1)); - temp[row * W + col] = temp[row * W + col - 1] + ((float)((src[row * W + col + radx]) * (src[rr * W + cc]) - - (src[row * W + col - radx - 1]) * (src[rr * W + cc1]))) / len; - } - - for (int col = W - radx; col < W; col++) { - int cc1 = min(W - 1, max(0, col + dx - radx - 1)); - temp[row * W + col] = (temp[row * W + col - 1] * len - (src[row * W + col - radx - 1]) * (src[rr * W + cc1])) / (len - 1); - len --; - } - } - } - - if (rady == 0) { -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int row = 0; row < H; row++) - for (int col = 0; col < W; col++) { - dst[row * W + col] = temp[row * W + col]; - } - } else { - //vertical blur -//OpenMP here -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int col = 0; col < W; col++) { - int len = rady + 1; - dst[0 * W + col] = temp[0 * W + col] / len; - - for (int i = 1; i <= rady; i++) { - dst[0 * W + col] += temp[i * W + col] / len; - } - - for (int row = 1; row <= rady; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1); - len ++; - } - - for (int row = rady + 1; row < H - rady; row++) { - dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len; - } - - for (int row = H - rady; row < H; row++) { - dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1); - len --; - } - } - } - - delete buffer; - -} - - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - template SSEFUNCTION void boxabsblur (T* src, A* dst, int radx, int rady, int W, int H, float * temp) { @@ -1131,7 +639,5 @@ template SSEFUNCTION void boxabsblur (T* src, A* dst, int radx } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - } #endif /* _BOXBLUR_H_ */ diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 149ed3787..e2cd6b951 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -28,6 +28,7 @@ #include "coord2d.h" #include "procparams.h" #include "color.h" +#include "../rtgui/threadutils.h" #define TR_NONE 0 #define TR_R90 1 From 123c8b44431aa38f6f5afdfc7ffd602b06ed78e5 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 22:25:05 +0200 Subject: [PATCH 19/52] Make compilation unit rtengine/curves.cc -Wextra clean, #4155 --- rtengine/curves.cc | 20 ++++++++------------ rtengine/curves.h | 10 +++++----- rtengine/improccoordinator.cc | 2 +- rtengine/procparams.cc | 6 +++--- rtengine/rtthumbnail.cc | 4 ++-- rtengine/simpleprocess.cc | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/rtengine/curves.cc b/rtengine/curves.cc index ee589bc74..db6c4c5f5 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -476,14 +476,10 @@ void CurveFactory::complexsgnCurve (bool & autili, bool & butili, bool & ccutil } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, - procparams::ToneCurveParams::eTCModeId curveMode, const std::vector& curvePoints, - procparams::ToneCurveParams::eTCModeId curveMode2, const std::vector& curvePoints2, + const std::vector& curvePoints, + const std::vector& curvePoints2, LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, @@ -1360,7 +1356,7 @@ void ColorGradientCurve::Reset() lut3.reset(); } -void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) +void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], float satur, float lumin) { if (pCurve->isIdentity()) { lut1.reset(); @@ -1500,7 +1496,7 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], */ } -void ColorGradientCurve::SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) +void ColorGradientCurve::SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], float satur, float lumin) { std::unique_ptr tcurve; @@ -1509,11 +1505,11 @@ void ColorGradientCurve::SetXYZ(const std::vector &curvePoints, const do } if (tcurve) { - SetXYZ(tcurve.get(), xyz_rgb, rgb_xyz, satur, lumin); + SetXYZ(tcurve.get(), xyz_rgb, satur, lumin); } } -void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) +void ColorGradientCurve::SetRGB(const Curve *pCurve) { if (pCurve->isIdentity()) { lut1.reset(); @@ -1599,7 +1595,7 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], */ } -void ColorGradientCurve::SetRGB(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) +void ColorGradientCurve::SetRGB(const std::vector &curvePoints) { std::unique_ptr tcurve; @@ -1608,7 +1604,7 @@ void ColorGradientCurve::SetRGB(const std::vector &curvePoints, const do } if (tcurve) { - SetRGB(tcurve.get(), xyz_rgb, rgb_xyz); + SetRGB(tcurve.get()); } } diff --git a/rtengine/curves.h b/rtengine/curves.h index c20b78772..10f62fb13 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -281,7 +281,7 @@ public: public: static void complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, - procparams::ToneCurveParams::eTCModeId curveMode, const std::vector& curvePoints, procparams::ToneCurveParams::eTCModeId curveMode2, const std::vector& curvePoints2, + const std::vector& curvePoints, const std::vector& curvePoints2, LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, ToneCurve & outToneCurve, ToneCurve & outToneCurve2, int skip = 1); @@ -687,10 +687,10 @@ public: virtual ~ColorGradientCurve() {}; void Reset(); - void SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); - void SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); - void SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); - void SetRGB(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); + void SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], float satur, float lumin); + void SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], float satur, float lumin); + void SetRGB(const Curve *pCurve); + void SetRGB(const std::vector &curvePoints); /** * @brief Get the value of Red, Green and Blue corresponding to the requested index diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9366bec27..9a216ed46 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -461,7 +461,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black / 65535.0, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, - params.toneCurve.curveMode, params.toneCurve.curve, params.toneCurve.curveMode2, params.toneCurve.curve2, + params.toneCurve.curve, params.toneCurve.curve2, vhist16, hltonecurve, shtonecurve, tonecurve, histToneCurve, customToneCurve1, customToneCurve2, 1); CurveFactory::RGBCurve (params.rgbCurves.rcurve, rCurve, 1); diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 7a3fec1ea..3e78d9879 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -584,13 +584,13 @@ void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCur satur = 0.9f; } - colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin); + colorCurveLUT.SetXYZ (cCurve, xyz_rgb, satur, lumin); opacityCurveLUT.Set (oCurve, opautili); } else if (method == "Splitlr" || method == "Splitco") { - colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin); + colorCurveLUT.SetXYZ (cCurve, xyz_rgb, satur, lumin); opacityCurveLUT.Set (oCurve, opautili); } else if (method.substr (0, 3) == "RGB") { - colorCurveLUT.SetRGB (cCurve, xyz_rgb, rgb_xyz); + colorCurveLUT.SetRGB (cCurve); opacityCurveLUT.Set (oCurve, opautili); } } diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index b458464b8..c26a788bb 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1152,8 +1152,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT ToneCurve customToneCurvebw2; CurveFactory::complexCurve (expcomp, black / 65535.0, hlcompr, hlcomprthresh, params.toneCurve.shcompr, bright, contr, - params.toneCurve.curveMode, params.toneCurve.curve, - params.toneCurve.curveMode2, params.toneCurve.curve2, + params.toneCurve.curve, + params.toneCurve.curve2, hist16, curve1, curve2, curve, dummy, customToneCurve1, customToneCurve2, 16); LUTf rCurve; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index e8bcb7054..9bbaf856b 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -870,7 +870,7 @@ private: //if(params.blackwhite.enabled) params.toneCurve.hrenabled=false; CurveFactory::complexCurve (expcomp, black / 65535.0, hlcompr, hlcomprthresh, params.toneCurve.shcompr, bright, contr, - params.toneCurve.curveMode, params.toneCurve.curve, params.toneCurve.curveMode2, params.toneCurve.curve2, + params.toneCurve.curve, params.toneCurve.curve2, hist16, curve1, curve2, curve, dummy, customToneCurve1, customToneCurve2 ); CurveFactory::RGBCurve (params.rgbCurves.rcurve, rCurve, 1); From 31c75864d43a64b5a8248590b36e5683a129f5ab Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 23:08:02 +0200 Subject: [PATCH 20/52] Make compilation unit rtengine/dirpyr_equalizer.cc -Wextra clean, #4155 --- rtengine/dirpyr_equalizer.cc | 58 +++++++++++++----------------------- rtengine/improcfun.cc | 11 ++----- rtengine/improcfun.h | 6 ++-- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 8f3ebae9f..e20bc04e7 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -20,38 +20,27 @@ #include #include -#include "curves.h" -#include "labimage.h" -#include "color.h" -#include "mytime.h" #include "improcfun.h" -#include "rawimagesource.h" #include "array2D.h" #include "rt_math.h" #include "opthelper.h" -#ifdef _OPENMP -#include -#endif -#define CLIPI(a) ((a)>0 ?((a)<32768 ?(a):32768):0) #define RANGEFN(i) ((1000.0f / (i + 1000.0f))) -#define CLIPC(a) ((a)>-32000?((a)<32000?(a):32000):-32000) #define DIRWT(i1,j1,i,j) ( domker[(i1-i)/scale+halfwin][(j1-j)/scale+halfwin] * RANGEFN(fabsf((data_fine[i1][j1]-data_fine[i][j]))) ) namespace rtengine { -static const int maxlevel = 6; -static const float noise = 2000; +constexpr int maxlevel = 6; +constexpr float noise = 2000; //sequence of scales -static const int scales[6] = {1, 2, 4, 8, 16, 32}; +constexpr int scales[maxlevel] = {1, 2, 4, 8, 16, 32}; extern const Settings* settings; //sequence of scales - -SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) +SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scaleprev) { int lastlevel = maxlevel; @@ -94,10 +83,10 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, } int level; - float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; - float scalefl[6]; + float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; + float scalefl[maxlevel]; - for(int lv = 0; lv < 6; lv++) { + for(int lv = 0; lv < maxlevel; lv++) { scalefl[lv] = ((float) scales[lv]) / (float) scaleprev; if(lv >= 1) { @@ -226,12 +215,12 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, float ** buffer = dirpyrlo[lastlevel - 1]; for(int level = lastlevel - 1; level > 0; level--) { - idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, b_l, t_l, t_r); } scale = scales[0]; - idirpyr_eq_channel(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + idirpyr_eq_channel(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, b_l, t_l, t_r); if(skinprot != 0.f) { for (int i = 0; i < srcheight; i++) { @@ -247,7 +236,6 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, delete [] tmpHue; } - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #pragma omp parallel for for (int i = 0; i < srcheight; i++) @@ -259,7 +247,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, -void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) +void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scaleprev) { int lastlevel = maxlevel; @@ -303,10 +291,10 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float int level; - float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; - float scalefl[6]; + float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; + float scalefl[maxlevel]; - for(int lv = 0; lv < 6; lv++) { + for(int lv = 0; lv < maxlevel; lv++) { scalefl[lv] = ((float) scales[lv]) / (float) scaleprev; // if(scalefl[lv] < 1.f) multi[lv] = 1.f; else multi[lv]=(float) mult[lv]; @@ -371,7 +359,6 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float idirpyr_eq_channelcam(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if(execdir) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -385,20 +372,17 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float dst[i][j] = src[i][j]; } } - } else + } else { for (int i = 0; i < srcheight; i++) for (int j = 0; j < srcwidth; j++) { dst[i][j] = CLIP( buffer[i][j] ); // TODO: Really a clip necessary? } - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + } } - SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** data_coarse, int width, int height, int level, int scale) { - //scale is spacing of directional averaging weights - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + // scale is spacing of directional averaging weights // calculate weights, compute directionally weighted average if(level > 1) { @@ -620,9 +604,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da } } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) +void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[maxlevel], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, float b_l, float t_l, float t_r) { const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -635,7 +617,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin offs = -1.f; } - float multbis[6]; + float multbis[maxlevel]; multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult @@ -714,7 +696,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin } -void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) +void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[maxlevel], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) { const float skinprotneg = -skinprot; @@ -728,7 +710,7 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_ offs = -1.f; } - float multbis[6]; + float multbis[maxlevel]; multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 3b5bd3275..efdef778a 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -1310,10 +1310,8 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L if (rtt == 1) { float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; //not disabled in case of ! always 0 - dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); //contrast by detail adapted to CIECAM + dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM } } @@ -2757,11 +2755,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw if (rtt == 1) { float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; // I have not suppress this statement in case of !! always to 0 lab->deleteLab(); - dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); //contrast by detail adapted to CIECAM + dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM lab->reallocLab(); } @@ -6506,7 +6502,6 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; //I have not disabled this statement in case of ! always 0 // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; float artifact = (float) settings->artifact_cbdl; @@ -6526,7 +6521,7 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) } //dirpyrLab_equalizer(lab, lab, params->dirpyrequalizer.mult); - dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); + dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, b_l, t_l, t_r, scale); } } void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates, int skip) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 1065c5833..d6bbdff32 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -332,10 +332,10 @@ public: float MadRgb (float * DataList, const int datalen); // pyramid wavelet - void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet - void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet + void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scale);//Emil's directional pyramid wavelet + void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scale);//Emil's directional pyramid wavelet void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale); - void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); + void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe (LabImage* lab); void defringecam (CieImage* ncie); From 330ee9a91fa37254fbdd60727fa0bbdea6dd1b79 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 22 Oct 2017 23:48:38 +0200 Subject: [PATCH 21/52] Make compilation unit rtengine/procparams.cc -Wextra clean, #4155 --- rtengine/improccoordinator.cc | 8 +------- rtengine/procparams.cc | 6 +++--- rtengine/procparams.h | 4 ++-- rtengine/rtthumbnail.cc | 8 +------- rtengine/simpleprocess.cc | 8 +------- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9a216ed46..ccf517329 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -478,13 +478,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {wprof[1][0], wprof[1][1], wprof[1][2]}, {wprof[2][0], wprof[2][1], wprof[2][2]} }; - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working); - double wip[3][3] = { - {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, - {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, - {wiprof[2][0], wiprof[2][1], wiprof[2][2]} - }; - params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili); + params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili); CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16); CurveFactory::curveToning (params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16); } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 3e78d9879..1c29f3e4b 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -18,7 +18,6 @@ */ #include #include "procparams.h" -#include "rt_math.h" #include "curves.h" #include "../rtgui/multilangmgr.h" #include "../rtgui/version.h" @@ -26,6 +25,7 @@ #include "../rtgui/paramsedited.h" #include "../rtgui/options.h" #include + #define APPVERSION RTVERSION using namespace std; @@ -558,7 +558,7 @@ void ColorToningParams::slidersToCurve (std::vector &colorCurve, std::ve opacityCurve.at (8) = 0.35; } -void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const +void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], bool &opautili) const { float satur = 0.8f; float lumin = 0.5f; //middle of luminance for optimization of gamut - no real importance...as we work in XYZ and gamut control @@ -8829,7 +8829,7 @@ void PartialProfile::clearGeneral () } } -const void PartialProfile::applyTo (ProcParams *destParams) const +void PartialProfile::applyTo (ProcParams *destParams) const { if (destParams && pparams && pedited) { pedited->combine (*destParams, *pparams, true); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index aaf62c53f..616e75537 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -435,7 +435,7 @@ public: /// @brief Specifically transform the sliders values to their curve equivalences void slidersToCurve (std::vector &colorCurve, std::vector &opacityCurve) const; /// @brief Fill the ColorGradientCurve and OpacityCurve LUTf from the control points curve or sliders value - void getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const; + void getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], bool &opautili) const; static void getDefaultColorCurve (std::vector &curve); static void getDefaultOpacityCurve (std::vector &curve); @@ -1493,7 +1493,7 @@ public: void clearGeneral (); int load (const Glib::ustring &fName); void set (bool v); - const void applyTo (ProcParams *destParams) const ; + void applyTo (ProcParams *destParams) const ; }; /** diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index c26a788bb..8398ea2d2 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1172,13 +1172,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT {wprof[1][0], wprof[1][1], wprof[1][2]}, {wprof[2][0], wprof[2][1], wprof[2][2]} }; - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working); - double wip[3][3] = { - {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, - {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, - {wiprof[2][0], wiprof[2][1], wiprof[2][2]} - }; - params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili); + params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili); clToningcurve (65536); CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 9bbaf856b..30d7a8ec7 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -886,13 +886,7 @@ private: {wprof[1][0], wprof[1][1], wprof[1][2]}, {wprof[2][0], wprof[2][1], wprof[2][2]} }; - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working); - double wip[3][3] = { - {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, - {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, - {wiprof[2][0], wiprof[2][1], wiprof[2][2]} - }; - params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili); + params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili); clToningcurve (65536, 0); CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, 1); cl2Toningcurve (65536, 0); From 54a07be45d2d94848e0e48bd33fc696555c14013 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 23 Oct 2017 00:16:22 +0200 Subject: [PATCH 22/52] Make compilation unit rtengine/PF_correct_RT.cc -Wextra clean, #4155 --- rtengine/PF_correct_RT.cc | 4 ++-- rtengine/improcfun.cc | 28 +++++++++------------------- rtengine/improcfun.h | 8 ++++---- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index 6e1fe75d6..a31c78767 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -655,7 +655,7 @@ SSEFUNCTION void ImProcFunctions::PF_correct_RTcam(CieImage * src, CieImage * ds free(fringe); } -SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad) +SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, double radius, int thresh, int mode, float skinprot, float chrom, int hotbad) { const int halfwin = ceil(2 * radius) + 1; MyTime t1, t2; @@ -1263,7 +1263,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d } -SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom) +SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, double radius, int thresh, int mode, float skinprot, float chrom) { const int halfwin = ceil(2 * radius) + 1; MyTime t1, t2; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index efdef778a..883b8bd78 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -1264,11 +1264,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L //if(params->dirpyrequalizer.enabled) if(execsharp) { if (params->dirpyrequalizer.enabled) { if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) { - float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - float artifact = (float) settings->artifact_cbdl; if (artifact > 6.f) { @@ -1282,14 +1277,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, L float chrom = 50.f; { int hotbad = 0; - ImProcFunctions::badpixcam (ncie, artifact, 5, 2, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL + ImProcFunctions::badpixcam (ncie, artifact, 5, 2, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL } } } if (params->colorappearance.badpixsl > 0) if (execsharp) { int mode = params->colorappearance.badpixsl; - ImProcFunctions::badpixcam (ncie, 3.4, 5, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM + ImProcFunctions::badpixcam (ncie, 3.4, 5, mode, 0, 0, 1);//for bad pixels CIECAM } if (params->sharpenMicro.enabled)if (execsharp) { @@ -2699,10 +2694,6 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw //if(params->dirpyrequalizer.enabled) if(execsharp) { if (params->dirpyrequalizer.enabled) { if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) { //remove artifacts by gaussian blur - skin control - float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; float artifact = (float) settings->artifact_cbdl; if (artifact > 6.f) { @@ -2716,7 +2707,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw int hotbad = 0; float chrom = 50.f; lab->deleteLab(); - ImProcFunctions::badpixcam (ncie, artifact, 5, 2, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL + ImProcFunctions::badpixcam (ncie, artifact, 5, 2, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL lab->reallocLab(); } } @@ -2725,7 +2716,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw if (params->colorappearance.badpixsl > 0) if (execsharp) { int mode = params->colorappearance.badpixsl; lab->deleteLab(); - ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM + ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, 0, 1);//for bad pixels CIECAM lab->reallocLab(); } @@ -6481,17 +6472,17 @@ void ImProcFunctions::defringecam (CieImage* ncie) } } -void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad) +void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float skinprot, float chrom, int hotbad) { if (ncie->W >= 8 && ncie->H >= 8) { - Badpixelscam (ncie, ncie, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom, hotbad); + Badpixelscam (ncie, ncie, rad, thr, mode, skinprot, chrom, hotbad); } } -void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom) +void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, int mode, float skinprot, float chrom) { if (lab->W >= 8 && lab->H >= 8) { - BadpixelsLab (lab, lab, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom); + BadpixelsLab (lab, lab, rad, thr, mode, skinprot, chrom); } } @@ -6500,7 +6491,6 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) if (params->dirpyrequalizer.enabled && lab->W >= 8 && lab->H >= 8) { float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; @@ -6517,7 +6507,7 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) float chrom = 50.f; if (params->dirpyrequalizer.gamutlab) { - ImProcFunctions::badpixlab (lab, artifact, 5, 3, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom); //for artifacts + ImProcFunctions::badpixlab (lab, artifact, 5, 3, params->dirpyrequalizer.skinprotect, chrom); //for artifacts } //dirpyrLab_equalizer(lab, lab, params->dirpyrequalizer.mult); diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index d6bbdff32..37bbf61cf 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -339,13 +339,13 @@ public: void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe (LabImage* lab); void defringecam (CieImage* ncie); - void badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); - void badpixlab (LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom); + void badpixcam (CieImage* ncie, double rad, int thr, int mode, float skinprot, float chrom, int hotbad); + void badpixlab (LabImage* lab, double rad, int thr, int mode, float skinprot, float chrom); void PF_correct_RT (LabImage * src, LabImage * dst, double radius, int thresh); void PF_correct_RTcam (CieImage * src, CieImage * dst, double radius, int thresh); - void Badpixelscam (CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); - void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom); + void Badpixelscam (CieImage * src, CieImage * dst, double radius, int thresh, int mode, float skinprot, float chrom, int hotbad); + void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float skinprot, float chrom); Image8* lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm); Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga = nullptr); From fa4444d6d3915fb122f423b76f2ac35f5f85c497 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 23 Oct 2017 14:06:04 +0200 Subject: [PATCH 23/52] Make rtengine/fujicompressed.cc -Wextra clean, #4155 --- rtengine/dcraw.h | 4 ++-- rtengine/fujicompressed.cc | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index a109b43c2..d01e265ad 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -285,8 +285,8 @@ void fuji_extend_generic(ushort *linebuf[_ltotal], int line_width, int start, in void fuji_extend_red(ushort *linebuf[_ltotal], int line_width); void fuji_extend_green(ushort *linebuf[_ltotal], int line_width); void fuji_extend_blue(ushort *linebuf[_ltotal], int line_width); -void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); -void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); +void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params); +void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params); void fuji_decode_strip(const struct fuji_compressed_params* info_common, int cur_block, INT64 raw_offset, unsigned dsize); void fuji_compressed_load_raw(); void fuji_decode_loop(const struct fuji_compressed_params* common_info, int count, INT64* raw_block_offsets, unsigned *block_sizes); diff --git a/rtengine/fujicompressed.cc b/rtengine/fujicompressed.cc index 156c338d5..e00e037fc 100644 --- a/rtengine/fujicompressed.cc +++ b/rtengine/fujicompressed.cc @@ -534,7 +534,7 @@ void CLASS fuji_extend_blue (ushort *linebuf[_ltotal], int line_width) fuji_extend_generic (linebuf, line_width, _B2, _B4); } -void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line) +void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct fuji_compressed_params *params) { int r_even_pos = 0, r_odd_pos = 1; int g_even_pos = 0, g_odd_pos = 1; @@ -699,8 +699,7 @@ void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct } } -void CLASS fuji_bayer_decode_block (struct fuji_compressed_block *info, const struct fuji_compressed_params *params, - int cur_line) +void CLASS fuji_bayer_decode_block (struct fuji_compressed_block *info, const struct fuji_compressed_params *params) { int r_even_pos = 0, r_odd_pos = 1; int g_even_pos = 0, g_odd_pos = 1; @@ -867,9 +866,9 @@ void CLASS fuji_decode_strip (const struct fuji_compressed_params* info_common, for (cur_line = 0; cur_line < fuji_total_lines; cur_line++) { if (fuji_raw_type == 16) { - xtrans_decode_block (&info, info_common, cur_line); + xtrans_decode_block (&info, info_common); } else { - fuji_bayer_decode_block (&info, info_common, cur_line); + fuji_bayer_decode_block (&info, info_common); } // copy data from line buffers and advance From 841679c6db496f75b08467e6bad8f2ac1051a92a Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 23 Oct 2017 20:41:20 +0200 Subject: [PATCH 24/52] Remove some duplicate code in rtengine/curves.cc --- rtengine/curves.h | 158 ++---------------------------------------- rtengine/improcfun.cc | 12 ++-- 2 files changed, 12 insertions(+), 158 deletions(-) diff --git a/rtengine/curves.h b/rtengine/curves.h index 10f62fb13..c616c94da 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -801,11 +801,6 @@ class StandardToneCurve : public ToneCurve public: void Apply(float& r, float& g, float& b) const; }; -class StandardToneCurvebw : public ToneCurve -{ -public: - void Apply(float& r, float& g, float& b) const; -}; class AdobeToneCurve : public ToneCurve { @@ -816,27 +811,12 @@ public: void Apply(float& r, float& g, float& b) const; }; -class AdobeToneCurvebw : public ToneCurve -{ -private: - void RGBTone(float& r, float& g, float& b) const; // helper for tone curve - -public: - void Apply(float& r, float& g, float& b) const; -}; - class SatAndValueBlendingToneCurve : public ToneCurve { public: void Apply(float& r, float& g, float& b) const; }; -class SatAndValueBlendingToneCurvebw : public ToneCurve -{ -public: - void Apply(float& r, float& g, float& b) const; -}; - class WeightedStdToneCurve : public ToneCurve { private: @@ -884,14 +864,6 @@ public: void Apply(float& r, float& g, float& b, PerceptualToneCurveState & state) const; }; -class WeightedStdToneCurvebw : public ToneCurve -{ -private: - float Triangle(float refX, float refY, float X2) const; -public: - void Apply(float& r, float& g, float& b) const; -}; - // Standard tone curve inline void StandardToneCurve::Apply (float& r, float& g, float& b) const { @@ -902,16 +874,6 @@ inline void StandardToneCurve::Apply (float& r, float& g, float& b) const g = lutToneCurve[g]; b = lutToneCurve[b]; } -// Standard tone curve -inline void StandardToneCurvebw::Apply (float& r, float& g, float& b) const -{ - - assert (lutToneCurve); - - r = lutToneCurve[r]; - g = lutToneCurve[g]; - b = lutToneCurve[b]; -} // Tone curve according to Adobe's reference implementation // values in 0xffff space @@ -943,33 +905,6 @@ inline void AdobeToneCurve::Apply (float& r, float& g, float& b) const } } } -inline void AdobeToneCurvebw::Apply (float& r, float& g, float& b) const -{ - - assert (lutToneCurve); - - if (r >= g) { - if (g > b) { - RGBTone (r, g, b); // Case 1: r >= g > b - } else if (b > r) { - RGBTone (b, r, g); // Case 2: b > r >= g - } else if (b > g) { - RGBTone (r, b, g); // Case 3: r >= b > g - } else { // Case 4: r >= g == b - r = lutToneCurve[r]; - g = lutToneCurve[g]; - b = g; - } - } else { - if (r >= b) { - RGBTone (g, r, b); // Case 5: g > r >= b - } else if (b > g) { - RGBTone (b, g, r); // Case 6: b > g > r - } else { - RGBTone (g, b, r); // Case 7: g >= b > r - } - } -} inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const { @@ -979,14 +914,6 @@ inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const b = lutToneCurve[bold]; g = b + ((r - b) * (gold - bold) / (rold - bold)); } -inline void AdobeToneCurvebw::RGBTone (float& r, float& g, float& b) const -{ - float rold = r, gold = g, bold = b; - - r = lutToneCurve[rold]; - b = lutToneCurve[bold]; - g = b + ((r - b) * (gold - bold) / (rold - bold)); -} // Modifying the Luminance channel only inline void LuminanceToneCurve::Apply(float &r, float &g, float &b) const @@ -1019,23 +946,6 @@ inline float WeightedStdToneCurve::Triangle(float a, float a1, float b) const return a1; } -inline float WeightedStdToneCurvebw::Triangle(float a, float a1, float b) const -{ - if (a != b) { - float b1; - float a2 = a1 - a; - - if (b < a) { - b1 = b + a2 * b / a ; - } else { - b1 = b + a2 * (65535.f - b) / (65535.f - a); - } - - return b1; - } - - return a1; -} // Tone curve modifying the value channel only, preserving hue and saturation // values in 0xffff space @@ -1061,28 +971,6 @@ inline void WeightedStdToneCurve::Apply (float& r, float& g, float& b) const b = CLIP(b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); } -inline void WeightedStdToneCurvebw::Apply (float& r, float& g, float& b) const -{ - - assert (lutToneCurve); - - float r1 = lutToneCurve[r]; - float g1 = Triangle(r, r1, g); - float b1 = Triangle(r, r1, b); - - float g2 = lutToneCurve[g]; - float r2 = Triangle(g, g2, r); - float b2 = Triangle(g, g2, b); - - float b3 = lutToneCurve[b]; - float r3 = Triangle(b, b3, r); - float g3 = Triangle(b, b3, g); - - r = CLIP( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); - g = CLIP(g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); - b = CLIP(b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); -} - // Tone curve modifying the value channel only, preserving hue and saturation // values in 0xffff space inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) const @@ -1099,54 +987,20 @@ inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) c return; } - bool increase = newLum > lum; - Color::rgb2hsv(r, g, b, h, s, v); - if (increase) { + float dV; + if (newLum > lum) { // Linearly targeting Value = 1 and Saturation = 0 float coef = (newLum - lum) / (65535.f - lum); - float dV = (1.f - v) * coef; + dV = (1.f - v) * coef; s *= 1.f - coef; - Color::hsv2rgb(h, s, v + dV, r, g, b); } else { // Linearly targeting Value = 0 - float coef = (lum - newLum) / lum ; - float dV = v * coef; - Color::hsv2rgb(h, s, v - dV, r, g, b); - } -} - -inline void SatAndValueBlendingToneCurvebw::Apply (float& r, float& g, float& b) const -{ - - assert (lutToneCurve); - - float h, s, v; - float lum = (r + g + b) / 3.f; - //float lum = Color::rgbLuminance(r, g, b); - float newLum = lutToneCurve[lum]; - - if (newLum == lum) { - return; - } - - bool increase = newLum > lum; - - Color::rgb2hsv(r, g, b, h, s, v); - - if (increase) { - // Linearly targeting Value = 1 and Saturation = 0 - float coef = (newLum - lum) / (65535.f - lum); - float dV = (1.f - v) * coef; - s *= 1.f - coef; - Color::hsv2rgb(h, s, v + dV, r, g, b); - } else { - // Linearly targeting Value = 0 - float coef = (lum - newLum) / lum ; - float dV = v * coef; - Color::hsv2rgb(h, s, v - dV, r, g, b); + float coef = (newLum - lum) / lum ; + dV = v * coef; } + Color::hsv2rgb(h, s, v + dV, r, g, b); } } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 883b8bd78..8236aaf37 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -4196,21 +4196,21 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (beforeCurveMode == BlackWhiteParams::TC_MODE_STD_BW) { // Standard for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const StandardToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + const StandardToneCurve& userToneCurvebw = static_cast (customToneCurvebw1); userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_FILMLIKE_BW) { // Adobe like for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const AdobeToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + const AdobeToneCurve& userToneCurvebw = static_cast (customToneCurvebw1); userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_SATANDVALBLENDING_BW) { // apply the curve on the saturation and value channels for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const SatAndValueBlendingToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + const SatAndValueBlendingToneCurve& userToneCurvebw = static_cast (customToneCurvebw1); rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); @@ -4220,7 +4220,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW) { // apply the curve to the rgb channels, weighted for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const WeightedStdToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + const WeightedStdToneCurve& userToneCurvebw = static_cast (customToneCurvebw1); rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); @@ -4660,7 +4660,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - const StandardToneCurvebw& userToneCurve = static_cast (customToneCurvebw2); + const StandardToneCurve& userToneCurve = static_cast (customToneCurvebw2); userToneCurve.Apply (tmpImage->r (i, j), tmpImage->g (i, j), tmpImage->b (i, j)); } } @@ -4671,7 +4671,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { //for ulterior usage if bw data modified for (int j = 0; j < tW; j++) { - const WeightedStdToneCurvebw& userToneCurve = static_cast (customToneCurvebw2); + const WeightedStdToneCurve& userToneCurve = static_cast (customToneCurvebw2); tmpImage->r (i, j) = CLIP (tmpImage->r (i, j)); tmpImage->g (i, j) = CLIP (tmpImage->g (i, j)); From 80b23e7168a7a66a39a5f3284e3cd5e1eaabaa21 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 23 Oct 2017 20:59:47 +0200 Subject: [PATCH 25/52] Make compilation unit rtengine/imagedata.cc -Wextra clean, #4155 --- rtengine/imagedata.cc | 4 ++-- rtengine/imagedata.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index b498f69f1..d90053476 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -24,7 +24,7 @@ #include "iptcpairs.h" #include "imagesource.h" #include "rt_math.h" - +#pragma GCC diagnostic warning "-Wextra" #define PRINT_HDR_PS_DETECTION 0 using namespace rtengine; @@ -1041,7 +1041,7 @@ failure: } -FramesData::FramesData (const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly, bool loadAll) : +FramesData::FramesData (const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly) : iptc(nullptr), dcrawFrameCount (0) { if (rml && (rml->exifBase >= 0 || rml->ciffBase >= 0)) { diff --git a/rtengine/imagedata.h b/rtengine/imagedata.h index 2da97a5d1..b9f955611 100644 --- a/rtengine/imagedata.h +++ b/rtengine/imagedata.h @@ -95,7 +95,7 @@ private: unsigned int dcrawFrameCount; public: - FramesData (const Glib::ustring& fname, std::unique_ptr rml = nullptr, bool firstFrameOnly = false, bool loadAll = false); + FramesData (const Glib::ustring& fname, std::unique_ptr rml = nullptr, bool firstFrameOnly = false); ~FramesData (); void setDCRawFrameCount (unsigned int frameCount); From ba63016e9844cbc894f5f13c3c3e159605eb89ea Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 23 Oct 2017 21:16:07 +0200 Subject: [PATCH 26/52] Make rtengine/impulse_denoise a compilation unit --- rtengine/CMakeLists.txt | 1 + rtengine/improcfun.cc | 1 - rtengine/{impulse_denoise.h => impulse_denoise.cc} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename rtengine/{impulse_denoise.h => impulse_denoise.cc} (100%) diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 424b3352e..0b003909f 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -72,6 +72,7 @@ set(RTENGINESOURCEFILES imageio.cc improccoordinator.cc improcfun.cc + impulse_denoise.cc init.cc iplab2rgb.cc ipresize.cc diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 8236aaf37..c22d7b509 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -28,7 +28,6 @@ #include "curves.h" #include "mytime.h" #include "iccstore.h" -#include "impulse_denoise.h" #include "imagesource.h" #include "rtthumbnail.h" #include "utils.h" diff --git a/rtengine/impulse_denoise.h b/rtengine/impulse_denoise.cc similarity index 100% rename from rtengine/impulse_denoise.h rename to rtengine/impulse_denoise.cc From 87c109a10e3e0461b1874bb29bff79256cd994ed Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 12:56:23 +0200 Subject: [PATCH 27/52] Make compilation unit rtengine/cJSON.c -Wextra clean, #4155 --- rtengine/cJSON.c | 1 + 1 file changed, 1 insertion(+) diff --git a/rtengine/cJSON.c b/rtengine/cJSON.c index 31c43dd2e..cf5ebef56 100644 --- a/rtengine/cJSON.c +++ b/rtengine/cJSON.c @@ -31,6 +31,7 @@ #include #include #include "cJSON.h" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" static const char *ep; From beb6347a4878bac653431b954f68de32840f5a44 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 13:11:15 +0200 Subject: [PATCH 28/52] Make compilation unit rtengine/fast_demo.cc -Wextra clean, #4155 --- rtengine/expo_before_b.cc | 2 +- rtengine/fast_demo.cc | 2 +- rtengine/rawimagesource.cc | 2 +- rtengine/rawimagesource.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rtengine/expo_before_b.cc b/rtengine/expo_before_b.cc index 98fed04f7..f94b2c292 100644 --- a/rtengine/expo_before_b.cc +++ b/rtengine/expo_before_b.cc @@ -80,7 +80,7 @@ void RawImageSource::processRawWhitepoint(float expos, float preser, array2DgetSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS) { // Demosaic to allow calculation of luminosity. if(ri->getSensorType() == ST_BAYER) { - fast_demosaic (0, 0, W, H); + fast_demosaic(); } else { fast_xtrans_interpolate(); } diff --git a/rtengine/fast_demo.cc b/rtengine/fast_demo.cc index 12286d9f1..6143d172e 100644 --- a/rtengine/fast_demo.cc +++ b/rtengine/fast_demo.cc @@ -52,7 +52,7 @@ LUTf RawImageSource::initInvGrad() #endif //LUTf RawImageSource::invGrad = RawImageSource::initInvGrad(); -SSEFUNCTION void RawImageSource::fast_demosaic(int winx, int winy, int winw, int winh) +SSEFUNCTION void RawImageSource::fast_demosaic() { double progress = 0.0; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 78fa1f829..5eb7aa7b9 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2046,7 +2046,7 @@ void RawImageSource::demosaic(const RAWParams &raw) } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::lmmse]) { lmmse_interpolate_omp(W, H, rawData, red, green, blue, raw.bayersensor.lmmse_iterations); } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::fast] ) { - fast_demosaic (0, 0, W, H); + fast_demosaic(); } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::mono] ) { nodemosaic(true); } else { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 9da7d44f4..d2ce77fed 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -245,7 +245,7 @@ protected: void igv_interpolate(int winw, int winh); void lmmse_interpolate_omp(int winw, int winh, array2D &rawData, array2D &red, array2D &green, array2D &blue, int iterations); void amaze_demosaic_RT(int winx, int winy, int winw, int winh, array2D &rawData, array2D &red, array2D &green, array2D &blue);//Emil's code for AMaZE - void fast_demosaic(int winx, int winy, int winw, int winh );//Emil's code for fast demosaicing + void fast_demosaic();//Emil's code for fast demosaicing void dcb_demosaic(int iterations, bool dcb_enhance); void ahd_demosaic(); void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0); From 7542cfc45682a5223d1ff0dabdfb2b0a92a4666e Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 13:26:14 +0200 Subject: [PATCH 29/52] Make compilation unit rtengine/icons.cc -Wextra clean, #4155 --- rtengine/icons.cc | 3 ++- rtengine/icons.h | 2 +- rtgui/main-cli.cc | 2 +- rtgui/main.cc | 2 +- rtgui/preferences.cc | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rtengine/icons.cc b/rtengine/icons.cc index 2c5075007..b4477f09c 100644 --- a/rtengine/icons.cc +++ b/rtengine/icons.cc @@ -21,6 +21,7 @@ #include "icons.h" #include +#pragma GCC diagnostic warning "-Wextra" namespace rtengine { @@ -86,7 +87,7 @@ Glib::ustring findIconAbsolutePath (const Glib::ustring& iconName) return Glib::ustring(); } -void setPaths (const Options& options) +void setPaths () { // TODO: Forcing the Dark theme, so reading the icon set files is useless for now... diff --git a/rtengine/icons.h b/rtengine/icons.h index 9f6654a9c..a890555b2 100644 --- a/rtengine/icons.h +++ b/rtengine/icons.h @@ -26,7 +26,7 @@ namespace rtengine { Glib::ustring findIconAbsolutePath (const Glib::ustring& iconName); -void setPaths (const Options& options); +void setPaths (); } diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 1cb63ef6d..76ed84489 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -163,7 +163,7 @@ int main (int argc, char **argv) return -2; } - rtengine::setPaths (options); + rtengine::setPaths(); TIFFSetWarningHandler (nullptr); // avoid annoying message boxes diff --git a/rtgui/main.cc b/rtgui/main.cc index 6dd9ccf7f..bd8f381c4 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -257,7 +257,7 @@ RTWindow *create_rt_window() Glib::RefPtr defaultIconTheme = Gtk::IconTheme::get_default(); defaultIconTheme->append_search_path (icon_path); - rtengine::setPaths (options); + rtengine::setPaths(); MyExpander::init(); // has to stay AFTER rtengine::setPaths // ------- loading theme files diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 974ba5450..8fd33673f 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -2147,7 +2147,7 @@ void Preferences::cancelPressed () { // set the initial theme back if (themeFNames.at (theme->get_active_row_number ()).longFName != options.theme) { - rtengine::setPaths (options); + rtengine::setPaths(); RTImage::updateImages(); switchThemeTo (options.theme); } @@ -2205,7 +2205,7 @@ void Preferences::themeChanged () { moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName; - rtengine::setPaths (moptions); + rtengine::setPaths(); RTImage::updateImages(); switchThemeTo (moptions.theme); } From fb02e6883e80aff04f83854e2808b94c7f7b19c5 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 13:27:02 +0200 Subject: [PATCH 30/52] remove #pragma... --- rtengine/icons.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/rtengine/icons.cc b/rtengine/icons.cc index b4477f09c..aa3b67cbf 100644 --- a/rtengine/icons.cc +++ b/rtengine/icons.cc @@ -21,7 +21,6 @@ #include "icons.h" #include -#pragma GCC diagnostic warning "-Wextra" namespace rtengine { From 7b3c36c7c6152598b8f7d03a456e83aca43fe261 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 16:50:03 +0200 Subject: [PATCH 31/52] reduce scope of warning silencing --- rtengine/cJSON.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rtengine/cJSON.c b/rtengine/cJSON.c index cf5ebef56..bf46c98c4 100644 --- a/rtengine/cJSON.c +++ b/rtengine/cJSON.c @@ -31,7 +31,6 @@ #include #include #include "cJSON.h" -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" static const char *ep; @@ -192,12 +191,21 @@ static const char *parse_string(cJSON *item,const char *str) len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len; +#ifdef __GNUC__ // silence warning +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif + switch (len) { case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; case 1: *--ptr2 =(uc | firstByteMark[len]); } + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif ptr2+=len; break; default: *ptr2++=*ptr; break; From 9a17962f4b72eb5f88bff3551a0a845b51dcf9d5 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 16:53:17 +0200 Subject: [PATCH 32/52] Make compilation unit rtengine/iptransform.cc -Wextra clean, #4155 --- rtengine/iptransform.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index f227af2ed..43a110a5f 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -788,6 +788,10 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag bool enableLCPDist = false; bool enableCA = false; +#ifdef __GNUC__ // silence warning +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif switch (mode) { case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE: { enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); @@ -809,6 +813,9 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag break; } } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif if (!enableCA) { chDist[0] = 0.0; From 2e645debb440199fda1269c9922e9de4c9c8f839 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 17:09:46 +0200 Subject: [PATCH 33/52] =?UTF-8?q?Fix=20two=20issues=20detected=20by=20Fl?= =?UTF-8?q?=C3=B6ssie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtengine/imagedata.cc | 3 +-- rtengine/labimage.cc | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index d90053476..47688fca6 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -857,8 +857,7 @@ bool FramesData::hasIPTC (unsigned int frame) const tm FramesData::getDateTime (unsigned int frame) const { if (frames.empty() || frame >= frames.size() ) { - tm emptytm = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - return emptytm; + return {}; } else { return frames.at(frame)->getDateTime (); } diff --git a/rtengine/labimage.cc b/rtengine/labimage.cc index 4cd5ce31a..bcadda0ed 100644 --- a/rtengine/labimage.cc +++ b/rtengine/labimage.cc @@ -17,9 +17,11 @@ * along with RawTherapee. If not, see . */ -#include "labimage.h" +#include #include +#include "labimage.h" + namespace rtengine { From d1ba2091a0f548a1bb0cc4dbef5df5ee8559b1de Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 17:22:42 +0200 Subject: [PATCH 34/52] Make compilation unit rtengine/myfile.cc -Wextra clean, #4155 --- rtengine/myfile.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rtengine/myfile.cc b/rtengine/myfile.cc index 903fd8354..920421188 100644 --- a/rtengine/myfile.cc +++ b/rtengine/myfile.cc @@ -33,6 +33,11 @@ #define PROT_READ 1 #define MAP_FAILED (void *)-1 +#ifdef __GNUC__ // silence warning +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + void* mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { HANDLE handle = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL, PAGE_WRITECOPY, 0, 0, NULL); @@ -51,6 +56,9 @@ int munmap(void *start, size_t length) UnmapViewOfFile(start); return 0; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #else // WIN32 From f3690d00ac52490495efde79a11a96852d8fded2 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 17:36:43 +0200 Subject: [PATCH 35/52] Make compilation unit rtengine/rtlensfun.cc -Wextra clean, #4155 --- rtengine/rtlensfun.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index ed19f44f0..29dfacb17 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -75,11 +75,19 @@ bool LFModifier::isCACorrectionAvailable() const return false; } +#ifdef __GNUC__ // silence warning, can be removed when function is implemented +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif void LFModifier::correctCA(double &x, double &y, int channel) const { } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + void LFModifier::processVignetteLine(int width, int y, float *line) const { From 2b2bbd69f4a7fbfd5279897e62af737958b35519 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 25 Oct 2017 19:07:38 +0200 Subject: [PATCH 36/52] Make compilation unit rtengine/iplab2rgb.cc -Wextra clean, #4155 --- rtengine/improcfun.h | 2 +- rtengine/iplab2rgb.cc | 2 +- rtengine/simpleprocess.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 37bbf61cf..5746ce285 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -348,7 +348,7 @@ public: void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float skinprot, float chrom); Image8* lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm); - Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga = nullptr); + Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, GammaValues *ga = nullptr); // CieImage *ciec; bool transCoord (int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr); diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index dac24411d..abef0a878 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -262,7 +262,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, * If a custom gamma profile can be created, divide by 327.68, convert to xyz and apply the custom gamma transform * otherwise divide by 327.68, convert to xyz and apply the sRGB transform, before converting with gamma2curve */ -Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga) +Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, GammaValues *ga) { if (cx < 0) { diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 30d7a8ec7..056575be5 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1232,7 +1232,7 @@ private: GammaValues ga; // if(params.blackwhite.enabled) params.toneCurve.hrenabled=false; - readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, bwonly, &ga); + readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, &ga); customGamma = true; //or selected Free gamma @@ -1246,7 +1246,7 @@ private: // if Default gamma mode: we use the profile selected in the "Output profile" combobox; // gamma come from the selected profile, otherwise it comes from "Free gamma" tool - readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, bwonly); + readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm); if (settings->verbose) { printf ("Output profile_: \"%s\"\n", params.icm.output.c_str()); From a29287eaa08268b46e728d5e6d79bf81952ee6fe Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Thu, 26 Oct 2017 22:51:03 +0200 Subject: [PATCH 37/52] started working on enabling full support for CA correction with a lens profile --- rtengine/improcfun.h | 3 +- rtengine/iptransform.cc | 128 +++++++++++++++++++++++++--------------- 2 files changed, 82 insertions(+), 49 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 6c5ded3b6..3b835a124 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -57,7 +57,8 @@ class ImProcFunctions enum TransformMode { TRANSFORM_PREVIEW, TRANSFORM_HIGH_QUALITY, - TRANSFORM_HIGH_QUALITY_FULLIMAGE + TRANSFORM_HIGH_QUALITY_FULLIMAGE, + TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA }; void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); void transformGeneral(TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index d06872a64..5a50fafe9 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -315,7 +315,7 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, pLCPMap.reset( new LCPMapper (pLCPProf, focalLen, focalLen35mm, focusDist, fNumber, false, - params->lensProf.useDist, + false, oW, oH, params->coarse, rawRotationDeg ) ); @@ -326,12 +326,26 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, transformLuminanceOnly (original, transformed, cx, cy, oW, oH, fW, fH); } else { TransformMode mode; + std::unique_ptr tmpimg; if (!needsCA() && scale != 1) { mode = TRANSFORM_PREVIEW; } else if (!fullImage) { mode = TRANSFORM_HIGH_QUALITY; } else { mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE; + // agriggio: CA correction via the lens profile has to be + // performed before all the other transformations (except for the + // coarse rotation/flipping). In order to not change the code too + // much, I simply introduced a new mode + // TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA, which applies *only* + // profile-based CA correction. So, the correction in this case + // occurs in two steps, using an intermediate temporary + // image. There's room for optimization of course... + if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) { + tmpimg.reset(new Imagefloat(transformed->getWidth(), transformed->getHeight())); + transformGeneral(TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA, original, tmpimg.get(), cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); + original = tmpimg.get(); + } } transformGeneral(mode, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); } @@ -725,21 +739,59 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap) { + // set up stuff, depending on the mode we are + bool enableLCPDist = pLCPMap && params->lensProf.useDist; + bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); + bool enableCA = needsCA(); + bool enableGradient = needsGradient(); + bool enablePCVignetting = needsPCVignetting(); + bool enableVignetting = needsVignetting(); + bool enablePerspective = needsPerspective(); + bool enableDistortion = needsDistortion(); + + switch (mode) { + case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA: + enableLCPDist = false; + enablePerspective = false; + enableDistortion = false; + enableGradient = false; + enableVignetting = false; + enablePCVignetting = false; + enableCA = false; + break; + case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE: + enableLCPCA = false; + break; + case ImProcFunctions::TRANSFORM_HIGH_QUALITY: + if (enableLCPDist) { + enableLCPCA = false; + } + break; + case ImProcFunctions::TRANSFORM_PREVIEW: + enableLCPCA = false; + enableCA = false; + break; + } + + bool useCA = enableCA || enableLCPCA; + double w2 = (double) oW / 2.0 - 0.5; double h2 = (double) oH / 2.0 - 0.5; double vig_w2, vig_h2, maxRadius, v, b, mul; - calcVignettingParams (oW, oH, params->vignetting, vig_w2, vig_h2, maxRadius, v, b, mul); + if (enableVignetting) { + calcVignettingParams (oW, oH, params->vignetting, vig_w2, vig_h2, maxRadius, v, b, mul); + } struct grad_params gp; - if (needsGradient()) { + if (enableGradient) { calcGradientParams (oW, oH, params->gradient, gp); } struct pcv_params pcv; - if (needsPCVignetting()) { + if (enablePCVignetting) { calcPCVignetteParams (fW, fH, oW, oH, params->pcvignette, params->crop, pcv); } @@ -755,12 +807,11 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag // auxiliary variables for c/a correction double chDist[3]; - chDist[0] = params->cacorrection.red; + chDist[0] = enableCA ? params->cacorrection.red : 0.0; chDist[1] = 0.0; - chDist[2] = params->cacorrection.blue; + chDist[2] = enableCA ? params->cacorrection.blue : 0.0; // auxiliary variables for distortion correction - bool needsDist = needsDistortion(); // for performance double distAmount = params->distortion.amount; // auxiliary variables for rotation @@ -781,39 +832,20 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag oH * tan (hpalpha) * sqrt (SQR (4 * maxRadius) + SQR (oH * tan (hpalpha)))) / (SQR (maxRadius) * 8))); double hpcospt = (hpdeg >= 0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); - double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; - - // smaller crop images are a problem, so only when processing fully - bool enableLCPCA = false; - bool enableLCPDist = false; - bool enableCA = false; - - switch (mode) { - case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE: { - enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); - } - //no break on purpose - - case ImProcFunctions::TRANSFORM_HIGH_QUALITY: { - enableLCPDist = pLCPMap && params->lensProf.useDist; - enableCA = enableLCPCA || needsCA(); - } - //no break on purpose - - default: - case ImProcFunctions::TRANSFORM_PREVIEW: { - enableLCPDist = pLCPMap && params->lensProf.useDist; - break; - } + //double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; + double ascale = 1.0; + if (mode != ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA && + params->commonTrans.autofill) { + ascale = getTransformAutoFill (oW, oH, pLCPMap); } - if (enableLCPCA) { - enableLCPDist = false; - } + // if (enableLCPCA) { + // enableLCPDist = false; + // } - if (!enableCA) { - chDist[0] = 0.0; - } + // if (!enableCA) { + // chDist[0] = 0.0; + // } // main cycle bool darkening = (params->vignetting.amount <= 0.0); @@ -835,12 +867,12 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag double vig_x_d = 0., vig_y_d = 0.; - if (needsVignetting()) { + if (enableVignetting) { vig_x_d = ascale * (x + cx - vig_w2); // centering x coord & scale vig_y_d = ascale * (y + cy - vig_h2); // centering y coord & scale } - if (needsPerspective()) { + if (enablePerspective) { // horizontal perspective transformation y_d *= maxRadius / (maxRadius + x_d * hptanpt); x_d *= maxRadius * hpcospt / (maxRadius + x_d * hptanpt); @@ -857,20 +889,20 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag // distortion correction double s = 1; - if (needsDist) { + if (enableDistortion) { double r = sqrt (Dxc * Dxc + Dyc * Dyc) / maxRadius; // sqrt is slow s = 1.0 - distAmount + distAmount * r ; } double r2 = 0.; - if (needsVignetting()) { + if (enableVignetting) { double vig_Dx = vig_x_d * cost - vig_y_d * sint; double vig_Dy = vig_x_d * sint + vig_y_d * cost; r2 = sqrt (vig_Dx * vig_Dx + vig_Dy * vig_Dy); } - for (int c = 0; c < (enableCA ? 3 : 1); c++) { + for (int c = 0; c < (useCA ? 3 : 1); c++) { double Dx = Dxc * (s + chDist[c]); double Dy = Dyc * (s + chDist[c]); @@ -897,7 +929,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag // multiplier for vignetting correction double vignmul = 1.0; - if (needsVignetting()) { + if (enableVignetting) { if (darkening) { vignmul /= std::max (v + mul * tanh (b * (maxRadius - s * r2) / maxRadius), 0.001); } else { @@ -905,17 +937,17 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag } } - if (needsGradient()) { + if (enableGradient) { vignmul *= calcGradientFactor (gp, cx + x, cy + y); } - if (needsPCVignetting()) { + if (enablePCVignetting) { vignmul *= calcPCVignetteFactor (pcv, cx + x, cy + y); } if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) { // all interpolation pixels inside image - if (enableCA) { + if (useCA) { interpolateTransformChannelsCubic (chOrig[c], xc - 1, yc - 1, Dx, Dy, & (chTrans[c][y][x]), vignmul); } else if (mode == ImProcFunctions::TRANSFORM_PREVIEW) { transformed->r (y, x) = vignmul * (original->r (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->r (yc, xc + 1) * Dx * (1.0 - Dy) + original->r (yc + 1, xc) * (1.0 - Dx) * Dy + original->r (yc + 1, xc + 1) * Dx * Dy); @@ -931,7 +963,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag int x1 = LIM (xc, 0, original->getWidth() - 1); int x2 = LIM (xc + 1, 0, original->getWidth() - 1); - if (enableCA) { + if (useCA) { chTrans[c][y][x] = vignmul * (chOrig[c][y1][x1] * (1.0 - Dx) * (1.0 - Dy) + chOrig[c][y1][x2] * Dx * (1.0 - Dy) + chOrig[c][y2][x1] * (1.0 - Dx) * Dy + chOrig[c][y2][x2] * Dx * Dy); } else { transformed->r (y, x) = vignmul * (original->r (y1, x1) * (1.0 - Dx) * (1.0 - Dy) + original->r (y1, x2) * Dx * (1.0 - Dy) + original->r (y2, x1) * (1.0 - Dx) * Dy + original->r (y2, x2) * Dx * Dy); @@ -940,7 +972,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag } } } else { - if (enableCA) { + if (useCA) { // not valid (source pixel x,y not inside source image, etc.) chTrans[c][y][x] = 0; } else { From 830fd6fdbb3933a616cb0e2125f8055a3d2bbe4c Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Thu, 26 Oct 2017 23:55:52 +0200 Subject: [PATCH 38/52] added support for CA correction via lensfun Performance could be improved (see the comments marked "agriggio" in iptransform.cc and rtlensfun.cc) --- rtengine/rtlensfun.cc | 35 +++++++++++++++++++++++++++++++++-- rtengine/rtlensfun.h | 1 + rtgui/lensprofile.cc | 10 ++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index ed19f44f0..99315c20d 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -72,12 +72,29 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double bool LFModifier::isCACorrectionAvailable() const { - return false; + return (flags_ & LF_MODIFY_TCA); } void LFModifier::correctCA(double &x, double &y, int channel) const { + assert(channel >= 0 && channel <= 2); + + // agriggio: RT currently applies the CA correction per channel, whereas + // lensfun applies it to all the three channels simultaneously. This means + // we do the work 3 times, because each time we discard 2 of the 3 + // channels. We could consider caching the info to speed this up + + float pos[6]; + if (swap_xy_) { + std::swap(x, y); + } + data_->ApplySubpixelDistortion(x, y, 1, 1, pos); + x = pos[2*channel]; + y = pos[2*channel+1]; + if (swap_xy_) { + std::swap(x, y); + } } @@ -109,6 +126,11 @@ Glib::ustring LFModifier::getDisplayString() const ret += "vignetting"; sep = ", "; } + if (flags_ & LF_MODIFY_TCA) { + ret += sep; + ret += "CA"; + sep = ", "; + } if (flags_ & LF_MODIFY_SCALE) { ret += sep; ret += "autoscaling"; @@ -245,6 +267,15 @@ bool LFLens::hasDistortionCorrection() const } } +bool LFLens::hasCACorrection() const +{ + if (data_) { + return data_->CalibTCA; + } else { + return false; + } +} + //----------------------------------------------------------------------------- // LFDatabase @@ -428,7 +459,7 @@ std::unique_ptr LFDatabase::getModifier(const LFCamera &camera, cons if (data_) { if (camera && lens) { lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height); - int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE; + int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE | LF_MODIFY_TCA; if (aperture > 0) { flags |= LF_MODIFY_VIGNETTING; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 207e4e86e..ddc6d885a 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -90,6 +90,7 @@ public: float getCropFactor() const; bool hasVignettingCorrection() const; bool hasDistortionCorrection() const; + bool hasCACorrection() const; private: friend class LFDatabase; diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc index 6415c1fce..d158f44f4 100644 --- a/rtgui/lensprofile.cc +++ b/rtgui/lensprofile.cc @@ -254,6 +254,16 @@ void LensProfilePanel::updateLensfunWarning() } ckbUseVign->set_sensitive(l.hasVignettingCorrection()); ckbUseDist->set_sensitive(l.hasDistortionCorrection()); + ckbUseCA->set_sensitive(l.hasCACorrection()); + if (!isRaw || !l.hasVignettingCorrection()) { + ckbUseVign->set_active(false); + } + if (!l.hasDistortionCorrection()) { + ckbUseDist->set_active(false); + } + if (!l.hasCACorrection()) { + ckbUseCA->set_active(false); + } } } From 5a05b04e0973feb28a5fac9e3abcd5b883fa7608 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sun, 29 Oct 2017 21:41:19 +0100 Subject: [PATCH 39/52] profile-based CA correction applied during 1:1 preview --- rtengine/improcfun.h | 2 +- rtengine/iptransform.cc | 24 +++++++++++++----------- rtengine/lcp.cc | 8 +++++++- rtengine/lcp.h | 4 ++-- rtengine/rtlensfun.cc | 6 +++++- rtengine/rtlensfun.h | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 3b835a124..699193632 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -58,7 +58,7 @@ class ImProcFunctions TRANSFORM_PREVIEW, TRANSFORM_HIGH_QUALITY, TRANSFORM_HIGH_QUALITY_FULLIMAGE, - TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA + TRANSFORM_HIGH_QUALITY_CA }; void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); void transformGeneral(TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 5a50fafe9..87ab7b922 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -329,21 +329,23 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, std::unique_ptr tmpimg; if (!needsCA() && scale != 1) { mode = TRANSFORM_PREVIEW; - } else if (!fullImage) { - mode = TRANSFORM_HIGH_QUALITY; } else { - mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE; + if (!fullImage) { + mode = TRANSFORM_HIGH_QUALITY; + } else { + mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE; + } // agriggio: CA correction via the lens profile has to be // performed before all the other transformations (except for the // coarse rotation/flipping). In order to not change the code too // much, I simply introduced a new mode - // TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA, which applies *only* + // TRANSFORM_HIGH_QUALITY_CA, which applies *only* // profile-based CA correction. So, the correction in this case // occurs in two steps, using an intermediate temporary // image. There's room for optimization of course... if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) { - tmpimg.reset(new Imagefloat(transformed->getWidth(), transformed->getHeight())); - transformGeneral(TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA, original, tmpimg.get(), cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); + tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight())); + transformGeneral(TRANSFORM_HIGH_QUALITY_CA, original, tmpimg.get(), 0, 0, 0, 0, fW, fH, fW, fH, pLCPMap.get()); original = tmpimg.get(); } } @@ -750,7 +752,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag bool enableDistortion = needsDistortion(); switch (mode) { - case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA: + case ImProcFunctions::TRANSFORM_HIGH_QUALITY_CA: enableLCPDist = false; enablePerspective = false; enableDistortion = false; @@ -763,9 +765,9 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag enableLCPCA = false; break; case ImProcFunctions::TRANSFORM_HIGH_QUALITY: - if (enableLCPDist) { + // if (enableLCPDist) { enableLCPCA = false; - } + // } break; case ImProcFunctions::TRANSFORM_PREVIEW: enableLCPCA = false; @@ -834,7 +836,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag //double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; double ascale = 1.0; - if (mode != ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE_CA && + if (mode != ImProcFunctions::TRANSFORM_HIGH_QUALITY_CA && params->commonTrans.autofill) { ascale = getTransformAutoFill (oW, oH, pLCPMap); } @@ -912,7 +914,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag // LCP CA if (enableLCPCA) { - pLCPMap->correctCA (Dx, Dy, c); + pLCPMap->correctCA (Dx, Dy, cx, cy, c); } // Extract integer and fractions of source screen coordinates diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 3824d2b2f..44a470e17 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -1077,12 +1077,15 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy y -= cy * scale; } -void rtengine::LCPMapper::correctCA(double& x, double& y, int channel) const +void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int channel) const { if (!enableCA) { return; } + x += cx; + y += cy; + double xgreen, ygreen; // First calc the green channel like normal distortion @@ -1123,6 +1126,9 @@ void rtengine::LCPMapper::correctCA(double& x, double& y, int channel) const x = (chrom[channel].scale_factor * ( xd * commonSum + xfac * rsqr )) * chrom[channel].fx + chrom[channel].x0; y = (chrom[channel].scale_factor * ( yd * commonSum + yfac * rsqr )) * chrom[channel].fy + chrom[channel].y0; } + + x -= cx; + x -= cy; } SSEFUNCTION void rtengine::LCPMapper::processVignetteLine(int width, int y, float* line) const diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 17eb892c8..b50fd335e 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -164,7 +164,7 @@ public: virtual ~LensCorrection() {} virtual void correctDistortion(double &x, double &y, int cx, int cy, double scale) const = 0; virtual bool isCACorrectionAvailable() const = 0; - virtual void correctCA(double &x, double &y, int channel) const = 0; + virtual void correctCA(double &x, double &y, int cx, int cy, int channel) const = 0; virtual void processVignetteLine(int width, int y, float *line) const = 0; virtual void processVignetteLine3Channels(int width, int y, float *line) const = 0; }; @@ -192,7 +192,7 @@ public: void correctDistortion(double &x, double &y, int cx, int cy, double scale) const; // MUST be the first stage bool isCACorrectionAvailable() const; - void correctCA(double& x, double& y, int channel) const; + void correctCA(double& x, double& y, int cx, int cy, int channel) const; void processVignetteLine(int width, int y, float* line) const; void processVignetteLine3Channels(int width, int y, float* line) const; diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 99315c20d..cc4f6f53c 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -76,7 +76,7 @@ bool LFModifier::isCACorrectionAvailable() const } -void LFModifier::correctCA(double &x, double &y, int channel) const +void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const { assert(channel >= 0 && channel <= 2); @@ -84,6 +84,8 @@ void LFModifier::correctCA(double &x, double &y, int channel) const // lensfun applies it to all the three channels simultaneously. This means // we do the work 3 times, because each time we discard 2 of the 3 // channels. We could consider caching the info to speed this up + x += cx; + y += cy; float pos[6]; if (swap_xy_) { @@ -95,6 +97,8 @@ void LFModifier::correctCA(double &x, double &y, int channel) const if (swap_xy_) { std::swap(x, y); } + x -= cx; + y -= cy; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index ddc6d885a..60ef461c7 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -44,7 +44,7 @@ public: void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override; bool isCACorrectionAvailable() const override; - void correctCA(double &x, double &y, int channel) const override; + void correctCA(double &x, double &y, int cx, int cy, int channel) const override; void processVignetteLine(int width, int y, float *line) const override; void processVignetteLine3Channels(int width, int y, float *line) const override; From dfff9812bfb9851f2fe80409e8f9ba6569c0784b Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 31 Oct 2017 00:51:01 +0100 Subject: [PATCH 40/52] improved profile-based CA correction in preview also cleaned up the code --- rtengine/improcfun.h | 9 +-- rtengine/iptransform.cc | 135 ++++++++++++++++++++++------------------ 2 files changed, 75 insertions(+), 69 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 699193632..7f9acc9e7 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -54,14 +54,9 @@ class ImProcFunctions void calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); - enum TransformMode { - TRANSFORM_PREVIEW, - TRANSFORM_HIGH_QUALITY, - TRANSFORM_HIGH_QUALITY_FULLIMAGE, - TRANSFORM_HIGH_QUALITY_CA - }; void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); - void transformGeneral(TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); + void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); + void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, int oW, int oH, const LensCorrection *pLCPMap); void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, int W, int H, const SharpeningParams &sharpenParam); void sharpenHaloCtrl (LabImage* lab, float** blurmap, float** base, int W, int H, SharpeningParams &sharpenParam); diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 87ab7b922..9871c7a57 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -325,16 +325,12 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, if (! (needsCA() || needsDistortion() || needsRotation() || needsPerspective() || needsLCP() || needsLensfun()) && (needsVignetting() || needsPCVignetting() || needsGradient())) { transformLuminanceOnly (original, transformed, cx, cy, oW, oH, fW, fH); } else { - TransformMode mode; + bool highQuality; std::unique_ptr tmpimg; if (!needsCA() && scale != 1) { - mode = TRANSFORM_PREVIEW; + highQuality = false; } else { - if (!fullImage) { - mode = TRANSFORM_HIGH_QUALITY; - } else { - mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE; - } + highQuality = true; // agriggio: CA correction via the lens profile has to be // performed before all the other transformations (except for the // coarse rotation/flipping). In order to not change the code too @@ -345,14 +341,15 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, // image. There's room for optimization of course... if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) { tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight())); - transformGeneral(TRANSFORM_HIGH_QUALITY_CA, original, tmpimg.get(), 0, 0, 0, 0, fW, fH, fW, fH, pLCPMap.get()); + transformLCPCAOnly(original, tmpimg.get(), cx, cy, oW, oH, pLCPMap.get()); original = tmpimg.get(); } } - transformGeneral(mode, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); + transformGeneral(highQuality, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); } } + // helper function void ImProcFunctions::calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul) { @@ -739,44 +736,17 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* } -void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap) +void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap) { // set up stuff, depending on the mode we are bool enableLCPDist = pLCPMap && params->lensProf.useDist; - bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); - bool enableCA = needsCA(); + bool enableCA = highQuality && needsCA(); bool enableGradient = needsGradient(); bool enablePCVignetting = needsPCVignetting(); bool enableVignetting = needsVignetting(); bool enablePerspective = needsPerspective(); bool enableDistortion = needsDistortion(); - switch (mode) { - case ImProcFunctions::TRANSFORM_HIGH_QUALITY_CA: - enableLCPDist = false; - enablePerspective = false; - enableDistortion = false; - enableGradient = false; - enableVignetting = false; - enablePCVignetting = false; - enableCA = false; - break; - case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE: - enableLCPCA = false; - break; - case ImProcFunctions::TRANSFORM_HIGH_QUALITY: - // if (enableLCPDist) { - enableLCPCA = false; - // } - break; - case ImProcFunctions::TRANSFORM_PREVIEW: - enableLCPCA = false; - enableCA = false; - break; - } - - bool useCA = enableCA || enableLCPCA; - double w2 = (double) oW / 2.0 - 0.5; double h2 = (double) oH / 2.0 - 0.5; @@ -834,20 +804,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag oH * tan (hpalpha) * sqrt (SQR (4 * maxRadius) + SQR (oH * tan (hpalpha)))) / (SQR (maxRadius) * 8))); double hpcospt = (hpdeg >= 0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); - //double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; - double ascale = 1.0; - if (mode != ImProcFunctions::TRANSFORM_HIGH_QUALITY_CA && - params->commonTrans.autofill) { - ascale = getTransformAutoFill (oW, oH, pLCPMap); - } - - // if (enableLCPCA) { - // enableLCPDist = false; - // } - - // if (!enableCA) { - // chDist[0] = 0.0; - // } + double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; // main cycle bool darkening = (params->vignetting.amount <= 0.0); @@ -904,7 +861,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag r2 = sqrt (vig_Dx * vig_Dx + vig_Dy * vig_Dy); } - for (int c = 0; c < (useCA ? 3 : 1); c++) { + for (int c = 0; c < (enableCA ? 3 : 1); c++) { double Dx = Dxc * (s + chDist[c]); double Dy = Dyc * (s + chDist[c]); @@ -912,11 +869,6 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag Dx += w2; Dy += h2; - // LCP CA - if (enableLCPCA) { - pLCPMap->correctCA (Dx, Dy, cx, cy, c); - } - // Extract integer and fractions of source screen coordinates int xc = (int)Dx; Dx -= (double)xc; @@ -949,9 +901,9 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) { // all interpolation pixels inside image - if (useCA) { + if (enableCA) { interpolateTransformChannelsCubic (chOrig[c], xc - 1, yc - 1, Dx, Dy, & (chTrans[c][y][x]), vignmul); - } else if (mode == ImProcFunctions::TRANSFORM_PREVIEW) { + } else if (!highQuality) { transformed->r (y, x) = vignmul * (original->r (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->r (yc, xc + 1) * Dx * (1.0 - Dy) + original->r (yc + 1, xc) * (1.0 - Dx) * Dy + original->r (yc + 1, xc + 1) * Dx * Dy); transformed->g (y, x) = vignmul * (original->g (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->g (yc, xc + 1) * Dx * (1.0 - Dy) + original->g (yc + 1, xc) * (1.0 - Dx) * Dy + original->g (yc + 1, xc + 1) * Dx * Dy); transformed->b (y, x) = vignmul * (original->b (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->b (yc, xc + 1) * Dx * (1.0 - Dy) + original->b (yc + 1, xc) * (1.0 - Dx) * Dy + original->b (yc + 1, xc + 1) * Dx * Dy); @@ -965,7 +917,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag int x1 = LIM (xc, 0, original->getWidth() - 1); int x2 = LIM (xc + 1, 0, original->getWidth() - 1); - if (useCA) { + if (enableCA) { chTrans[c][y][x] = vignmul * (chOrig[c][y1][x1] * (1.0 - Dx) * (1.0 - Dy) + chOrig[c][y1][x2] * Dx * (1.0 - Dy) + chOrig[c][y2][x1] * (1.0 - Dx) * Dy + chOrig[c][y2][x2] * Dx * Dy); } else { transformed->r (y, x) = vignmul * (original->r (y1, x1) * (1.0 - Dx) * (1.0 - Dy) + original->r (y1, x2) * Dx * (1.0 - Dy) + original->r (y2, x1) * (1.0 - Dx) * Dy + original->r (y2, x2) * Dx * Dy); @@ -974,7 +926,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag } } } else { - if (useCA) { + if (enableCA) { // not valid (source pixel x,y not inside source image, etc.) chTrans[c][y][x] = 0; } else { @@ -989,6 +941,65 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag } +void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, int oW, int oH, const LensCorrection *pLCPMap) +{ + assert(pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()); + + double w2 = (double) oW / 2.0 - 0.5; + double h2 = (double) oH / 2.0 - 0.5; + + float** chOrig[3]; + chOrig[0] = original->r.ptrs; + chOrig[1] = original->g.ptrs; + chOrig[2] = original->b.ptrs; + + float** chTrans[3]; + chTrans[0] = transformed->r.ptrs; + chTrans[1] = transformed->g.ptrs; + chTrans[2] = transformed->b.ptrs; + + #pragma omp parallel for if (multiThread) + + for (int y = 0; y < transformed->getHeight(); y++) { + for (int x = 0; x < transformed->getWidth(); x++) { + for (int c = 0; c < 3; c++) { + double Dx = x; + double Dy = y; + + pLCPMap->correctCA(Dx, Dy, cx, cy, c); + + // Extract integer and fractions of coordinates + int xc = (int)Dx; + Dx -= (double)xc; + int yc = (int)Dy; + Dy -= (double)yc; + + // Convert only valid pixels + if (yc >= 0 && yc < original->getHeight() && xc >= 0 && xc < original->getWidth()) { + + // multiplier for vignetting correction + if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) { + // all interpolation pixels inside image + interpolateTransformChannelsCubic (chOrig[c], xc - 1, yc - 1, Dx, Dy, & (chTrans[c][y][x]), 1.0); + } else { + // edge pixels + int y1 = LIM (yc, 0, original->getHeight() - 1); + int y2 = LIM (yc + 1, 0, original->getHeight() - 1); + int x1 = LIM (xc, 0, original->getWidth() - 1); + int x2 = LIM (xc + 1, 0, original->getWidth() - 1); + + chTrans[c][y][x] = (chOrig[c][y1][x1] * (1.0 - Dx) * (1.0 - Dy) + chOrig[c][y1][x2] * Dx * (1.0 - Dy) + chOrig[c][y2][x1] * (1.0 - Dx) * Dy + chOrig[c][y2][x2] * Dx * Dy); + } + } else { + // not valid (source pixel x,y not inside source image, etc.) + chTrans[c][y][x] = 0; + } + } + } + } +} + + double ImProcFunctions::getTransformAutoFill (int oW, int oH, const LensCorrection *pLCPMap) { if (!needsCA() && !needsDistortion() && !needsRotation() && !needsPerspective() && (!params->lensProf.useDist || pLCPMap == nullptr)) { From 770479f643e0dde2629d97917025bd17f0df4b02 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 31 Oct 2017 09:38:27 +0100 Subject: [PATCH 41/52] removed unused parameters from transformLCPCAOnly --- rtengine/improcfun.h | 2 +- rtengine/iptransform.cc | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 7f9acc9e7..136e9491b 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -56,7 +56,7 @@ class ImProcFunctions void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); - void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, int oW, int oH, const LensCorrection *pLCPMap); + void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap); void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, int W, int H, const SharpeningParams &sharpenParam); void sharpenHaloCtrl (LabImage* lab, float** blurmap, float** base, int W, int H, SharpeningParams &sharpenParam); diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 9871c7a57..cb14727a9 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -341,7 +341,7 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, // image. There's room for optimization of course... if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) { tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight())); - transformLCPCAOnly(original, tmpimg.get(), cx, cy, oW, oH, pLCPMap.get()); + transformLCPCAOnly(original, tmpimg.get(), cx, cy, pLCPMap.get()); original = tmpimg.get(); } } @@ -941,13 +941,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I } -void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, int oW, int oH, const LensCorrection *pLCPMap) +void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap) { assert(pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()); - double w2 = (double) oW / 2.0 - 0.5; - double h2 = (double) oH / 2.0 - 0.5; - float** chOrig[3]; chOrig[0] = original->r.ptrs; chOrig[1] = original->g.ptrs; From 2006a1755b49799f919a2242fbb46dcd5ee0b035 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 31 Oct 2017 10:49:40 +0100 Subject: [PATCH 42/52] fixed regression in ImProcFunctions::transformGeneral introduced by recent refactorings --- rtengine/iptransform.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index cb14727a9..4d71b236b 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -751,9 +751,7 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I double h2 = (double) oH / 2.0 - 0.5; double vig_w2, vig_h2, maxRadius, v, b, mul; - if (enableVignetting) { - calcVignettingParams (oW, oH, params->vignetting, vig_w2, vig_h2, maxRadius, v, b, mul); - } + calcVignettingParams (oW, oH, params->vignetting, vig_w2, vig_h2, maxRadius, v, b, mul); struct grad_params gp; From d6a26f68122e86b99fbe9e34917a67ed8ecb12c2 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 1 Nov 2017 20:19:38 +0100 Subject: [PATCH 43/52] Fix a bug in Hasselblad decoder I introduced with my changes for phase one decoder --- rtengine/dcraw.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index bf46d0c91..9da4b151d 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -2272,6 +2272,7 @@ void CLASS hasselblad_load_raw() FORC3 back[c] = back[4] + c*raw_width; cblack[6] >>= sh = tiff_samples > 1; shot = LIM(shot_select, 1, tiff_samples) - 1; + ph1_bithuff_t ph1_bithuff(this, ifp, order); for (row=0; row < raw_height; row++) { FORC4 back[(c+3) & 3] = back[c]; for (col=0; col < raw_width; col+=2) { From 8fa477793defe51ff892a957c8d5740d9c60194c Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 11 Nov 2017 18:31:37 +0100 Subject: [PATCH 44/52] Speedup for initial thumb creation from raw files, fixes #4109 --- rtengine/rtthumbnail.cc | 242 ++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 143 deletions(-) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 8398ea2d2..5572984f9 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -38,7 +38,6 @@ #include "improccoordinator.h" #include - namespace { @@ -659,69 +658,18 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati tpp->scale = (double) height / (rotate_90 ? w : h); } - // generate histogram for auto exposure + // generate histogram for auto exposure, also calculate autoWB tpp->aeHistCompression = 3; - tpp->aeHistogram (65536 >> tpp->aeHistCompression); + tpp->aeHistogram(65536 >> tpp->aeHistCompression); tpp->aeHistogram.clear(); - int radd = 4; - int gadd = 4; - int badd = 4; - if (!filter) { - radd = gadd = badd = 1; - } + const unsigned int add = filter ? 1 : 4 / ri->get_colors(); - for (int i = 8; i < height - 8; i++) { - int start, end; - - if (ri->get_FujiWidth() != 0) { - int fw = ri->get_FujiWidth(); - start = ABS (fw - i) + 8; - end = min (height + width - fw - i, fw + i) - 8; - } else { - start = 8; - end = width - 8; - } - - if (ri->get_colors() == 1) { - for (int j = start; j < end; j++) { - tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += radd; - tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += gadd; - tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += badd; - } - } else if (ri->getSensorType() == ST_BAYER) { - for (int j = start; j < end; j++) - if (FISGREEN (filter, i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbGreen * image[i * width + j][1])) >> tpp->aeHistCompression] += gadd; - } else if (FISRED (filter, i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbRed * image[i * width + j][0])) >> tpp->aeHistCompression] += radd; - } else if (FISBLUE (filter, i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbBlue * image[i * width + j][2])) >> tpp->aeHistCompression] += badd; - } - } else if (ri->getSensorType() == ST_FUJI_XTRANS) { - for (int j = start; j < end; j++) - if (ri->ISXTRANSGREEN (i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbGreen * image[i * width + j][1])) >> tpp->aeHistCompression] += gadd; - } else if (ri->ISXTRANSRED (i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbRed * image[i * width + j][0])) >> tpp->aeHistCompression] += radd; - } else if (ri->ISXTRANSBLUE (i, j)) { - tpp->aeHistogram[ ((int) (tpp->camwbBlue * image[i * width + j][2])) >> tpp->aeHistCompression] += badd; - } - } else { /* if(ri->getSensorType()==ST_FOVEON) */ - for (int j = start; j < end; j++) { - tpp->aeHistogram[ ((int) (image[i * width + j][0] * 2.f)) >> tpp->aeHistCompression] += radd; - tpp->aeHistogram[ ((int) (image[i * width + j][1])) >> tpp->aeHistCompression] += gadd; - tpp->aeHistogram[ ((int) (image[i * width + j][2] * 0.5f)) >> tpp->aeHistCompression] += badd; - } - } - } - - // generate autoWB - double avg_r = 0; - double avg_g = 0; - double avg_b = 0; - - unsigned int rn = 0, gn = 0, bn = 0; + double pixSum[3] = {0.0}; + unsigned int n[3] = {0}; + const double compression = pow(2.0, tpp->aeHistCompression); + const double camWb[3] = {tpp->camwbRed / compression, tpp->camwbGreen / compression, tpp->camwbBlue / compression}; + const double clipval = 64000.0 / tpp->defGain; for (int i = 32; i < height - 32; i++) { int start, end; @@ -735,110 +683,118 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati end = width - 32; } - if (ri->getSensorType() == ST_BAYER) { + if (ri->get_colors() == 1) { for (int j = start; j < end; j++) { - if (!filter) { - double d = tpp->defGain * image[i * width + j][0]; - - if (d > 64000.) { - continue; - } - - avg_g += d; - avg_r += d; - avg_b += d; - rn++; - gn++; - bn++; - } else if (FISGREEN (filter, i, j)) { - double d = tpp->defGain * image[i * width + j][1]; - - if (d > 64000.) { - continue; - } - - avg_g += d; - gn++; - } else if (FISRED (filter, i, j)) { - double d = tpp->defGain * image[i * width + j][0]; - - if (d > 64000.) { - continue; - } - - avg_r += d; - rn++; - } else if (FISBLUE (filter, i, j)) { - double d = tpp->defGain * image[i * width + j][2]; - - if (d > 64000.) { - continue; - } - - avg_b += d; - bn++; + tpp->aeHistogram[image[i * width + j][0] >> tpp->aeHistCompression]++; + } + } else if (ri->getSensorType() == ST_BAYER) { + int c0 = ri->FC(i, start); + int c1 = ri->FC(i, start + 1); + int j = start; + int n0 = 0; + int n1 = 0; + double pixSum0 = 0.0; + double pixSum1 = 0.0; + for (; j < end - 1; j+=2) { + double v0 = image[i * width + j][c0]; + tpp->aeHistogram[(int)(camWb[c0] * v0)]++; + if (v0 <= clipval) { + pixSum0 += v0; + n0++; + } + double v1 = image[i * width + j + 1][c1]; + tpp->aeHistogram[(int)(camWb[c1] * v1)]++; + if (v1 <= clipval) { + pixSum1 += v1; + n1++; } } + if (j < end) { + double v0 = image[i * width + j][c0]; + tpp->aeHistogram[(int)(camWb[c0] * v0)]++; + if (v0 <= clipval) { + pixSum0 += v0; + n0++; + } + } + n[c0] += n0; + n[c1] += n1; + pixSum[c0] += pixSum0; + pixSum[c1] += pixSum1; } else if (ri->getSensorType() == ST_FUJI_XTRANS) { - for (int j = start; j < end; j++) { + int c[6]; + for(int cc = 0; cc < 6; ++cc) { + c[cc] = ri->XTRANSFC(i, start + cc); + } + int j = start; + for (; j < end - 5; j += 6) { + for(int cc = 0; cc < 6; ++cc) { + double d = image[i * width + j + cc][c[cc]]; + tpp->aeHistogram[(int)(camWb[c[cc]] * d)]++; + if (d <= clipval) { + pixSum[c[cc]] += d; + n[c[cc]]++; + } + } + } + for (; j < end; j++) { if (ri->ISXTRANSGREEN (i, j)) { - double d = tpp->defGain * image[i * width + j][1]; - - if (d > 64000.) { - continue; + double d = image[i * width + j][1]; + tpp->aeHistogram[(int)(camWb[1] * d)]++; + if (d <= clipval) { + pixSum[1] += d; + n[1]++; } - - avg_g += d; - gn++; } else if (ri->ISXTRANSRED (i, j)) { - double d = tpp->defGain * image[i * width + j][0]; - - if (d > 64000.) { - continue; + double d = image[i * width + j][0]; + tpp->aeHistogram[(int)(camWb[0] * d)]++; + if (d <= clipval) { + pixSum[0] += d; + n[0]++; } - - avg_r += d; - rn++; } else if (ri->ISXTRANSBLUE (i, j)) { - double d = tpp->defGain * image[i * width + j][2]; - - if (d > 64000.) { - continue; + double d = image[i * width + j][2]; + tpp->aeHistogram[(int)(camWb[2] * d)]++; + if (d <= clipval) { + pixSum[2] += d; + n[2]++; } - - avg_b += d; - bn++; } } } else { /* if(ri->getSensorType()==ST_FOVEON) */ for (int j = start; j < end; j++) { - double d = tpp->defGain * image[i * width + j][0]; - - if (d <= 64000.) { - avg_r += d; - rn++; + double r = image[i * width + j][0]; + if (r <= clipval) { + pixSum[0] += r; + n[0]++; } - - d = tpp->defGain * image[i * width + j][1]; - - if (d <= 64000.) { - avg_g += d; - gn++; + double g = image[i * width + j][1]; + if (g <= clipval) { + pixSum[1] += g; + n[1]++; } - - d = tpp->defGain * image[i * width + j][2]; - - if (d <= 64000.) { - avg_b += d; - bn++; + tpp->aeHistogram[((int)g) >> tpp->aeHistCompression] += add; + double b = image[i * width + j][2]; + if (b <= clipval) { + pixSum[2] += b; + n[2]++; } + tpp->aeHistogram[((int) (b * 0.5f)) >> tpp->aeHistCompression] += add; } } } - double reds = avg_r / std::max(rn, 1u) * tpp->camwbRed; - double greens = avg_g / std::max(gn, 1u) * tpp->camwbGreen; - double blues = avg_b / std::max(bn, 1u) * tpp->camwbBlue; + if (ri->get_colors() == 1) { + pixSum[0] = pixSum[1] = pixSum[2] = 1.; + n[0] = n[1] = n[2] = 1; + } + pixSum[0] *= tpp->defGain; + pixSum[1] *= tpp->defGain; + pixSum[2] *= tpp->defGain; + + double reds = pixSum[0] / std::max(n[0], 1u) * tpp->camwbRed; + double greens = pixSum[1] / std::max(n[1], 1u) * tpp->camwbGreen; + double blues = pixSum[2] / std::max(n[2], 1u) * tpp->camwbBlue; tpp->redAWBMul = ri->get_rgb_cam (0, 0) * reds + ri->get_rgb_cam (0, 1) * greens + ri->get_rgb_cam (0, 2) * blues; tpp->greenAWBMul = ri->get_rgb_cam (1, 0) * reds + ri->get_rgb_cam (1, 1) * greens + ri->get_rgb_cam (1, 2) * blues; From 4754d5a6cc7721a3e0c882dfc631801cb0129aab Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 11 Nov 2017 18:48:44 +0100 Subject: [PATCH 45/52] Speedup for loading of Phase One files, fixes #4050 --- rtengine/dcraw.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index ddbe6103b..b5d769fde 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -25,8 +25,6 @@ /*RT*/#include "jpeg.h" #include "opthelper.h" -#define BENCHMARK -#include "StopWatch.h" /* dcraw.c -- Dave Coffin's raw photo decoder @@ -1501,7 +1499,6 @@ void CLASS phase_one_flat_field (int is_float, int nc) void CLASS phase_one_correct() { -BENCHFUN unsigned entries, tag, data, save, col, row, type; int len, i, j, k, cip, val[4], dev[4], sum, max; int head[9], diff, mindiff=INT_MAX, off_412=0; @@ -1784,7 +1781,6 @@ inline unsigned CLASS ph1_bithuff_t::operator() () #ifndef MYFILE_MMAP void CLASS phase_one_load_raw_c() { - BENCHFUN static const int length[] = { 8,7,6,9,11,10,5,12,14,13 }; int *offset, len[2], pred[2], row, col, i, j; ushort *pixel; @@ -1839,7 +1835,6 @@ void CLASS phase_one_load_raw_c() #else void CLASS phase_one_load_raw_c() { -BENCHFUN static const int length[] = { 8,7,6,9,11,10,5,12,14,13 }; int *offset = (int *)calloc(raw_width * 2 + raw_height * 4, 2); From bd9592cb1f200f9463fb56261e85b6baf6783662 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 12 Nov 2017 13:42:25 +0100 Subject: [PATCH 46/52] Fix two warnings when using gcc < 7 --- rtengine/cJSON.c | 4 ++-- rtengine/iptransform.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rtengine/cJSON.c b/rtengine/cJSON.c index bf46c98c4..8e9cdcccf 100644 --- a/rtengine/cJSON.c +++ b/rtengine/cJSON.c @@ -191,7 +191,7 @@ static const char *parse_string(cJSON *item,const char *str) len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len; -#ifdef __GNUC__ // silence warning +#if defined( __GNUC__ ) && __GNUC__ >= 7// silence warning #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif @@ -203,7 +203,7 @@ static const char *parse_string(cJSON *item,const char *str) case 1: *--ptr2 =(uc | firstByteMark[len]); } -#ifdef __GNUC__ +#if defined( __GNUC__ ) && __GNUC__ >= 7 #pragma GCC diagnostic pop #endif ptr2+=len; diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index bfdf484d3..d73dc8ac0 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -788,7 +788,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag bool enableLCPDist = false; bool enableCA = false; -#ifdef __GNUC__ // silence warning +#if defined( __GNUC__ ) && __GNUC__ >= 7// silence warning #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif @@ -810,7 +810,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag break; } } -#ifdef __GNUC__ +#if defined( __GNUC__ ) && __GNUC__ >= 7 #pragma GCC diagnostic pop #endif From 46e4dece2e4dab0dbb82c906501a3919e44f02ed Mon Sep 17 00:00:00 2001 From: Benitoite Date: Mon, 13 Nov 2017 09:51:21 -0800 Subject: [PATCH 47/52] Enable detection of non-Apple clang Clang features Ups macOS cmake requirement to 3.3 and sets policy 25, to differentiate compiler features between AppleClang and plain ole' clang. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 490cfa7ca..32921dcae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ if(WIN32) cmake_minimum_required(VERSION 2.8.4) +elseif(APPLE) + cmake_minimum_required(VERSION 3.3) + CMAKE_POLICY(SET CMP0025 NEW) else() cmake_minimum_required(VERSION 2.6) endif() From 7507b74d6fe0668343732b6c468b5fd5b1ba5a6d Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 13 Nov 2017 18:56:18 +0100 Subject: [PATCH 48/52] explicitly set -ftree-vectorize to get auto vectorizations even for builds using -o2 instead of -o3 (some distros do that for whatever reason) --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 490cfa7ca..dffefbc25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,8 @@ set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") set(PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") # Set special compilation flags for rtengine which get added to CMAKE_CXX_FLAGS: -set(RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") +# Some Linux distros build with -O2 instead of -O3. We explicitly enable auto vectorization by using -ftree-vectorize +set(RTENGINE_CXX_FLAGS "-ftree-vectorize" CACHE STRING "Special compilation flags for RTEngine") # Loads the ProcessorTargets list: include(ProcessorTargets.cmake) From 0efee599a1e7f4b4bc04017594aec5324fb68a2f Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 13 Nov 2017 18:57:44 +0100 Subject: [PATCH 49/52] Fix bugs I introduced with the speedup for Phase One decoder --- rtengine/dcraw.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index b5d769fde..8da29761f 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1906,9 +1906,6 @@ void CLASS phase_one_load_raw_c() } else { pixel = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1)); } - if (UNLIKELY(pixel >> 16)) { - derror(); - } if (ph1.format == 5 && pixel < 256) { pixel = curve[pixel]; } @@ -3261,6 +3258,7 @@ void CLASS samsung_load_raw() int row, col, c, i, dir, op[4], len[4]; order = 0x4949; + ph1_bithuff_t ph1_bithuff(this, ifp, order); for (row=0; row < raw_height; row++) { fseek (ifp, strip_offset+row*4, SEEK_SET); fseek (ifp, data_offset+get4(), SEEK_SET); @@ -3318,6 +3316,7 @@ void CLASS samsung3_load_raw() fseek (ifp, 9, SEEK_CUR); opt = fgetc(ifp); init = (get2(),get2()); + ph1_bithuff_t ph1_bithuff(this, ifp, order); for (row=0; row < raw_height; row++) { fseek (ifp, (data_offset-ftell(ifp)) & 15, SEEK_CUR); hb_bits(-1); From 99f41baf4f0d6ae8adb59b44b7efa8200d486c1d Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 14 Nov 2017 22:52:57 +0100 Subject: [PATCH 50/52] disable LCP-based CA correction, as it is currently broken --- rtengine/lcp.cc | 2 +- rtgui/lensprofile.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 44a470e17..cd338258f 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -1023,7 +1023,7 @@ rtengine::LCPMapper::LCPMapper( bool rtengine::LCPMapper::isCACorrectionAvailable() const { - return enableCA; + return false /*enableCA*/; // agriggio TODO -- this is currently broken } void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy, double scale) const diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc index d158f44f4..d96d65cb6 100644 --- a/rtgui/lensprofile.cc +++ b/rtgui/lensprofile.cc @@ -192,7 +192,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa ckbUseDist->set_active (pp->lensProf.useDist); ckbUseVign->set_active (pp->lensProf.useVign && isRaw); - ckbUseCA->set_active (pp->lensProf.useCA && isRaw); + ckbUseCA->set_active(pp->lensProf.useCA && isRaw && ckbUseCA->get_sensitive()); const LFDatabase *db = LFDatabase::getInstance(); LFCamera c; @@ -380,7 +380,8 @@ void LensProfilePanel::updateDisabled(bool enable) { ckbUseDist->set_sensitive(enable); ckbUseVign->set_sensitive(enable && isRaw); - ckbUseCA->set_sensitive(enable && allowFocusDep); + // agriggio TODO -- CA correction via LCP is currently broken + ckbUseCA->set_sensitive(false);//enable && allowFocusDep); } void LensProfilePanel::setBatchMode(bool yes) From 18f775d805ec349a1a95ff397b0baf50bcadef05 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 15 Nov 2017 00:54:05 +0100 Subject: [PATCH 51/52] review of ph1_bithuff --- rtengine/dcraw.cc | 3 ++- rtengine/dcraw.h | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 8da29761f..e0ef59c9b 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1802,6 +1802,7 @@ void CLASS phase_one_load_raw_c() read_shorts ((ushort *) rblack[0], raw_width*2); for (i=0; i < 256; i++) curve[i] = i*i / 3.969 + 0.5; + ph1_bithuff_t ph1_bithuff(this, ifp, order); for (row=0; row < raw_height; row++) { fseek (ifp, data_offset + offset[row], SEEK_SET); ph1_init(); @@ -2258,13 +2259,13 @@ void CLASS hasselblad_load_raw() if (!ljpeg_start (&jh, 0)) return; order = 0x4949; + ph1_bithuff_t ph1_bithuff(this, ifp, order); hb_bits(-1); back[4] = (int *) calloc (raw_width, 3*sizeof **back); merror (back[4], "hasselblad_load_raw()"); FORC3 back[c] = back[4] + c*raw_width; cblack[6] >>= sh = tiff_samples > 1; shot = LIM(shot_select, 1, tiff_samples) - 1; - ph1_bithuff_t ph1_bithuff(this, ifp, order); for (row=0; row < raw_height; row++) { FORC4 back[(c+3) & 3] = back[c]; for (col=0; col < raw_width; col+=2) { diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index f30c0c6f1..0a3316d63 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -59,7 +59,6 @@ public: ,RT_blacklevel_from_constant(0) ,RT_matrix_from_constant(0) ,getbithuff(this,ifp,zero_after_ff) - ,ph1_bithuff(this,ifp,order) ,pana_bits(ifp,load_flags) { memset(&hbd, 0, sizeof(hbd)); @@ -316,7 +315,7 @@ void parse_qt (int end); // ph1_bithuff(int nbits, ushort *huff); class ph1_bithuff_t { public: - ph1_bithuff_t(DCraw *p,IMFILE *i,short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){} + ph1_bithuff_t(DCraw *p, IMFILE *i, short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){} unsigned operator()(int nbits, ushort *huff); unsigned operator()(int nbits); unsigned operator()(); @@ -355,7 +354,6 @@ private: UINT64 bitbuf; int vbits; }; -ph1_bithuff_t ph1_bithuff; void phase_one_load_raw_c(); void hasselblad_correct(); From 76ac9b02880765dfc7b21d98265923706f3a4de4 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 15 Nov 2017 14:56:57 +0100 Subject: [PATCH 52/52] =?UTF-8?q?Fix=20for=20ph1=5Fbithuff=5Ft,=20thanks?= =?UTF-8?q?=20to=20Fl=C3=B6ssie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtengine/dcraw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index 0a3316d63..2c47ee7e5 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -350,7 +350,7 @@ private: DCraw *parent; short ℴ - IMFILE *&ifp; + IMFILE* const ifp; UINT64 bitbuf; int vbits; };