Improve start time of rawtherapee when Dark-frames and Flat-fileds directories are set at default (windows), fixes #4103

This commit is contained in:
heckflosse 2017-10-08 17:27:39 +02:00
parent 2f32afa841
commit d84a3fd40a
2 changed files with 46 additions and 57 deletions

View File

@ -334,41 +334,36 @@ void DFManager::init( Glib::ustring pathname )
dfInfo* DFManager::addFileInfo (const Glib::ustring& filename, bool pool)
{
auto file = Gio::File::create_for_path (filename);
auto ext = getFileExtension(filename);
if (ext.empty() || !options.is_extention_enabled(ext)) {
return nullptr;
}
auto file = Gio::File::create_for_path(filename);
if (!file) {
return nullptr;
}
if (!file->query_exists ()) {
if (!file->query_exists()) {
return nullptr;
}
try {
auto info = file->query_info ();
auto info = file->query_info("standard::name,standard::type,standard::is-hidden");
if (!info && info->get_file_type () == Gio::FILE_TYPE_DIRECTORY) {
if (!info && info->get_file_type() == Gio::FILE_TYPE_DIRECTORY) {
return nullptr;
}
if (!options.fbShowHidden && info->is_hidden ()) {
if (!options.fbShowHidden && info->is_hidden()) {
return nullptr;
}
Glib::ustring ext;
auto lastdot = info->get_name ().find_last_of ('.');
if (lastdot != Glib::ustring::npos) {
ext = info->get_name ().substr (lastdot + 1);
}
if (!options.is_extention_enabled (ext)) {
return nullptr;
}
RawImage ri (filename);
int res = ri.loadRaw (false); // Read informations about shot
RawImage ri(filename);
int res = ri.loadRaw(false); // Read informations about shot
if (res != 0) {
return nullptr;
@ -378,7 +373,7 @@ dfInfo* DFManager::addFileInfo (const Glib::ustring& filename, bool pool)
if(!pool) {
dfInfo n(filename, "", "", 0, 0, 0);
iter = dfList.insert(std::pair< std::string, dfInfo>( "", n ) );
iter = dfList.emplace("", n);
return &(iter->second);
}
@ -388,22 +383,22 @@ dfInfo* DFManager::addFileInfo (const Glib::ustring& filename, bool pool)
rml.ciffLength = ri.get_ciffLen();
ImageData idata(filename, &rml);
/* Files are added in the map, divided by same maker/model,ISO and shutter*/
std::string key( dfInfo::key(((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed()) );
iter = dfList.find( key );
std::string key(dfInfo::key(((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed()));
iter = dfList.find(key);
if( iter == dfList.end() ) {
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS() );
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
if(iter == dfList.end()) {
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS());
iter = dfList.emplace(key, n);
} else {
while( iter != dfList.end() && iter->second.key() == key && ABS(iter->second.timestamp - idata.getDateTimeAsTS()) > 60 * 60 * 6 ) { // 6 hour difference
while(iter != dfList.end() && iter->second.key() == key && ABS(iter->second.timestamp - idata.getDateTimeAsTS()) > 60 * 60 * 6) { // 6 hour difference
++iter;
}
if( iter != dfList.end() ) {
iter->second.pathNames.push_back( filename );
if(iter != dfList.end()) {
iter->second.pathNames.push_back(filename);
} else {
dfInfo n(filename, ((Glib::ustring)idata.getMake()).uppercase(), ((Glib::ustring)idata.getModel()).uppercase(), idata.getISOSpeed(), idata.getShutterSpeed(), idata.getDateTimeAsTS());
iter = dfList.insert(std::pair< std::string, dfInfo>( key, n ) );
iter = dfList.emplace(key, n);
}
}

View File

@ -21,6 +21,7 @@
#include "rawimage.h"
#include "imagedata.h"
#include "median.h"
#include "utils.h"
namespace rtengine
{
@ -288,43 +289,36 @@ void FFManager::init( Glib::ustring pathname )
ffInfo* FFManager::addFileInfo (const Glib::ustring& filename, bool pool)
{
auto file = Gio::File::create_for_path (filename);
auto ext = getFileExtension(filename);
if (ext.empty() || !options.is_extention_enabled(ext)) {
return nullptr;
}
auto file = Gio::File::create_for_path(filename);
if (!file ) {
return nullptr;
}
if (!file->query_exists ()) {
if (!file->query_exists()) {
return nullptr;
}
try {
auto info = file->query_info ();
auto info = file->query_info("standard::name,standard::type,standard::is-hidden");
if (!info || info->get_file_type () == Gio::FILE_TYPE_DIRECTORY) {
if (!info || info->get_file_type() == Gio::FILE_TYPE_DIRECTORY) {
return nullptr;
}
if (!options.fbShowHidden && info->is_hidden ()) {
if (!options.fbShowHidden && info->is_hidden()) {
return nullptr;
}
Glib::ustring ext;
auto lastdot = info->get_name ().find_last_of ('.');
if (lastdot != Glib::ustring::npos) {
ext = info->get_name ().substr (lastdot + 1);
}
if (!options.is_extention_enabled (ext)) {
return nullptr;
}
RawImage ri (filename);
int res = ri.loadRaw (false); // Read informations about shot
RawImage ri(filename);
int res = ri.loadRaw(false); // Read informations about shot
if (res != 0) {
return nullptr;
@ -334,7 +328,7 @@ ffInfo* FFManager::addFileInfo (const Glib::ustring& filename, bool pool)
if(!pool) {
ffInfo n(filename, "", "", "", 0, 0, 0);
iter = ffList.insert(std::pair< std::string, ffInfo>( "", n ) );
iter = ffList.emplace("", n);
return &(iter->second);
}
@ -344,22 +338,22 @@ ffInfo* FFManager::addFileInfo (const Glib::ustring& filename, bool pool)
rml.ciffLength = ri.get_ciffLen();
ImageData idata(filename, &rml);
/* Files are added in the map, divided by same maker/model,lens and aperture*/
std::string key( ffInfo::key(idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber()) );
iter = ffList.find( key );
std::string key(ffInfo::key(idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber()));
iter = ffList.find(key);
if( iter == ffList.end() ) {
if(iter == ffList.end()) {
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
iter = ffList.emplace(key, n);
} else {
while( iter != ffList.end() && iter->second.key() == key && ABS(iter->second.timestamp - ri.get_timestamp()) > 60 * 60 * 6 ) { // 6 hour difference
while(iter != ffList.end() && iter->second.key() == key && ABS(iter->second.timestamp - ri.get_timestamp()) > 60 * 60 * 6) { // 6 hour difference
++iter;
}
if( iter != ffList.end() ) {
iter->second.pathNames.push_back( filename );
if(iter != ffList.end()) {
iter->second.pathNames.push_back(filename);
} else {
ffInfo n(filename, idata.getMake(), idata.getModel(), idata.getLens(), idata.getFocalLen(), idata.getFNumber(), idata.getDateTimeAsTS());
iter = ffList.insert(std::pair< std::string, ffInfo>( key, n ) );
iter = ffList.emplace(key, n);
}
}