1 /*
2  *  This file is part of RawTherapee.
3  *
4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5  *
6  *  RawTherapee is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  RawTherapee is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 #pragma once
20 
21 #include <glibmm/ustring.h>
22 
23 #include "options.h"
24 
25 #include "../rtengine/imageformat.h"
26 #include "../rtengine/rtengine.h"
27 
28 class CacheImageData :
29     public rtengine::FramesMetaData
30 {
31 public:
32 
33     // basic information
34     Glib::ustring  md5;
35     Glib::ustring  version;
36     bool  supported;
37     ThFileType  format;
38     char  rankOld; // old implementation of rank
39     bool  inTrashOld; // old implementation of inTrash
40     bool  recentlySaved;
41 
42     // time/date info
43     bool  timeValid;
44     short year;
45     char  month;
46     char  day;
47     char  hour;
48     char  min;
49     char  sec;
50     // exif info
51     bool  exifValid;
52     unsigned short frameCount;
53     double fnumber;
54     double shutter;
55     double focalLen, focalLen35mm;
56     float focusDist;
57     unsigned iso;
58     int rating;
59     bool isHDR;
60     bool isPixelShift;
61     int sensortype;
62     rtengine::IIO_Sample_Format sampleFormat;
63     Glib::ustring lens;
64     Glib::ustring camMake;
65     Glib::ustring camModel;
66     Glib::ustring filetype;
67     Glib::ustring expcomp;
68 
69     // store a copy of the autoWB's multipliers computed in Thumbnail::_generateThumbnailImage
70     // they are not stored in the cache file by this class, but by rtengine::Thumbnail
71     // -1 = Unknown
72     double redAWBMul, greenAWBMul, blueAWBMul;
73 
74     // additional info on raw images
75     int   rotate;
76     int   thumbImgType;
77 
78     enum {
79         FULL_THUMBNAIL = 0,  // was the thumbnail generated from whole file
80         QUICK_THUMBNAIL = 1  // was the thumbnail generated from embedded jpeg
81     };
82 
83     CacheImageData ();
84 
85     int load (const Glib::ustring& fname);
86     int save (const Glib::ustring& fname);
87 
88     //-------------------------------------------------------------------------
89     // FramesMetaData interface
90     //-------------------------------------------------------------------------
91 
getRootCount()92     unsigned int getRootCount () const override { return -1; }
getFrameCount()93     unsigned int getFrameCount () const override { return frameCount; }
94     bool hasExif (unsigned int frame = 0) const override  { return false; }
95     rtexif::TagDirectory* getRootExifData (unsigned int root = 0) const override { return nullptr; }
96     rtexif::TagDirectory* getFrameExifData (unsigned int frame = 0) const override { return nullptr; }
getBestExifData(rtengine::ImageSource * imgSource,rtengine::procparams::RAWParams * rawParams)97     rtexif::TagDirectory* getBestExifData (rtengine::ImageSource *imgSource, rtengine::procparams::RAWParams *rawParams) const override { return nullptr; }
98     bool hasIPTC (unsigned int frame = 0) const override { return false; }
99     rtengine::procparams::IPTCPairs getIPTCData (unsigned int frame = 0) const override;
100     tm getDateTime (unsigned int frame = 0) const override { return tm{}; }
101     time_t getDateTimeAsTS(unsigned int frame = 0) const override { return time_t(-1); }
102     int getISOSpeed (unsigned int frame = 0) const override { return iso; }
103     double getFNumber  (unsigned int frame = 0) const override { return fnumber; }
104     double getFocalLen (unsigned int frame = 0) const override { return focalLen; }
105     double getFocalLen35mm (unsigned int frame = 0) const override { return focalLen35mm; }
106     float getFocusDist (unsigned int frame = 0) const override { return focusDist; }
107     double getShutterSpeed (unsigned int frame = 0) const override { return shutter; }
108     double getExpComp (unsigned int frame = 0) const override { return atof(expcomp.c_str()); }
109     std::string getMake     (unsigned int frame = 0) const override { return camMake; }
110     std::string getModel    (unsigned int frame = 0) const override { return camModel; }
111     std::string getLens     (unsigned int frame = 0) const override { return lens; }
112     std::string getOrientation (unsigned int frame = 0) const override { return ""; } // TODO
113     int getRating (unsigned int frame = 0) const override { return rating; } // FIXME-piotr : missing rating
getPixelShift()114     bool getPixelShift () const override { return isPixelShift; }
115     bool getHDR (unsigned int frame = 0) const override { return isHDR; }
getImageType(unsigned int frame)116     std::string getImageType (unsigned int frame) const override { return isPixelShift ? "PS" : isHDR ? "HDR" : "STD"; }
117     rtengine::IIOSampleFormat getSampleFormat (unsigned int frame = 0) const override { return sampleFormat; }
118 };
119