00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MRW_CONTAINER_H__
00024 #define _MRW_CONTAINER_H__
00025
00026 #include <string>
00027 #include <boost/config.hpp>
00028 #include <boost/shared_ptr.hpp>
00029
00030 #include "ifdfilecontainer.h"
00031
00032 namespace OpenRaw {
00033 namespace Internals {
00034
00035 class IOFile;
00036
00037 class MRWContainer;
00038
00039 namespace MRW {
00040
00041 const int DataBlockHeaderLength = 8;
00042
00045 class DataBlock
00046 {
00047 public:
00048 typedef boost::shared_ptr<DataBlock> Ref;
00049 typedef std::vector<Ref> RefVec;
00050
00055 DataBlock(off_t start, MRWContainer * container);
00056
00059 off_t offset()
00060 {
00061 return m_start;
00062 }
00063
00066 off_t length()
00067 {
00068 return m_length;
00069 }
00070
00073 std::string name()
00074 {
00075 char id[4];
00076 id[0] = m_name[1];
00077 id[1] = m_name[2];
00078 id[2] = m_name[3];
00079 id[3] = 0;
00080 return std::string(id);
00081 }
00082
00085 int8_t int8_val (off_t offset);
00086
00089 uint8_t uint8_val (off_t offset);
00090
00093 uint16_t uint16_val (off_t offset);
00094 bool loaded() const
00095 {
00096 return m_loaded;
00097 }
00098
00099 private:
00100
00101 DataBlock(const DataBlock &);
00102 DataBlock & operator=(const DataBlock &);
00103
00104 off_t m_start;
00105 char m_name[4];
00106 int32_t m_length;
00107 MRWContainer *m_container;
00108 bool m_loaded;
00109 };
00110
00111
00112
00113 enum {
00114 PRD_VERSION = 0,
00115 PRD_SENSOR_LENGTH = 8,
00116 PRD_SENSOR_WIDTH = 10,
00117 PRD_IMAGE_LENGTH = 12,
00118 PRD_IMAGE_WIDTH = 14,
00119 PRD_DATA_SIZE = 16,
00120 PRD_PIXEL_SIZE = 17,
00121 PRD_STORAGE_TYPE = 18,
00122 PRD_UNKNOWN1 = 19,
00123 PRD_UNKNOWN2 = 20,
00124 PRD_BAYER_PATTERN = 22
00125 };
00126
00127 enum {
00128 STORAGE_TYPE_UNPACKED = 0x52,
00129 STORAGE_TYPE_PACKED = 0x59
00130 };
00131
00132 enum {
00133 BAYER_PATTERN_RGGB = 0x0001,
00134 BAYER_PATTERN_GBRG = 0x0004
00135 };
00136
00137
00138
00139 enum {
00140 WBG_DENOMINATOR_R = 0,
00141 WBG_DENOMINATOR_G1 = 1,
00142 WBG_DENOMINATOR_G2 = 2,
00143 WBG_DENOMINATOR_B = 3,
00144 WBG_NOMINATOR_R = 4,
00145 WBG_NOMINATOR_G1 = 6,
00146 WBG_NOMINATOR_G2 = 8,
00147 WBG_NOMINATOR_B = 10
00148 };
00149
00150
00151
00152 enum {
00153 RIF_UNKNOWN1 = 0,
00154 RIF_SATURATION = 1,
00155 RIF_CONTRAST = 2,
00156 RIF_SHARPNESS = 3,
00157 RIF_WHITE_BALANCE = 4,
00158 RIF_SUBJECT_PROGRAM = 5,
00159 RIF_FILM_SPEED = 6,
00160 RIF_COLOR_MODE = 7,
00161 RIF_COLOR_FILTER = 56,
00162 RIF_BANDW_FILTER = 57
00163 };
00164
00165 enum {
00166 WHITE_BALANCE_AUTO = 0,
00167 WHITE_BALANCE_DAYLIGHT = 1,
00168 WHITE_BALANCE_CLOUDY = 2,
00169 WHITE_BALANCE_TUNGSTEN = 3,
00170 WHITE_BALANCE_FLUORESCENT = 4
00171 };
00172
00173 enum {
00174 SUBJECT_PROGRAM_NONE = 0,
00175 SUBJECT_PROGRAM_PORTRAIT = 1,
00176 SUBJECT_PROGRAM_TEXT = 2,
00177 SUBJECT_PROGRAM_NIGHT_PORTRAIT = 3,
00178 SUBJECT_PROGRAM_SUNSET = 4,
00179 SUBJECT_PROGRAM_SPORTS_ACTION = 5
00180 };
00181
00182 enum {
00183 COLOR_MODE_NORMAL = 0,
00184 COLOR_MODE_BLACK_AND_WHITE = 1,
00185 COLOR_MODE_VIVID_COLOR = 2,
00186 COLOR_MODE_SOLARIZATION = 3,
00187 COLOR_MODE_ADOBE_RGB = 4
00188 };
00189
00190
00191
00192
00193 enum {
00194 IFDTAG_WIDTH = 0x0100,
00195 IFDTAG_HEIGHT = 0x0101,
00196 IFDTAG_COMPRESS = 0x0103,
00197 IFDTAG_DCFVER = 0x010E,
00198 IFDTAG_MANUF = 0x010F,
00199 IFDTAG_CAMERA = 0x0110,
00200 IFDTAG_FIRMWARE = 0x0131,
00201 IFDTAG_DATETIME = 0x0132,
00202 IFDTAG_EXIFOFFSET = 0x8769,
00203 IFDTAG_PIMOFFSET = 0xC4A5
00204 };
00205
00206
00207 enum {
00208 MRWTAG_THUMBNAIL = 0x0081,
00209 MRWTAG_THUMBNAIL_OFFSET = 0x0088,
00210 MRWTAG_THUMBNAIL_LENGTH = 0x0089
00211 };
00212
00213
00214 }
00215
00218 class MRWContainer
00219 : public IFDFileContainer
00220 {
00221 public:
00222 MRWContainer(IO::Stream *file, off_t offset = 0);
00224 virtual ~MRWContainer();
00225
00229 virtual IFDFileContainer::EndianType
00230 isMagicHeader(const char *p, int len);
00231
00232
00233
00234 MRW::DataBlock::Ref mrm;
00235 MRW::DataBlock::Ref prd;
00236 MRW::DataBlock::Ref ttw;
00237 MRW::DataBlock::Ref wbg;
00238 MRW::DataBlock::Ref rif;
00239
00242 off_t pixelDataOffset()
00243 {
00244
00245 return mrm->offset() + MRW::DataBlockHeaderLength + mrm->length();
00246 }
00247 protected:
00248 virtual bool locateDirsPreHook();
00249 private:
00250 std::string m_version;
00251
00252
00253 MRWContainer(const MRWContainer &);
00254 MRWContainer & operator=(const MRWContainer &);
00255 };
00256
00257
00258 }
00259 }
00260
00261 #endif