1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2017 Andreas Huggel <ahuggel@gmx.net>
4  *
5  * This program is part of the Exiv2 distribution.
6  *
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.
11  *
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.
16  *
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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
20  */
21 /*
22   File:      sigmamn.cpp
23   Version:   $Rev: 4719 $
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>
29  */
30 // *****************************************************************************
31 #include "rcsid_int.hpp"
32 EXIV2_RCSID("@(#) $Id: sigmamn.cpp 4719 2017-03-08 20:42:28Z robinwmills $")
33 
34 // *****************************************************************************
35 // included header files
36 #include "types.hpp"
37 #include "sigmamn_int.hpp"
38 #include "tags_int.hpp"
39 #include "value.hpp"
40 #include "i18n.h"                // NLS support.
41 
42 // + standard includes
43 #include <string>
44 #include <sstream>
45 #include <iomanip>
46 #include <cassert>
47 #include <cstring>
48 
49 // *****************************************************************************
50 // class member definitions
51 namespace Exiv2 {
52     namespace Internal {
53 
54     // Sigma (Foveon) MakerNote Tag Info
55     const TagInfo SigmaMakerNote::tagInfo_[] = {
56         TagInfo(0x0002, "SerialNumber", N_("Serial Number"),
57                 N_("Camera serial number"),
58                 sigmaId, makerTags, asciiString, -1, printValue),
59         TagInfo(0x0003, "DriveMode", N_("Drive Mode"),
60                 N_("Drive mode"),
61                 sigmaId, makerTags, asciiString, -1, printValue),
62         TagInfo(0x0004, "ResolutionMode", N_("Resolution Mode"),
63                 N_("Resolution mode"),
64                 sigmaId, makerTags, asciiString, -1, printValue),
65         TagInfo(0x0005, "AutofocusMode", N_("Autofocus Mode"),
66                 N_("Autofocus mode"),
67                 sigmaId, makerTags, asciiString, -1, printValue),
68         TagInfo(0x0006, "FocusSetting", N_("Focus Setting"),
69                 N_("Focus setting"),
70                 sigmaId, makerTags, asciiString, -1, printValue),
71         TagInfo(0x0007, "WhiteBalance", N_("White Balance"),
72                 N_("White balance"),
73                 sigmaId, makerTags, asciiString, -1, printValue),
74         TagInfo(0x0008, "ExposureMode", N_("Exposure Mode"),
75                 N_("Exposure mode"),
76                 sigmaId, makerTags, asciiString, -1, print0x0008),
77         TagInfo(0x0009, "MeteringMode", N_("Metering Mode"),
78                 N_("Metering mode"),
79                 sigmaId, makerTags, asciiString, -1, print0x0009),
80         TagInfo(0x000a, "LensRange", N_("Lens Range"),
81                 N_("Lens focal length range"),
82                 sigmaId, makerTags, asciiString, -1, printValue),
83         TagInfo(0x000b, "ColorSpace", N_("Color Space"),
84                 N_("Color space"),
85                 sigmaId, makerTags, asciiString, -1, printValue),
86         TagInfo(0x000c, "Exposure", N_("Exposure"),
87                 N_("Exposure"),
88                 sigmaId, makerTags, asciiString, -1, printStripLabel),
89         TagInfo(0x000d, "Contrast", N_("Contrast"),
90                 N_("Contrast"),
91                 sigmaId, makerTags, asciiString, -1, printStripLabel),
92         TagInfo(0x000e, "Shadow", N_("Shadow"),
93                 N_("Shadow"),
94                 sigmaId, makerTags, asciiString, -1, printStripLabel),
95         TagInfo(0x000f, "Highlight", N_("Highlight"),
96                 N_("Highlight"),
97                 sigmaId, makerTags, asciiString, -1, printStripLabel),
98         TagInfo(0x0010, "Saturation", N_("Saturation"),
99                 N_("Saturation"),
100                 sigmaId, makerTags, asciiString, -1, printStripLabel),
101         TagInfo(0x0011, "Sharpness", N_("Sharpness"),
102                 N_("Sharpness"),
103                 sigmaId, makerTags, asciiString, -1, printStripLabel),
104         TagInfo(0x0012, "FillLight", N_("Fill Light"),
105                 N_("X3 Fill light"),
106                 sigmaId, makerTags, asciiString, -1, printStripLabel),
107         TagInfo(0x0014, "ColorAdjustment", N_("Color Adjustment"),
108                 N_("Color adjustment"),
109                 sigmaId, makerTags, asciiString, -1, printStripLabel),
110         TagInfo(0x0015, "AdjustmentMode", N_("Adjustment Mode"),
111                 N_("Adjustment mode"),
112                 sigmaId, makerTags, asciiString, -1, printValue),
113         TagInfo(0x0016, "Quality", N_("Quality"),
114                 N_("Quality"),
115                 sigmaId, makerTags, asciiString, -1, printStripLabel),
116         TagInfo(0x0017, "Firmware", N_("Firmware"),
117                 N_("Firmware"),
118                 sigmaId, makerTags, asciiString, -1, printValue),
119         TagInfo(0x0018, "Software", N_("Software"),
120                 N_("Software"),
121                 sigmaId, makerTags, asciiString, -1, printValue),
122         TagInfo(0x0019, "AutoBracket", N_("Auto Bracket"),
123                 N_("Auto bracket"),
124                 sigmaId, makerTags, asciiString, -1, printValue),
125         // End of list marker
126         TagInfo(0xffff, "(UnknownSigmaMakerNoteTag)", "(UnknownSigmaMakerNoteTag)",
127                 N_("Unknown SigmaMakerNote tag"),
128                 sigmaId, makerTags, asciiString, -1, printValue)
129     };
130 
tagList()131     const TagInfo* SigmaMakerNote::tagList()
132     {
133         return tagInfo_;
134     }
135 
printStripLabel(std::ostream & os,const Value & value,const ExifData *)136     std::ostream& SigmaMakerNote::printStripLabel(std::ostream& os,
137                                                   const Value& value,
138                                                   const ExifData*)
139     {
140         std::string v = value.toString();
141         std::string::size_type pos = v.find(':');
142         if (pos != std::string::npos) {
143             if (v[pos + 1] == ' ') ++pos;
144             v = v.substr(pos + 1);
145         }
146         return os << v;
147     }
148 
print0x0008(std::ostream & os,const Value & value,const ExifData *)149     std::ostream& SigmaMakerNote::print0x0008(std::ostream& os,
150                                               const Value& value,
151                                               const ExifData*)
152     {
153         switch (value.toString()[0]) {
154         case 'P': os << _("Program"); break;
155         case 'A': os << _("Aperture priority"); break;
156         case 'S': os << _("Shutter priority"); break;
157         case 'M': os << _("Manual"); break;
158         default: os << "(" << value << ")"; break;
159         }
160         return os;
161     }
162 
print0x0009(std::ostream & os,const Value & value,const ExifData *)163     std::ostream& SigmaMakerNote::print0x0009(std::ostream& os,
164                                               const Value& value,
165                                               const ExifData*)
166     {
167         switch (value.toString()[0]) {
168         case 'A': os << _("Average"); break;
169         case 'C': os << _("Center"); break;
170         case '8': os << _("8-Segment"); break;
171         default: os << "(" << value << ")"; break;
172         }
173         return os;
174     }
175 
176 }}                                      // namespace Internal, Exiv2
177