|
|
@ -20,14 +20,14 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
File: ifd.cpp
|
|
|
|
File: ifd.cpp
|
|
|
|
Version: $Name: $ $Revision: 1.13 $
|
|
|
|
Version: $Name: $ $Revision: 1.14 $
|
|
|
|
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
|
|
|
|
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
|
|
|
|
History: 26-Jan-04, ahu: created
|
|
|
|
History: 26-Jan-04, ahu: created
|
|
|
|
11-Feb-04, ahu: isolated as a component
|
|
|
|
11-Feb-04, ahu: isolated as a component
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// *****************************************************************************
|
|
|
|
// *****************************************************************************
|
|
|
|
#include "rcsid.hpp"
|
|
|
|
#include "rcsid.hpp"
|
|
|
|
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.13 $ $RCSfile: ifd.cpp,v $")
|
|
|
|
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.14 $ $RCSfile: ifd.cpp,v $")
|
|
|
|
|
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
// *****************************************************************************
|
|
|
|
// included header files
|
|
|
|
// included header files
|
|
|
@ -156,18 +156,41 @@ namespace Exif {
|
|
|
|
} // Entry::component
|
|
|
|
} // Entry::component
|
|
|
|
|
|
|
|
|
|
|
|
Ifd::Ifd(IfdId ifdId)
|
|
|
|
Ifd::Ifd(IfdId ifdId)
|
|
|
|
: alloc_(true), ifdId_(ifdId), offset_(0), next_(0)
|
|
|
|
: alloc_(true), ifdId_(ifdId), offset_(0), pNext_(0), next_(0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pNext_ = new char[4];
|
|
|
|
|
|
|
|
memset(pNext_, 0x0, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ifd::Ifd(IfdId ifdId, uint32 offset)
|
|
|
|
Ifd::Ifd(IfdId ifdId, uint32 offset)
|
|
|
|
: alloc_(true), ifdId_(ifdId), offset_(offset), next_(0)
|
|
|
|
: alloc_(true), ifdId_(ifdId), offset_(offset), pNext_(0), next_(0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
pNext_ = new char[4];
|
|
|
|
|
|
|
|
memset(pNext_, 0x0, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ifd::Ifd(IfdId ifdId, uint32 offset, bool alloc)
|
|
|
|
Ifd::Ifd(IfdId ifdId, uint32 offset, bool alloc)
|
|
|
|
: alloc_(alloc), ifdId_(ifdId), offset_(offset), next_(0)
|
|
|
|
: alloc_(alloc), ifdId_(ifdId), offset_(offset), pNext_(0), next_(0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (alloc_) {
|
|
|
|
|
|
|
|
pNext_ = new char[4];
|
|
|
|
|
|
|
|
memset(pNext_, 0x0, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ifd::~Ifd()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (alloc_) delete[] pNext_;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ifd::Ifd(const Ifd& rhs)
|
|
|
|
|
|
|
|
: alloc_(rhs.alloc_), entries_(rhs.entries_), ifdId_(rhs.ifdId_),
|
|
|
|
|
|
|
|
offset_(rhs.offset_), pNext_(rhs.pNext_), next_(rhs.next_)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (alloc_ && rhs.pNext_) {
|
|
|
|
|
|
|
|
pNext_ = new char[4];
|
|
|
|
|
|
|
|
memcpy(pNext_, rhs.pNext_, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ifd::read(const char* buf, ByteOrder byteOrder, long offset)
|
|
|
|
int Ifd::read(const char* buf, ByteOrder byteOrder, long offset)
|
|
|
@ -190,6 +213,12 @@ namespace Exif {
|
|
|
|
preEntries.push_back(pe);
|
|
|
|
preEntries.push_back(pe);
|
|
|
|
o += 12;
|
|
|
|
o += 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alloc_) {
|
|
|
|
|
|
|
|
memcpy(pNext_, buf + o, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
pNext_ = const_cast<char*>(buf + o);
|
|
|
|
|
|
|
|
}
|
|
|
|
next_ = getULong(buf+o, byteOrder);
|
|
|
|
next_ = getULong(buf+o, byteOrder);
|
|
|
|
|
|
|
|
|
|
|
|
// Guess the offset of the IFD, if it was not given. The guess is based
|
|
|
|
// Guess the offset of the IFD, if it was not given. The guess is based
|
|
|
@ -304,7 +333,13 @@ namespace Exif {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add the offset to the next IFD to the data buffer
|
|
|
|
// Add the offset to the next IFD to the data buffer
|
|
|
|
o += ul2Data(buf + o, next_, byteOrder);
|
|
|
|
if (pNext_) {
|
|
|
|
|
|
|
|
memcpy(buf + o, pNext_, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
memset(buf + o, 0x0, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
o += 4;
|
|
|
|
|
|
|
|
|
|
|
|
// Add the data of all IFD entries to the data buffer
|
|
|
|
// Add the data of all IFD entries to the data buffer
|
|
|
|
for (i = b; i != e; ++i) {
|
|
|
|
for (i = b; i != e; ++i) {
|
|
|
@ -320,10 +355,22 @@ namespace Exif {
|
|
|
|
void Ifd::clear()
|
|
|
|
void Ifd::clear()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
entries_.clear();
|
|
|
|
entries_.clear();
|
|
|
|
next_ = 0;
|
|
|
|
if (alloc_) {
|
|
|
|
|
|
|
|
memset(pNext_, 0x0, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
pNext_ = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
offset_ = 0;
|
|
|
|
offset_ = 0;
|
|
|
|
} // Ifd::clear
|
|
|
|
} // Ifd::clear
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Ifd::setNext(uint32 next, ByteOrder byteOrder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(pNext_);
|
|
|
|
|
|
|
|
ul2Data(pNext_, next, byteOrder);
|
|
|
|
|
|
|
|
next_ = next;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Ifd::add(const Entry& entry)
|
|
|
|
void Ifd::add(const Entry& entry)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(alloc_ == entry.alloc());
|
|
|
|
assert(alloc_ == entry.alloc());
|
|
|
@ -407,7 +454,7 @@ namespace Exif {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
os << prefix << "Next IFD: 0x"
|
|
|
|
os << prefix << "Next IFD: 0x"
|
|
|
|
<< std::setw(8) << std::setfill('0') << std::hex
|
|
|
|
<< std::setw(8) << std::setfill('0') << std::hex
|
|
|
|
<< std::right << next_ << "\n";
|
|
|
|
<< std::right << next() << "\n";
|
|
|
|
// Print data of IFD entries
|
|
|
|
// Print data of IFD entries
|
|
|
|
for (i = b; i != e; ++i) {
|
|
|
|
for (i = b; i != e; ++i) {
|
|
|
|
if (i->size() > 4) {
|
|
|
|
if (i->size() > 4) {
|
|
|
|