TIFF parser (experimental): Added TiffIfdMakernote base class, added separate files for Olympus makernote and the makernote registry
This commit is contained in:
parent
41424cdfd4
commit
e1eedc0f26
@ -52,10 +52,10 @@ CCHDR = exv_conf.h exv_msvc.h mn.hpp rcsid.hpp tiffvisitor_tmpl.hpp
|
||||
# Add library C++ source files to this list
|
||||
CCSRC = basicio.cpp canonmn.cpp crwimage.cpp datasets.cpp error.cpp exif.cpp \
|
||||
futils.cpp fujimn.cpp ifd.cpp image.cpp imgreg.cpp iptc.cpp \
|
||||
jpgimage.cpp makernote.cpp makernote2.cpp metadatum.cpp nikonmn.cpp \
|
||||
olympusmn.cpp panasonicmn.cpp sigmamn.cpp sonymn.cpp tags.cpp \
|
||||
tiffcomposite.cpp tiffimage.cpp tiffparser.cpp tiffvisitor.cpp \
|
||||
types.cpp value.cpp
|
||||
jpgimage.cpp makernote.cpp makernote2.cpp metadatum.cpp mnreg.cpp \
|
||||
nikonmn.cpp olympusmn.cpp olympusmn2.cpp panasonicmn.cpp sigmamn.cpp \
|
||||
sonymn.cpp tags.cpp tiffcomposite.cpp tiffimage.cpp tiffparser.cpp \
|
||||
tiffvisitor.cpp types.cpp value.cpp
|
||||
|
||||
# Add library C source files to this list
|
||||
ifndef HAVE_TIMEGM
|
||||
|
||||
@ -46,89 +46,46 @@ EXIV2_RCSID("@(#) $Id$");
|
||||
|
||||
// + standard includes
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
// *****************************************************************************
|
||||
// class member definitions
|
||||
namespace Exiv2 {
|
||||
|
||||
const TiffMnRegistry TiffMnCreator::registry_[] = {
|
||||
{ "OLYMPUS", newOlympusMn }
|
||||
};
|
||||
|
||||
bool TiffMnRegistry::operator==(const TiffMnRegistry::Key& key) const
|
||||
{
|
||||
std::string make(make_);
|
||||
return make == key.make_.substr(0, make.length());
|
||||
}
|
||||
|
||||
TiffComponent* TiffMnCreator::create(uint16_t tag,
|
||||
uint16_t group,
|
||||
std::string make,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder)
|
||||
bool TiffIfdMakernote::readHeader(const byte* pData, uint32_t size)
|
||||
{
|
||||
TiffComponent* tc = 0;
|
||||
const TiffMnRegistry* tmr = find(registry_, TiffMnRegistry::Key(make));
|
||||
if (tmr) tc = tmr->newMnFct_(tag, group, pData, size, byteOrder);
|
||||
return tc;
|
||||
} // TiffMnCreator::create
|
||||
|
||||
const char* OlympusMnHeader::signature_ = "OLYMP\0\1\0";
|
||||
const uint32_t OlympusMnHeader::size_ = 8;
|
||||
|
||||
OlympusMnHeader::OlympusMnHeader()
|
||||
{
|
||||
read(reinterpret_cast<const byte*>(signature_), size_);
|
||||
return doReadHeader(pData, size);
|
||||
}
|
||||
|
||||
bool OlympusMnHeader::read(const byte* pData, uint32_t size)
|
||||
bool TiffIfdMakernote::checkHeader() const
|
||||
{
|
||||
assert (pData != 0);
|
||||
return doCheckHeader();
|
||||
}
|
||||
|
||||
if (size < size_) return false;
|
||||
|
||||
header_.alloc(size_);
|
||||
memcpy(header_.pData_, pData, header_.size_);
|
||||
return true;
|
||||
} // OlympusMnHeader::read
|
||||
|
||||
bool OlympusMnHeader::check() const
|
||||
uint32_t TiffIfdMakernote::ifdOffset() const
|
||||
{
|
||||
if ( static_cast<uint32_t>(header_.size_) < size_
|
||||
|| 0 != memcmp(header_.pData_, signature_, 5)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // OlympusMnHeader::check
|
||||
return doIfdOffset();
|
||||
}
|
||||
|
||||
void TiffOlympusMn::doAddChild(TiffComponent::AutoPtr tiffComponent)
|
||||
void TiffIfdMakernote::doAddChild(TiffComponent::AutoPtr tiffComponent)
|
||||
{
|
||||
ifd_.addChild(tiffComponent);
|
||||
}
|
||||
|
||||
void TiffOlympusMn::doAddNext(TiffComponent::AutoPtr tiffComponent)
|
||||
void TiffIfdMakernote::doAddNext(TiffComponent::AutoPtr tiffComponent)
|
||||
{
|
||||
ifd_.addNext(tiffComponent);
|
||||
}
|
||||
|
||||
void TiffOlympusMn::doAccept(TiffVisitor& visitor)
|
||||
void TiffIfdMakernote::doAccept(TiffVisitor& visitor)
|
||||
{
|
||||
visitor.visitOlympusMn(this);
|
||||
visitor.visitIfdMakernote(this);
|
||||
ifd_.accept(visitor);
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// free functions
|
||||
|
||||
TiffComponent* newOlympusMn(uint16_t tag,
|
||||
uint16_t group,
|
||||
const byte* /*pData*/,
|
||||
uint32_t /*size*/,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
return new TiffOlympusMn(tag, group);
|
||||
}
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
@ -44,35 +44,38 @@ namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
|
||||
class TiffComponent;
|
||||
template<typename CreationPolicy> class TiffReader;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
namespace Group {
|
||||
const uint16_t olympmn = 257; //!< Olympus makernote
|
||||
}
|
||||
|
||||
//! Type for a pointer to a function creating a makernote
|
||||
typedef TiffComponent* (*NewMnFct)(uint16_t tag,
|
||||
uint16_t group,
|
||||
uint16_t mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Makernote registry
|
||||
//! Makernote registry structure
|
||||
struct TiffMnRegistry {
|
||||
struct Key;
|
||||
//! Compare a TiffMnRegistry structure with a TiffMnRegistry::Key
|
||||
/*!
|
||||
@brief Compare a TiffMnRegistry structure with a TiffMnRegistry::Key
|
||||
The two are equal if TiffMnRegistry::make_ equals a substring
|
||||
of the key of the same size. E.g., registry = "OLYMPUS",
|
||||
key = "OLYMPUS OPTICAL CO.,LTD" (found in the makernote of
|
||||
the image) match.
|
||||
*/
|
||||
bool operator==(const Key& key) const;
|
||||
|
||||
// DATA
|
||||
const char* make_; //!< Camera make
|
||||
NewMnFct newMnFct_; //!< Makernote create function
|
||||
uint16_t mnGroup_; //!< Group identifier
|
||||
};
|
||||
|
||||
//! Search key for TIFF structure.
|
||||
//! Search key for Makernote registry structure.
|
||||
struct TiffMnRegistry::Key {
|
||||
//! Constructor
|
||||
Key(const std::string& make) : make_(make) {}
|
||||
@ -129,82 +132,71 @@ namespace Exiv2 {
|
||||
@brief Start of the makernote directory relative to the start of the
|
||||
header.
|
||||
*/
|
||||
virtual uint32_t offset() const =0;
|
||||
virtual uint32_t ifdOffset() const =0;
|
||||
//! Check the header, return true if ok
|
||||
virtual bool check() const =0;
|
||||
//@}
|
||||
|
||||
}; // class MnHeader
|
||||
|
||||
//! Header of an Olympus Makernote
|
||||
class OlympusMnHeader : public MnHeader {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
OlympusMnHeader();
|
||||
//! Virtual destructor.
|
||||
virtual ~OlympusMnHeader() {}
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
virtual bool read(const byte* pData,
|
||||
uint32_t size);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
virtual uint32_t size() const { return header_.size_; }
|
||||
virtual uint32_t offset() const { return size_; }
|
||||
virtual bool check() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
static const char* signature_; //!< Olympus makernote header signature
|
||||
static const uint32_t size_; //!< Size of the signature
|
||||
|
||||
}; // class OlympusMnHeader
|
||||
|
||||
/*!
|
||||
@brief Olympus Makernote
|
||||
@brief Tiff IFD Makernote. Defines the interface for all IFD makernotes.
|
||||
Contains an IFD and implements child mgmt functions to deal with
|
||||
the IFD entries.
|
||||
*/
|
||||
class TiffOlympusMn : public TiffComponent {
|
||||
template<typename CreationPolicy>
|
||||
class TiffIfdMakernote : public TiffComponent {
|
||||
template<typename CreationPolicy>
|
||||
friend class TiffReader;
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
TiffOlympusMn(uint16_t tag, uint16_t group)
|
||||
: TiffComponent(tag, group), ifd_(tag, Group::olympmn) {}
|
||||
TiffIfdMakernote(uint16_t tag, uint16_t group, uint16_t mnGroup)
|
||||
: TiffComponent(tag, group), ifd_(tag, mnGroup) {}
|
||||
//! Virtual destructor
|
||||
virtual ~TiffOlympusMn() {}
|
||||
virtual ~TiffIfdMakernote() {}
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Read the header from a data buffer, return true if successful
|
||||
bool readHeader(const byte* pData, uint32_t size);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Check the header, return true if ok
|
||||
bool checkHeader() const;
|
||||
/*!
|
||||
@brief Return the offset to the start of the Makernote IFD from
|
||||
the start of the Makernote.
|
||||
*/
|
||||
uint32_t ifdOffset() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
virtual void doAddChild(TiffComponent::AutoPtr tiffComponent);
|
||||
virtual void doAddNext(TiffComponent::AutoPtr tiffComponent);
|
||||
virtual void doAccept(TiffVisitor& visitor);
|
||||
//! Implements readHeader();
|
||||
virtual bool doReadHeader(const byte* pData, uint32_t size) =0;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Implements checkHeader()
|
||||
virtual bool doCheckHeader() const =0;
|
||||
//! Implements ifdOffset()
|
||||
virtual uint32_t doIfdOffset() const =0;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// DATA
|
||||
OlympusMnHeader header_; //!< Makernote header
|
||||
TiffDirectory ifd_; //!< Makernote IFD
|
||||
|
||||
}; // TiffOlympusMn
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
//! Function to create an Olympus makernote
|
||||
TiffComponent* newOlympusMn(uint16_t tag,
|
||||
uint16_t group,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
}; // class TiffIfdMakernote
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
|
||||
68
src/mnreg.cpp
Normal file
68
src/mnreg.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
// ***************************************************************** -*- C++ -*-
|
||||
/*
|
||||
* Copyright (C) 2005, 2006 Andreas Huggel <ahuggel@gmx.net>
|
||||
*
|
||||
* This program is part of the Exiv2 distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
/*
|
||||
File: mnreg.cpp
|
||||
Version: $Rev$
|
||||
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
|
||||
History: 15-Apr-06, ahu: created
|
||||
|
||||
*/
|
||||
// *****************************************************************************
|
||||
#include "rcsid.hpp"
|
||||
EXIV2_RCSID("@(#) $Id$");
|
||||
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
#include "makernote2.hpp"
|
||||
#include "olympusmn2.hpp"
|
||||
|
||||
// + standard includes
|
||||
|
||||
// *****************************************************************************
|
||||
// class member definitions
|
||||
namespace Exiv2 {
|
||||
|
||||
const TiffMnRegistry TiffMnCreator::registry_[] = {
|
||||
{ "OLYMPUS", newOlympusMn, Group::olympmn }
|
||||
};
|
||||
|
||||
|
||||
// The find template needs to be in the same compilation unit as the array
|
||||
TiffComponent* TiffMnCreator::create(uint16_t tag,
|
||||
uint16_t group,
|
||||
std::string make,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder)
|
||||
{
|
||||
TiffComponent* tc = 0;
|
||||
const TiffMnRegistry* tmr = find(registry_, TiffMnRegistry::Key(make));
|
||||
if (tmr) tc = tmr->newMnFct_(tag,
|
||||
group,
|
||||
tmr->mnGroup_,
|
||||
pData,
|
||||
size,
|
||||
byteOrder);
|
||||
return tc;
|
||||
} // TiffMnCreator::create
|
||||
|
||||
|
||||
} // namespace Exiv2
|
||||
111
src/olympusmn2.cpp
Normal file
111
src/olympusmn2.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
// ***************************************************************** -*- C++ -*-
|
||||
/*
|
||||
* Copyright (C) 2006 Andreas Huggel <ahuggel@gmx.net>
|
||||
*
|
||||
* This program is part of the Exiv2 distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
/*
|
||||
File: olympusmn2.cpp
|
||||
Version: $Rev$
|
||||
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
|
||||
History: 11-Apr-06, ahu: created
|
||||
*/
|
||||
// *****************************************************************************
|
||||
#include "rcsid.hpp"
|
||||
EXIV2_RCSID("@(#) $Id$");
|
||||
|
||||
// Define DEBUG to output debug information to std::cerr, e.g, by calling make
|
||||
// like this: make DEFS=-DDEBUG makernote2.o
|
||||
//#define DEBUG
|
||||
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
#ifdef _MSC_VER
|
||||
# include "exv_msvc.h"
|
||||
#else
|
||||
# include "exv_conf.h"
|
||||
#endif
|
||||
|
||||
#include "olympusmn2.hpp"
|
||||
#include "tiffcomposite.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
// + standard includes
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
// *****************************************************************************
|
||||
// class member definitions
|
||||
namespace Exiv2 {
|
||||
|
||||
const char* OlympusMnHeader::signature_ = "OLYMP\0\1\0";
|
||||
const uint32_t OlympusMnHeader::size_ = 8;
|
||||
|
||||
OlympusMnHeader::OlympusMnHeader()
|
||||
{
|
||||
read(reinterpret_cast<const byte*>(signature_), size_);
|
||||
}
|
||||
|
||||
bool OlympusMnHeader::read(const byte* pData, uint32_t size)
|
||||
{
|
||||
assert (pData != 0);
|
||||
|
||||
if (size < size_) return false;
|
||||
|
||||
header_.alloc(size_);
|
||||
memcpy(header_.pData_, pData, header_.size_);
|
||||
return true;
|
||||
} // OlympusMnHeader::read
|
||||
|
||||
bool OlympusMnHeader::check() const
|
||||
{
|
||||
if ( static_cast<uint32_t>(header_.size_) < size_
|
||||
|| 0 != memcmp(header_.pData_, signature_, 5)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // OlympusMnHeader::check
|
||||
|
||||
bool TiffOlympusMn::doReadHeader(const byte* pData, uint32_t size)
|
||||
{
|
||||
return header_.read(pData, size);
|
||||
}
|
||||
|
||||
bool TiffOlympusMn::doCheckHeader() const
|
||||
{
|
||||
return header_.check();
|
||||
}
|
||||
|
||||
uint32_t TiffOlympusMn::doIfdOffset() const
|
||||
{
|
||||
return header_.ifdOffset();
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// free functions
|
||||
|
||||
TiffComponent* newOlympusMn(uint16_t tag,
|
||||
uint16_t group,
|
||||
uint16_t mnGroup,
|
||||
const byte* /*pData*/,
|
||||
uint32_t /*size*/,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
return new TiffOlympusMn(tag, group, mnGroup);
|
||||
}
|
||||
|
||||
} // namespace Exiv2
|
||||
125
src/olympusmn2.hpp
Normal file
125
src/olympusmn2.hpp
Normal file
@ -0,0 +1,125 @@
|
||||
// ***************************************************************** -*- C++ -*-
|
||||
/*
|
||||
* Copyright (C) 2006 Andreas Huggel <ahuggel@gmx.net>
|
||||
*
|
||||
* This program is part of the Exiv2 distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
/*!
|
||||
@file olympusmn2.hpp
|
||||
@brief TIFF Olympus makernote
|
||||
@version $Rev$
|
||||
@author Andreas Huggel (ahu)
|
||||
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
|
||||
@date 15-Apr-06, ahu: created
|
||||
*/
|
||||
#ifndef OLYMPUSMN2_HPP_
|
||||
#define OLYMPUSMN2_HPP_
|
||||
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
#include "makernote2.hpp"
|
||||
#include "tiffcomposite.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
// + standard includes
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
namespace Group {
|
||||
const uint16_t olympmn = 257; //!< Olympus makernote
|
||||
}
|
||||
|
||||
//! Header of an Olympus Makernote
|
||||
class OlympusMnHeader : public MnHeader {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
OlympusMnHeader();
|
||||
//! Virtual destructor.
|
||||
virtual ~OlympusMnHeader() {}
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
virtual bool read(const byte* pData,
|
||||
uint32_t size);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
virtual uint32_t size() const { return header_.size_; }
|
||||
virtual uint32_t ifdOffset() const { return size_; }
|
||||
virtual bool check() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
static const char* signature_; //!< Olympus makernote header signature
|
||||
static const uint32_t size_; //!< Size of the signature
|
||||
|
||||
}; // class OlympusMnHeader
|
||||
|
||||
/*!
|
||||
@brief Olympus Makernote
|
||||
*/
|
||||
class TiffOlympusMn : public TiffIfdMakernote {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
TiffOlympusMn(uint16_t tag, uint16_t group, uint16_t mnGroup)
|
||||
: TiffIfdMakernote(tag, group, mnGroup) {}
|
||||
//! Virtual destructor
|
||||
virtual ~TiffOlympusMn() {}
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
virtual bool doReadHeader(const byte* pData, uint32_t size);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
virtual bool doCheckHeader() const;
|
||||
virtual uint32_t doIfdOffset() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// DATA
|
||||
OlympusMnHeader header_; //!< Makernote header
|
||||
|
||||
}; // TiffOlympusMn
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
//! Function to create an Olympus makernote
|
||||
TiffComponent* newOlympusMn(uint16_t tag,
|
||||
uint16_t group,
|
||||
uint16_t mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef OLYMPUSMN2_HPP_
|
||||
@ -42,6 +42,7 @@ EXIV2_RCSID("@(#) $Id$");
|
||||
|
||||
#include "tiffcomposite.hpp"
|
||||
#include "tiffvisitor.hpp"
|
||||
#include "makernote2.hpp"
|
||||
#include "value.hpp"
|
||||
|
||||
// + standard includes
|
||||
@ -86,10 +87,10 @@ namespace Exiv2 {
|
||||
delete pValue_;
|
||||
} // TiffEntryBase::~TiffEntryBase
|
||||
|
||||
TiffMakernote::~TiffMakernote()
|
||||
TiffMnEntry::~TiffMnEntry()
|
||||
{
|
||||
delete mn_;
|
||||
} // TiffMakernote::~TiffMakernote
|
||||
} // TiffMnEntry::~TiffMnEntry
|
||||
|
||||
const uint16_t TiffHeade2::tag_ = 42;
|
||||
|
||||
@ -126,7 +127,6 @@ namespace Exiv2 {
|
||||
case 257: group = "Olympus"; break;
|
||||
default: group = "Unknown"; break;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
@ -145,10 +145,10 @@ namespace Exiv2 {
|
||||
ifd_.addChild(tiffComponent);
|
||||
} // TiffSubIfd::doAddChild
|
||||
|
||||
void TiffMakernote::doAddChild(TiffComponent::AutoPtr tiffComponent)
|
||||
void TiffMnEntry::doAddChild(TiffComponent::AutoPtr tiffComponent)
|
||||
{
|
||||
if (mn_) mn_->addChild(tiffComponent);
|
||||
} // TiffMakernote::doAddChild
|
||||
} // TiffMnEntry::doAddChild
|
||||
|
||||
void TiffComponent::addNext(TiffComponent::AutoPtr tiffComponent)
|
||||
{
|
||||
@ -165,10 +165,10 @@ namespace Exiv2 {
|
||||
ifd_.addNext(tiffComponent);
|
||||
} // TiffSubIfd::doAddNext
|
||||
|
||||
void TiffMakernote::doAddNext(TiffComponent::AutoPtr tiffComponent)
|
||||
void TiffMnEntry::doAddNext(TiffComponent::AutoPtr tiffComponent)
|
||||
{
|
||||
if (mn_) mn_->addNext(tiffComponent);
|
||||
} // TiffMakernote::doAddNext
|
||||
} // TiffMnEntry::doAddNext
|
||||
|
||||
void TiffComponent::accept(TiffVisitor& visitor)
|
||||
{
|
||||
@ -202,11 +202,11 @@ namespace Exiv2 {
|
||||
ifd_.accept(visitor);
|
||||
} // TiffSubIfd::doAccept
|
||||
|
||||
void TiffMakernote::doAccept(TiffVisitor& visitor)
|
||||
void TiffMnEntry::doAccept(TiffVisitor& visitor)
|
||||
{
|
||||
visitor.visitMakernote(this);
|
||||
visitor.visitMnEntry(this);
|
||||
if (mn_) mn_->accept(visitor);
|
||||
} // TiffMakernote::doAccept
|
||||
} // TiffMnEntry::doAccept
|
||||
|
||||
// *************************************************************************
|
||||
// free functions
|
||||
|
||||
@ -51,6 +51,7 @@ namespace Exiv2 {
|
||||
template<typename CreationPolicy> class TiffReader;
|
||||
class TiffMetadataDecoder;
|
||||
class TiffPrinter;
|
||||
class TiffIfdMakernote;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
@ -145,7 +146,7 @@ namespace Exiv2 {
|
||||
/*!
|
||||
@brief Interface class for components of a TIFF directory hierarchy
|
||||
(Composite pattern). Both TIFF directories as well as entries
|
||||
implement this interface. A component can be un iquely identified
|
||||
implement this interface. A component can be uniquely identified
|
||||
by a tag, group tupel. This class is implemented as a NVI
|
||||
(Non-Virtual Interface) and it has an interface for visitors (Visitor
|
||||
pattern).
|
||||
@ -201,10 +202,10 @@ namespace Exiv2 {
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Implements addChild().
|
||||
//! Implements addChild(). The default implementation does nothing.
|
||||
virtual void doAddChild(AutoPtr tiffComponent) {}
|
||||
|
||||
//! Implements addNext().
|
||||
//! Implements addNext(). The default implementation does nothing.
|
||||
virtual void doAddNext(AutoPtr tiffComponent) {}
|
||||
|
||||
//! Implements accept()
|
||||
@ -370,7 +371,7 @@ namespace Exiv2 {
|
||||
management methods are forwarded to the concrete Makernote, if
|
||||
there is one.
|
||||
*/
|
||||
class TiffMakernote : public TiffEntryBase {
|
||||
class TiffMnEntry : public TiffEntryBase {
|
||||
template<typename CreationPolicy>
|
||||
friend class TiffReader;
|
||||
friend class TiffMetadataDecoder;
|
||||
@ -379,10 +380,10 @@ namespace Exiv2 {
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
TiffMakernote(uint16_t tag, uint16_t group, uint16_t newGroup)
|
||||
: TiffEntryBase(tag, group), newGroup_(newGroup), mn_(0) {}
|
||||
TiffMnEntry(uint16_t tag, uint16_t group, uint16_t mnGroup)
|
||||
: TiffEntryBase(tag, group), mnGroup_(mnGroup), mn_(0) {}
|
||||
//! Virtual destructor
|
||||
virtual ~TiffMakernote();
|
||||
virtual ~TiffMnEntry();
|
||||
//@}
|
||||
|
||||
private:
|
||||
@ -395,13 +396,10 @@ namespace Exiv2 {
|
||||
|
||||
private:
|
||||
// DATA
|
||||
uint16_t newGroup_; //!< New group for concrete mn
|
||||
TiffComponent* mn_; //!< The Makernote
|
||||
uint16_t mnGroup_; //!< New group for concrete mn
|
||||
TiffComponent* mn_; //!< The Makernote
|
||||
|
||||
}; // class TiffMakernote
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
}; // class TiffMnEntry
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
|
||||
@ -58,9 +58,9 @@ EXIV2_RCSID("@(#) $Id$");
|
||||
+ Make TiffImage a template StandardImage, which can be parametrized with
|
||||
a parser and the necessary checking functions to cover all types of
|
||||
images which need to be loaded completely.
|
||||
+ Decide what tag and group should be assigned to TiffMakernote and
|
||||
+ Decide what tag and group should be assigned to TiffMnEntry and
|
||||
concrete Makernotes and which of them should derive from base-entry
|
||||
- TiffMakernote tag 0x927c, group exif, derives from tiffentry: because
|
||||
- TiffMnEntry tag 0x927c, group exif, derives from tiffentry: because
|
||||
create needs the entry
|
||||
- ConcreteMn tag 0, group Mn, derives from component so that the plain entry
|
||||
is only kept in one place,
|
||||
@ -99,7 +99,7 @@ namespace Exiv2 {
|
||||
{ 0x8769, Group::ifd0, newTiffSubIfd, Group::exif },
|
||||
{ 0x8825, Group::ifd0, newTiffSubIfd, Group::gps },
|
||||
{ 0xa005, Group::exif, newTiffSubIfd, Group::iop },
|
||||
{ 0x927c, Group::exif, newTiffMakernote, Group::mn },
|
||||
{ 0x927c, Group::exif, newTiffMnEntry, Group::mn },
|
||||
{ Tag::next, Group::ifd0, newTiffDirectory, Group::ifd0 }
|
||||
};
|
||||
|
||||
@ -141,12 +141,12 @@ namespace Exiv2 {
|
||||
ts->newGroup_));
|
||||
}
|
||||
|
||||
TiffComponent::AutoPtr newTiffMakernote(const TiffStructure* ts)
|
||||
TiffComponent::AutoPtr newTiffMnEntry(const TiffStructure* ts)
|
||||
{
|
||||
assert(ts);
|
||||
return TiffComponent::AutoPtr(new TiffMakernote(ts->tag(),
|
||||
ts->group_,
|
||||
ts->newGroup_));
|
||||
return TiffComponent::AutoPtr(new TiffMnEntry(ts->tag(),
|
||||
ts->group_,
|
||||
ts->newGroup_));
|
||||
}
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
@ -147,8 +147,8 @@ namespace Exiv2 {
|
||||
//! Function to create and initialize a new TIFF sub-directory
|
||||
TiffComponent::AutoPtr newTiffSubIfd(const TiffStructure* ts);
|
||||
|
||||
//! Function to create and initialize a new TIFF makernote
|
||||
TiffComponent::AutoPtr newTiffMakernote(const TiffStructure* ts);
|
||||
//! Function to create and initialize a new TIFF makernote entry
|
||||
TiffComponent::AutoPtr newTiffMnEntry(const TiffStructure* ts);
|
||||
|
||||
template<typename CreationPolicy>
|
||||
void TiffParser<CreationPolicy>::decode(Image* pImage,
|
||||
|
||||
@ -83,12 +83,12 @@ namespace Exiv2 {
|
||||
findObject(object);
|
||||
}
|
||||
|
||||
void TiffFinder::visitMakernote(TiffMakernote* object)
|
||||
void TiffFinder::visitMnEntry(TiffMnEntry* object)
|
||||
{
|
||||
findObject(object);
|
||||
}
|
||||
|
||||
void TiffFinder::visitOlympusMn(TiffOlympusMn* object)
|
||||
void TiffFinder::visitIfdMakernote(TiffIfdMakernote* object)
|
||||
{
|
||||
findObject(object);
|
||||
}
|
||||
@ -108,12 +108,12 @@ namespace Exiv2 {
|
||||
decodeTiffEntry(object);
|
||||
}
|
||||
|
||||
void TiffMetadataDecoder::visitMakernote(TiffMakernote* object)
|
||||
void TiffMetadataDecoder::visitMnEntry(TiffMnEntry* object)
|
||||
{
|
||||
if (!object->mn_) decodeTiffEntry(object);
|
||||
}
|
||||
|
||||
void TiffMetadataDecoder::visitOlympusMn(TiffOlympusMn* object)
|
||||
void TiffMetadataDecoder::visitIfdMakernote(TiffIfdMakernote* object)
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
@ -179,16 +179,16 @@ namespace Exiv2 {
|
||||
printTiffEntry(object);
|
||||
} // TiffPrinter::visitSubIfd
|
||||
|
||||
void TiffPrinter::visitMakernote(TiffMakernote* object)
|
||||
void TiffPrinter::visitMnEntry(TiffMnEntry* object)
|
||||
{
|
||||
if (!object->mn_) printTiffEntry(object, prefix());
|
||||
else os_ << prefix() << "Makernote ";
|
||||
} // TiffPrinter::visitMakernote
|
||||
} // TiffPrinter::visitMnEntry
|
||||
|
||||
void TiffPrinter::visitOlympusMn(TiffOlympusMn* object)
|
||||
void TiffPrinter::visitIfdMakernote(TiffIfdMakernote* object)
|
||||
{
|
||||
os_ << prefix() << "Todo: Olympus Makernote header\n";
|
||||
} // TiffPrinter::visitOlympusMn
|
||||
os_ << prefix() << "Todo: Print IFD makernote header\n";
|
||||
} // TiffPrinter::visitIfdMakernote
|
||||
|
||||
void TiffPrinter::printTiffEntry(TiffEntryBase* object,
|
||||
const std::string& px) const
|
||||
|
||||
@ -50,8 +50,8 @@ namespace Exiv2 {
|
||||
class TiffEntry;
|
||||
class TiffDirectory;
|
||||
class TiffSubIfd;
|
||||
class TiffMakernote;
|
||||
class TiffOlympusMn;
|
||||
class TiffMnEntry;
|
||||
class TiffIfdMakernote;
|
||||
class Image;
|
||||
|
||||
// *****************************************************************************
|
||||
@ -103,9 +103,9 @@ namespace Exiv2 {
|
||||
//! Operation to perform for a TIFF sub-IFD
|
||||
virtual void visitSubIfd(TiffSubIfd* object) =0;
|
||||
//! Operation to perform for the makernote component
|
||||
virtual void visitMakernote(TiffMakernote* object) =0;
|
||||
//! Operation to perform for an Olympus makernote
|
||||
virtual void visitOlympusMn(TiffOlympusMn* object) =0;
|
||||
virtual void visitMnEntry(TiffMnEntry* object) =0;
|
||||
//! Operation to perform for an IFD makernote
|
||||
virtual void visitIfdMakernote(TiffIfdMakernote* object) =0;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@ -145,9 +145,9 @@ namespace Exiv2 {
|
||||
//! Find tag and group in a TIFF sub-IFD
|
||||
virtual void visitSubIfd(TiffSubIfd* object);
|
||||
//! Find tag and group in a TIFF makernote
|
||||
virtual void visitMakernote(TiffMakernote* object);
|
||||
//! Find tag and group in an Olympus makernote
|
||||
virtual void visitOlympusMn(TiffOlympusMn* object);
|
||||
virtual void visitMnEntry(TiffMnEntry* object);
|
||||
//! Find tag and group in an IFD makernote
|
||||
virtual void visitIfdMakernote(TiffIfdMakernote* object);
|
||||
|
||||
//! Check if \em object matches \em tag and \em group
|
||||
void findObject(TiffComponent* object);
|
||||
@ -195,9 +195,9 @@ namespace Exiv2 {
|
||||
//! Decode a TIFF sub-IFD
|
||||
virtual void visitSubIfd(TiffSubIfd* object);
|
||||
//! Decode a TIFF makernote
|
||||
virtual void visitMakernote(TiffMakernote* object);
|
||||
//! Decode an Olympus makernote
|
||||
virtual void visitOlympusMn(TiffOlympusMn* object);
|
||||
virtual void visitMnEntry(TiffMnEntry* object);
|
||||
//! Decode an IFD makernote
|
||||
virtual void visitIfdMakernote(TiffIfdMakernote* object);
|
||||
|
||||
//! Decode a standard TIFF entry
|
||||
void decodeTiffEntry(const TiffEntryBase* object);
|
||||
@ -246,9 +246,9 @@ namespace Exiv2 {
|
||||
//! Read a TIFF sub-IFD from the data buffer
|
||||
virtual void visitSubIfd(TiffSubIfd* object);
|
||||
//! Read a TIFF makernote entry from the data buffer
|
||||
virtual void visitMakernote(TiffMakernote* object);
|
||||
//! Read an Olympus makernote from the data buffer
|
||||
virtual void visitOlympusMn(TiffOlympusMn* object);
|
||||
virtual void visitMnEntry(TiffMnEntry* object);
|
||||
//! Read an IFD makernote from the data buffer
|
||||
virtual void visitIfdMakernote(TiffIfdMakernote* object);
|
||||
|
||||
//! Read a standard TIFF entry from the data buffer
|
||||
void readTiffEntry(TiffEntryBase* object);
|
||||
@ -292,9 +292,9 @@ namespace Exiv2 {
|
||||
//! Print a TIFF sub-IFD
|
||||
virtual void visitSubIfd(TiffSubIfd* object);
|
||||
//! Print a TIFF makernote
|
||||
virtual void visitMakernote(TiffMakernote* object);
|
||||
//! Print an Olympus makernote
|
||||
virtual void visitOlympusMn(TiffOlympusMn* object);
|
||||
virtual void visitMnEntry(TiffMnEntry* object);
|
||||
//! Print an IFD makernote
|
||||
virtual void visitIfdMakernote(TiffIfdMakernote* object);
|
||||
|
||||
//! Increment the indent by one level
|
||||
void incIndent();
|
||||
|
||||
@ -163,7 +163,7 @@ namespace Exiv2 {
|
||||
} // TiffReader::visitSubIfd
|
||||
|
||||
template<typename CreationPolicy>
|
||||
void TiffReader<CreationPolicy>::visitMakernote(TiffMakernote* object)
|
||||
void TiffReader<CreationPolicy>::visitMnEntry(TiffMnEntry* object)
|
||||
{
|
||||
assert(object != 0);
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Exiv2 {
|
||||
make = te->pValue()->toString();
|
||||
// create concrete makernote, based on model and makernote contents
|
||||
object->mn_ = TiffMnCreator::create(object->tag(),
|
||||
object->newGroup_,
|
||||
object->mnGroup_,
|
||||
make,
|
||||
object->pData(),
|
||||
object->size(),
|
||||
@ -185,21 +185,21 @@ namespace Exiv2 {
|
||||
}
|
||||
if (object->mn_) object->mn_->setStart(object->pData());
|
||||
|
||||
} // TiffReader::visitMakernote
|
||||
} // TiffReader::visitMnEntry
|
||||
|
||||
template<typename CreationPolicy>
|
||||
void TiffReader<CreationPolicy>::visitOlympusMn(TiffOlympusMn* object)
|
||||
void TiffReader<CreationPolicy>::visitIfdMakernote(TiffIfdMakernote* object)
|
||||
{
|
||||
object->header_.read(object->start(), pLast_ - object->start());
|
||||
if (!object->header_.check()) {
|
||||
object->readHeader(object->start(), pLast_ - object->start());
|
||||
if (!object->checkHeader()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Olympus Makernote header check failed.\n";
|
||||
std::cerr << "Error: IFD Makernote header check failed.\n";
|
||||
#endif
|
||||
return; // todo: signal error to parent, delete object
|
||||
}
|
||||
object->ifd_.setStart(object->start() + object->header_.offset());
|
||||
object->ifd_.setStart(object->start() + object->ifdOffset());
|
||||
|
||||
} // TiffReader::visitOlympusMn
|
||||
} // TiffReader::visitIfdMakernote
|
||||
|
||||
template<typename CreationPolicy>
|
||||
void TiffReader<CreationPolicy>::readTiffEntry(TiffEntryBase* object)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user