diff --git a/rtengine/dfmanager.cc b/rtengine/dfmanager.cc index ab76ff854..1dedf661f 100644 --- a/rtengine/dfmanager.cc +++ b/rtengine/dfmanager.cc @@ -138,7 +138,8 @@ void dfInfo::updateRawImage() std::list::iterator iName = pathNames.begin(); ri = new RawImage(*iName); // First file used also for extra pixels informations (width,height, shutter, filters etc.. ) - if( ri->loadRaw(true)) { + unsigned int imageNum = 0; + if( ri->loadRaw(true, imageNum)) { delete ri; ri = nullptr; } else { @@ -163,7 +164,7 @@ void dfInfo::updateRawImage() for( ++iName; iName != pathNames.end(); ++iName) { RawImage* temp = new RawImage(*iName); - if( !temp->loadRaw(true)) { + if( !temp->loadRaw(true,imageNum)) { temp->compress_image(); //\ TODO would be better working on original, because is temporary nFiles++; @@ -199,8 +200,9 @@ void dfInfo::updateRawImage() } } else { ri = new RawImage(pathname); + unsigned int imageNum = 0; - if( ri->loadRaw(true)) { + if( ri->loadRaw(true,imageNum)) { delete ri; ri = nullptr; } else { @@ -365,7 +367,8 @@ dfInfo* DFManager::addFileInfo (const Glib::ustring& filename, bool pool) } RawImage ri (filename); - int res = ri.loadRaw (false); // Read informations about shot + unsigned int imageNum = 0; + int res = ri.loadRaw (false, imageNum); // Read informations about shot if (res != 0) { return nullptr; diff --git a/rtengine/ffmanager.cc b/rtengine/ffmanager.cc index 069bbf563..42a46802b 100644 --- a/rtengine/ffmanager.cc +++ b/rtengine/ffmanager.cc @@ -130,8 +130,8 @@ void ffInfo::updateRawImage() if( !pathNames.empty() ) { std::list::iterator iName = pathNames.begin(); ri = new RawImage(*iName); // First file used also for extra pixels informations (width,height, shutter, filters etc.. ) - - if( ri->loadRaw(true)) { + unsigned int imageNum = 0; + if( ri->loadRaw(true, imageNum)) { delete ri; ri = nullptr; } else { @@ -156,7 +156,7 @@ void ffInfo::updateRawImage() for( ++iName; iName != pathNames.end(); ++iName) { RawImage* temp = new RawImage(*iName); - if( !temp->loadRaw(true)) { + if( !temp->loadRaw(true,imageNum)) { temp->compress_image(); //\ TODO would be better working on original, because is temporary nFiles++; @@ -192,8 +192,9 @@ void ffInfo::updateRawImage() } } else { ri = new RawImage(pathname); + unsigned int imageNum = 0; - if( ri->loadRaw(true)) { + if( ri->loadRaw(true, imageNum)) { delete ri; ri = nullptr; } else { @@ -326,7 +327,8 @@ ffInfo* FFManager::addFileInfo (const Glib::ustring& filename, bool pool) RawImage ri (filename); - int res = ri.loadRaw (false); // Read informations about shot + unsigned int imageNum = 0; + int res = ri.loadRaw (false, imageNum); // Read informations about shot if (res != 0) { return nullptr; diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 4acffef6c..98e5446a1 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -80,6 +80,9 @@ public: virtual bool IsrgbSourceModified() const = 0; // tracks whether cached rgb output of demosaic has been modified + virtual void setCurrentFrame(unsigned int frameNum) = 0; + + // use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat* virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const ColorManagementParams &cmp, const RAWParams &raw) = 0; virtual eSensorType getSensorType () diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 741370813..afa791b4f 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -185,6 +185,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // raw auto CA is bypassed if no high detail is needed, so we have to compute it when high detail is needed if ( (todo & M_PREPROC) || (!highDetailPreprocessComputed && highDetailNeeded)) { + imgsrc->setCurrentFrame(params.raw.bayersensor.imageNum); imgsrc->preprocess( rp, params.lensProf, params.coarse ); imgsrc->getRAWHistogram( histRedRaw, histGreenRaw, histBlueRaw ); diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index 0ec9f548c..85d6a00b5 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -398,7 +398,7 @@ skip_block: } } -int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, ProgressListener *plistener, double progressRange) +int RawImage::loadRaw (bool loadData, unsigned int &imageNum, bool closeFile, ProgressListener *plistener, double progressRange) { ifname = filename.c_str(); image = nullptr; @@ -427,8 +427,10 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro identify (); + std::cout << "israw : " << is_raw << std::endl; // in case dcraw didn't handle the above mentioned case... shot_select = std::min(shot_select, std::max(is_raw, 1u) - 1); + imageNum = shot_select; if (!is_raw) { fclose(ifp); diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index 4f39ac855..4080702a6 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -106,7 +106,7 @@ public: explicit RawImage( const Glib::ustring &name ); ~RawImage(); - int loadRaw (bool loadData = true, unsigned int imageNum = 0, bool closeFile = true, ProgressListener *plistener = nullptr, double progressRange = 1.0); + int loadRaw (bool loadData, unsigned int &imageNum, bool closeFile = true, ProgressListener *plistener = nullptr, double progressRange = 1.0); void get_colorsCoeff( float* pre_mul_, float* scale_mul_, float* cblack_, bool forceAutoWB ); void set_prefilters() { diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 737e733cd..1d30706aa 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -475,8 +475,8 @@ RawImageSource::~RawImageSource () delete idata; - if (ri) { - delete ri; + for(size_t i = 0; i < numFrames; ++i) { + delete riFrames[i]; } flushRGB(); @@ -1506,14 +1506,29 @@ int RawImageSource::load (const Glib::ustring &fname, int imageNum, bool batch) plistener->setProgress (0.0); } - ri = new RawImage(fname); - int errCode = ri->loadRaw (true, imageNum, true, plistener, 0.8); + unsigned int tempImageNum = 4; + do { + tempImageNum --; + numFrames ++; + ri = new RawImage(fname); + int errCode = ri->loadRaw (true, tempImageNum, true, plistener, 0.8); + std::cout << "imagenum : " << tempImageNum << " width : " << ri->get_width() << " height : " << ri->get_height() << std::endl; - if (errCode) { - return errCode; + if (errCode) { + return errCode; + } + riFrames[tempImageNum] = ri; + ri->compress_image(); + ri->set_prefilters(); + } while (tempImageNum); + + if(numFrames > 1 ) { + if(riFrames[0]->get_width() != riFrames[1]->get_width() || riFrames[0]->get_height() != riFrames[1]->get_height()) { + numFrames = 1; + } } - ri->compress_image(); +std::cout << "numframes : " << numFrames << std::endl; if (plistener) { plistener->setProgress (0.9); @@ -1627,7 +1642,6 @@ int RawImageSource::load (const Glib::ustring &fname, int imageNum, bool batch) }*/ - ri->set_prefilters(); //Load complete Exif informations RawMetaDataLocation rml; diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index cec3d78b7..79d89be88 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -25,7 +25,7 @@ #include "curves.h" #include "color.h" #include "iimage.h" - +#include #define HR_SCALE 2 namespace rtengine @@ -71,6 +71,9 @@ protected: bool rgbSourceModified; RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc. + RawImage* riFrames[16] = {nullptr}; + unsigned int currFrame = 0; + unsigned int numFrames = 0; // to accelerate CIELAB conversion: double lc00, lc01, lc02, lc10, lc11, lc12, lc20, lc21, lc22; @@ -195,7 +198,11 @@ public: static void HLRecovery_blend (float* rin, float* gin, float* bin, int width, float maxval, float* hlmax); static void init (); static void cleanup (); - + void setCurrentFrame(unsigned int frameNum) { + currFrame = std::min(numFrames - 1, frameNum); + ri = riFrames[currFrame]; + std::cout << "currFrame : " << currFrame << std::endl; + } protected: typedef unsigned short ushort; void processFalseColorCorrection (Imagefloat* i, const int steps); diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 8325ac17d..33e988674 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -470,7 +470,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = { RETINEX, // EvRetinexgaintransmission RETINEX, // EvLskal OUTPUTPROFILE, // EvOBPCompens - DEMOSAIC // EvRawImageNum + DARKFRAME // EvRawImageNum }; diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 6321f0dcf..9b71d2156 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -156,7 +156,8 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, bool rotate, bool inspectorMode) { RawImage *ri = new RawImage(fname); - int r = ri->loadRaw(false, 0, false); + unsigned int imageNum = 0; + int r = ri->loadRaw(false, imageNum, false); if( r ) { delete ri; @@ -270,7 +271,9 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname) rml.ciffLength = -1; RawImage ri(fname); - int r = ri.loadRaw(false); + unsigned int imageNum = 0; + + int r = ri.loadRaw(false, imageNum); if( !r ) { rml.exifBase = ri.get_exifBase(); @@ -284,7 +287,9 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname) Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum) { RawImage *ri = new RawImage (fname); - int r = ri->loadRaw(1, imageNum, 0); + unsigned int tempImageNum = 0; + + int r = ri->loadRaw(1, tempImageNum, 0); if( r ) { delete ri; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 9e7d5f58f..250875b6a 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -102,6 +102,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p ImProcFunctions ipf (¶ms, true); PreviewProps pp (0, 0, fw, fh, 1); + imgsrc->setCurrentFrame(params.raw.bayersensor.imageNum); imgsrc->preprocess( params.raw, params.lensProf, params.coarse, params.dirpyrDenoise.enabled); if (params.toneCurve.autoexp) {// this enabled HLRecovery diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 38b6952b0..733a44c42 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -95,6 +95,8 @@ public: { return rgbSourceModified; } + void setCurrentFrame(unsigned int frameNum) {} + }; } #endif