Get rid of aehistogram files in RT cache, fixes #4904

This commit is contained in:
heckflosse 2018-10-31 15:02:53 +01:00
parent cef5d12779
commit f6c864d477
3 changed files with 82 additions and 8 deletions

View File

@ -279,6 +279,11 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
printf ("loadFromImage: Unsupported image type \"%s\"!\n", img->getType()); printf ("loadFromImage: Unsupported image type \"%s\"!\n", img->getType());
} }
ProcParams paramsForAutoExp; // Dummy for constructor
ImProcFunctions ipf (&paramsForAutoExp, false);
ipf.getAutoExp (tpp->aeHistogram, tpp->aeHistCompression, 0.02, tpp->aeExposureCompensation, tpp->aeLightness, tpp->aeContrast, tpp->aeBlack, tpp->aeHighlightCompression, tpp->aeHighlightCompressionThreshold);
tpp->aeValid = true;
if (n > 0) { if (n > 0) {
ColorTemp cTemp; ColorTemp cTemp;
@ -923,6 +928,11 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
} }
} }
} }
ProcParams paramsForAutoExp; // Dummy for constructor
ImProcFunctions ipf (&paramsForAutoExp, false);
ipf.getAutoExp (tpp->aeHistogram, tpp->aeHistCompression, 0.02, tpp->aeExposureCompensation, tpp->aeLightness, tpp->aeContrast, tpp->aeBlack, tpp->aeHighlightCompression, tpp->aeHighlightCompressionThreshold);
tpp->aeValid = true;
if (ri->get_colors() == 1) { if (ri->get_colors() == 1) {
pixSum[0] = pixSum[1] = pixSum[2] = 1.; pixSum[0] = pixSum[1] = pixSum[2] = 1.;
n[0] = n[1] = n[2] = 1; n[0] = n[1] = n[2] = 1;
@ -993,6 +1003,13 @@ Thumbnail::Thumbnail () :
wbEqual (-1.0), wbEqual (-1.0),
wbTempBias (0.0), wbTempBias (0.0),
aeHistCompression (3), aeHistCompression (3),
aeValid(false),
aeExposureCompensation(0.0),
aeLightness(0),
aeContrast(0),
aeBlack(0),
aeHighlightCompression(0),
aeHighlightCompressionThreshold(0),
embProfileLength (0), embProfileLength (0),
embProfileData (nullptr), embProfileData (nullptr),
embProfile (nullptr), embProfile (nullptr),
@ -1224,8 +1241,17 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
int hlcompr = params.toneCurve.hlcompr; int hlcompr = params.toneCurve.hlcompr;
int hlcomprthresh = params.toneCurve.hlcomprthresh; int hlcomprthresh = params.toneCurve.hlcomprthresh;
if (params.toneCurve.autoexp && aeHistogram) { if (params.toneCurve.autoexp) {
ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); if (aeValid) {
expcomp = aeExposureCompensation;
bright = aeLightness;
contr = aeContrast;
black = aeBlack;
hlcompr = aeHighlightCompression;
hlcomprthresh = aeHighlightCompressionThreshold;
} else if (aeHistogram) {
ipf.getAutoExp (aeHistogram, aeHistCompression, 0.02, expcomp, bright, contr, black, hlcompr, hlcomprthresh);
}
} }
LUTf curve1 (65536); LUTf curve1 (65536);
@ -1992,6 +2018,38 @@ bool Thumbnail::readData (const Glib::ustring& fname)
aeHistCompression = keyFile.get_integer ("LiveThumbData", "AEHistCompression"); aeHistCompression = keyFile.get_integer ("LiveThumbData", "AEHistCompression");
} }
aeValid = true;
if (keyFile.has_key ("LiveThumbData", "AEExposureCompensation")) {
aeExposureCompensation = keyFile.get_double ("LiveThumbData", "AEExposureCompensation");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "AELightness")) {
aeLightness = keyFile.get_integer ("LiveThumbData", "AELightness");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "AEContrast")) {
aeContrast = keyFile.get_integer ("LiveThumbData", "AEContrast");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "AEBlack")) {
aeBlack = keyFile.get_integer ("LiveThumbData", "AEBlack");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "AEHighlightCompression")) {
aeHighlightCompression = keyFile.get_integer ("LiveThumbData", "AEHighlightCompression");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "AEHighlightCompressionThreshold")) {
aeHighlightCompressionThreshold = keyFile.get_integer ("LiveThumbData", "AEHighlightCompressionThreshold");
} else {
aeValid = false;
}
if (keyFile.has_key ("LiveThumbData", "RedMultiplier")) { if (keyFile.has_key ("LiveThumbData", "RedMultiplier")) {
redMultiplier = keyFile.get_double ("LiveThumbData", "RedMultiplier"); redMultiplier = keyFile.get_double ("LiveThumbData", "RedMultiplier");
} }
@ -2065,7 +2123,12 @@ bool Thumbnail::writeData (const Glib::ustring& fname)
keyFile.set_double ("LiveThumbData", "RedAWBMul", redAWBMul); keyFile.set_double ("LiveThumbData", "RedAWBMul", redAWBMul);
keyFile.set_double ("LiveThumbData", "GreenAWBMul", greenAWBMul); keyFile.set_double ("LiveThumbData", "GreenAWBMul", greenAWBMul);
keyFile.set_double ("LiveThumbData", "BlueAWBMul", blueAWBMul); keyFile.set_double ("LiveThumbData", "BlueAWBMul", blueAWBMul);
keyFile.set_integer ("LiveThumbData", "AEHistCompression", aeHistCompression); keyFile.set_double ("LiveThumbData", "AEExposureCompensation", aeExposureCompensation);
keyFile.set_integer ("LiveThumbData", "AELightness", aeLightness);
keyFile.set_integer ("LiveThumbData", "AEContrast", aeContrast);
keyFile.set_integer ("LiveThumbData", "AEBlack", aeBlack);
keyFile.set_integer ("LiveThumbData", "AEHighlightCompression", aeHighlightCompression);
keyFile.set_integer ("LiveThumbData", "AEHighlightCompressionThreshold", aeHighlightCompressionThreshold);
keyFile.set_double ("LiveThumbData", "RedMultiplier", redMultiplier); keyFile.set_double ("LiveThumbData", "RedMultiplier", redMultiplier);
keyFile.set_double ("LiveThumbData", "GreenMultiplier", greenMultiplier); keyFile.set_double ("LiveThumbData", "GreenMultiplier", greenMultiplier);
keyFile.set_double ("LiveThumbData", "BlueMultiplier", blueMultiplier); keyFile.set_double ("LiveThumbData", "BlueMultiplier", blueMultiplier);

