Further cleanup and astyled lcp.*
This commit is contained in:
@@ -80,7 +80,7 @@ void LCPModelCommon::merge(const LCPModelCommon& a, const LCPModelCommon& b, flo
|
||||
param[i] = facA * a.param[i] + facB * b.param[i];
|
||||
}
|
||||
|
||||
const float param0Sqr = param[0] * param[0];
|
||||
const double param0Sqr = param[0] * param[0];
|
||||
|
||||
vign_param[0] = -param[0];
|
||||
vign_param[1] = param0Sqr - param[1];
|
||||
@@ -115,8 +115,9 @@ void LCPModelCommon::prepareParams(int fullWidth, int fullHeight, float focalLen
|
||||
fx = foc_len_x * Dmax;
|
||||
fy = foc_len_y * Dmax;
|
||||
}
|
||||
rfx = 1.0f / fx;
|
||||
rfy = 1.0f / fy;
|
||||
|
||||
rfx = 1.0 / fx; // calculatiom with double precision doesn't cost anything at this step
|
||||
rfy = 1.0 / fy; // "
|
||||
|
||||
//printf("FW %i /X0 %g FH %i /Y0 %g %g\n",fullWidth,x0,fullHeight,y0, imgYCenter);
|
||||
}
|
||||
@@ -265,17 +266,6 @@ void LCPMapper::correctCA(double& x, double& y, int channel) const
|
||||
}
|
||||
}
|
||||
|
||||
float LCPMapper::calcVignetteFac(int x, int y) const
|
||||
{
|
||||
// No need for swapXY, since vignette is in RAW and always before rotation
|
||||
float xd = ((float)x - mc.x0) * mc.rfx, yd = ((float)y - mc.y0) * mc.rfy;
|
||||
|
||||
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
||||
float rsqr = xd * xd + yd * yd;
|
||||
|
||||
return rsqr * (vignParam[0] + rsqr * ((vignParam[1]) - (vignParam[2]) * rsqr + (vignParam[3]) * rsqr * rsqr));
|
||||
}
|
||||
|
||||
SSEFUNCTION void LCPMapper::processVignetteLine (int width, int y, float *line) const
|
||||
{
|
||||
// No need for swapXY, since vignette is in RAW and always before rotation
|
||||
@@ -294,6 +284,7 @@ SSEFUNCTION void LCPMapper::processVignetteLine(int width, int y, float *line) c
|
||||
const vfloat rfxv = F2V (mc.rfx);
|
||||
|
||||
vfloat xv = _mm_setr_ps (0.f, 1.f, 2.f, 3.f);
|
||||
|
||||
for (; x < width - 3; x += 4) {
|
||||
vfloat xdv = (xv - x0v) * rfxv;
|
||||
vfloat rsqr = xdv * xdv + ydv;
|
||||
@@ -303,9 +294,11 @@ SSEFUNCTION void LCPMapper::processVignetteLine(int width, int y, float *line) c
|
||||
STVFU (line[x], valv);
|
||||
xv += fourv;
|
||||
}
|
||||
|
||||
#endif // __SSE2__
|
||||
|
||||
for (; x < width; x++) {
|
||||
if (line[x] > 0) {
|
||||
if (line[x] > 0.f) {
|
||||
float xd = ((float)x - mc.x0) * mc.rfx;
|
||||
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
||||
float rsqr = xd * xd + yd;
|
||||
@@ -314,16 +307,18 @@ SSEFUNCTION void LCPMapper::processVignetteLine(int width, int y, float *line) c
|
||||
}
|
||||
}
|
||||
|
||||
SSEFUNCTION void LCPMapper::processVignetteLine3Channels(int width, int y, float *line) const
|
||||
void LCPMapper::processVignetteLine3Channels (int width, int y, float *line) const
|
||||
{
|
||||
// No need for swapXY, since vignette is in RAW and always before rotation
|
||||
float yd = ((float)y - mc.y0) * mc.rfy;
|
||||
yd *= yd;
|
||||
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
float xd = ((float)x - mc.x0) * mc.rfx;
|
||||
float rsqr = xd * xd + yd;
|
||||
float vignetteFactor = rsqr * (vignParam[0] + rsqr * ((vignParam[1]) - (vignParam[2]) * rsqr + (vignParam[3]) * rsqr * rsqr));
|
||||
|
||||
for (int c = 0; c < 3; ++c) {
|
||||
if (line[3 * x + c] > 0) {
|
||||
line[3 * x + c] += line[3 * x + c] * vignetteFactor;
|
||||
@@ -332,7 +327,6 @@ SSEFUNCTION void LCPMapper::processVignetteLine3Channels(int width, int y, float
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LCPProfile::LCPProfile (const Glib::ustring &fname)
|
||||
{
|
||||
const int BufferSize = 8192;
|
||||
@@ -450,7 +444,6 @@ int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft)
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
||||
// mode: 0=vignette, 1=distortion, 2=CA
|
||||
void LCPProfile::calcParams (int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const
|
||||
{
|
||||
|
@@ -148,7 +148,6 @@ public:
|
||||
|
||||
void correctDistortion (double& x, double& y) const; // MUST be the first stage
|
||||
void correctCA (double& x, double& y, int channel) const;
|
||||
float calcVignetteFac (int x, int y) const; // MUST be in RAW
|
||||
void processVignetteLine (int width, int y, float *line) const;
|
||||
void processVignetteLine3Channels (int width, int y, float *line) const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user