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];
|
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[0] = -param[0];
|
||||||
vign_param[1] = param0Sqr - param[1];
|
vign_param[1] = param0Sqr - param[1];
|
||||||
@@ -115,8 +115,9 @@ void LCPModelCommon::prepareParams(int fullWidth, int fullHeight, float focalLen
|
|||||||
fx = foc_len_x * Dmax;
|
fx = foc_len_x * Dmax;
|
||||||
fy = foc_len_y * 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);
|
//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
|
SSEFUNCTION void LCPMapper::processVignetteLine (int width, int y, float *line) const
|
||||||
{
|
{
|
||||||
// No need for swapXY, since vignette is in RAW and always before rotation
|
// 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);
|
const vfloat rfxv = F2V (mc.rfx);
|
||||||
|
|
||||||
vfloat xv = _mm_setr_ps (0.f, 1.f, 2.f, 3.f);
|
vfloat xv = _mm_setr_ps (0.f, 1.f, 2.f, 3.f);
|
||||||
|
|
||||||
for (; x < width - 3; x += 4) {
|
for (; x < width - 3; x += 4) {
|
||||||
vfloat xdv = (xv - x0v) * rfxv;
|
vfloat xdv = (xv - x0v) * rfxv;
|
||||||
vfloat rsqr = xdv * xdv + ydv;
|
vfloat rsqr = xdv * xdv + ydv;
|
||||||
@@ -303,9 +294,11 @@ SSEFUNCTION void LCPMapper::processVignetteLine(int width, int y, float *line) c
|
|||||||
STVFU (line[x], valv);
|
STVFU (line[x], valv);
|
||||||
xv += fourv;
|
xv += fourv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __SSE2__
|
#endif // __SSE2__
|
||||||
|
|
||||||
for (; x < width; x++) {
|
for (; x < width; x++) {
|
||||||
if (line[x] > 0) {
|
if (line[x] > 0.f) {
|
||||||
float xd = ((float)x - mc.x0) * mc.rfx;
|
float xd = ((float)x - mc.x0) * mc.rfx;
|
||||||
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
||||||
float rsqr = xd * xd + yd;
|
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
|
// No need for swapXY, since vignette is in RAW and always before rotation
|
||||||
float yd = ((float)y - mc.y0) * mc.rfy;
|
float yd = ((float)y - mc.y0) * mc.rfy;
|
||||||
yd *= yd;
|
yd *= yd;
|
||||||
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
const LCPModelCommon::VignParam vignParam = mc.vign_param;
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
float xd = ((float)x - mc.x0) * mc.rfx;
|
float xd = ((float)x - mc.x0) * mc.rfx;
|
||||||
float rsqr = xd * xd + yd;
|
float rsqr = xd * xd + yd;
|
||||||
float vignetteFactor = rsqr * (vignParam[0] + rsqr * ((vignParam[1]) - (vignParam[2]) * rsqr + (vignParam[3]) * rsqr * rsqr));
|
float vignetteFactor = rsqr * (vignParam[0] + rsqr * ((vignParam[1]) - (vignParam[2]) * rsqr + (vignParam[3]) * rsqr * rsqr));
|
||||||
|
|
||||||
for (int c = 0; c < 3; ++c) {
|
for (int c = 0; c < 3; ++c) {
|
||||||
if (line[3 * x + c] > 0) {
|
if (line[3 * x + c] > 0) {
|
||||||
line[3 * x + c] += line[3 * x + c] * vignetteFactor;
|
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)
|
LCPProfile::LCPProfile (const Glib::ustring &fname)
|
||||||
{
|
{
|
||||||
const int BufferSize = 8192;
|
const int BufferSize = 8192;
|
||||||
@@ -450,7 +444,6 @@ int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft)
|
|||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// mode: 0=vignette, 1=distortion, 2=CA
|
// 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
|
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 correctDistortion (double& x, double& y) const; // MUST be the first stage
|
||||||
void correctCA (double& x, double& y, int channel) const;
|
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 processVignetteLine (int width, int y, float *line) const;
|
||||||
void processVignetteLine3Channels (int width, int y, float *line) const;
|
void processVignetteLine3Channels (int width, int y, float *line) const;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user