diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index db245ad47..1dbe2dcb5 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -38,4 +38,4 @@ target_link_libraries (rtengine rtexif ${EXTRA_LIB} ${GOBJECT_LIBRARIES} ${GTHRE ${GLIB2_LIBRARIES} ${GLIBMM_LIBRARIES} ${LCMS_LIBRARIES} ${EXPAT_LIBRARIES} ${FFTW3F_LIBRARIES} ${IPTCDATA_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES}) -install (FILES ${CAMCONSTSFILE} DESTINATION "${BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install (FILES ${CAMCONSTSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index f5cea4772..5d5d667e0 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -594,6 +594,10 @@ if(params->colorappearance.enabled) { protect_red=30.0f; sk=1; Color::skinred(Jpro, hpro, sres, Cp, dred, protect_red,sk,rstprotection, ko, Cpro); + if(Jpro < 1. && Cpro > 12.) Cpro=12.;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2. && Cpro > 15.) Cpro=15.; + else if(Jpro < 4. && Cpro > 30.) Cpro=30.; + else if(Jpro < 7. && Cpro > 50.) Cpro=50.; hpro=hpro+hue;if( hpro < 0.0 ) hpro += 360.0;//hue } @@ -627,6 +631,7 @@ if(params->colorappearance.enabled) { Jpro=(double)(Jj/327.68f); + if(Jpro < 1.) Jpro=1.; t1L=true; } else if (curveMode==ColorAppearanceParams::TC_MODE_BRIGHT){ @@ -654,7 +659,9 @@ if(params->colorappearance.enabled) { else if (Qq>=0.f) Qq=0.7f*(Qq-Qold)+Qold;// not zero ==>artifacts Qpro=(double)(Qq*(coef)/327.68f); Jpro=100.*(Qpro*Qpro)/((4.0/c)*(4.0/c)*(aw+4.0)*(aw+4.0)); - t1B=true; + t1B=true; + if(Jpro < 1.) Jpro=1.; + } } @@ -685,6 +692,8 @@ if(params->colorappearance.enabled) { else if (Jj>=0.f){if(!t1L)Jj=0.90f*(Jj-Jold)+Jold;else Jj=0.5f*(Jj-Jold)+Jold;}// not zero ==>artifacts Jpro=(double)(Jj/327.68f); + if(Jpro < 1.) Jpro=1.; + } else if (curveMode2==ColorAppearanceParams::TC_MODE_BRIGHT){ // float coef=((aw+4.f)*(4.f/c))/100.f; @@ -722,7 +731,7 @@ if(params->colorappearance.enabled) { Qpro=(double)(Qq/coef); Jpro=100.*(Qpro*Qpro)/((4.0/c)*(4.0/c)*(aw+4.0)*(aw+4.0)); } - + if(Jpro < 1.) Jpro=1.; } } @@ -739,6 +748,11 @@ if(params->colorappearance.enabled) { float sk=1; float ko=1.f/coef; Color::skinred(Jpro, hpro, Cc, Ccold, dred, protect_red,sk,rstprotection,ko, Cpro); + if(Jpro < 1. && Cpro > 12.) Cpro=12.;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2. && Cpro > 15.) Cpro=15.; + else if(Jpro < 4. && Cpro > 30.) Cpro=30.; + else if(Jpro < 7. && Cpro > 50.) Cpro=50.; + // Cpro=Cc/coef; } else if (curveMode3==ColorAppearanceParams::TC_MODE_SATUR){ // @@ -778,6 +792,12 @@ if(params->colorappearance.enabled) { float ko=1.f/coef; Color::skinred(Jpro, hpro, Mm, Mold, dred, protect_red,sk,rstprotection,ko, Mpro); Cpro= Mpro/coe; + if(Jpro < 1. && Mpro > 12.*coe) Mpro=12.*coe;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2. && Mpro > 15.*coe) Mpro=15.*coe; + else if(Jpro < 4. && Mpro > 30.*coe) Mpro=30.*coe; + else if(Jpro < 7. && Mpro > 50.*coe) Mpro=50.*coe; + + c1co=1; } } @@ -1302,6 +1322,8 @@ if(params->colorappearance.enabled) { float nj,dj,nbbj,ncbj,czj,awj,flj; ColorTemp::initcam2float(gamu,yb2, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj,czj, awj, flj); +// printf("fl=%f Coef=%f\n",fl,pow_F(fl,0.25f)); + #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,nj, nbbj, ncbj, flj, czj, dj, awj, n, nbb, ncb, pfl, cz) @@ -1433,6 +1455,10 @@ if(params->colorappearance.enabled) { protect_red=30.0f; sk=1; Color::skinredfloat(Jpro, hpro, sres, Cp, dred, protect_red,sk,rstprotection, ko, Cpro); + if(Jpro < 1.f && Cpro > 12.f) Cpro=12.f;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2.f && Cpro > 15.f) Cpro=15.f; + else if(Jpro < 4.f && Cpro > 30.f) Cpro=30.f; + else if(Jpro < 7.f && Cpro > 50.f) Cpro=50.f; hpro=hpro+hue;if( hpro < 0.0f ) hpro += 360.0f;//hue } @@ -1457,7 +1483,8 @@ if(params->colorappearance.enabled) { } else if(Jj>10.f) Jj=0.8f*(Jj-Jold)+Jold; else if (Jj>=0.f) Jj=0.90f*(Jj-Jold)+Jold;// not zero ==>artifacts - Jpro=(float)(Jj/327.68f); + Jpro=(float)(Jj/327.68f); + if(Jpro<1.f) Jpro=1.f; t1L=true; } else if (curveMode==ColorAppearanceParams::TC_MODE_BRIGHT){ @@ -1485,6 +1512,7 @@ if(params->colorappearance.enabled) { else if (Qq>=0.f) Qq=0.7f*(Qq-Qold)+Qold;// not zero ==>artifacts Qpro=(float)(Qq*(coef)/327.68f); Jpro=100.f*(Qpro*Qpro)/((4.0f/c)*(4.0f/c)*(aw+4.0f)*(aw+4.0f)); + if(Jpro< 1.f) Jpro=1.f; t1B=true; } } @@ -1510,6 +1538,8 @@ if(params->colorappearance.enabled) { else if(Jj>10.f) {if(!t1L)Jj=0.8f*(Jj-Jold)+Jold;else Jj=0.4f*(Jj-Jold)+Jold;} else if (Jj>=0.f){if(!t1L)Jj=0.90f*(Jj-Jold)+Jold;else Jj=0.5f*(Jj-Jold)+Jold;}// not zero ==>artifacts Jpro=(float)(Jj/327.68f); + if(Jpro< 1.f) Jpro=1.f; + } else if (curveMode2==ColorAppearanceParams::TC_MODE_BRIGHT){ // float coef=((aw+4.f)*(4.f/c))/100.f; @@ -1533,6 +1563,7 @@ if(params->colorappearance.enabled) { } else if(Qq>10.f) Qq=0.5f*(Qq-Qold)+Qold; else if (Qq>=0.f) Qq=0.7f*(Qq-Qold)+Qold;// not zero ==>artifacts + Qpro=(float)(Qq*(coef)/327.68f); Jpro=100.f*(Qpro*Qpro)/((4.0f/c)*(4.0f/c)*(aw+4.0f)*(aw+4.0f)); t2B=true; @@ -1547,7 +1578,7 @@ if(params->colorappearance.enabled) { Qpro=(float)(Qq/coef); Jpro=100.f*(Qpro*Qpro)/((4.0f/c)*(4.0f/c)*(aw+4.0f)*(aw+4.0f)); } - + if(Jpro < 1.f) Jpro=1.f; } } @@ -1564,6 +1595,11 @@ if(params->colorappearance.enabled) { float sk=1; float ko=1.f/coef; Color::skinredfloat(Jpro, hpro, Cc, Ccold, dred, protect_red,sk,rstprotection,ko, Cpro); + if(Jpro < 1.f && Cpro > 12.f) Cpro=12.f;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2.f && Cpro > 15.f) Cpro=15.f; + else if(Jpro < 4.f && Cpro > 30.f) Cpro=30.f; + else if(Jpro < 7.f && Cpro > 50.f) Cpro=50.f; + } else if (curveMode3==ColorAppearanceParams::TC_MODE_SATUR){ // float parsat=0.8f;//0.6 @@ -1602,11 +1638,16 @@ if(params->colorappearance.enabled) { float ko=1.f/coef; Color::skinredfloat(Jpro, hpro, Mm, Mold, dred, protect_red,sk,rstprotection,ko, Mpro); Cpro= Mpro/coe; + if(Jpro < 1.f && Mpro > 12.f*coe) Mpro=12.f*coe;//reduce artifacts by "pseudo gamut control CIECAM" + else if(Jpro < 2.f && Mpro > 15.f*coe) Mpro=15.f*coe; + else if(Jpro < 4.f && Mpro > 30.f*coe) Mpro=30.f*coe; + else if(Jpro < 7.f && Mpro > 50.f*coe) Mpro=50.f*coe; + c1co=1; } } //to retrieve the correct values of variables - + if(c1s==1) { Qpro= ( 4.0f / c ) * sqrt( Jpro / 100.0f ) * ( aw + 4.0f ) ;//for saturation curve Cpro=(spro*spro*Qpro)/(10000.0f); @@ -1674,6 +1715,15 @@ if(params->colorappearance.enabled) { float Ll,aa,bb; //convert xyz=>lab Color::XYZ2Lab(x, y, z, Ll, aa, bb); + if(Ll > 70000.f && J < 1.f) { +#pragma omp critical +{ + printf("Why is Ll so big when J is so small?\n"); + printf("J : %f, Ll : %f, xx : %f, yy : %f, zz : %f\n",J,Ll,xx,yy,zz); + printf("J : %f, C : %f, h : %f\n",J,C,h); +} + } + lab->L[i][j]=Ll; lab->a[i][j]=aa; lab->b[i][j]=bb; diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index b2896fe82..ef175a511 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -22,9 +22,8 @@ #include #endif #include "mytime.h" - #include "rt_math.h" - +#include "sleef.c" using namespace std; namespace rtengine { @@ -236,7 +235,7 @@ void ImProcFunctions::calcVignettingParams(int oW, int oH, const VignettingParam maxRadius = sqrt( (double)( oW*oW + oH*oH ) ) / 2.; // vignette variables with applied strength - v = 1.0 - vignetting.strength * vignetting.amount * 3.0 / 400.0; + v = 1.0 + vignetting.strength * fabs(vignetting.amount) * 3.0 / 400.0; b = 1.0 + vignetting.radius * 7.0 / 100.0; mul = (1.0-v) / tanh(b); } @@ -458,18 +457,26 @@ static float calcPCVignetteFactor(const struct pcv_params& pcv, int x, int y) { a = fabs((x-pcv.x1)-pcv.w*0.5); b = fabs((y-pcv.y1)-pcv.h*0.5); } - float angle = atan2f(b, a); + float angle = xatan2f(b, a); float dist = sqrtf(a*a+b*b); float dist_oe, dist_ie; + float2 sincosval; + if(dist==0.0f) { + sincosval.y = 1.0f; // cos + sincosval.x = 0.0f; // sin + } else { + sincosval.y = a / dist; // cos + sincosval.x = b / dist; // sin + } if (pcv.is_super_ellipse_mode) { - float dist_oe1 = pcv.oe1_a*pcv.oe1_b / powf(powf(pcv.oe1_b*cosf(angle), pcv.sep) + powf(pcv.oe1_a*sinf(angle), pcv.sep), 1.0/pcv.sep); - float dist_oe2 = pcv.oe2_a*pcv.oe2_b / powf(powf(pcv.oe2_b*cosf(angle), pcv.sep+2) + powf(pcv.oe2_a*sinf(angle), pcv.sep+2), 1.0/(pcv.sep+2)); + float dist_oe1 = pcv.oe1_a*pcv.oe1_b / pow_F(pow(pcv.oe1_b*sincosval.y, pcv.sep) + pow(pcv.oe1_a*sincosval.x, pcv.sep), 1.0/pcv.sep); + float dist_oe2 = pcv.oe2_a*pcv.oe2_b / pow_F(pow(pcv.oe2_b*sincosval.y, pcv.sep+2) + pow(pcv.oe2_a*sincosval.x, pcv.sep+2), 1.0/(pcv.sep+2)); float dist_ie1 = pcv.ie1_mul * dist_oe1 * (1.0 - pcv.feather); float dist_ie2 = pcv.ie2_mul * dist_oe2 * (1.0 - pcv.feather); dist_oe = dist_oe1 * (1.0 - pcv.sepmix) + dist_oe2 * pcv.sepmix; dist_ie = dist_ie1 * (1.0 - pcv.sepmix) + dist_ie2 * pcv.sepmix; } else { - dist_oe = pcv.oe_a*pcv.oe_b / sqrtf(pcv.oe_b*cosf(angle)*pcv.oe_b*cosf(angle) + pcv.oe_a*sinf(angle)*pcv.oe_a*sinf(angle)); + dist_oe = pcv.oe_a*pcv.oe_b / sqrtf(SQR(pcv.oe_b*sincosval.y) + SQR(pcv.oe_a*sincosval.x)); dist_ie = pcv.ie_mul * dist_oe * (1.0 - pcv.feather); } if (dist <= dist_ie) { @@ -481,9 +488,9 @@ static float calcPCVignetteFactor(const struct pcv_params& pcv, int x, int y) { } else { val = (dist - dist_ie) / (dist_oe - dist_ie); if (pcv.scale < 1.0) { - val = pow(cos(val*M_PI/2), 4); + val = pow(xcosf(val*M_PI/2), 4); } else { - val = 1 - pow(sin(val*M_PI/2), 4); + val = 1 - pow(xsinf(val*M_PI/2), 4); } val = pcv.scale + val * (1.0 - pcv.scale); } @@ -494,7 +501,6 @@ static float calcPCVignetteFactor(const struct pcv_params& pcv, int x, int y) { } void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH) { - const bool applyVignetting = needsVignetting(); const bool applyGradient = needsGradient(); const bool applyPCVignetting = needsPCVignetting(); @@ -514,7 +520,7 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* //fprintf(stderr, "%d %d | %d %d | %d %d | %d %d [%d %d]\n", fW, fH, oW, oH, transformed->width, transformed->height, cx, cy, params->crop.w, params->crop.h); calcPCVignetteParams(fW, fH, oW, oH, params->pcvignette, params->crop, pcv); } - + bool darkening = (params->vignetting.amount <= 0.0); #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { double vig_y_d = (double) (y + cy) - vig_h2 ; @@ -523,7 +529,10 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* double r = sqrt(vig_x_d*vig_x_d + vig_y_d*vig_y_d); double factor = 1.0; if (applyVignetting) { - factor /= std::max(v + mul * tanh (b*(maxRadius-r) / maxRadius), 0.001); + if(darkening) + factor /= std::max(v + mul * tanh (b*(maxRadius-r) / maxRadius), 0.001); + else + factor = v + mul * tanh (b*(maxRadius-r) / maxRadius); } if (applyGradient) { factor *= calcGradientFactor(gp, cx+x, cy+y); @@ -604,6 +613,7 @@ void ImProcFunctions::transformHighQuality (Imagefloat* original, Imagefloat* tr bool enableCA = enableLCPCA || needsCA(); // main cycle + bool darkening = (params->vignetting.amount <= 0.0); #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { for (int x=0; xwidth; x++) { @@ -667,7 +677,10 @@ void ImProcFunctions::transformHighQuality (Imagefloat* original, Imagefloat* tr // multiplier for vignetting correction double vignmul = 1.0; if (needsVignetting()) - vignmul /= std::max(v + mul * tanh (b*(maxRadius-s*r2) / maxRadius), 0.001); + if(darkening) + vignmul /= std::max(v + mul * tanh (b*(maxRadius-s*r2) / maxRadius), 0.001); + else + vignmul *= (v + mul * tanh (b*(maxRadius-s*r2) / maxRadius)); if (needsGradient()) { vignmul *= calcGradientFactor(gp, cx+x, cy+y); } @@ -752,6 +765,8 @@ void ImProcFunctions::transformPreview (Imagefloat* original, Imagefloat* transf double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0; + bool darkening = (params->vignetting.amount <= 0.0); + // main cycle #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { @@ -811,7 +826,10 @@ void ImProcFunctions::transformPreview (Imagefloat* original, Imagefloat* transf // multiplier for vignetting correction double vignmul = 1.0; if (needsVignetting()) - vignmul /= std::max(v + mul * tanh (b*(maxRadius-s*r2) / maxRadius), 0.001); + if(darkening) + vignmul /= std::max(v + mul * tanh (b*(maxRadius-s*r2) / maxRadius), 0.001); + else + vignmul = v + mul * tanh (b*(maxRadius-s*r2) / maxRadius); if (needsGradient()) vignmul *= calcGradientFactor(gp, cx+x, cy+y); if (needsPCVignetting()) diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 19c964ce0..94d897744 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2452,62 +2452,77 @@ void RawImageSource::getAutoExpHistogram (LUTu & histogram, int& histcompr) { // Histogram MUST be 256 in size; gamma is applied, blackpoint and gain also void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw) { - histRedRaw.clear(); histGreenRaw.clear(); histBlueRaw.clear(); - float mult[4] = { 65535.0 / ri->get_white(0), 65535.0 / ri->get_white(1), 65535.0 / ri->get_white(2), 65535.0 / ri->get_white(3) }; -#pragma omp parallel -{ - LUTu tmphistRedRaw( 256 ); - LUTu tmphistGreenRaw( 256 ); - LUTu tmphistBlueRaw( 256 ); - tmphistRedRaw.clear(); - tmphistGreenRaw.clear(); - tmphistBlueRaw.clear(); + histRedRaw.clear(); histGreenRaw.clear(); histBlueRaw.clear(); + const float mult[4] = { 65535.0 / ri->get_white(0), 65535.0 / ri->get_white(1), 65535.0 / ri->get_white(2), 65535.0 / ri->get_white(3) }; +#ifdef _OPENMP + int numThreads; + // reduce the number of threads under certain conditions to avoid overhaed of too many critical regions + numThreads = sqrt((((H-2*border)*(W-2*border))/262144.f)); + numThreads = std::min(std::max(numThreads,1), omp_get_max_threads()); + +#pragma omp parallel num_threads(numThreads) +#endif +{ + // we need one LUT per color and thread, which corresponds to 1 MB per thread + LUTu tmphist[4]; + tmphist[0](65536);tmphist[0].clear(); + tmphist[1](65536);tmphist[1].clear(); + tmphist[2](65536);tmphist[2].clear(); + tmphist[3](65536);tmphist[3].clear(); + +#ifdef _OPENMP #pragma omp for nowait +#endif for (int i=border; iisBayer()) { - for (int j=start; jdata[i][j]-(cblacksom[c4]/*+black_lev[c4]*/)))); - - switch (c) { - case 0: tmphistRedRaw[idx>>8]++; break; - case 1: tmphistGreenRaw[idx>>8]++; break; - case 2: tmphistBlueRaw[idx>>8]++; break; - } + int j; + int c1 = FC(i,start); + c1 = ( c1 == 1 && !(i&1) ) ? 3 : c1; + int c2 = FC(i,start+1); + c2 = ( c2 == 1 && !(i&1) ) ? 3 : c2; + for (j=start; jdata[i][j]]++; + tmphist[c2][ri->data[i][j+1]]++; + } + if(jdata[i][j]]++; } } else { for (int j=start; jdata[i][3*j+c]-cblacksom[c]))); - - switch (c) { - case 0: tmphistRedRaw[idx>>8]++; break; - case 1: tmphistGreenRaw[idx>>8]++; break; - case 2: tmphistBlueRaw[idx>>8]++; break; - } + tmphist[c][ri->data[i][3*j+c]]++; } } } } +#ifdef _OPENMP #pragma omp critical +#endif { - for(int i=0;i<256;i++){ - histRedRaw[i] += tmphistRedRaw[i]; - histGreenRaw[i] += tmphistGreenRaw[i]; - histBlueRaw[i] += tmphistBlueRaw[i]; + for(int i=0;i<65536;i++){ + int idx; + idx = CLIP((int)Color::gamma(mult[0]*(i-(cblacksom[0]/*+black_lev[0]*/)))); + histRedRaw[idx>>8] += tmphist[0][i]; + idx = CLIP((int)Color::gamma(mult[1]*(i-(cblacksom[1]/*+black_lev[1]*/)))); + histGreenRaw[idx>>8] += tmphist[1][i]; + idx = CLIP((int)Color::gamma(mult[3]*(i-(cblacksom[3]/*+black_lev[3]*/)))); + histGreenRaw[idx>>8] += tmphist[3][i]; + idx = CLIP((int)Color::gamma(mult[2]*(i-(cblacksom[2]/*+black_lev[2]*/)))); + histBlueRaw[idx>>8] += tmphist[2][i]; } -} -} +} // end of critical region +} // end of parallel region // since there are twice as many greens, correct for it - if (ri->isBayer()) for (int i=0;i<256;i++) histGreenRaw[i]>>=1; + if (ri->isBayer()) + for (int i=0;i<256;i++) + histGreenRaw[i]>>=1; + } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/rtexif/canonattribs.cc b/rtexif/canonattribs.cc index a62cf9c45..45fa4bbb9 100644 --- a/rtexif/canonattribs.cc +++ b/rtexif/canonattribs.cc @@ -683,53 +683,54 @@ class CALensInterpreter : public IntLensInterpreter< int > { virtual std::string toString (Tag* t) { - int lensID = t->toInt(); + int lensID = t->toInt(); - it_t r; - size_t nFound = choices.count( lensID ); - if( 1== nFound ) { - r = choices.find ( lensID ); - return r->second; - } + it_t r; + size_t nFound = choices.count( lensID ); + if(1 == nFound) { + r = choices.find ( lensID ); + return r->second; + } - Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxAperture"); - Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength"); - Tag *focalLengthMaxTag = t->getParent()->getRoot()->findTag("LongFocal"); - Tag *focalLengthMinTag = t->getParent()->getRoot()->findTag("ShortFocal"); - Tag *unitTag = t->getParent()->getRoot()->findTag("FocalUnits"); - double maxApertureAtFocal = 0.; - double focalLength = 0.; - double focalLengthMin = 0.; - double focalLengthMax = 0.; - if( apertureTag ) - maxApertureAtFocal = pow(2.0, apertureTag->toDouble()/64.0); - if( unitTag ){ - double unit = unitTag->toDouble(); - if( unit==0. ) unit=1; + Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxAperture"); + Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength"); + Tag *focalLengthMaxTag = t->getParent()->getRoot()->findTag("LongFocal"); + Tag *focalLengthMinTag = t->getParent()->getRoot()->findTag("ShortFocal"); + Tag *unitTag = t->getParent()->getRoot()->findTag("FocalUnits"); + double maxApertureAtFocal = 0.; + double focalLength = 0.; + double focalLengthMin = 0.; + double focalLengthMax = 0.; + if( apertureTag ) + maxApertureAtFocal = pow(2.0, apertureTag->toDouble()/64.0); + if( unitTag ){ + double unit = unitTag->toDouble(); + if( unit==0. ) + unit=1; if( focalLengthTag ) focalLength = focalLengthTag->toDouble(); if( focalLengthMinTag ) focalLengthMin = focalLengthMinTag->toDouble()/unit; if( focalLengthMaxTag ) focalLengthMax = focalLengthMaxTag->toDouble()/unit; - } + } - if (0 == nFound) { - std::ostringstream s; - s << "Unknown "; - if (focalLengthMin > 0.) - s << focalLengthMin; - if (focalLengthMax > 0. && focalLengthMax != focalLengthMin) - s << "-" << focalLengthMax; - if (focalLengthMin > 0.) - s << "mm"; + std::ostringstream s; + s << "Unknown "; + if (focalLengthMin > 0.) + s << focalLengthMin; + if (focalLengthMax > 0. && focalLengthMax != focalLengthMin) + s << "-" << focalLengthMax; + if (focalLengthMin > 0.) + s << "mm"; - s << " (" << lensID << ")"; + s << " (" << lensID << ")"; + if (0 == nFound) { return s.str(); - } - double deltaMin = 1000.; + } + double deltaMin = 1000.; - std::string bestMatch("Unknown"); + std::string bestMatch(s.str()); std::ostringstream candidates; for (r = choices.lower_bound(lensID); r != choices.upper_bound(lensID); r++) { double a1,a2,f1,f2,lensAperture,dif; @@ -755,7 +756,7 @@ class CALensInterpreter : public IntLensInterpreter< int > { lensAperture = exp( log(a1)+(log(a2)-log(a1))/(log(f2)-log(f1))*(log(focalLength)-log(f1)) ); dif = abs(lensAperture - maxApertureAtFocal); - }else + } else dif = 0; if( dif < deltaMin ){ diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index 9bb1ca126..c8ef25791 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -2,11 +2,13 @@ #define _PPVERSION_ // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 317 +#define PPVERSION 318 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes + 318 2014-02-10 + Vignetting Correction bug makes hard transitions for positive Amount values, Issue 2241 317 2014-01-19 changes to behaviour of LC curve, Issue 2209 315 2013-12-12