22 #include <libopenraw/types.h>
25 #include "exception.h"
27 #include "io/stream.h"
28 #include "ifdfilecontainer.h"
31 using namespace Debug;
37 bool IFDDir::isPrimary::operator()(
const Ref &dir)
40 return dir->getValue(IFD::EXIF_TAG_NEW_SUBFILE_TYPE, subtype)
44 bool IFDDir::isThumbnail::operator()(
const Ref &dir)
47 return dir->getValue(IFD::EXIF_TAG_NEW_SUBFILE_TYPE, subtype)
51 IFDDir::IFDDir(off_t _offset, IFDFileContainer & _container)
52 : m_offset(_offset), m_container(_container),
65 Trace(DEBUG1) <<
"IFDDir::load() m_offset =" << m_offset <<
"\n";
66 int16_t numEntries = 0;
69 file->
seek(m_offset, SEEK_SET);
72 for(int16_t i = 0; i < numEntries; i++) {
82 count, data, m_container));
83 m_entries[id] = entry;
91 std::map<uint16_t, IFDEntry::Ref>::const_iterator iter;
92 iter = m_entries.find(
id);
93 if (iter != m_entries.end()) {
102 bool success =
false;
108 case IFD::EXIF_FORMAT_LONG:
112 case IFD::EXIF_FORMAT_SHORT:
120 catch(
const std::exception & ex) {
121 Trace(ERROR) <<
"Exception raised " << ex.what()
122 <<
" fetch integer value for " <<
id <<
"\n";
134 if(m_entries.size() == 0) {
135 file->
seek(m_offset, SEEK_SET);
137 Trace(DEBUG1) <<
"numEntries =" << numEntries
138 <<
" shifting " << (numEntries * 12) + 2
142 numEntries = m_entries.size();
145 file->
seek(m_offset + (numEntries * 12) + 2, SEEK_SET);
156 std::vector<uint32_t> offsets;
160 e->getArray(offsets);
161 if (idx >= offsets.size()) {
162 Ref ref(
new IFDDir(offsets[idx], m_container));
167 catch(
const std::exception &ex) {
168 Trace(ERROR) <<
"Exception " << ex.what() <<
"\n";
171 return Ref(static_cast<IFDDir*>(NULL));
177 bool success =
false;
178 std::vector<uint32_t> offsets;
182 e->getArray(offsets);
183 for (std::vector<uint32_t>::const_iterator iter = offsets.begin();
184 iter != offsets.end(); iter++) {
185 Ref ifd(
new IFDDir(*iter, m_container));
191 catch(
const std::exception &ex) {
192 Trace(ERROR) <<
"Exception " << ex.what() <<
"\n";
203 bool success =
false;
204 uint32_t val_offset = 0;
205 success =
getValue(IFD::EXIF_TAG_EXIF_IFD_POINTER, val_offset);
207 Trace(DEBUG1) <<
"Exif IFD offset (uncorrected) = " << val_offset
209 val_offset += m_container.exifOffsetCorrection();
210 Trace(DEBUG1) <<
"Exif IFD offset = " << val_offset <<
"\n";
211 Ref ref(
new IFDDir(val_offset, m_container));
216 Trace(DEBUG1) <<
"Exif IFD offset not found.\n";
218 return Ref(static_cast<IFDDir*>(NULL));
static T get(IFDEntry &e, uint32_t idx=0, bool ignore_type=false)
bool getIntegerValue(uint16_t id, uint32_t &v)
bool readInt16(IO::Stream *f, int16_t &v)
bool readUInt16(IO::Stream *f, uint16_t &v)
bool getSubIFDs(std::vector< IFDDir::Ref > &ifds)
Ref getSubIFD(uint32_t idx=0) const
virtual int seek(off_t offset, int whence)=0
virtual int read(void *buf, size_t count)=0
bool getValue(uint16_t id, T &v) const
bool readInt32(IO::Stream *f, int32_t &v)
base virtual class for IO
boost::shared_ptr< IFDEntry > Ref