speed up un-cached directories

embedded thumbnails will be used for the first pass when cached thumbnails are not found.
This commit is contained in:
Steve Herrell
2010-10-29 12:06:17 +02:00
parent 7ce062cfc3
commit b25d03e6ea
18 changed files with 397 additions and 59 deletions

View File

@@ -34,7 +34,8 @@ using namespace rtengine::procparams;
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL),
pparamsValid(false), needsReProcessing(true), lastImg(NULL) {
pparamsValid(false), needsReProcessing(true), lastImg(NULL),
quick_(false), initial_(false) {
cfs.load (getCacheFileName ("data")+".txt");
loadProcParams ();
@@ -44,68 +45,90 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageDa
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5)
: fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false),
needsReProcessing(true), lastImg(NULL) {
needsReProcessing(true), lastImg(NULL),
quick_(false), initial_(true) {
cfs.md5 = md5;
_generateThumbnailImage ();
loadProcParams ();
cfs.recentlySaved = false;
initial_ = false;
}
void Thumbnail::_generateThumbnailImage () {
// delete everything loaded into memory
delete tpp;
tpp = NULL;
delete [] lastImg;
lastImg = NULL;
tw = -1;
th = options.maxThumbnailHeight;
// delete everything loaded into memory
delete tpp;
tpp = NULL;
delete [] lastImg;
lastImg = NULL;
tw = -1;
th = options.maxThumbnailHeight;
// generate thumbnail image
// generate thumbnail image
Glib::ustring ext = getExtension (fname);
if (ext=="")
return;
cfs.supported = false;
cfs.exifValid = false;
cfs.timeValid = false;
delete tpp;
tpp = NULL;
if (ext.lowercase()=="jpg" || ext.lowercase()=="png" || ext.lowercase()=="tif" || ext.lowercase()=="tiff")
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1);
if (tpp) {
if (ext.lowercase()=="jpg") {
cfs.format = FT_Jpeg;
infoFromImage (fname);
}
else if (ext.lowercase()=="png")
cfs.format = FT_Png;
else if (ext.lowercase()=="tif" || ext.lowercase()=="tiff") {
cfs.format = FT_Tiff;
infoFromImage (fname);
}
}
else {
rtengine::RawMetaDataLocation ri;
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1);
if (tpp) {
cfs.format = FT_Raw;
infoFromImage (fname, &ri);
}
}
if (tpp) {
// save thumbnail image to cache
_saveThumbnail ();
cfs.supported = true;
}
needsReProcessing = true;
Glib::ustring ext = getExtension (fname);
if (ext=="")
return;
cfs.supported = false;
cfs.exifValid = false;
cfs.timeValid = false;
cfs.save (getCacheFileName ("data")+".txt");
delete tpp;
tpp = NULL;
if (ext.lowercase()=="jpg" || ext.lowercase()=="png" || ext.lowercase()=="tif" || ext.lowercase()=="tiff")
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1);
if (tpp) {
if (ext.lowercase()=="jpg") {
cfs.format = FT_Jpeg;
infoFromImage (fname);
}
else if (ext.lowercase()=="png")
cfs.format = FT_Png;
else if (ext.lowercase()=="tif" || ext.lowercase()=="tiff") {
cfs.format = FT_Tiff;
infoFromImage (fname);
}
}
else {
// RAW works like this:
// 1. if we are here it's because we aren't in the cache so load the JPG
// image out of the RAW. Mark as "quick".
// 2. if we don't find that then just grab the real image.
rtengine::RawMetaDataLocation ri;
if ( initial_ )
{
quick_ = true;
tpp = rtengine::Thumbnail::loadQuickFromRaw (fname, ri, tw, th, 1);
}
if ( tpp == 0 )
{
quick_ = false;
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1);
}
if (tpp) {
cfs.format = FT_Raw;
infoFromImage (fname, &ri);
}
}
if (tpp )
{
if ( !quick_ )
{
_saveThumbnail ();
}
cfs.supported = true;
}
needsReProcessing = true;
generateExifDateTimeStrings ();
if ( !quick_ )
{
cfs.save (getCacheFileName ("data")+".txt");
}
generateExifDateTimeStrings ();
}
void Thumbnail::generateThumbnailImage () {
@@ -262,9 +285,28 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro
if (!tpp)
return NULL;
rtengine::IImage8* res = tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
if ( quick_ )
{
return tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest, scale);
}
else
{
return tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
}
}
return res;
rtengine::IImage8* Thumbnail::upgradeThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale) {
Glib::Mutex::Lock lock(mutex);
if ( !quick_ )
{
return 0;
}
quick_ = false;
_generateThumbnailImage();
return tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
}
void Thumbnail::generateExifDateTimeStrings () {