diff --git a/src/Makefile b/src/Makefile index 6ded735c..3aadbe7b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,14 +55,12 @@ CCHDR = exv_conf.h \ # Add library C++ source files to this list CCSRC = basicio.cpp \ canonmn.cpp \ - canonmn2.cpp \ crwimage.cpp \ datasets.cpp \ error.cpp \ exif.cpp \ futils.cpp \ fujimn.cpp \ - fujimn2.cpp \ ifd.cpp \ image.cpp \ imgreg.cpp \ @@ -71,17 +69,11 @@ CCSRC = basicio.cpp \ makernote.cpp \ makernote2.cpp \ metadatum.cpp \ - mnreg.cpp \ nikonmn.cpp \ - nikonmn2.cpp \ olympusmn.cpp \ - olympusmn2.cpp \ panasonicmn.cpp \ - panasonicmn2.cpp \ sigmamn.cpp \ - sigmamn2.cpp \ sonymn.cpp \ - sonymn2.cpp \ tags.cpp \ tiffcomposite.cpp \ tiffimage.cpp \ diff --git a/src/canonmn2.cpp b/src/canonmn2.cpp deleted file mode 100644 index d1b5acf8..00000000 --- a/src/canonmn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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: canonmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "canonmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const TiffStructure TiffCanonCreator::tiffStructure_[] = { - // ext. tag group create function new group - //--------- -------------- ------------------- -------------- - { 0x0001, Group::canonmn, newTiffArrayEntry, Group::canoncs }, - { 0x0004, Group::canonmn, newTiffArrayEntry, Group::canonsi }, - { 0x000f, Group::canonmn, newTiffArrayEntry, Group::canoncf }, - { Tag::all, Group::canoncs, newTiffArrayElement, Group::canoncs }, - { Tag::all, Group::canonsi, newTiffArrayElement, Group::canonsi }, - { Tag::all, Group::canoncf, newTiffArrayElement, Group::canoncf } - }; - - TiffComponent::AutoPtr TiffCanonCreator::create(uint32_t extendedTag, - uint16_t group) - { - TiffComponent::AutoPtr tc(0); - uint16_t tag = static_cast(extendedTag & 0xffff); - const TiffStructure* ts = find(tiffStructure_, - TiffStructure::Key(extendedTag, group)); - if (ts && ts->newTiffCompFct_) { - tc = ts->newTiffCompFct_(tag, ts); - } - if (!ts && extendedTag != Tag::next) { - tc = TiffComponent::AutoPtr(new TiffEntry(tag, group)); - } - return tc; - } // TiffCanonCreator::create - - TiffRwState::AutoPtr TiffCanonMn::doGetState(uint32_t /*mnOffset*/, - ByteOrder byteOrder) const - { - // Byteorder: No change - // Offsets : No change (relative to the start of the TIFF header) - // Creator : Canon TIFF component factory - return TiffRwState::AutoPtr( - new TiffRwState(byteOrder, 0, TiffCanonCreator::create)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newCanonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffCanonMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/canonmn2.hpp b/src/canonmn2.hpp deleted file mode 100644 index 3879d0b4..00000000 --- a/src/canonmn2.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 canonmn2.hpp - @brief TIFF Canon makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 18-Apr-06, ahu: created - */ -#ifndef CANONMN2_HPP_ -#define CANONMN2_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 canonmn = 259; //!< Canon makernote - const uint16_t canoncs = 260; //!< Canon camera settings - const uint16_t canonsi = 261; //!< Canon shot info - const uint16_t canoncf = 262; //!< Canon customer functions - } - - /*! - @brief Canon Makernote - */ - class TiffCanonMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffCanonMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffCanonMn() {} - //@} - private: - //! @name Accessors - //@{ - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - }; // class TiffCanonMn - - /*! - @brief TIFF component factory for Canon TIFF components. - */ - class TiffCanonCreator { - public: - /*! - @brief Create the TiffComponent for TIFF entry \em extendedTag and - \em group based on the embedded lookup table. - - If a tag and group combination is not found in the table, a TiffEntry - is created. If the pointer that is returned is 0, then the TIFF entry - should be ignored. - */ - static TiffComponent::AutoPtr create(uint32_t extendedTag, - uint16_t group); - - private: - static const TiffStructure tiffStructure_[]; // - * - * 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: fujimn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 15-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "fujimn2.hpp" -#include "tiffcomposite.hpp" -#include "tiffparser.hpp" -#include "types.hpp" - -// + standard includes -#include -#include - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte FujiMnHeader::signature_[] = { - 'F', 'U', 'J', 'I', 'F', 'I', 'L', 'M', 0x0c, 0x00, 0x00, 0x00 - }; - const uint32_t FujiMnHeader::size_ = 12; - const ByteOrder FujiMnHeader::byteOrder_ = littleEndian; - - FujiMnHeader::FujiMnHeader() - { - read(signature_, size_, byteOrder_); - } - - bool FujiMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - - header_.alloc(size_); - memcpy(header_.pData_, pData, header_.size_); - - // Read offset to the IFD relative to the start of the makernote - // from the header. Note that we ignore the byteOrder argument - start_ = getUShort(header_.pData_ + 8, byteOrder_); - - if ( static_cast(header_.size_) < size_ - || 0 != memcmp(header_.pData_, signature_, 8)) { - return false; - } - return true; - } // FujiMnHeader::read - - bool TiffFujiMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffFujiMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - TiffRwState::AutoPtr TiffFujiMn::doGetState(uint32_t mnOffset, - ByteOrder /*byteOrder*/) const - { - // Byteorder: from the header (little endian) - // Offsets : relative to the start of the makernote - // Creator : no change - return TiffRwState::AutoPtr( - new TiffRwState(header_.byteOrder(), mnOffset, 0)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newFujiMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffFujiMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/fujimn2.hpp b/src/fujimn2.hpp deleted file mode 100644 index d4ccd8f6..00000000 --- a/src/fujimn2.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 fujimn2.hpp - @brief TIFF Fujifilm makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 15-Apr-06, ahu: created - */ -#ifndef FUJIMN2_HPP_ -#define FUJIMN2_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 fujimn = 258; //!< Fujifilm makernote - } - - //! Header of a Fujifilm Makernote - class FujiMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - FujiMnHeader(); - //! Virtual destructor. - virtual ~FujiMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return header_.size_; } - virtual uint32_t ifdOffset() const { return start_; } - //! Return the byte order for the header - ByteOrder byteOrder() const { return byteOrder_; } - //@} - - private: - DataBuf header_; //!< Data buffer for the makernote header - static const byte signature_[]; //!< Fujifilm makernote header signature - static const uint32_t size_; //!< Size of the signature - static const ByteOrder byteOrder_; //!< Byteorder for makernote (II) - uint32_t start_; //!< Start of the mn IFD rel. to mn start - - }; // class FujiMnHeader - - /*! - @brief Fujifilm Makernote - */ - class TiffFujiMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffFujiMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffFujiMn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - private: - // DATA - FujiMnHeader header_; //!< Makernote header - - }; // TiffFujiMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Fujifilm makernote - TiffComponent* newFujiMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef FUJIMN2_HPP_ diff --git a/src/makernote2.cpp b/src/makernote2.cpp index e8d9e911..aae68b98 100644 --- a/src/makernote2.cpp +++ b/src/makernote2.cpp @@ -39,6 +39,7 @@ EXIV2_RCSID("@(#) $Id$"); #include "makernote2.hpp" #include "tiffcomposite.hpp" #include "tiffvisitor.hpp" +#include "tiffimage.hpp" // + standard includes #include @@ -47,38 +48,70 @@ EXIV2_RCSID("@(#) $Id$"); // class member definitions namespace Exiv2 { + const TiffMnRegistry TiffMnCreator::registry_[] = { + { "Canon", newCanonMn, Group::canonmn }, + { "FOVEON", newSigmaMn, Group::sigmamn }, + { "FUJIFILM", newFujiMn, Group::fujimn }, + { "NIKON", newNikonMn, Group::nikonmn }, + { "OLYMPUS", newOlympusMn, Group::olympmn }, + { "Panasonic", newPanasonicMn, Group::panamn }, + { "SIGMA", newSigmaMn, Group::sigmamn }, + { "SONY", newSonyMn, Group::sonymn } + }; + 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, + const 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 + TiffIfdMakernote::~TiffIfdMakernote() { + delete pHeader_; } - bool TiffIfdMakernote::readHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) + uint32_t TiffIfdMakernote::ifdOffset() const { - return doReadHeader(pData, size, byteOrder); + if (!pHeader_) return 0; + return pHeader_->ifdOffset(); } - uint32_t TiffIfdMakernote::ifdOffset() const + ByteOrder TiffIfdMakernote::byteOrder () const { - return doIfdOffset(); + if (!pHeader_) return invalidByteOrder; + return pHeader_->byteOrder(); } - TiffRwState::AutoPtr TiffIfdMakernote::getState(uint32_t mnOffset, - ByteOrder byteOrder) const + uint32_t TiffIfdMakernote::baseOffset(uint32_t mnOffset) const { - return doGetState(mnOffset, byteOrder); + if (!pHeader_) return 0; + return pHeader_->baseOffset(mnOffset); } - TiffRwState::AutoPtr TiffIfdMakernote::doGetState(uint32_t /*mnOffset*/, - ByteOrder /*byteOrder*/) const + bool TiffIfdMakernote::readHeader(const byte* pData, + uint32_t size, + ByteOrder byteOrder) { - return TiffRwState::AutoPtr(0); + if (!pHeader_) return true; + return pHeader_->read(pData, size, byteOrder); } void TiffIfdMakernote::doAddChild(TiffComponent::AutoPtr tiffComponent) @@ -98,4 +131,285 @@ namespace Exiv2 { if (visitor.go()) visitor.visitIfdMakernoteEnd(this); } + const byte OlympusMnHeader::signature_[] = { + 'O', 'L', 'Y', 'M', 'P', 0x00, 0x01, 0x00 + }; + const uint32_t OlympusMnHeader::size_ = 8; + + OlympusMnHeader::OlympusMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool OlympusMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + + header_.alloc(size_); + memcpy(header_.pData_, pData, header_.size_); + if ( static_cast(header_.size_) < size_ + || 0 != memcmp(header_.pData_, signature_, 5)) { + return false; + } + return true; + } // OlympusMnHeader::read + + const byte FujiMnHeader::signature_[] = { + 'F', 'U', 'J', 'I', 'F', 'I', 'L', 'M', 0x0c, 0x00, 0x00, 0x00 + }; + const uint32_t FujiMnHeader::size_ = 12; + const ByteOrder FujiMnHeader::byteOrder_ = littleEndian; + + FujiMnHeader::FujiMnHeader() + { + read(signature_, size_, byteOrder_); + } + + bool FujiMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + + header_.alloc(size_); + memcpy(header_.pData_, pData, header_.size_); + + // Read offset to the IFD relative to the start of the makernote + // from the header. Note that we ignore the byteOrder argument + start_ = getUShort(header_.pData_ + 8, byteOrder_); + + if ( static_cast(header_.size_) < size_ + || 0 != memcmp(header_.pData_, signature_, 8)) { + return false; + } + return true; + } // FujiMnHeader::read + + + const byte Nikon2MnHeader::signature_[] = { + 'N', 'i', 'k', 'o', 'n', '\0', 0x00, 0x01 + }; + const uint32_t Nikon2MnHeader::size_ = 8; + + Nikon2MnHeader::Nikon2MnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool Nikon2MnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 6)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // Nikon2MnHeader::read + + const byte Nikon3MnHeader::signature_[] = { + 'N', 'i', 'k', 'o', 'n', '\0', + 0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08 + }; + const uint32_t Nikon3MnHeader::size_ = 18; + + Nikon3MnHeader::Nikon3MnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool Nikon3MnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 6)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + TiffHeade2 th; + if (!th.read(buf_.pData_ + 10, 8)) return false; + byteOrder_ = th.byteOrder(); + start_ = 10 + th.ifdOffset(); + return true; + + } // Nikon3MnHeader::read + + const byte PanasonicMnHeader::signature_[] = { + 'P', 'a', 'n', 'a', 's', 'o', 'n', 'i', 'c', 0x00, 0x00, 0x00 + }; + const uint32_t PanasonicMnHeader::size_ = 12; + + PanasonicMnHeader::PanasonicMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool PanasonicMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 9)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // PanasonicMnHeader::read + + const byte SigmaMnHeader::signature1_[] = { + 'S', 'I', 'G', 'M', 'A', '\0', '\0', '\0', 0x01, 0x00 + }; + const byte SigmaMnHeader::signature2_[] = { + 'F', 'O', 'V', 'E', 'O', 'N', '\0', '\0', 0x01, 0x00 + }; + const uint32_t SigmaMnHeader::size_ = 10; + + SigmaMnHeader::SigmaMnHeader() + { + read(signature1_, size_, invalidByteOrder); + } + + bool SigmaMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if ( 0 != memcmp(pData, signature1_, 8) + && 0 != memcmp(pData, signature2_, 8)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // SigmaMnHeader::read + + const byte SonyMnHeader::signature_[] = { + 'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0' + }; + const uint32_t SonyMnHeader::size_ = 12; + + SonyMnHeader::SonyMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool SonyMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, size_)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // SonyMnHeader::read + + // ************************************************************************* + // free functions + + TiffComponent* newCanonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, 0); + } + + TiffComponent* newOlympusMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new OlympusMnHeader); + } + + TiffComponent* newFujiMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new FujiMnHeader); + } + + TiffComponent* newNikonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + // If there is no "Nikon" string it must be Nikon1 format + if (size < 6 || std::string(reinterpret_cast(pData), 6) + != std::string("Nikon\0", 6)) { + return new TiffIfdMakernote(tag, group, Group::nikon1mn, 0); + } + // If the "Nikon" string is not followed by a TIFF header, we assume + // Nikon2 format + TiffHeade2 tiffHeader; + if ( size < 18 + || !tiffHeader.read(pData + 10, size - 10) + || tiffHeader.tag() != 0x002a) { + return new TiffIfdMakernote(tag, group, Group::nikon2mn, new Nikon2MnHeader); + } + // Else we have a Nikon3 makernote + return new TiffIfdMakernote(tag, group, Group::nikon3mn, new Nikon3MnHeader); + } + + TiffComponent* newPanasonicMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new PanasonicMnHeader, false); + } + + TiffComponent* newSigmaMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new SigmaMnHeader); + } + + TiffComponent* newSonyMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new SonyMnHeader); + } + } // namespace Exiv2 diff --git a/src/makernote2.hpp b/src/makernote2.hpp index 8b788b9e..e51d53b3 100644 --- a/src/makernote2.hpp +++ b/src/makernote2.hpp @@ -20,7 +20,7 @@ */ /*! @file makernote2.hpp - @brief Makernote base classes, factory and registry + @brief Makernote related classes @version $Rev$ @author Andreas Huggel (ahu) ahuggel@gmx.net @@ -42,6 +42,23 @@ // namespace extensions namespace Exiv2 { + namespace Group { + const uint16_t olympmn = 257; //!< Olympus makernote + const uint16_t fujimn = 258; //!< Fujifilm makernote + const uint16_t canonmn = 259; //!< Canon makernote + const uint16_t canoncs = 260; //!< Canon camera settings + const uint16_t canonsi = 261; //!< Canon shot info + const uint16_t canoncf = 262; //!< Canon customer functions + const uint16_t nikonmn = 263; //!< Any Nikon makernote (pseudo group) + const uint16_t nikon1mn = 264; //!< Nikon1 makernote + const uint16_t nikon2mn = 265; //!< Nikon2 makernote + const uint16_t nikon3mn = 266; //!< Nikon3 makernote + const uint16_t panamn = 267; //!< Panasonic makernote + const uint16_t sigmamn = 268; //!< Sigma makernote + const uint16_t sonymn = 269; //!< Sony makernote + + } + // ***************************************************************************** // class definitions @@ -119,25 +136,43 @@ namespace Exiv2 { //! Read the header from a data buffer, return true if ok virtual bool read(const byte* pData, uint32_t size, - ByteOrder byteOrder) =0; + ByteOrder byteOrder) =0; //@} //! @name Accessors //@{ - //! Size of the header + //! Return the size of the header (in bytes). virtual uint32_t size() const =0; /*! - @brief Start of the makernote directory relative to the start of the - header. + @brief Return the offset to the start of the Makernote IFD from + the start of the Makernote (= the start of the header). + */ + virtual uint32_t ifdOffset() const { return 0; } + /*! + @brief Return the byte order for the makernote. If the return value is + invalidByteOrder, this means that the byte order of the the + image should be used for the makernote. + */ + virtual ByteOrder byteOrder() const { return invalidByteOrder; } + /*! + @brief Return the base offset for the makernote IFD entries relative + to the start of the TIFF header. + + @param mnOffset Offset to the makernote from the start of the + TIFF header. */ - virtual uint32_t ifdOffset() const =0; + virtual uint32_t baseOffset(uint32_t mnOffset) const { return 0; } //@} }; // class MnHeader /*! - @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. + @brief Tiff IFD Makernote. This is a concrete class suitable for all + IFD makernotes. + + Contains a makernote header (which can be 0) and an IFD and + implements child mgmt functions to deal with the IFD entries. The + various makernote weirdnesses are taken care of in the makernote + header. */ class TiffIfdMakernote : public TiffComponent { friend class TiffReader; @@ -145,18 +180,25 @@ namespace Exiv2 { //! @name Creators //@{ //! Default constructor - TiffIfdMakernote(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - bool hasNext =true) - : TiffComponent(tag, group), ifd_(tag, mnGroup, hasNext) {} + TiffIfdMakernote(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + MnHeader* pHeader, + bool hasNext =true) + : TiffComponent(tag, group), + pHeader_(pHeader), + ifd_(tag, mnGroup, hasNext) {} //! Virtual destructor - virtual ~TiffIfdMakernote() =0; + virtual ~TiffIfdMakernote(); //@} //! @name Manipulators //@{ - //! Read the header from a data buffer, return true if successful + /*! + @brief Read the header from a data buffer, return true if successful. + + The default implementation simply returns true. + */ bool readHeader(const byte* pData, uint32_t size, ByteOrder byteOrder); //@} @@ -167,21 +209,21 @@ namespace Exiv2 { the start of the Makernote. */ uint32_t ifdOffset() const; + /*! + @brief Return the byte order for the makernote. Default (if there is + no header) is invalidByteOrder. This means that the byte order + of the the image should be used for the makernote. + */ + ByteOrder byteOrder() const; /*! - @brief Get status information relevant for the makernote. - - State includes byte order, offset and TIFF component factory. - This method allows the TiffReader to change state, i.e., change - these parameters, to parse the Makernote and its sub components - (if any). + @brief Return the base offset for the makernote IFD entries relative + to the start of the TIFF header. The default, if there is no + header, is 0. @param mnOffset Offset to the makernote from the start of the TIFF header. - @param byteOrder Byte order in use at the point where the function - is called. */ - TiffRwState::AutoPtr getState(uint32_t mnOffset, - ByteOrder byteOrder) const; + uint32_t baseOffset (uint32_t mnOffset) const; //@} protected: @@ -190,43 +232,292 @@ namespace Exiv2 { virtual void doAddChild(TiffComponent::AutoPtr tiffComponent); virtual void doAddNext(TiffComponent::AutoPtr tiffComponent); virtual void doAccept(TiffVisitor& visitor); - /*! - @brief Implements readHeader(). + //@} - The default implementation simply returns true. Derived classes for - makernotes which have a header should overwrite this. - */ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) { return true; } + private: + // DATA + MnHeader* pHeader_; //!< Makernote header + TiffDirectory ifd_; //!< Makernote IFD + + }; // class TiffIfdMakernote + + //! 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, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return header_.size_; } + virtual uint32_t ifdOffset() const { return size_; } + //@} + + private: + DataBuf header_; //!< Data buffer for the makernote header + static const byte signature_[]; //!< Olympus makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class OlympusMnHeader + //! Header of a Fujifilm Makernote + class FujiMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + FujiMnHeader(); + //! Virtual destructor. + virtual ~FujiMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} //! @name Accessors //@{ - /*! - @brief Implements ifdOffset(). + virtual uint32_t size() const { return header_.size_; } + virtual uint32_t ifdOffset() const { return start_; } + virtual ByteOrder byteOrder() const { return byteOrder_; } + virtual uint32_t baseOffset(uint32_t mnOffset) const { return mnOffset; } + //@} - Default implementation returns 0. Derived classes for makernotes - with an IFD which doesn't start at the beginning of the buffer - should overwrite this. - */ - virtual uint32_t doIfdOffset() const { return 0; } - /*! - @brief Implements getState(). - - Default implementation returns a 0-pointer. Derived classes for - makernotes which need a different byte order, base offset or - TIFF component factory should overwrite this. - */ - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; + private: + DataBuf header_; //!< Data buffer for the makernote header + static const byte signature_[]; //!< Fujifilm makernote header signature + static const uint32_t size_; //!< Size of the signature + static const ByteOrder byteOrder_; //!< Byteorder for makernote (II) + uint32_t start_; //!< Start of the mn IFD rel. to mn start + + }; // class FujiMnHeader + + //! Header of a Nikon 2 Makernote + class Nikon2MnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + Nikon2MnHeader(); + //! Virtual destructor. + virtual ~Nikon2MnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } //@} private: - // DATA - TiffDirectory ifd_; //!< Makernote IFD - - }; // class TiffIfdMakernote + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Nikon 2 makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class Nikon2MnHeader + + //! Header of a Nikon 3 Makernote + class Nikon3MnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + Nikon3MnHeader(); + //! Virtual destructor. + virtual ~Nikon3MnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + virtual ByteOrder byteOrder() const { return byteOrder_; } + virtual uint32_t baseOffset(uint32_t mnOffset) const { return mnOffset + 10; } + //@} + + private: + DataBuf buf_; //!< Raw header data + ByteOrder byteOrder_; //!< Byteorder for makernote + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Nikon 3 makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class Nikon3MnHeader + + //! Header of a Panasonic Makernote + class PanasonicMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + PanasonicMnHeader(); + //! Virtual destructor. + virtual ~PanasonicMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Panasonic makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class PanasonicMnHeader + + //! Header of a Sigma Makernote + class SigmaMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + SigmaMnHeader(); + //! Virtual destructor. + virtual ~SigmaMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature1_[]; //!< Sigma makernote header signature 1 + static const byte signature2_[]; //!< Sigma makernote header signature 2 + static const uint32_t size_; //!< Size of the signature + + }; // class SigmaMnHeader + + //! Header of a Sony Makernote + class SonyMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + SonyMnHeader(); + //! Virtual destructor. + virtual ~SonyMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Sony makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class SonyMnHeader + +// ***************************************************************************** +// template, inline and free functions + + //! Function to create a Canon makernote + TiffComponent* newCanonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! 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); + + //! Function to create a Fujifilm makernote + TiffComponent* newFujiMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + /*! + @brief Function to create a Nikon makernote. This will create the + appropriate Nikon 1, 2 or 3 makernote, based on the arguments. + */ + TiffComponent* newNikonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Panasonic makernote + TiffComponent* newPanasonicMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Sigma makernote + TiffComponent* newSigmaMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Sony makernote + TiffComponent* newSonyMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); } // namespace Exiv2 diff --git a/src/mnreg.cpp b/src/mnreg.cpp deleted file mode 100644 index 0cf997d4..00000000 --- a/src/mnreg.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2005, 2006 Andreas Huggel - * - * 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) - History: 15-Apr-06, ahu: created - - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "canonmn2.hpp" -#include "fujimn2.hpp" -#include "nikonmn2.hpp" -#include "olympusmn2.hpp" -#include "panasonicmn2.hpp" -#include "sigmamn2.hpp" -#include "sonymn2.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const TiffMnRegistry TiffMnCreator::registry_[] = { - { "Canon", newCanonMn, Group::canonmn }, - { "FOVEON", newSigmaMn, Group::sigmamn }, - { "FUJIFILM", newFujiMn, Group::fujimn }, - { "NIKON", newNikonMn, Group::nikonmn }, - { "OLYMPUS", newOlympusMn, Group::olympmn }, - { "Panasonic", newPanasonicMn, Group::panamn }, - { "SIGMA", newSigmaMn, Group::sigmamn }, - { "SONY", newSonyMn, Group::sonymn } - }; - - - // The find template needs to see the array from where it is called - TiffComponent* TiffMnCreator::create(uint16_t tag, - uint16_t group, - const 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 diff --git a/src/nikonmn2.cpp b/src/nikonmn2.cpp deleted file mode 100644 index fa8955ce..00000000 --- a/src/nikonmn2.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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: nikonmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "nikonmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte Nikon2MnHeader::signature_[] = { - 'N', 'i', 'k', 'o', 'n', '\0', 0x00, 0x01 - }; - const uint32_t Nikon2MnHeader::size_ = 8; - - Nikon2MnHeader::Nikon2MnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool Nikon2MnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 6)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // Nikon2MnHeader::read - - bool TiffNikon2Mn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffNikon2Mn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - const byte Nikon3MnHeader::signature_[] = { - 'N', 'i', 'k', 'o', 'n', '\0', - 0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08 - }; - const uint32_t Nikon3MnHeader::size_ = 18; - - Nikon3MnHeader::Nikon3MnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool Nikon3MnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 6)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - TiffHeade2 th; - if (!th.read(buf_.pData_ + 10, 8)) return false; - byteOrder_ = th.byteOrder(); - start_ = 10 + th.ifdOffset(); - return true; - - } // Nikon3MnHeader::read - - bool TiffNikon3Mn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffNikon3Mn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - TiffRwState::AutoPtr TiffNikon3Mn::doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const - { - // Byteorder: From header - // Offsets : From header - // Creator : No change - return TiffRwState::AutoPtr( - new TiffRwState(header_.byteOrder(), - mnOffset + header_.baseOffset(), - 0)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newNikonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - // If there is no "Nikon" string it must be Nikon1 format - if (size < 6 || std::string(reinterpret_cast(pData), 6) - != std::string("Nikon\0", 6)) { - return new TiffNikon1Mn(tag, group, Group::nikon1mn); - } - // If the "Nikon" string is not followed by a TIFF header, we assume - // Nikon2 format - TiffHeade2 tiffHeader; - if ( size < 18 - || !tiffHeader.read(pData + 10, size - 10) - || tiffHeader.tag() != 0x002a) { - return new TiffNikon2Mn(tag, group, Group::nikon2mn); - } - // Else we have a Nikon3 makernote - return new TiffNikon3Mn(tag, group, Group::nikon3mn); - } - -} // namespace Exiv2 diff --git a/src/nikonmn2.hpp b/src/nikonmn2.hpp deleted file mode 100644 index 5f227c76..00000000 --- a/src/nikonmn2.hpp +++ /dev/null @@ -1,221 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 nikonmn2.hpp - @brief TIFF Nikon makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 18-Apr-06, ahu: created - */ -#ifndef NIKONMN2_HPP_ -#define NIKONMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" -#include "tiffimage.hpp" // for TiffHeade2 - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t nikonmn = 263; //!< Any Nikon makernote - const uint16_t nikon1mn = 264; //!< Nikon1 makernote - const uint16_t nikon2mn = 265; //!< Nikon2 makernote - const uint16_t nikon3mn = 266; //!< Nikon3 makernote - } - - //! Nikon 1 Makernote - class TiffNikon1Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon1Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon1Mn() {} - //@} - - }; // class TiffNikon1Mn - - //! Header of a Nikon 2 Makernote - class Nikon2MnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - Nikon2MnHeader(); - //! Virtual destructor. - virtual ~Nikon2MnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Nikon 2 makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class Nikon2MnHeader - - /*! - @brief Nikon 2 Makernote - */ - class TiffNikon2Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon2Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon2Mn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - Nikon2MnHeader header_; //!< Makernote header - - }; // class TiffNikon2Mn - - //! Header of a Nikon 3 Makernote - class Nikon3MnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - Nikon3MnHeader(); - //! Virtual destructor. - virtual ~Nikon3MnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //! Return the byte order for the header - ByteOrder byteOrder() const { return byteOrder_; } - /*! - @brief Return the base offset for the makernote IFD entries relative - to the start of the makernote. - */ - uint32_t baseOffset() const { return 10; } - //@} - - private: - DataBuf buf_; //!< Raw header data - ByteOrder byteOrder_; //!< Byteorder for makernote - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Nikon 3 makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class Nikon3MnHeader - - /*! - @brief Nikon 3 Makernote - */ - class TiffNikon3Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon3Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon3Mn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - private: - // DATA - Nikon3MnHeader header_; //!< Makernote header - - }; // class TiffNikon3Mn - -// ***************************************************************************** -// template, inline and free functions - - /*! - @brief Function to create a Nikon makernote. This will create the - appropriate Nikon 1, 2 or 3 makernote, based on the arguments. - */ - TiffComponent* newNikonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef NIKONMN2_HPP_ diff --git a/src/olympusmn2.cpp b/src/olympusmn2.cpp deleted file mode 100644 index ad3178d9..00000000 --- a/src/olympusmn2.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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) - History: 15-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// 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 -#include - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte OlympusMnHeader::signature_[] = { - 'O', 'L', 'Y', 'M', 'P', 0x00, 0x01, 0x00 - }; - const uint32_t OlympusMnHeader::size_ = 8; - - OlympusMnHeader::OlympusMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool OlympusMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - - header_.alloc(size_); - memcpy(header_.pData_, pData, header_.size_); - if ( static_cast(header_.size_) < size_ - || 0 != memcmp(header_.pData_, signature_, 5)) { - return false; - } - return true; - } // OlympusMnHeader::read - - bool TiffOlympusMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - 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 diff --git a/src/olympusmn2.hpp b/src/olympusmn2.hpp deleted file mode 100644 index 68aba42a..00000000 --- a/src/olympusmn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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) - ahuggel@gmx.net - @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, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return header_.size_; } - virtual uint32_t ifdOffset() const { return size_; } - //@} - - private: - DataBuf header_; //!< Data buffer for the makernote header - static const byte 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, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - 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_ diff --git a/src/panasonicmn2.cpp b/src/panasonicmn2.cpp deleted file mode 100644 index c512b7b9..00000000 --- a/src/panasonicmn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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: panasonicmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "panasonicmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte PanasonicMnHeader::signature_[] = { - 'P', 'a', 'n', 'a', 's', 'o', 'n', 'i', 'c', 0x00, 0x00, 0x00 - }; - const uint32_t PanasonicMnHeader::size_ = 12; - - PanasonicMnHeader::PanasonicMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool PanasonicMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 9)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // PanasonicMnHeader::read - - bool TiffPanasonicMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffPanasonicMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newPanasonicMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffPanasonicMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/panasonicmn2.hpp b/src/panasonicmn2.hpp deleted file mode 100644 index d6676cf4..00000000 --- a/src/panasonicmn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 panasonicmn2.hpp - @brief TIFF Panasonic makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 18-Apr-06, ahu: created - */ -#ifndef PANASONICMN2_HPP_ -#define PANASONICMN2_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 panamn = 267; //!< Panasonic makernote - } - - //! Header of a Panasonic Makernote - class PanasonicMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - PanasonicMnHeader(); - //! Virtual destructor. - virtual ~PanasonicMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Panasonic makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class PanasonicMnHeader - - /*! - @brief Panasonic Makernote - */ - class TiffPanasonicMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffPanasonicMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup, false) {} - //! Virtual destructor - virtual ~TiffPanasonicMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - PanasonicMnHeader header_; //!< Makernote header - - }; // class TiffPanasonicMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Panasonic makernote - TiffComponent* newPanasonicMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef PANASONICMN2_HPP_ diff --git a/src/sigmamn2.cpp b/src/sigmamn2.cpp deleted file mode 100644 index 5545f4cf..00000000 --- a/src/sigmamn2.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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: sigmamn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "sigmamn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte SigmaMnHeader::signature1_[] = { - 'S', 'I', 'G', 'M', 'A', '\0', '\0', '\0', 0x01, 0x00 - }; - const byte SigmaMnHeader::signature2_[] = { - 'F', 'O', 'V', 'E', 'O', 'N', '\0', '\0', 0x01, 0x00 - }; - const uint32_t SigmaMnHeader::size_ = 10; - - SigmaMnHeader::SigmaMnHeader() - { - read(signature1_, size_, invalidByteOrder); - } - - bool SigmaMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if ( 0 != memcmp(pData, signature1_, 8) - && 0 != memcmp(pData, signature2_, 8)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // SigmaMnHeader::read - - bool TiffSigmaMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffSigmaMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newSigmaMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffSigmaMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/sigmamn2.hpp b/src/sigmamn2.hpp deleted file mode 100644 index 4359536f..00000000 --- a/src/sigmamn2.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 sigmamn2.hpp - @brief TIFF Sigma makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 18-Apr-06, ahu: created - */ -#ifndef SIGMAMN2_HPP_ -#define SIGMAMN2_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 sigmamn = 268; //!< Sigma makernote - } - - //! Header of a Sigma Makernote - class SigmaMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - SigmaMnHeader(); - //! Virtual destructor. - virtual ~SigmaMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature1_[]; //!< Sigma makernote header signature 1 - static const byte signature2_[]; //!< Sigma makernote header signature 2 - static const uint32_t size_; //!< Size of the signature - - }; // class SigmaMnHeader - - /*! - @brief Sigma Makernote - */ - class TiffSigmaMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffSigmaMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffSigmaMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - SigmaMnHeader header_; //!< Makernote header - - }; // class TiffSigmaMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Sigma makernote - TiffComponent* newSigmaMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef SIGMAMN2_HPP_ diff --git a/src/sonymn2.cpp b/src/sonymn2.cpp deleted file mode 100644 index ecd794cf..00000000 --- a/src/sonymn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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: sonymn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "sonymn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte SonyMnHeader::signature_[] = { - 'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0' - }; - const uint32_t SonyMnHeader::size_ = 12; - - SonyMnHeader::SonyMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool SonyMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, size_)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // SonyMnHeader::read - - bool TiffSonyMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffSonyMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newSonyMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffSonyMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/sonymn2.hpp b/src/sonymn2.hpp deleted file mode 100644 index 6987ad27..00000000 --- a/src/sonymn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel - * - * 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 sonymn2.hpp - @brief TIFF Sony makernote - @version $Rev$ - @author Andreas Huggel (ahu) - ahuggel@gmx.net - @date 18-Apr-06, ahu: created - */ -#ifndef SONYMN2_HPP_ -#define SONYMN2_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 sonymn = 269; //!< Sony makernote - } - - //! Header of a Sony Makernote - class SonyMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - SonyMnHeader(); - //! Virtual destructor. - virtual ~SonyMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Sony makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class SonyMnHeader - - /*! - @brief Sony Makernote - */ - class TiffSonyMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffSonyMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffSonyMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - SonyMnHeader header_; //!< Makernote header - - }; // class TiffSonyMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Sony makernote - TiffComponent* newSonyMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef SONYMN2_HPP_ diff --git a/src/tiffparser.cpp b/src/tiffparser.cpp index a4cec697..ba7a3d4d 100644 --- a/src/tiffparser.cpp +++ b/src/tiffparser.cpp @@ -39,6 +39,7 @@ EXIV2_RCSID("@(#) $Id$"); #include "tiffparser.hpp" #include "tiffcomposite.hpp" +#include "makernote2.hpp" #include "tiffvisitor.hpp" #include "tiffimage.hpp" #include "error.hpp" @@ -62,6 +63,10 @@ EXIV2_RCSID("@(#) $Id$"); + Is it easier (for writing) to combine all creation tables into one? + CR2 Makernotes don't seem to have a next pointer but Canon Jpeg Makernotes do. What a mess. (That'll become an issue when it comes to writing to CR2) + + Sony makernotes in RAW files do not seem to have header like those in Jpegs. + And maybe no next pointer either. + + Filtering of large unknown tags: Should be moved to writing/encoding code + and done only if really needed (i.e., if writing to a Jpeg segment) in crwimage.* : @@ -87,19 +92,26 @@ namespace Exiv2 { new component is. */ const TiffStructure TiffCreator::tiffStructure_[] = { - // ext. tag group create function new group - //--------- ----------- ---------------- ----------- - { Tag::root, Group::none, newTiffDirectory, Group::ifd0 }, - { 0x8769, Group::ifd0, newTiffSubIfd, Group::exif }, - { 0x8825, Group::ifd0, newTiffSubIfd, Group::gps }, - { 0x014a, Group::ifd0, newTiffSubIfd, Group::ignr }, - { 0xa005, Group::exif, newTiffSubIfd, Group::iop }, - { 0x927c, Group::exif, newTiffMnEntry, Group::mn }, - { 0x0201, Group::ifd1, newTiffThumbData, Group::ifd1 }, - { 0x0202, Group::ifd1, newTiffThumbSize, Group::ifd1 }, - { Tag::next, Group::ifd0, newTiffDirectory, Group::ifd1 }, - { Tag::next, Group::ifd1, newTiffDirectory, Group::ignr }, - { Tag::next, Group::ignr, newTiffDirectory, Group::ignr } + // ext. tag group create function new group + //--------- -------------- ------------------- -------------- + { Tag::root, Group::none, newTiffDirectory, Group::ifd0 }, + { 0x8769, Group::ifd0, newTiffSubIfd, Group::exif }, + { 0x8825, Group::ifd0, newTiffSubIfd, Group::gps }, + { 0x014a, Group::ifd0, newTiffSubIfd, Group::ignr }, // todo: better support + { 0xa005, Group::exif, newTiffSubIfd, Group::iop }, + { 0x927c, Group::exif, newTiffMnEntry, Group::mn }, + { 0x0201, Group::ifd1, newTiffThumbData, Group::ifd1 }, + { 0x0202, Group::ifd1, newTiffThumbSize, Group::ifd1 }, + { Tag::next, Group::ifd0, newTiffDirectory, Group::ifd1 }, + { Tag::next, Group::ifd1, newTiffDirectory, Group::ignr }, + { Tag::next, Group::ignr, newTiffDirectory, Group::ignr }, + // Canon makernote structure + { 0x0001, Group::canonmn, newTiffArrayEntry, Group::canoncs }, + { 0x0004, Group::canonmn, newTiffArrayEntry, Group::canonsi }, + { 0x000f, Group::canonmn, newTiffArrayEntry, Group::canoncf }, + { Tag::all, Group::canoncs, newTiffArrayElement, Group::canoncs }, + { Tag::all, Group::canonsi, newTiffArrayElement, Group::canonsi }, + { Tag::all, Group::canoncf, newTiffArrayElement, Group::canoncf } }; TiffComponent::AutoPtr TiffCreator::create(uint32_t extendedTag, diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp index 5e444dd2..08343455 100644 --- a/src/tiffvisitor.cpp +++ b/src/tiffvisitor.cpp @@ -284,7 +284,7 @@ namespace Exiv2 { void TiffPrinter::visitIfdMakernote(TiffIfdMakernote* object) { - os_ << prefix() << "Todo: Print IFD makernote header\n"; + // Nothing to do } // TiffPrinter::visitIfdMakernote void TiffPrinter::printTiffEntry(TiffEntryBase* object, @@ -359,6 +359,8 @@ namespace Exiv2 { if (pOrigState_ != pState_) delete pState_; // 0 for create function indicates 'no change' if (state->createFct_ == 0) state->createFct_ = pState_->createFct_; + // invalidByteOrder indicates 'no change' + if (state->byteOrder_ == invalidByteOrder) state->byteOrder_ = pState_->byteOrder_; pState_ = state.release(); } } @@ -589,10 +591,11 @@ namespace Exiv2 { setGo(false); return; } - // Modify reader for Makernote peculiarities, byte order, offset, - // component factory - changeState(object->getState(static_cast(object->start() - pData_), - byteOrder())); + // Modify reader for Makernote peculiarities, byte order and offset + TiffRwState::AutoPtr state( + new TiffRwState(object->byteOrder(), + object->baseOffset(static_cast(object->start() - pData_)))); + changeState(state); object->ifd_.setStart(object->start() + object->ifdOffset()); } // TiffReader::visitIfdMakernote diff --git a/src/tiffvisitor.hpp b/src/tiffvisitor.hpp index b0580166..ee301e02 100644 --- a/src/tiffvisitor.hpp +++ b/src/tiffvisitor.hpp @@ -253,37 +253,56 @@ namespace Exiv2 { reader can change state if needed (e.g., to read certain complex makernotes). */ - struct TiffRwState { + class TiffRwState { + friend class TiffReader; + public: //! TiffRWState auto_ptr type typedef std::auto_ptr AutoPtr; + + //! @name Creators + //@{ //! Constructor. - explicit TiffRwState(ByteOrder byteOrder, - uint32_t baseOffset, - TiffCompFactoryFct createFct) + TiffRwState(ByteOrder byteOrder, + uint32_t baseOffset, + TiffCompFactoryFct createFct =0) : byteOrder_(byteOrder), baseOffset_(baseOffset), createFct_(createFct) {} + //@} + + //! @name Manipulators + //@{ /*! - Applicable byte order. May be different for the Makernote and the - rest of the TIFF entries. + @brief Return the applicable byte order. May be different for + the Makernote and the rest of the TIFF entries. */ - const ByteOrder byteOrder_; + ByteOrder byteOrder() const { return byteOrder_; } /*! - Base offset. TIFF standard format uses byte offsets which are - always relative to the start of the TIFF file, i.e., relative to the - start of the TIFF image header. In this case, the base offset is 0. - However, some camera vendors encode their makernotes in TIFF IFDs - using offsets relative to (somewhere near) the start of the makernote - data. In this case, base offset added to the start of the TIFF image - header points to the basis for such makernote offsets. + @brief Return the base offset. + + TIFF standard format uses byte offsets which are always relative to + the start of the TIFF file, i.e., relative to the start of the TIFF + image header. In this case, the base offset is 0. However, some + camera vendors encode their makernotes in TIFF IFDs using offsets + relative to (somewhere near) the start of the makernote data. In this + case, base offset added to the start of the TIFF image header points + to the basis for such makernote offsets. */ - const uint32_t baseOffset_; + uint32_t baseOffset() const { return baseOffset_; } /*! - Factory function to create new TIFF components. Different create - functions may use different lookup tables, so that makernotes - can independently use their own factory function and lookup table, - which can be defined together with the makernote implementation. + @brief Return the factory function to create new TIFF components. + + Different create functions may use different lookup tables, so that + makernotes can independently use their own factory function and lookup + table, which can be defined together with the makernote + implementation. */ + TiffCompFactoryFct createFct() const { return createFct_; } + //@} + + private: + ByteOrder byteOrder_; + const uint32_t baseOffset_; TiffCompFactoryFct createFct_; }; // TiffRwState