1
// ***************************************************************** -*- C++ -*-
3
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
5
* This program is part of the Exiv2 distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
History: 02-Apr-04, ahu: created
26
Credits: Sigma and Foveon MakerNote implemented according to the specification
27
in "SIGMA and FOVEON EXIF MakerNote Documentation" by Foveon.
28
<http://www.x3f.info/technotes/FileDocs/MakerNoteDoc.html>
30
// *****************************************************************************
32
EXIV2_RCSID("@(#) $Id: sigmamn.cpp 600 2005-07-09 10:38:09Z ahuggel $");
34
// *****************************************************************************
35
// included header files
37
#include "sigmamn.hpp"
38
#include "makernote.hpp"
41
// + standard includes
47
// *****************************************************************************
48
// class member definitions
52
SigmaMakerNote::RegisterMn::RegisterMn()
54
MakerNoteFactory::registerMakerNote("SIGMA", "*", createSigmaMakerNote);
55
MakerNoteFactory::registerMakerNote("FOVEON", "*", createSigmaMakerNote);
56
MakerNoteFactory::registerMakerNote(
57
sigmaIfdId, MakerNote::AutoPtr(new SigmaMakerNote));
59
ExifTags::registerMakerTagInfo(sigmaIfdId, tagInfo_);
63
// Sigma (Foveon) MakerNote Tag Info
64
const TagInfo SigmaMakerNote::tagInfo_[] = {
65
TagInfo(0x0002, "SerialNumber", "Camera serial number", sigmaIfdId, makerTags, asciiString, printValue),
66
TagInfo(0x0003, "DriveMode", "Drive Mode", sigmaIfdId, makerTags, asciiString, printValue),
67
TagInfo(0x0004, "ResolutionMode", "Resolution Mode", sigmaIfdId, makerTags, asciiString, printValue),
68
TagInfo(0x0005, "AutofocusMode", "Autofocus mode", sigmaIfdId, makerTags, asciiString, printValue),
69
TagInfo(0x0006, "FocusSetting", "Focus setting", sigmaIfdId, makerTags, asciiString, printValue),
70
TagInfo(0x0007, "WhiteBalance", "White balance", sigmaIfdId, makerTags, asciiString, printValue),
71
TagInfo(0x0008, "ExposureMode", "Exposure mode", sigmaIfdId, makerTags, asciiString, print0x0008),
72
TagInfo(0x0009, "MeteringMode", "Metering mode", sigmaIfdId, makerTags, asciiString, print0x0009),
73
TagInfo(0x000a, "LensRange", "Lens focal length range", sigmaIfdId, makerTags, asciiString, printValue),
74
TagInfo(0x000b, "ColorSpace", "Color space", sigmaIfdId, makerTags, asciiString, printValue),
75
TagInfo(0x000c, "Exposure", "Exposure", sigmaIfdId, makerTags, asciiString, printStripLabel),
76
TagInfo(0x000d, "Contrast", "Contrast", sigmaIfdId, makerTags, asciiString, printStripLabel),
77
TagInfo(0x000e, "Shadow", "Shadow", sigmaIfdId, makerTags, asciiString, printStripLabel),
78
TagInfo(0x000f, "Highlight", "Highlight", sigmaIfdId, makerTags, asciiString, printStripLabel),
79
TagInfo(0x0010, "Saturation", "Saturation", sigmaIfdId, makerTags, asciiString, printStripLabel),
80
TagInfo(0x0011, "Sharpness", "Sharpness", sigmaIfdId, makerTags, asciiString, printStripLabel),
81
TagInfo(0x0012, "FillLight", "X3 Fill light", sigmaIfdId, makerTags, asciiString, printStripLabel),
82
TagInfo(0x0014, "ColorAdjustment", "Color adjustment", sigmaIfdId, makerTags, asciiString, printStripLabel),
83
TagInfo(0x0015, "AdjustmentMode", "Adjustment mode", sigmaIfdId, makerTags, asciiString, printValue),
84
TagInfo(0x0016, "Quality", "Quality", sigmaIfdId, makerTags, asciiString, printStripLabel),
85
TagInfo(0x0017, "Firmware", "Firmware", sigmaIfdId, makerTags, asciiString, printValue),
86
TagInfo(0x0018, "Software", "Software", sigmaIfdId, makerTags, asciiString, printValue),
87
TagInfo(0x0019, "AutoBracket", "Auto bracket", sigmaIfdId, makerTags, asciiString, printValue),
89
TagInfo(0xffff, "(UnknownSigmaMakerNoteTag)", "Unknown SigmaMakerNote tag", sigmaIfdId, makerTags, invalidTypeId, printValue)
92
SigmaMakerNote::SigmaMakerNote(bool alloc)
93
: IfdMakerNote(sigmaIfdId, alloc)
96
'S', 'I', 'G', 'M', 'A', '\0', '\0', '\0', 0x01, 0x00
98
readHeader(buf, 10, byteOrder_);
101
SigmaMakerNote::SigmaMakerNote(const SigmaMakerNote& rhs)
106
int SigmaMakerNote::readHeader(const byte* buf,
110
if (len < 10) return 1;
112
// Copy the header. My one and only Sigma sample has two undocumented
113
// extra bytes (0x01, 0x00) between the ID string and the start of the
114
// Makernote IFD. So we copy 10 bytes into the header.
116
memcpy(header_.pData_, buf, header_.size_);
117
// Adjust the offset of the IFD for the prefix
122
int SigmaMakerNote::checkHeader() const
125
// Check the SIGMA or FOVEON prefix
126
if ( header_.size_ < 10
127
|| std::string(reinterpret_cast<char*>(header_.pData_), 8)
128
!= std::string("SIGMA\0\0\0", 8)
129
&& std::string(reinterpret_cast<char*>(header_.pData_), 8)
130
!= std::string("FOVEON\0\0", 8)) {
136
SigmaMakerNote::AutoPtr SigmaMakerNote::create(bool alloc) const
138
return AutoPtr(create_(alloc));
141
SigmaMakerNote* SigmaMakerNote::create_(bool alloc) const
143
AutoPtr makerNote = AutoPtr(new SigmaMakerNote(alloc));
144
assert(makerNote.get() != 0);
145
makerNote->readHeader(header_.pData_, header_.size_, byteOrder_);
146
return makerNote.release();
149
SigmaMakerNote::AutoPtr SigmaMakerNote::clone() const
151
return AutoPtr(clone_());
154
SigmaMakerNote* SigmaMakerNote::clone_() const
156
return new SigmaMakerNote(*this);
159
std::ostream& SigmaMakerNote::printStripLabel(std::ostream& os,
162
std::string v = value.toString();
163
std::string::size_type pos = v.find(':');
164
if (pos != std::string::npos) {
165
if (v[pos + 1] == ' ') ++pos;
166
v = v.substr(pos + 1);
171
std::ostream& SigmaMakerNote::print0x0008(std::ostream& os,
174
switch (value.toString()[0]) {
175
case 'P': os << "Program"; break;
176
case 'A': os << "Aperture priority"; break;
177
case 'S': os << "Shutter priority"; break;
178
case 'M': os << "Manual"; break;
179
default: os << "(" << value << ")"; break;
184
std::ostream& SigmaMakerNote::print0x0009(std::ostream& os,
187
switch (value.toString()[0]) {
188
case 'A': os << "Average"; break;
189
case 'C': os << "Center"; break;
190
case '8': os << "8-Segment"; break;
191
default: os << "(" << value << ")"; break;
196
// *****************************************************************************
199
MakerNote::AutoPtr createSigmaMakerNote(bool alloc,
205
return MakerNote::AutoPtr(new SigmaMakerNote(alloc));