View File

@ -50,6 +50,13 @@ class Thumbnail
double autoWBTemp, autoWBGreen, wbEqual, wbTempBias; // autoWBTemp and autoWBGreen are updated each time autoWB is requested and if wbEqual has been modified double autoWBTemp, autoWBGreen, wbEqual, wbTempBias; // autoWBTemp and autoWBGreen are updated each time autoWB is requested and if wbEqual has been modified
LUTu aeHistogram; LUTu aeHistogram;
int aeHistCompression; int aeHistCompression;
bool aeValid;
double aeExposureCompensation;
int aeLightness;
int aeContrast;
int aeBlack;
int aeHighlightCompression;
int aeHighlightCompressionThreshold;
int embProfileLength; int embProfileLength;
unsigned char* embProfileData; unsigned char* embProfileData;
cmsHPROFILE embProfile; cmsHPROFILE embProfile;
@ -100,6 +107,7 @@ public:
bool readAEHistogram (const Glib::ustring& fname); bool readAEHistogram (const Glib::ustring& fname);
bool writeAEHistogram (const Glib::ustring& fname); bool writeAEHistogram (const Glib::ustring& fname);
bool isAeValid() { return aeValid; };
unsigned char* getImage8Data(); // accessor to the 8bit image if it is one, which should be the case for the "Inspector" mode. unsigned char* getImage8Data(); // accessor to the 8bit image if it is one, which should be the case for the "Inspector" mode.
// Hombre: ... let's hope that proper template can make this cleaner // Hombre: ... let's hope that proper template can make this cleaner

View File

@ -854,8 +854,10 @@ void Thumbnail::_loadThumbnail(bool firstTrial)
} }
if ( cfs.thumbImgType == CacheImageData::FULL_THUMBNAIL ) { if ( cfs.thumbImgType == CacheImageData::FULL_THUMBNAIL ) {
// load aehistogram if(!tpp->isAeValid()) {
tpp->readAEHistogram (getCacheFileName ("aehistograms", "")); // load aehistogram
tpp->readAEHistogram (getCacheFileName ("aehistograms", ""));
}
// load embedded profile // load embedded profile
tpp->readEmbProfile (getCacheFileName ("embprofiles", ".icc")); tpp->readEmbProfile (getCacheFileName ("embprofiles", ".icc"));
@ -907,9 +909,10 @@ void Thumbnail::_saveThumbnail ()
// save thumbnail image // save thumbnail image
tpp->writeImage (getCacheFileName ("images", "")); tpp->writeImage (getCacheFileName ("images", ""));
// save aehistogram if(!tpp->isAeValid()) {
tpp->writeAEHistogram (getCacheFileName ("aehistograms", "")); // save aehistogram
tpp->writeAEHistogram (getCacheFileName ("aehistograms", ""));
}
// save embedded profile // save embedded profile
tpp->writeEmbProfile (getCacheFileName ("embprofiles", ".icc")); tpp->writeEmbProfile (getCacheFileName ("embprofiles", ".icc"));