22 #include <sys/types.h>
27 #include <libopenraw/debug.h>
30 #include "ifdfilecontainer.hpp"
32 using namespace Debug;
41 , m_exif_offset_correction(0)
59 if ((p[0] == 0x49) && (p[1] == 0x49) && (p[2] == 0x2a) && (p[3] == 0x00)) {
61 }
else if ((p[0] == 0x4d) && (p[1] == 0x4d) && (p[2] == 0x00) &&
70 if (m_dirs.size() == 0) {
72 bool ret = _locateDirs();
82 if (m_dirs.size() == 0) {
102 if (dir > (
int)m_dirs.size()) {
106 m_current_dir = m_dirs[dir];
107 m_current_dir->load();
108 return m_current_dir;
114 LOGDBG1(
"getDirectoryDataSize()\n");
115 off_t dir_offset = m_current_dir->offset();
117 LOGDBG1(
"offset = %lld m_numTags = %d\n", (
long long int)dir_offset,
118 m_current_dir->numTags());
119 off_t begin = dir_offset + 2 + (m_current_dir->numTags() * 12);
121 LOGDBG1(
"begin = %lld\n", (
long long int)begin);
123 m_file->seek(begin, SEEK_SET);
127 LOGDBG1(
"nextIFD = %d\n", nextIFD);
132 return nextIFD - begin;
140 bool IfdFileContainer::_locateDirs(
void)
145 LOGDBG1(
"_locateDirs()\n");
160 if (dir_offset != 0) {
161 LOGDBG1(
"push offset =0x%x\n", dir_offset);
167 m_dirs.push_back(dir);
169 dir_offset = dir->nextIFD();
171 }
while (dir_offset != 0);
173 LOGDBG1(
"# dir found = %lu\n", (LSIZE)m_dirs.size());
174 return (m_dirs.size() != 0);
std::shared_ptr< Stream > Ptr
std::shared_ptr< IfdDir > Ref
Shared ptr of an IfdDir.
std::vector< IfdDir::Ref > & directories()
Get the directories, loading them if necessary.
virtual EndianType isMagicHeader(const char *p, int len)
Check the IFD magic header.
IfdDir::Ref setDirectory(int dir)
Set the current directory.
size_t getDirectoryDataSize()
get the extra data size chunk associated to the current image directory
virtual ~IfdFileContainer()
Destructor.
int countDirectories(void)
Count the number of image file directories, not including EXIF, GPS and INTEROP.
virtual bool locateDirsPreHook()
hook to be called at the start of _locateDirs()
Generic interface for the RAW file container.
IO::Stream::Ptr m_file
The file handle.
EndianType
Define the endian of the container.
Option< int32_t > readInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an int32 following the m_endian set.
off_t m_offset
The offset from the beginning of the file.
Global namespace for libopenraw.