* 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
Version: $Name: $ $Revision: 1.4 $
Version: $Name: $ $Revision: 1.5 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 02-Apr-04, ahu: created
Credits: Sigma and Foveon MakerNote implemented according to the specification
@ -29,7 +29,7 @@
*/
// *****************************************************************************
#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
@ -42,6 +42,7 @@ EXIV2_RCSID("@(#) $Name: $ $Revision: 1.4 $ $RCSfile: sigmamn.cpp,v $")
#include <string>
#include <sstream>
#include <iomanip>
#include <cassert>
// Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE
@ -84,15 +85,42 @@ namespace Exiv2 {
SigmaMakerNote::SigmaMakerNote(bool alloc)
: 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,
@ -161,7 +189,7 @@ namespace Exiv2 {
MakerNote* createSigmaMakerNote(bool alloc)
{
return new SigmaMakerNote(alloc);
return new SigmaMakerNote(alloc);
}
} // namespace Exiv2

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

Loading…
Cancel
Save