Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_exif.h

raw
1 /*****************************************************************************/
2 // Copyright 2006-2019 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE: Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8
9 /** \file
10 * EXIF read access support. See the \ref spec_exif "EXIF specification" for full
11 * description of tags.
12 */
13
14 /*****************************************************************************/
15
16 #ifndef __dng_exif__
17 #define __dng_exif__
18
19 /*****************************************************************************/
20
21 #include "dng_classes.h"
22 #include "dng_date_time.h"
23 #include "dng_fingerprint.h"
24 #include "dng_types.h"
25 #include "dng_matrix.h"
26 #include "dng_rational.h"
27 #include "dng_string.h"
28 #include "dng_stream.h"
29 #include "dng_sdk_limits.h"
30
31 /*****************************************************************************/
32
33 /// @brief Container class for parsing and holding EXIF tags.
34 ///
35 /// Public member fields are documented in \ref spec_exif "EXIF specification."
36
37 class dng_exif
38 {
39
40 public:
41
42 dng_string fImageDescription;
43 dng_string fMake;
44 dng_string fModel;
45 dng_string fSoftware;
46 dng_string fArtist;
47 dng_string fCopyright;
48 dng_string fCopyright2;
49 dng_string fUserComment;
50
51 dng_date_time_info fDateTime;
52 dng_date_time_storage_info fDateTimeStorageInfo;
53
54 dng_date_time_info fDateTimeOriginal;
55 dng_date_time_storage_info fDateTimeOriginalStorageInfo;
56
57 dng_date_time_info fDateTimeDigitized;
58 dng_date_time_storage_info fDateTimeDigitizedStorageInfo;
59
60 uint32 fTIFF_EP_StandardID;
61 uint32 fExifVersion;
62 uint32 fFlashPixVersion;
63
64 dng_urational fExposureTime;
65 dng_urational fFNumber;
66 dng_srational fShutterSpeedValue;
67 dng_urational fApertureValue;
68 dng_srational fBrightnessValue;
69 dng_srational fExposureBiasValue;
70 dng_urational fMaxApertureValue;
71 dng_urational fFocalLength;
72 dng_urational fDigitalZoomRatio;
73 dng_urational fExposureIndex;
74 dng_urational fSubjectDistance;
75 dng_urational fGamma;
76
77 dng_urational fBatteryLevelR;
78 dng_string fBatteryLevelA;
79
80 uint32 fExposureProgram;
81 uint32 fMeteringMode;
82 uint32 fLightSource;
83 uint32 fFlash;
84 uint32 fFlashMask;
85 uint32 fSensingMethod;
86 uint32 fColorSpace;
87 uint32 fFileSource;
88 uint32 fSceneType;
89 uint32 fCustomRendered;
90 uint32 fExposureMode;
91 uint32 fWhiteBalance;
92 uint32 fSceneCaptureType;
93 uint32 fGainControl;
94 uint32 fContrast;
95 uint32 fSaturation;
96 uint32 fSharpness;
97 uint32 fSubjectDistanceRange;
98 uint32 fSelfTimerMode;
99 uint32 fImageNumber;
100
101 uint32 fFocalLengthIn35mmFilm;
102
103 uint32 fISOSpeedRatings [3]; // EXIF 2.3: PhotographicSensitivity.
104
105 // Sensitivity tags added in EXIF 2.3.
106
107 uint32 fSensitivityType;
108 uint32 fStandardOutputSensitivity;
109 uint32 fRecommendedExposureIndex;
110 uint32 fISOSpeed;
111 uint32 fISOSpeedLatitudeyyy;
112 uint32 fISOSpeedLatitudezzz;
113
114 uint32 fSubjectAreaCount;
115 uint32 fSubjectArea [4];
116
117 uint32 fComponentsConfiguration;
118
119 dng_urational fCompresssedBitsPerPixel;
120
121 uint32 fPixelXDimension;
122 uint32 fPixelYDimension;
123
124 dng_urational fFocalPlaneXResolution;
125 dng_urational fFocalPlaneYResolution;
126
127 uint32 fFocalPlaneResolutionUnit;
128
129 uint32 fCFARepeatPatternRows;
130 uint32 fCFARepeatPatternCols;
131
132 uint8 fCFAPattern [kMaxCFAPattern] [kMaxCFAPattern];
133
134 dng_fingerprint fImageUniqueID;
135
136 uint32 fGPSVersionID;
137 dng_string fGPSLatitudeRef;
138 dng_urational fGPSLatitude [3];
139 dng_string fGPSLongitudeRef;
140 dng_urational fGPSLongitude [3];
141 uint32 fGPSAltitudeRef;
142 dng_urational fGPSAltitude;
143 dng_urational fGPSTimeStamp [3];
144 dng_string fGPSSatellites;
145 dng_string fGPSStatus;
146 dng_string fGPSMeasureMode;
147 dng_urational fGPSDOP;
148 dng_string fGPSSpeedRef;
149 dng_urational fGPSSpeed;
150 dng_string fGPSTrackRef;
151 dng_urational fGPSTrack;
152 dng_string fGPSImgDirectionRef;
153 dng_urational fGPSImgDirection;
154 dng_string fGPSMapDatum;
155 dng_string fGPSDestLatitudeRef;
156 dng_urational fGPSDestLatitude [3];
157 dng_string fGPSDestLongitudeRef;
158 dng_urational fGPSDestLongitude [3];
159 dng_string fGPSDestBearingRef;
160 dng_urational fGPSDestBearing;
161 dng_string fGPSDestDistanceRef;
162 dng_urational fGPSDestDistance;
163 dng_string fGPSProcessingMethod;
164 dng_string fGPSAreaInformation;
165 dng_string fGPSDateStamp;
166 uint32 fGPSDifferential;
167 dng_urational fGPSHPositioningError;
168
169 dng_string fInteroperabilityIndex;
170
171 uint32 fInteroperabilityVersion;
172
173 dng_string fRelatedImageFileFormat;
174
175 uint32 fRelatedImageWidth;
176 uint32 fRelatedImageLength;
177
178 dng_string fCameraSerialNumber; // EXIF 2.3: BodySerialNumber.
179
180 dng_urational fLensInfo [4]; // EXIF 2.3: LensSpecification.
181
182 dng_string fLensID;
183 dng_string fLensMake;
184 dng_string fLensName; // EXIF 2.3: LensModel.
185 dng_string fLensSerialNumber;
186
187 // Was the lens name field read from a LensModel tag?
188
189 bool fLensNameWasReadFromExif;
190
191 // Private field to hold the approximate focus distance of the lens, in
192 // meters. This value is often coarsely measured/reported and hence should be
193 // interpreted only as a rough estimate of the true distance from the plane
194 // of focus (in object space) to the focal plane. It is still useful for the
195 // purposes of applying lens corrections.
196
197 dng_urational fApproxFocusDistance;
198
199 dng_srational fFlashCompensation;
200
201 dng_string fOwnerName; // EXIF 2.3: CameraOwnerName.
202 dng_string fFirmware;
203
204 // EXIF 2.3.1:
205
206 dng_srational fTemperature;
207 dng_urational fHumidity;
208 dng_urational fPressure;
209 dng_srational fWaterDepth;
210 dng_urational fAcceleration;
211 dng_srational fCameraElevationAngle;
212
213 // Not really part of EXIF, but some formats may use.
214
215 dng_string fTitle;
216
217 // Image-specific radial distortion correction metadata that can be
218 // used later during (UI-driven) lens profile corrections. Same model
219 // as DNG 1.3 opcode model.
220
221 dng_srational fLensDistortInfo [4];
222
223 // Some cameras have a built-in neutral density filter. If the ND
224 // filter is applied, it reduces the incoming light by a linear factor
225 // K. This field stores the value of K. For example, if the camera has
226 // applied a 3-stop neutral density filter, this reduces the incoming
227 // light by a linear factor of 8, so this field should store 8/1.
228 //
229 // The default value is invalid (0/0) which means ND is not present or
230 // unknown.
231
232 dng_urational fNeutralDensityFactor;
233
234 public:
235
236 dng_exif ();
237
238 virtual ~dng_exif ();
239
240 /// Make clone.
241
242 virtual dng_exif * Clone () const;
243
244 /// Clear all EXIF fields.
245
246 void SetEmpty ();
247
248 /// Copy all GPS-related fields.
249 /// \param exif Source object from which to copy GPS fields.
250
251 void CopyGPSFrom (const dng_exif &exif);
252
253 /// Copy EXIF date-related fields.
254 /// \param exif Source object from which to copy date fields.
255
256 void CopyDateFrom (const dng_exif &exif);
257
258 /// Utility to fix up common errors and rounding issues with EXIF exposure
259 /// times.
260
261 static real64 SnapExposureTime (real64 et);
262
263 /// Set exposure time and shutter speed fields. Optionally fix up common
264 /// errors and rounding issues with EXIF exposure times.
265 /// \param et Exposure time in seconds.
266 /// \param snap Set to true to fix up common errors and rounding issues with
267 /// EXIF exposure times.
268
269 void SetExposureTime (real64 et,
270 bool snap = true);
271
272 /// Set shutter speed value (APEX units) and exposure time.
273 /// \param ss Shutter speed in APEX units.
274
275 void SetShutterSpeedValue (real64 ss);
276
277 /// Utility to encode f-number as a rational.
278 /// \param fs The f-number to encode.
279
280 static dng_urational EncodeFNumber (real64 fs);
281
282 /// Set the FNumber and ApertureValue fields.
283 /// \param fs The f-number to set.
284
285 void SetFNumber (real64 fs);
286
287 /// Set the FNumber and ApertureValue fields.
288 /// \param av The aperture value (APEX units).
289
290 void SetApertureValue (real64 av);
291
292 /// Utility to convert aperture value (APEX units) to f-number.
293 /// \param av The aperture value (APEX units) to convert.
294
295 static real64 ApertureValueToFNumber (real64 av);
296
297 /// Utility to convert aperture value (APEX units) to f-number.
298 /// \param av The aperture value (APEX units) to convert.
299
300 static real64 ApertureValueToFNumber (const dng_urational &av);
301
302 /// Utility to convert f-number to aperture value (APEX units).
303 /// \param fNumber The f-number to convert.
304
305 static real64 FNumberToApertureValue (real64 fNumber);
306
307 /// Utility to convert f-number to aperture value (APEX units).
308 /// \param fNumber The f-number to convert.
309
310 static real64 FNumberToApertureValue (const dng_urational &fNumber);
311
312 /// Set the DateTime field.
313 /// \param dt The DateTime value.
314
315 void UpdateDateTime (const dng_date_time_info &dt);
316
317 /// Returns true iff the EXIF version is at least 2.3.
318
319 bool AtLeastVersion0230 () const;
320
321 /// Returns true iff the EXIF version is at least 2.3.1.
322
323 bool AtLeastVersion0231 () const;
324
325 /// Sets the EXIF version to 2.3.1.
326
327 void SetVersion0231 ();
328
329 bool HasLensDistortInfo () const;
330
331 void SetLensDistortInfo (const dng_vector &params);
332
333 virtual bool ParseTag (dng_stream &stream,
334 dng_shared &shared,
335 uint32 parentCode,
336 bool isMainIFD,
337 uint32 tagCode,
338 uint32 tagType,
339 uint32 tagCount,
340 uint64 tagOffset);
341
342 virtual void PostParse (dng_host &host,
343 dng_shared &shared);
344
345 protected:
346
347 virtual bool Parse_ifd0 (dng_stream &stream,
348 dng_shared &shared,
349 uint32 parentCode,
350 uint32 tagCode,
351 uint32 tagType,
352 uint32 tagCount,
353 uint64 tagOffset);
354
355 virtual bool Parse_ifd0_main (dng_stream &stream,
356 dng_shared &shared,
357 uint32 parentCode,
358 uint32 tagCode,
359 uint32 tagType,
360 uint32 tagCount,
361 uint64 tagOffset);
362
363 virtual bool Parse_ifd0_exif (dng_stream &stream,
364 dng_shared &shared,
365 uint32 parentCode,
366 uint32 tagCode,
367 uint32 tagType,
368 uint32 tagCount,
369 uint64 tagOffset);
370
371 virtual bool Parse_gps (dng_stream &stream,
372 dng_shared &shared,
373 uint32 parentCode,
374 uint32 tagCode,
375 uint32 tagType,
376 uint32 tagCount,
377 uint64 tagOffset);
378
379 virtual bool Parse_interoperability (dng_stream &stream,
380 dng_shared &shared,
381 uint32 parentCode,
382 uint32 tagCode,
383 uint32 tagType,
384 uint32 tagCount,
385 uint64 tagOffset);
386
387 };
388
389 /*****************************************************************************/
390
391 #endif
392
393 /*****************************************************************************/