Multithread lensfun vignetting correction
This commit is contained in:
parent
dba0d72ecd
commit
f95acfe74e
@ -1135,6 +1135,17 @@ void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int ch
|
|||||||
y -= cy;
|
y -= cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtengine::LCPMapper::processVignette(int width, int height, float** rawData) const
|
||||||
|
{
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for schedule(dynamic,16)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
processVignetteLine(width, y, rawData[y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rtengine::LCPMapper::processVignetteLine(int width, int y, float* line) const
|
void rtengine::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
|
||||||
@ -1173,6 +1184,17 @@ void rtengine::LCPMapper::processVignetteLine(int width, int y, float* line) con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtengine::LCPMapper::processVignette3Channels(int width, int height, float** rawData) const
|
||||||
|
{
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for schedule(dynamic,16)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
processVignetteLine3Channels(width, y, rawData[y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rtengine::LCPMapper::processVignetteLine3Channels(int width, int y, float* line) const
|
void rtengine::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
|
||||||
|
@ -172,8 +172,8 @@ public:
|
|||||||
virtual void correctDistortion(double &x, double &y, int cx, int cy, double scale) const = 0;
|
virtual void correctDistortion(double &x, double &y, int cx, int cy, double scale) const = 0;
|
||||||
virtual bool isCACorrectionAvailable() const = 0;
|
virtual bool isCACorrectionAvailable() const = 0;
|
||||||
virtual void correctCA(double &x, double &y, int cx, int cy, 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 processVignette(int width, int height, float** rawData) const = 0;
|
||||||
virtual void processVignetteLine3Channels(int width, int y, float *line) const = 0;
|
virtual void processVignette3Channels(int width, int height, float** rawData) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -200,8 +200,8 @@ public:
|
|||||||
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override; // MUST be the first stage
|
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override; // MUST be the first stage
|
||||||
bool isCACorrectionAvailable() const override;
|
bool isCACorrectionAvailable() const override;
|
||||||
void correctCA(double& x, double& y, int cx, int cy, 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 processVignette(int width, int height, float** rawData) const override;
|
||||||
void processVignetteLine3Channels(int width, int y, float* line) const override;
|
void processVignette3Channels(int width, int height, float** rawData) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool enableCA; // is the mapper capable if CA correction?
|
bool enableCA; // is the mapper capable if CA correction?
|
||||||
@ -210,6 +210,9 @@ private:
|
|||||||
LCPModelCommon mc;
|
LCPModelCommon mc;
|
||||||
LCPModelCommon chrom[3]; // in order RedGreen/Green/BlueGreen
|
LCPModelCommon chrom[3]; // in order RedGreen/Green/BlueGreen
|
||||||
bool isFisheye;
|
bool isFisheye;
|
||||||
|
|
||||||
|
void processVignetteLine(int width, int y, float* line) const;
|
||||||
|
void processVignetteLine3Channels(int width, int y, float* line) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1399,32 +1399,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
|||||||
if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS || ri->get_colors() == 1) {
|
if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS || ri->get_colors() == 1) {
|
||||||
if(numFrames == 4) {
|
if(numFrames == 4) {
|
||||||
for(int i = 0; i < 4; ++i) {
|
for(int i = 0; i < 4; ++i) {
|
||||||
#ifdef _OPENMP
|
map.processVignette(W, H, *rawDataFrames[i]);
|
||||||
#pragma omp parallel for schedule(dynamic,16)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int y = 0; y < H; y++) {
|
|
||||||
map.processVignetteLine(W, y, (*rawDataFrames[i])[y]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
map.processVignette(W, H, rawData);
|
||||||
#ifdef _OPENMP
|
|
||||||
#pragma omp parallel for schedule(dynamic,16)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int y = 0; y < H; y++) {
|
|
||||||
map.processVignetteLine(W, y, rawData[y]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if(ri->get_colors() == 3) {
|
} else if(ri->get_colors() == 3) {
|
||||||
#ifdef _OPENMP
|
map.processVignette3Channels(W, H, rawData);
|
||||||
#pragma omp parallel for schedule(dynamic,16)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int y = 0; y < H; y++) {
|
|
||||||
map.processVignetteLine3Channels(W, y, rawData[y]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ namespace rtengine
|
|||||||
LFModifier::~LFModifier()
|
LFModifier::~LFModifier()
|
||||||
{
|
{
|
||||||
if (data_) {
|
if (data_) {
|
||||||
MyMutex::MyLock lock(lfModifierMutex);
|
|
||||||
data_->Destroy();
|
data_->Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,11 +77,6 @@ bool LFModifier::isCACorrectionAvailable() const
|
|||||||
return (flags_ & LF_MODIFY_TCA);
|
return (flags_ & LF_MODIFY_TCA);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 cx, int cy, int channel) const
|
void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const
|
||||||
{
|
{
|
||||||
assert(channel >= 0 && channel <= 2);
|
assert(channel >= 0 && channel <= 2);
|
||||||
@ -108,25 +102,39 @@ void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) co
|
|||||||
y -= cy;
|
y -= cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef _OPENMP
|
||||||
#pragma GCC diagnostic pop
|
void LFModifier::processVignette(int width, int height, float** rawData) const
|
||||||
|
{
|
||||||
|
#pragma omp parallel for schedule(dynamic,16)
|
||||||
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
data_->ApplyColorModification(rawData[y], 0, y, width, 1, LF_CR_1(INTENSITY), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void LFModifier::processVignette(int width, int height, float** rawData) const
|
||||||
|
{
|
||||||
|
data_->ApplyColorModification(rawData[0], 0, 0, width, height, LF_CR_1(INTENSITY), width * sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
void LFModifier::processVignetteLine(int width, int y, float *line) const
|
void LFModifier::processVignette3Channels(int width, int height, float** rawData) const
|
||||||
{
|
{
|
||||||
MyMutex::MyLock lock(lfModifierMutex);
|
#pragma omp parallel for schedule(dynamic,16)
|
||||||
data_->ApplyColorModification(line, 0, y, width, 1, LF_CR_1(INTENSITY), 0);
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
data_->ApplyColorModification(rawData[y], 0, y, width, 1, LF_CR_3(RED, GREEN, BLUE), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void LFModifier::processVignette3Channels(int width, int height, float** rawData) const
|
||||||
|
{
|
||||||
|
data_->ApplyColorModification(rawData[y], 0, 0, width, height, LF_CR_3(RED, GREEN, BLUE), width * 3 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
void LFModifier::processVignetteLine3Channels(int width, int y, float *line) const
|
|
||||||
{
|
|
||||||
MyMutex::MyLock lock(lfModifierMutex);
|
|
||||||
data_->ApplyColorModification(line, 0, y, width, 1, LF_CR_3(RED, GREEN, BLUE), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Glib::ustring LFModifier::getDisplayString() const
|
Glib::ustring LFModifier::getDisplayString() const
|
||||||
{
|
{
|
||||||
if (!data_) {
|
if (!data_) {
|
||||||
|
@ -56,8 +56,8 @@ public:
|
|||||||
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override;
|
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override;
|
||||||
bool isCACorrectionAvailable() const override;
|
bool isCACorrectionAvailable() const override;
|
||||||
void correctCA(double &x, double &y, int cx, int cy, 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 processVignette(int width, int height, float** rawData) const override;
|
||||||
void processVignetteLine3Channels(int width, int y, float *line) const override;
|
void processVignette3Channels(int width, int height, float** rawData) const override;
|
||||||
|
|
||||||
Glib::ustring getDisplayString() const;
|
Glib::ustring getDisplayString() const;
|
||||||
|
|
||||||
@ -68,7 +68,6 @@ private:
|
|||||||
lfModifier *data_;
|
lfModifier *data_;
|
||||||
bool swap_xy_;
|
bool swap_xy_;
|
||||||
int flags_;
|
int flags_;
|
||||||
mutable MyMutex lfModifierMutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LFCamera final
|
class LFCamera final
|
||||||
|
Loading…
x
Reference in New Issue
Block a user