Small ~10% speedup for histogram matching on fast decoding raw files
This commit is contained in:
parent
6567380f7d
commit
7848915e58
@ -227,7 +227,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector<double> &outCurve)
|
|||||||
eSensorType sensor_type;
|
eSensorType sensor_type;
|
||||||
double scale;
|
double scale;
|
||||||
int w = fw / skip, h = fh / skip;
|
int w = fw / skip, h = fh / skip;
|
||||||
std::unique_ptr<Thumbnail> thumb(Thumbnail::loadFromRaw(getFileName(), rml, sensor_type, w, h, 1, false, false));
|
std::unique_ptr<Thumbnail> thumb(Thumbnail::loadFromRaw(getFileName(), rml, sensor_type, w, h, 1, false, false, true));
|
||||||
if (!thumb) {
|
if (!thumb) {
|
||||||
if (settings->verbose) {
|
if (settings->verbose) {
|
||||||
std::cout << "histogram matching: raw decoding failed, generating a neutral curve" << std::endl;
|
std::cout << "histogram matching: raw decoding failed, generating a neutral curve" << std::endl;
|
||||||
@ -235,7 +235,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector<double> &outCurve)
|
|||||||
histMatchingCache = outCurve;
|
histMatchingCache = outCurve;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
target.reset(thumb->processImage(neutral, sensor_type, fh / skip, TI_Nearest, getMetaData(), scale, false));
|
target.reset(thumb->processImage(neutral, sensor_type, fh / skip, TI_Nearest, getMetaData(), scale, false, true));
|
||||||
|
|
||||||
int sw = source->getWidth(), sh = source->getHeight();
|
int sw = source->getWidth(), sh = source->getHeight();
|
||||||
int tw = target->getWidth(), th = target->getHeight();
|
int tw = target->getWidth(), th = target->getHeight();
|
||||||
|
@ -56,7 +56,7 @@ bool checkRawImageThumb (const rtengine::RawImage& raw_image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void scale_colors (rtengine::RawImage *ri, float scale_mul[4], float cblack[4])
|
void scale_colors (rtengine::RawImage *ri, float scale_mul[4], float cblack[4], bool multiThread)
|
||||||
{
|
{
|
||||||
DCraw::dcrawImage_t image = ri->get_image();
|
DCraw::dcrawImage_t image = ri->get_image();
|
||||||
|
|
||||||
@ -64,6 +64,9 @@ void scale_colors (rtengine::RawImage *ri, float scale_mul[4], float cblack[4])
|
|||||||
const int height = ri->get_iheight();
|
const int height = ri->get_iheight();
|
||||||
const int width = ri->get_iwidth();
|
const int width = ri->get_iwidth();
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for if(multiThread)
|
||||||
|
#endif
|
||||||
for (int row = 0; row < height; ++row) {
|
for (int row = 0; row < height; ++row) {
|
||||||
unsigned c0 = ri->FC (row, 0);
|
unsigned c0 = ri->FC (row, 0);
|
||||||
unsigned c1 = ri->FC (row, 1);
|
unsigned c1 = ri->FC (row, 1);
|
||||||
@ -90,9 +93,12 @@ void scale_colors (rtengine::RawImage *ri, float scale_mul[4], float cblack[4])
|
|||||||
} else if (ri->isXtrans()) {
|
} else if (ri->isXtrans()) {
|
||||||
const int height = ri->get_iheight();
|
const int height = ri->get_iheight();
|
||||||
const int width = ri->get_iwidth();
|
const int width = ri->get_iwidth();
|
||||||
unsigned c[6];
|
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for if(multiThread)
|
||||||
|
#endif
|
||||||
for (int row = 0; row < height; ++row) {
|
for (int row = 0; row < height; ++row) {
|
||||||
|
unsigned c[6];
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
c[i] = ri->XTRANSFC (row, i);
|
c[i] = ri->XTRANSFC (row, i);
|
||||||
}
|
}
|
||||||
@ -120,6 +126,9 @@ void scale_colors (rtengine::RawImage *ri, float scale_mul[4], float cblack[4])
|
|||||||
} else {
|
} else {
|
||||||
const int size = ri->get_iheight() * ri->get_iwidth();
|
const int size = ri->get_iheight() * ri->get_iwidth();
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for if(multiThread)
|
||||||
|
#endif
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (int j = 0; j < 4; ++j) {
|
||||||
float val = image[i][j];
|
float val = image[i][j];
|
||||||
@ -386,7 +395,7 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname)
|
|||||||
return rml;
|
return rml;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate)
|
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, bool multiThread)
|
||||||
{
|
{
|
||||||
RawImage *ri = new RawImage (fname);
|
RawImage *ri = new RawImage (fname);
|
||||||
unsigned int tempImageNum = 0;
|
unsigned int tempImageNum = 0;
|
||||||
@ -421,7 +430,7 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
|
|||||||
//ri->scale_colors();
|
//ri->scale_colors();
|
||||||
float pre_mul[4], scale_mul[4], cblack[4];
|
float pre_mul[4], scale_mul[4], cblack[4];
|
||||||
ri->get_colorsCoeff (pre_mul, scale_mul, cblack, false);
|
ri->get_colorsCoeff (pre_mul, scale_mul, cblack, false);
|
||||||
scale_colors (ri, scale_mul, cblack);
|
scale_colors (ri, scale_mul, cblack, multiThread);
|
||||||
|
|
||||||
ri->pre_interpolate();
|
ri->pre_interpolate();
|
||||||
|
|
||||||
@ -921,7 +930,7 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Full thumbnail processing, second stage if complete profile exists
|
// Full thumbnail processing, second stage if complete profile exists
|
||||||
IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& myscale, bool forMonitor)
|
IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& myscale, bool forMonitor, bool multiThread)
|
||||||
{
|
{
|
||||||
unsigned int imgNum = 0;
|
unsigned int imgNum = 0;
|
||||||
if (isRaw) {
|
if (isRaw) {
|
||||||
@ -1053,7 +1062,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
|
|||||||
int fh = baseImg->getHeight();
|
int fh = baseImg->getHeight();
|
||||||
//ColorTemp::CAT02 (baseImg, ¶ms) ;//perhaps not good!
|
//ColorTemp::CAT02 (baseImg, ¶ms) ;//perhaps not good!
|
||||||
|
|
||||||
ImProcFunctions ipf (¶ms, false);
|
ImProcFunctions ipf (¶ms, multiThread);
|
||||||
ipf.setScale (sqrt (double (fw * fw + fh * fh)) / sqrt (double (thumbImg->getWidth() * thumbImg->getWidth() + thumbImg->getHeight() * thumbImg->getHeight()))*scale);
|
ipf.setScale (sqrt (double (fw * fw + fh * fh)) / sqrt (double (thumbImg->getWidth() * thumbImg->getWidth() + thumbImg->getHeight() * thumbImg->getHeight()))*scale);
|
||||||
ipf.updateColorProfiles (ICCStore::getInstance()->getDefaultMonitorProfileName(), options.rtSettings.monitorIntent, false, false);
|
ipf.updateColorProfiles (ICCStore::getInstance()->getDefaultMonitorProfileName(), options.rtSettings.monitorIntent, false, false);
|
||||||
|
|
||||||
|
@ -71,13 +71,13 @@ public:
|
|||||||
|
|
||||||
void init ();
|
void init ();
|
||||||
|
|
||||||
IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale, bool forMonitor=true);
|
IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale, bool forMonitor=true, bool multiThread = false);
|
||||||
IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp);
|
IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp);
|
||||||
int getImageWidth (const procparams::ProcParams& pparams, int rheight, float &ratio);
|
int getImageWidth (const procparams::ProcParams& pparams, int rheight, float &ratio);
|
||||||
void getDimensions (int& w, int& h, double& scaleFac);
|
void getDimensions (int& w, int& h, double& scaleFac);
|
||||||
|
|
||||||
static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, rtengine::RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode = false);
|
static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, rtengine::RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode = false);
|
||||||
static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate);
|
static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, bool multiThread = false);
|
||||||
static Thumbnail* loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode = false);
|
static Thumbnail* loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode = false);
|
||||||
static RawMetaDataLocation loadMetaDataFromRaw (const Glib::ustring& fname);
|
static RawMetaDataLocation loadMetaDataFromRaw (const Glib::ustring& fname);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user