* Replaced too simple prefix with a more general concept of a makernote header.

* Added "FOVEON" and "*" to registry.
* Code and documentation cleanup.
v0.27.3
Andreas Huggel 21 years ago
parent 63883fa21f
commit cbb317bc12

@ -20,7 +20,7 @@
*/ */
/* /*
File: sigmamn.cpp File: sigmamn.cpp
Version: $Name: $ $Revision: 1.4 $ Version: $Name: $ $Revision: 1.5 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 02-Apr-04, ahu: created History: 02-Apr-04, ahu: created
Credits: Sigma and Foveon MakerNote implemented according to the specification Credits: Sigma and Foveon MakerNote implemented according to the specification
@ -29,7 +29,7 @@
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.4 $ $RCSfile: sigmamn.cpp,v $") EXIV2_RCSID("@(#) $Name: $ $Revision: 1.5 $ $RCSfile: sigmamn.cpp,v $")
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
@ -42,6 +42,7 @@ EXIV2_RCSID("@(#) $Name: $ $Revision: 1.4 $ $RCSfile: sigmamn.cpp,v $")
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <cassert>
// Define DEBUG_MAKERNOTE to output debug information to std::cerr // Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE #undef DEBUG_MAKERNOTE
@ -84,15 +85,42 @@ namespace Exiv2 {
SigmaMakerNote::SigmaMakerNote(bool alloc) SigmaMakerNote::SigmaMakerNote(bool alloc)
: IfdMakerNote(sigmaMnTagInfo, alloc), sectionName_("Sigma") : IfdMakerNote(sigmaMnTagInfo, alloc), sectionName_("Sigma")
{ {
// My one and only Sigma sample has two undocumented extra bytes
// (0x01, 0x00) between the ID string and the start of the
// Makernote IFD. Adding them to the ID string is a hack...
prefix_ = std::string("SIGMA\0\0\0\x1\0", 10);
} }
MakerNote* SigmaMakerNote::clone(bool alloc) const int SigmaMakerNote::readHeader(const char* buf,
long len,
ByteOrder byteOrder)
{ {
return createSigmaMakerNote(alloc); if (len < 10) return 1;
// Copy the header. My one and only Sigma sample has two undocumented
// extra bytes (0x01, 0x00) between the ID string and the start of the
// Makernote IFD. So we copy 10 bytes into the header.
header_.alloc(10);
memcpy(header_.pData_, buf, header_.size_);
// Adjust the offset of the IFD for the prefix
adjOffset_ = 10;
return 0;
}
int SigmaMakerNote::checkHeader() const
{
int rc = 0;
// Check the SIGMA or FOVEON prefix
if ( header_.size_ < 10
|| std::string(header_.pData_, 8) != std::string("SIGMA\0\0\0", 8)
&& std::string(header_.pData_, 8) != std::string("FOVEON\0\0", 8)) {
rc = 2;
}
return rc;
}
SigmaMakerNote* SigmaMakerNote::clone(bool alloc) const
{
SigmaMakerNote* pMakerNote = new SigmaMakerNote(alloc);
assert(pMakerNote);
pMakerNote->readHeader(header_.pData_, header_.size_, byteOrder_);
return pMakerNote;
} }
std::ostream& SigmaMakerNote::printTag(std::ostream& os, std::ostream& SigmaMakerNote::printTag(std::ostream& os,

@ -21,9 +21,9 @@
/*! /*!
@file sigmamn.hpp @file sigmamn.hpp
@brief Sigma and Foveon MakerNote implemented according to the specification @brief Sigma and Foveon MakerNote implemented according to the specification
in "SIGMA and FOVEON EXIF MakerNote Documentation" by Foveon. <a href="http://www.x3f.info/technotes/FileDocs/MakerNoteDoc.html">
<http://www.x3f.info/technotes/FileDocs/MakerNoteDoc.html> SIGMA and FOVEON EXIF MakerNote Documentation</a> by Foveon.
@version $Name: $ $Revision: 1.3 $ @version $Name: $ $Revision: 1.4 $
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 02-Apr-04, ahu: created @date 02-Apr-04, ahu: created
@ -81,9 +81,17 @@ namespace Exiv2 {
virtual ~SigmaMakerNote() {} virtual ~SigmaMakerNote() {}
//@} //@}
//! @name Manipulators
//@{
int readHeader(const char* buf,
long len,
ByteOrder byteOrder);
//@}
//! @name Accessors //! @name Accessors
//@{ //@{
MakerNote* clone(bool alloc =true) const; int checkHeader() const;
SigmaMakerNote* clone(bool alloc =true) const;
//! Return the name of the makernote section ("Sigma") //! Return the name of the makernote section ("Sigma")
std::string sectionName(uint16 tag) const { return sectionName_; } std::string sectionName(uint16 tag) const { return sectionName_; }
std::ostream& printTag(std::ostream& os, std::ostream& printTag(std::ostream& os,
@ -109,8 +117,10 @@ namespace Exiv2 {
{ {
MakerNoteFactory& mnf = MakerNoteFactory::instance(); MakerNoteFactory& mnf = MakerNoteFactory::instance();
mnf.registerMakerNote("SIGMA", "*", createSigmaMakerNote); mnf.registerMakerNote("SIGMA", "*", createSigmaMakerNote);
mnf.registerMakerNote("FOVEON", "*", createSigmaMakerNote);
} }
}; };
// DATA
/*! /*!
The static member variable is initialized before main (see note) and The static member variable is initialized before main (see note) and
will in the process register the MakerNote class. (Remember the will in the process register the MakerNote class. (Remember the

Loading…
Cancel
Save