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
00095 std::string string_val(off_t offset);
00096
00097 bool loaded() const
00098 {
00099 return m_loaded;
00100 }
00101
00102 private:
00103
00104 DataBlock(const DataBlock &);
00105 DataBlock & operator=(const DataBlock &);
00106
00107 off_t m_start;
00108 char m_name[4];
00109 int32_t m_length;
00110 MRWContainer *m_container;
00111 bool m_loaded;
00112 };
00113
00114
00115
00116 enum {
00117 PRD_VERSION = 0,
00118 PRD_SENSOR_LENGTH = 8,
00119 PRD_SENSOR_WIDTH = 10,
00120 PRD_IMAGE_LENGTH = 12,
00121 PRD_IMAGE_WIDTH = 14,
00122 PRD_DATA_SIZE = 16,
00123 PRD_PIXEL_SIZE = 17,
00124 PRD_STORAGE_TYPE = 18,
00125 PRD_UNKNOWN1 = 19,
00126 PRD_UNKNOWN2 = 20,
00127 PRD_BAYER_PATTERN = 22
00128 };
00129
00130 enum {
00131 STORAGE_TYPE_UNPACKED = 0x52,
00132 STORAGE_TYPE_PACKED = 0x59
00133 };
00134
00135 enum {
00136 BAYER_PATTERN_RGGB = 0x0001,
00137 BAYER_PATTERN_GBRG = 0x0004
00138 };
00139
00140
00141
00142 enum {
00143 WBG_DENOMINATOR_R = 0,
00144 WBG_DENOMINATOR_G1 = 1,
00145 WBG_DENOMINATOR_G2 = 2,
00146 WBG_DENOMINATOR_B = 3,
00147 WBG_NOMINATOR_R = 4,
00148 WBG_NOMINATOR_G1 = 6,
00149 WBG_NOMINATOR_G2 = 8,
00150 WBG_NOMINATOR_B = 10
00151 };
00152
00153
00154
00155 enum {
00156 RIF_UNKNOWN1 = 0,
00157 RIF_SATURATION = 1,
00158 RIF_CONTRAST = 2,
00159 RIF_SHARPNESS = 3,
00160 RIF_WHITE_BALANCE = 4,
00161 RIF_SUBJECT_PROGRAM = 5,
00162 RIF_FILM_SPEED = 6,
00163 RIF_COLOR_MODE = 7,
00164 RIF_COLOR_FILTER = 56,
00165 RIF_BANDW_FILTER = 57
00166 };
00167
00168 enum {
00169 WHITE_BALANCE_AUTO = 0,
00170 WHITE_BALANCE_DAYLIGHT = 1,
00171 WHITE_BALANCE_CLOUDY = 2,
00172 WHITE_BALANCE_TUNGSTEN = 3,
00173 WHITE_BALANCE_FLUORESCENT = 4
00174 };
00175
00176 enum {
00177 SUBJECT_PROGRAM_NONE = 0,
00178 SUBJECT_PROGRAM_PORTRAIT = 1,
00179 SUBJECT_PROGRAM_TEXT = 2,
00180 SUBJECT_PROGRAM_NIGHT_PORTRAIT = 3,
00181 SUBJECT_PROGRAM_SUNSET = 4,
00182 SUBJECT_PROGRAM_SPORTS_ACTION = 5
00183 };
00184
00185 enum {
00186 COLOR_MODE_NORMAL = 0,
00187 COLOR_MODE_BLACK_AND_WHITE = 1,
00188 COLOR_MODE_VIVID_COLOR = 2,
00189 COLOR_MODE_SOLARIZATION = 3,
00190 COLOR_MODE_ADOBE_RGB = 4
00191 };
00192
00193
00194
00195
00196 enum {
00197 IFDTAG_WIDTH = 0x0100,
00198 IFDTAG_HEIGHT = 0x0101,
00199 IFDTAG_COMPRESS = 0x0103,
00200 IFDTAG_DCFVER = 0x010E,
00201 IFDTAG_MANUF = 0x010F,
00202 IFDTAG_CAMERA = 0x0110,
00203 IFDTAG_FIRMWARE = 0x0131,
00204 IFDTAG_DATETIME = 0x0132,
00205 IFDTAG_EXIFOFFSET = 0x8769,
00206 IFDTAG_PIMOFFSET = 0xC4A5
00207 };
00208
00209
00210 enum {
00211 MRWTAG_THUMBNAIL = 0x0081,
00212 MRWTAG_THUMBNAIL_OFFSET = 0x0088,
00213 MRWTAG_THUMBNAIL_LENGTH = 0x0089
00214 };
00215
00216
00217 }
00218
00221 class MRWContainer
00222 : public IFDFileContainer
00223 {
00224 public:
00225 MRWContainer(IO::Stream *file, off_t offset = 0);
00227 virtual ~MRWContainer();
00228
00232 virtual IFDFileContainer::EndianType
00233 isMagicHeader(const char *p, int len);
00234
00235
00236
00237 MRW::DataBlock::Ref mrm;
00238 MRW::DataBlock::Ref prd;
00239 MRW::DataBlock::Ref ttw;
00240 MRW::DataBlock::Ref wbg;
00241 MRW::DataBlock::Ref rif;
00242
00245 off_t pixelDataOffset()
00246 {
00247
00248 return mrm->offset() + MRW::DataBlockHeaderLength + mrm->length();
00249 }
00250 protected:
00251 virtual bool locateDirsPreHook();
00252 private:
00253 std::string m_version;
00254
00255
00256 MRWContainer(const MRWContainer &);
00257 MRWContainer & operator=(const MRWContainer &);
00258 };
00259
00260
00261 }
00262 }
00263
00264 #endif