ciffcontainer.h

00001 /*
00002  * libopenraw - ciffcontainer.h
00003  *
00004  * Copyright (C) 2006 Hubert Figuiere
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00027 #ifndef _CIFFCONTAINER_H_
00028 #define _CIFFCONTAINER_H_
00029 
00030 #include <vector>
00031 #include <boost/shared_ptr.hpp>
00032 
00033 #include "rawcontainer.h"
00034 
00035 namespace OpenRaw {
00036     namespace Internals {
00037 
00038         class CIFFContainer;
00039 
00040         namespace CIFF {
00041             
00043             enum {
00044                 STORAGELOC_MASK = 0xc000, 
00045                 FORMAT_MASK = 0x3800,     
00046                 TAGCODE_MASK = 0x3fff  
00048             };
00053             enum {
00054                 TAG_NULLRECORD =  0x0000,
00055                 TAG_FREEBYTES = 0x0001,
00056                 TAG_COLORINFO1 = 0x0032,
00057                 TAG_FILEDESCRIPTION = 0x0805,
00058                 TAG_RAWMAKEMODEL = 0x080a,
00059                 TAG_FIRMWAREVERSION = 0x080b,
00060                 TAG_COMPONENTVERSION = 0x080c,
00061                 TAG_ROMOPERATIONMODE = 0x080d,
00062                 TAG_OWNERNAME = 0x0810,
00063                 TAG_IMAGETYPE = 0x0815,
00064                 TAG_ORIGINALFILENAME = 0x0816,
00065                 TAG_THUMBNAILFILENAME = 0x0817,
00066 
00067                 TAG_TARGETIMAGETYPE = 0x100a,
00068                 TAG_SHUTTERRELEASEMETHOD = 0x1010,
00069                 TAG_SHUTTERRELEASETIMING = 0x1011,
00070                 TAG_RELEASESETTING = 0x1016,
00071                 TAG_BASEISO = 0x101c,
00072                 TAG_FOCALLENGTH = 0x1029,  
00073                 TAG_SHOTINFO = 0x102a,
00074                 TAG_COLORINFO2 = 0x102c,
00075                 TAG_CAMERASETTINGS = 0x102d,
00076                 TAG_SENSORINFO = 0x1031,
00077                 TAG_CUSTOMFUNCTIONS = 0x1033,
00078                 TAG_PICTUREINFO = 0x1038,
00079                 TAG_WHITEBALANCETABLE = 0x10a9,
00080                 TAG_COLORSPACE = 0x10b4,  
00081 
00082                 TAG_IMAGESPEC = 0x1803,
00083                 TAG_RECORDID = 0x1804,
00084                 TAG_SELFTIMERTIME = 0x1806,
00085                 TAG_TARGETDISTANCESETTING = 0x1807,
00086                 TAG_SERIALNUMBER = 0x180b,
00087                 TAG_CAPTUREDTIME = 0x180e,
00088                 TAG_IMAGEINFO = 0x1810,
00089                 TAG_FLASHINFO = 0x1813,
00090                 TAG_MEASUREDEV = 0x1814,
00091                 TAG_FILENUMBER = 0x1817,
00092                 TAG_EXPOSUREINFO = 0x1818,
00093                 TAG_DECODERTABLE = 0x1835,
00094 
00095                 TAG_RAWIMAGEDATA = 0x2005,
00096                 TAG_JPEGIMAGE = 0x2007,
00097                 TAG_JPEGTHUMBNAIL = 0x2008,
00098 
00099                 TAG_IMAGEDESCRIPTION = 0x2804,
00100                 TAG_CAMERAOBJECT = 0x2807,
00101                 TAG_SHOOTINGRECORD = 0x3002,
00102                 TAG_MEASUREDINFO = 0x3003,
00103                 TAG_CAMERASPECIFICATION = 0x3004,
00104                 TAG_IMAGEPROPS = 0x300a,
00105                 TAG_EXIFINFORMATION = 0x300b
00106             };
00107             
00108             class Heap;
00109 
00110             class RecordEntry 
00111             {
00112             public:
00113                 typedef std::vector<RecordEntry> List;
00114 
00115                 RecordEntry();
00116 
00121                 bool readFrom(CIFFContainer *container);
00128                 size_t fetchData(Heap* heap, void* buf, size_t size);
00129 
00130                 uint16_t   typeCode;/* type code of the record */
00131                 uint32_t   length;/* record length */
00132                 uint32_t   offset;/* offset of the record in the heap*/
00133             };
00134 
00136             class Heap
00137             {
00138             public:
00139                 typedef boost::shared_ptr<Heap> Ref;
00140 
00141                 Heap(off_t start, off_t length, CIFFContainer * container);
00142 
00143                 RecordEntry::List & records();
00144                 CIFFContainer *container()
00145                     {
00146                         return m_container;
00147                     }
00148                 off_t offset()
00149                     {
00150                         return m_start;
00151                     }
00152             private:
00153                 bool _loadRecords();
00154                 
00155                 Heap(const Heap &);
00156                 Heap & operator=(const Heap &);
00157 
00158                 off_t m_start;
00159                 off_t m_length;
00160                 CIFFContainer *m_container;
00161                 RecordEntry::List m_records;
00162             };
00163 
00164 
00166             class HeapFileHeader 
00167             {
00168             public:
00169                 bool readFrom(CIFFContainer *);
00170                 char       byteOrder[2];/* 'MM' for Motorola,'II' for Intel */
00171                 uint32_t   headerLength;/* length of header (in bytes) */
00172                 char       type[4];
00173                 char       subType[4];
00174                 uint32_t   version; /* higher word: 0x0001, Lower word: 0x0002 */
00175                 //uint32_t   reserved1;
00176                 //uint32_t   reserved2;
00177                 RawContainer::EndianType endian;                
00178             };
00179         }
00180 
00184         class CIFFContainer 
00185             : public RawContainer
00186         {
00187         public:
00188             CIFFContainer(IO::Stream *file);
00189             virtual ~CIFFContainer();
00190 
00191             CIFF::Heap::Ref heap();
00192 
00193             const CIFF::HeapFileHeader & header() const
00194                 {
00195                     return m_hdr;
00196                 }
00197         private:
00198             bool _loadHeap();
00199             EndianType _readHeader();
00200 
00201             CIFFContainer(const CIFFContainer &);
00202             CIFFContainer & operator=(const CIFFContainer &);
00203 
00204             friend class CIFF::HeapFileHeader;
00205             CIFF::HeapFileHeader m_hdr;
00206             CIFF::Heap::Ref m_heap;
00207         };
00208 
00209 
00210     }
00211 }
00212 
00213 
00214 
00215 #endif

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7