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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// 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
|
||||
{
|
||||
// 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 bool isCACorrectionAvailable() 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 processVignetteLine3Channels(int width, int y, float *line) const = 0;
|
||||
virtual void processVignette(int width, int height, float** rawData) 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
|
||||
bool isCACorrectionAvailable() 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 processVignetteLine3Channels(int width, int y, float* line) const override;
|
||||
void processVignette(int width, int height, float** rawData) const override;
|
||||
void processVignette3Channels(int width, int height, float** rawData) const override;
|
||||
|
||||
private:
|
||||
bool enableCA; // is the mapper capable if CA correction?
|
||||
@ -210,6 +210,9 @@ private:
|
||||
LCPModelCommon mc;
|
||||
LCPModelCommon chrom[3]; // in order RedGreen/Green/BlueGreen
|
||||
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(numFrames == 4) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H; y++) {
|
||||
map.processVignetteLine(W, y, (*rawDataFrames[i])[y]);
|
||||
}
|
||||
map.processVignette(W, H, *rawDataFrames[i]);
|
||||
}
|
||||
} else {
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H; y++) {
|
||||
map.processVignetteLine(W, y, rawData[y]);
|
||||
}
|
||||
map.processVignette(W, H, rawData);
|
||||
}
|
||||
} else if(ri->get_colors() == 3) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H; y++) {
|
||||
map.processVignetteLine3Channels(W, y, rawData[y]);
|
||||
}
|
||||
map.processVignette3Channels(W, H, rawData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ namespace rtengine
|
||||
LFModifier::~LFModifier()
|
||||
{
|
||||
if (data_) {
|
||||
MyMutex::MyLock lock(lfModifierMutex);
|
||||
data_->Destroy();
|
||||
}
|
||||
}
|
||||
@ -78,11 +77,6 @@ bool LFModifier::isCACorrectionAvailable() const
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#ifdef _OPENMP
|
||||
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
|
||||
|
||||
|
||||
void LFModifier::processVignetteLine(int width, int y, float *line) const
|
||||
#ifdef _OPENMP
|
||||
void LFModifier::processVignette3Channels(int width, int height, float** rawData) const
|
||||
{
|
||||
MyMutex::MyLock lock(lfModifierMutex);
|
||||
data_->ApplyColorModification(line, 0, y, width, 1, LF_CR_1(INTENSITY), 0);
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Glib::ustring LFModifier::getDisplayString() const
|
||||
{
|
||||
if (!data_) {
|
||||
|
@ -56,8 +56,8 @@ public:
|
||||
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override;
|
||||
bool isCACorrectionAvailable() 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 processVignetteLine3Channels(int width, int y, float *line) const override;
|
||||
void processVignette(int width, int height, float** rawData) const override;
|
||||
void processVignette3Channels(int width, int height, float** rawData) const override;
|
||||
|
||||
Glib::ustring getDisplayString() const;
|
||||
|
||||
@ -68,7 +68,6 @@ private:
|
||||
lfModifier *data_;
|
||||
bool swap_xy_;
|
||||
int flags_;
|
||||
mutable MyMutex lfModifierMutex;
|
||||
};
|
||||
|
||||
class LFCamera final
|
||||
|
Loading…
x
Reference in New Issue
Block a user