From 54bcc00087c9ea60907651fdfc5a108ac3e19229 Mon Sep 17 00:00:00 2001 From: Ilia Popov Date: Wed, 21 Jul 2010 21:48:40 +0200 Subject: [PATCH] Fixed compilation warning on hlmultipliers.cc: moved inline functions from rawimagesource.cc to rawimagesource_i.h --- rtengine/hlmultipliers.cc | 1 + rtengine/rawimagesource.cc | 310 +-------------------------------- rtengine/rawimagesource_i.h | 338 ++++++++++++++++++++++++++++++++++++ 3 files changed, 341 insertions(+), 308 deletions(-) create mode 100644 rtengine/rawimagesource_i.h diff --git a/rtengine/hlmultipliers.cc b/rtengine/hlmultipliers.cc index 0ebf5bbd7..1cd1451e6 100644 --- a/rtengine/hlmultipliers.cc +++ b/rtengine/hlmultipliers.cc @@ -19,6 +19,7 @@ #include #include #include +#include #define MAXVAL 0xffff #define CLIP(a) ((a)>0?((a). */ #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include + #ifdef _OPENMP #include #endif @@ -39,15 +41,11 @@ extern const Settings* settings; #undef MAX #undef MIN #undef DIST -#undef MAXVAL -#undef CLIP #define ABS(a) ((a)<0?-(a):(a)) #define MAX(a,b) ((a)<(b)?(b):(a)) #define MIN(a,b) ((a)>(b)?(b):(a)) #define DIST(a,b) (ABS(a-b)) -#define MAXVAL 0xffff -#define CLIP(a) ((a)>0?((a) -void RawImageSource::convert_to_cielab_row (unsigned short* ar, unsigned short* ag, unsigned short* ab, short* oL, short* oa, short* ob) { - - for (int j=0; jthreshold) - oL[j] = 300.0*cache[(int)y]; - else - oL[j] = 300.0 * 903.3 * y / CMAXVAL; - - oa[j] = 32.0 * 500.0 * ((x>threshold ? cache[(int)x] : 7.787*x/CMAXVAL+16.0/116.0) - (y>threshold ? cache[(int)y] : 7.787*y/CMAXVAL+16.0/116.0)); - ob[j] = 32.0 * 200.0 * ((y>threshold ? cache[(int)y] : 7.787*y/CMAXVAL+16.0/116.0) - (z>threshold ? cache[(int)z] : 7.787*z/CMAXVAL+16.0/116.0)); - } -} - -void RawImageSource::interpolate_row_g (unsigned short* agh, unsigned short* agv, int i) { - - for (int j=0; jdata[i][j]; - agv[j] = ri->data[i][j]; - } - else { - int gh=0; - int gv=0; - if (j>1 && jdata[i][j-2] + 2*ri->data[i][j-1] + 2*ri->data[i][j] + 2*ri->data[i][j+1] -ri->data[i][j+2]) / 4; - int maxgh = MAX(ri->data[i][j-1], ri->data[i][j+1]); - int mingh = MIN(ri->data[i][j-1], ri->data[i][j+1]); - if (gh>maxgh) - gh = maxgh; - else if (ghdata[i][1]; - else if (j==1) - gh = (ri->data[i][0] + ri->data[i][2]) / 2; - else if (j==W-1) - gh = ri->data[i][W-2]; - else if (j==W-2) - gh = (ri->data[i][W-1] + ri->data[i][W-3]) / 2; - - if (i>1 && idata[i-2][j] + 2*ri->data[i-1][j] + 2*ri->data[i][j] + 2*ri->data[i+1][j] - ri->data[i+2][j]) / 4; - int maxgv = MAX(ri->data[i-1][j], ri->data[i+1][j]); - int mingv = MIN(ri->data[i-1][j], ri->data[i+1][j]); - if (gv>maxgv) - gv = maxgv; - else if (gvdata[1][j]; - else if (i==1) - gv = (ri->data[0][j] + ri->data[2][j]) / 2; - else if (i==H-1) - gv = ri->data[H-2][j]; - else if (i==H-2) - gv = (ri->data[H-1][j] + ri->data[H-3][j]) / 2; - - agh[j] = CLIP(gh); - agv[j] = CLIP(gv); - } - } -} - -void RawImageSource::interpolate_row_rb (unsigned short* ar, unsigned short* ab, unsigned short* pg, unsigned short* cg, unsigned short* ng, int i) { - if (ISRED(ri,i,0) || ISRED(ri,i,1)) { - // RGRGR or GRGRGR line - for (int j=0; jdata[i][j]; - // blue: cross interpolation - int b = 0; - int n = 0; - if (i>0 && j>0) { - b += ri->data[i-1][j-1] - pg[j-1]; - n++; - } - if (i>0 && jdata[i-1][j+1] - pg[j+1]; - n++; - } - if (i0) { - b += ri->data[i+1][j-1] - ng[j-1]; - n++; - } - if (idata[i+1][j+1] - ng[j+1]; - n++; - } - b = cg[j] + b / n; - ab[j] = CLIP(b); - } - else { - // linear R-G interp. horizontally - int r; - if (j==0) - r = cg[0] + ri->data[i][1] - cg[1]; - else if (j==W-1) - r = cg[W-1] + ri->data[i][W-2] - cg[W-2]; - else - r = cg[j] + (ri->data[i][j-1] - cg[j-1] + ri->data[i][j+1] - cg[j+1]) / 2; - ar[j] = CLIP(r); - // linear B-G interp. vertically - int b; - if (i==0) - b = ng[j] + ri->data[1][j] - cg[j]; - else if (i==H-1) - b = pg[j] + ri->data[H-2][j] - cg[j]; - else - b = cg[j] + (ri->data[i-1][j] - pg[j] + ri->data[i+1][j] - ng[j]) / 2; - ab[j] = CLIP(b); - } - } - } - else { - // BGBGB or GBGBGB line - for (int j=0; jdata[i][j]; - // blue: cross interpolation - int r = 0; - int n = 0; - if (i>0 && j>0) { - r += ri->data[i-1][j-1] - pg[j-1]; - n++; - } - if (i>0 && jdata[i-1][j+1] - pg[j+1]; - n++; - } - if (i0) { - r += ri->data[i+1][j-1] - ng[j-1]; - n++; - } - if (idata[i+1][j+1] - ng[j+1]; - n++; - } - r = cg[j] + r / n; - - ar[j] = CLIP(r); - } - else { - // linear B-G interp. horizontally - int b; - if (j==0) - b = cg[0] + ri->data[i][1] - cg[1]; - else if (j==W-1) - b = cg[W-1] + ri->data[i][W-2] - cg[W-2]; - else - b = cg[j] + (ri->data[i][j-1] - cg[j-1] + ri->data[i][j+1] - cg[j+1]) / 2; - ab[j] = CLIP(b); - // linear R-G interp. vertically - int r; - if (i==0) - r = ng[j] + ri->data[1][j] - cg[j]; - else if (i==H-1) - r = pg[j] + ri->data[H-2][j] - cg[j]; - else - r = cg[j] + (ri->data[i-1][j] - pg[j] + ri->data[i+1][j] - ng[j]) / 2; - ar[j] = CLIP(r); - } - } - } -} - -void RawImageSource::interpolate_row_rb_mul_pp (unsigned short* ar, unsigned short* ab, unsigned short* pg, unsigned short* cg, unsigned short* ng, int i, double r_mul, double g_mul, double b_mul, int x1, int width, int skip) { - - if (ISRED(ri,i,0) || ISRED(ri,i,1)) { - // RGRGR or GRGRGR line - for (int j=x1, jx=0; jxdata[i][j]); - // blue: cross interpolation - int b = 0; - int n = 0; - if (i>0 && j>0) { - b += b_mul*ri->data[i-1][j-1] - g_mul*pg[j-1]; - n++; - } - if (i>0 && jdata[i-1][j+1] - g_mul*pg[j+1]; - n++; - } - if (i0) { - b += b_mul*ri->data[i+1][j-1] - g_mul*ng[j-1]; - n++; - } - if (idata[i+1][j+1] - g_mul*ng[j+1]; - n++; - } - b = g_mul*cg[j] + b / n; - ab[jx] = CLIP(b); - } - else { - // linear R-G interp. horizontally - int r; - if (j==0) - r = g_mul*cg[0] + r_mul*ri->data[i][1] - g_mul*cg[1]; - else if (j==W-1) - r = g_mul*cg[W-1] + r_mul*ri->data[i][W-2] - g_mul*cg[W-2]; - else - r = g_mul*cg[j] + (r_mul*ri->data[i][j-1] - g_mul*cg[j-1] + r_mul*ri->data[i][j+1] - g_mul*cg[j+1]) / 2; - ar[jx] = CLIP(r); - // linear B-G interp. vertically - int b; - if (i==0) - b = g_mul*ng[j] + b_mul*ri->data[1][j] - g_mul*cg[j]; - else if (i==H-1) - b = g_mul*pg[j] + b_mul*ri->data[H-2][j] - g_mul*cg[j]; - else - b = g_mul*cg[j] + (b_mul*ri->data[i-1][j] - g_mul*pg[j] + b_mul*ri->data[i+1][j] - g_mul*ng[j]) / 2; - ab[jx] = CLIP(b); - } - } - } - else { - // BGBGB or GBGBGB line - for (int j=x1, jx=0; jxdata[i][j]); - // blue: cross interpolation - int r = 0; - int n = 0; - if (i>0 && j>0) { - r += r_mul*ri->data[i-1][j-1] - g_mul*pg[j-1]; - n++; - } - if (i>0 && jdata[i-1][j+1] - g_mul*pg[j+1]; - n++; - } - if (i0) { - r += r_mul*ri->data[i+1][j-1] - g_mul*ng[j-1]; - n++; - } - if (idata[i+1][j+1] - g_mul*ng[j+1]; - n++; - } - r = g_mul*cg[j] + r / n; - - ar[jx] = CLIP(r); - } - else { - // linear B-G interp. horizontally - int b; - if (j==0) - b = g_mul*cg[0] + b_mul*ri->data[i][1] - g_mul*cg[1]; - else if (j==W-1) - b = g_mul*cg[W-1] + b_mul*ri->data[i][W-2] - g_mul*cg[W-2]; - else - b = g_mul*cg[j] + (b_mul*ri->data[i][j-1] - g_mul*cg[j-1] + b_mul*ri->data[i][j+1] - g_mul*cg[j+1]) / 2; - ab[jx] = CLIP(b); - // linear R-G interp. vertically - int r; - if (i==0) - r = g_mul*ng[j] + r_mul*ri->data[1][j] - g_mul*cg[j]; - else if (i==H-1) - r = g_mul*pg[j] + r_mul*ri->data[H-2][j] - g_mul*cg[j]; - else - r = g_mul*cg[j] + (r_mul*ri->data[i-1][j] - g_mul*pg[j] + r_mul*ri->data[i+1][j] - g_mul*ng[j]) / 2; - ar[jx] = CLIP(r); - } - } - } -} - - void RawImageSource::colorSpaceConversion (Image16* im, ColorManagementParams cmp, cmsHPROFILE embedded, cmsHPROFILE camprofile, double camMatrix[3][3], double& defgain) { if (cmp.input == "(none)") diff --git a/rtengine/rawimagesource_i.h b/rtengine/rawimagesource_i.h new file mode 100644 index 000000000..c9dcfaf8e --- /dev/null +++ b/rtengine/rawimagesource_i.h @@ -0,0 +1,338 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 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 . + */ + +#ifndef RAWIMAGESOURCE_I_H_INCLUDED +#define RAWIMAGESOURCE_I_H_INCLUDED + +#include + +#include + +#undef MAXVAL +#undef CLIP + +#define MAXVAL 0xffff +#define CLIP(a) ((a)>0?((a)threshold) + oL[j] = 300.0*cache[(int)y]; + else + oL[j] = 300.0 * 903.3 * y / CMAXVAL; + + oa[j] = 32.0 * 500.0 * ((x>threshold ? cache[(int)x] : 7.787*x/CMAXVAL+16.0/116.0) - (y>threshold ? cache[(int)y] : 7.787*y/CMAXVAL+16.0/116.0)); + ob[j] = 32.0 * 200.0 * ((y>threshold ? cache[(int)y] : 7.787*y/CMAXVAL+16.0/116.0) - (z>threshold ? cache[(int)z] : 7.787*z/CMAXVAL+16.0/116.0)); + } +} + +inline void RawImageSource::interpolate_row_g (unsigned short* agh, unsigned short* agv, int i) { + + for (int j=0; jdata[i][j]; + agv[j] = ri->data[i][j]; + } + else { + int gh=0; + int gv=0; + if (j>1 && jdata[i][j-2] + 2*ri->data[i][j-1] + 2*ri->data[i][j] + 2*ri->data[i][j+1] -ri->data[i][j+2]) / 4; + int maxgh = MAX(ri->data[i][j-1], ri->data[i][j+1]); + int mingh = MIN(ri->data[i][j-1], ri->data[i][j+1]); + if (gh>maxgh) + gh = maxgh; + else if (ghdata[i][1]; + else if (j==1) + gh = (ri->data[i][0] + ri->data[i][2]) / 2; + else if (j==W-1) + gh = ri->data[i][W-2]; + else if (j==W-2) + gh = (ri->data[i][W-1] + ri->data[i][W-3]) / 2; + + if (i>1 && idata[i-2][j] + 2*ri->data[i-1][j] + 2*ri->data[i][j] + 2*ri->data[i+1][j] - ri->data[i+2][j]) / 4; + int maxgv = MAX(ri->data[i-1][j], ri->data[i+1][j]); + int mingv = MIN(ri->data[i-1][j], ri->data[i+1][j]); + if (gv>maxgv) + gv = maxgv; + else if (gvdata[1][j]; + else if (i==1) + gv = (ri->data[0][j] + ri->data[2][j]) / 2; + else if (i==H-1) + gv = ri->data[H-2][j]; + else if (i==H-2) + gv = (ri->data[H-1][j] + ri->data[H-3][j]) / 2; + + agh[j] = CLIP(gh); + agv[j] = CLIP(gv); + } + } +} + +inline void RawImageSource::interpolate_row_rb (unsigned short* ar, unsigned short* ab, unsigned short* pg, unsigned short* cg, unsigned short* ng, int i) { + if (ISRED(ri,i,0) || ISRED(ri,i,1)) { + // RGRGR or GRGRGR line + for (int j=0; jdata[i][j]; + // blue: cross interpolation + int b = 0; + int n = 0; + if (i>0 && j>0) { + b += ri->data[i-1][j-1] - pg[j-1]; + n++; + } + if (i>0 && jdata[i-1][j+1] - pg[j+1]; + n++; + } + if (i0) { + b += ri->data[i+1][j-1] - ng[j-1]; + n++; + } + if (idata[i+1][j+1] - ng[j+1]; + n++; + } + b = cg[j] + b / n; + ab[j] = CLIP(b); + } + else { + // linear R-G interp. horizontally + int r; + if (j==0) + r = cg[0] + ri->data[i][1] - cg[1]; + else if (j==W-1) + r = cg[W-1] + ri->data[i][W-2] - cg[W-2]; + else + r = cg[j] + (ri->data[i][j-1] - cg[j-1] + ri->data[i][j+1] - cg[j+1]) / 2; + ar[j] = CLIP(r); + // linear B-G interp. vertically + int b; + if (i==0) + b = ng[j] + ri->data[1][j] - cg[j]; + else if (i==H-1) + b = pg[j] + ri->data[H-2][j] - cg[j]; + else + b = cg[j] + (ri->data[i-1][j] - pg[j] + ri->data[i+1][j] - ng[j]) / 2; + ab[j] = CLIP(b); + } + } + } + else { + // BGBGB or GBGBGB line + for (int j=0; jdata[i][j]; + // blue: cross interpolation + int r = 0; + int n = 0; + if (i>0 && j>0) { + r += ri->data[i-1][j-1] - pg[j-1]; + n++; + } + if (i>0 && jdata[i-1][j+1] - pg[j+1]; + n++; + } + if (i0) { + r += ri->data[i+1][j-1] - ng[j-1]; + n++; + } + if (idata[i+1][j+1] - ng[j+1]; + n++; + } + r = cg[j] + r / n; + + ar[j] = CLIP(r); + } + else { + // linear B-G interp. horizontally + int b; + if (j==0) + b = cg[0] + ri->data[i][1] - cg[1]; + else if (j==W-1) + b = cg[W-1] + ri->data[i][W-2] - cg[W-2]; + else + b = cg[j] + (ri->data[i][j-1] - cg[j-1] + ri->data[i][j+1] - cg[j+1]) / 2; + ab[j] = CLIP(b); + // linear R-G interp. vertically + int r; + if (i==0) + r = ng[j] + ri->data[1][j] - cg[j]; + else if (i==H-1) + r = pg[j] + ri->data[H-2][j] - cg[j]; + else + r = cg[j] + (ri->data[i-1][j] - pg[j] + ri->data[i+1][j] - ng[j]) / 2; + ar[j] = CLIP(r); + } + } + } +} + +inline void RawImageSource::interpolate_row_rb_mul_pp (unsigned short* ar, unsigned short* ab, unsigned short* pg, unsigned short* cg, unsigned short* ng, int i, double r_mul, double g_mul, double b_mul, int x1, int width, int skip) { + + if (ISRED(ri,i,0) || ISRED(ri,i,1)) { + // RGRGR or GRGRGR line + for (int j=x1, jx=0; jxdata[i][j]); + // blue: cross interpolation + int b = 0; + int n = 0; + if (i>0 && j>0) { + b += b_mul*ri->data[i-1][j-1] - g_mul*pg[j-1]; + n++; + } + if (i>0 && jdata[i-1][j+1] - g_mul*pg[j+1]; + n++; + } + if (i0) { + b += b_mul*ri->data[i+1][j-1] - g_mul*ng[j-1]; + n++; + } + if (idata[i+1][j+1] - g_mul*ng[j+1]; + n++; + } + b = g_mul*cg[j] + b / n; + ab[jx] = CLIP(b); + } + else { + // linear R-G interp. horizontally + int r; + if (j==0) + r = g_mul*cg[0] + r_mul*ri->data[i][1] - g_mul*cg[1]; + else if (j==W-1) + r = g_mul*cg[W-1] + r_mul*ri->data[i][W-2] - g_mul*cg[W-2]; + else + r = g_mul*cg[j] + (r_mul*ri->data[i][j-1] - g_mul*cg[j-1] + r_mul*ri->data[i][j+1] - g_mul*cg[j+1]) / 2; + ar[jx] = CLIP(r); + // linear B-G interp. vertically + int b; + if (i==0) + b = g_mul*ng[j] + b_mul*ri->data[1][j] - g_mul*cg[j]; + else if (i==H-1) + b = g_mul*pg[j] + b_mul*ri->data[H-2][j] - g_mul*cg[j]; + else + b = g_mul*cg[j] + (b_mul*ri->data[i-1][j] - g_mul*pg[j] + b_mul*ri->data[i+1][j] - g_mul*ng[j]) / 2; + ab[jx] = CLIP(b); + } + } + } + else { + // BGBGB or GBGBGB line + for (int j=x1, jx=0; jxdata[i][j]); + // blue: cross interpolation + int r = 0; + int n = 0; + if (i>0 && j>0) { + r += r_mul*ri->data[i-1][j-1] - g_mul*pg[j-1]; + n++; + } + if (i>0 && jdata[i-1][j+1] - g_mul*pg[j+1]; + n++; + } + if (i0) { + r += r_mul*ri->data[i+1][j-1] - g_mul*ng[j-1]; + n++; + } + if (idata[i+1][j+1] - g_mul*ng[j+1]; + n++; + } + r = g_mul*cg[j] + r / n; + + ar[jx] = CLIP(r); + } + else { + // linear B-G interp. horizontally + int b; + if (j==0) + b = g_mul*cg[0] + b_mul*ri->data[i][1] - g_mul*cg[1]; + else if (j==W-1) + b = g_mul*cg[W-1] + b_mul*ri->data[i][W-2] - g_mul*cg[W-2]; + else + b = g_mul*cg[j] + (b_mul*ri->data[i][j-1] - g_mul*cg[j-1] + b_mul*ri->data[i][j+1] - g_mul*cg[j+1]) / 2; + ab[jx] = CLIP(b); + // linear R-G interp. vertically + int r; + if (i==0) + r = g_mul*ng[j] + r_mul*ri->data[1][j] - g_mul*cg[j]; + else if (i==H-1) + r = g_mul*pg[j] + r_mul*ri->data[H-2][j] - g_mul*cg[j]; + else + r = g_mul*cg[j] + (r_mul*ri->data[i-1][j] - g_mul*pg[j] + r_mul*ri->data[i+1][j] - g_mul*ng[j]) / 2; + ar[jx] = CLIP(r); + } + } + } +} + +}; + +#endif