summaryrefslogtreecommitdiff
path: root/gpr/source/lib/dng_sdk/dng_exif.h
blob: a85fc7d4ea1c936f46e59516b70c161de11616e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*****************************************************************************/
// Copyright 2006-2008 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_exif.h#2 $ */ 
/* $DateTime: 2012/07/11 10:36:56 $ */
/* $Change: 838485 $ */
/* $Author: tknoll $ */

/** \file
 * EXIF read access support. See the \ref spec_exif "EXIF specification" for full
 * description of tags.
 */

/*****************************************************************************/

#ifndef __dng_exif__
#define __dng_exif__

/*****************************************************************************/

#include "dng_classes.h"
#include "dng_date_time.h"
#include "dng_fingerprint.h"
#include "dng_types.h"
#include "dng_matrix.h"
#include "dng_rational.h"
#include "dng_string.h"
#include "dng_stream.h"
#include "dng_sdk_limits.h"

/*****************************************************************************/

/// \brief Container class for parsing and holding EXIF tags.
///
/// Public member fields are documented in \ref spec_exif "EXIF specification."

class dng_exif
	{
	
	public:
	
		dng_string fImageDescription;
		dng_string fMake;
		dng_string fModel;
		dng_string fSoftware;
		dng_string fArtist;
		dng_string fCopyright;
		dng_string fCopyright2;
		dng_string fUserComment;
		
		dng_date_time_info         fDateTime;
		dng_date_time_storage_info fDateTimeStorageInfo;
		
		dng_date_time_info		   fDateTimeOriginal;
		dng_date_time_storage_info fDateTimeOriginalStorageInfo;

		dng_date_time_info 		   fDateTimeDigitized;
		dng_date_time_storage_info fDateTimeDigitizedStorageInfo;
		
		uint32 fTIFF_EP_StandardID;
		uint32 fExifVersion;
		uint32 fFlashPixVersion;
		
		dng_urational fExposureTime;
		dng_urational fFNumber;
		dng_srational fShutterSpeedValue;
		dng_urational fApertureValue;
		dng_srational fBrightnessValue;
		dng_srational fExposureBiasValue;
		dng_urational fMaxApertureValue;
		dng_urational fFocalLength;
		dng_urational fDigitalZoomRatio;
		dng_urational fExposureIndex;
		dng_urational fSubjectDistance;
		dng_urational fGamma;
		
		dng_urational fBatteryLevelR;
		dng_string    fBatteryLevelA;
		
		uint32 fExposureProgram;
		uint32 fMeteringMode;
		uint32 fLightSource;
		uint32 fFlash;
		uint32 fFlashMask;
		uint32 fSensingMethod;
		uint32 fColorSpace;
		uint32 fFileSource;
		uint32 fSceneType;
		uint32 fCustomRendered;
		uint32 fExposureMode;
		uint32 fWhiteBalance;
		uint32 fSceneCaptureType;
		uint32 fGainControl;
		uint32 fContrast;
		uint32 fSaturation;
		uint32 fSharpness;
		uint32 fSubjectDistanceRange;
		uint32 fSelfTimerMode;
		uint32 fImageNumber;

		uint32 fFocalLengthIn35mmFilm;
		
		uint32 fISOSpeedRatings [3];		 // EXIF 2.3: PhotographicSensitivity.

		// Sensitivity tags added in EXIF 2.3.

		uint32 fSensitivityType;
		uint32 fStandardOutputSensitivity;
		uint32 fRecommendedExposureIndex;
		uint32 fISOSpeed;
		uint32 fISOSpeedLatitudeyyy;
		uint32 fISOSpeedLatitudezzz;
		
		uint32 fSubjectAreaCount;
		uint32 fSubjectArea [4];
		
		uint32 fComponentsConfiguration;
		
		dng_urational fCompresssedBitsPerPixel;
		
		uint32 fPixelXDimension;
		uint32 fPixelYDimension;
		
		dng_urational fFocalPlaneXResolution;
		dng_urational fFocalPlaneYResolution;
		
		uint32 fFocalPlaneResolutionUnit;
		
		uint32 fCFARepeatPatternRows;
		uint32 fCFARepeatPatternCols;
		
		uint8 fCFAPattern [kMaxCFAPattern] [kMaxCFAPattern];
		
		dng_fingerprint fImageUniqueID;
		
		uint32 	      fGPSVersionID;
		dng_string    fGPSLatitudeRef;
		dng_urational fGPSLatitude [3];
		dng_string    fGPSLongitudeRef;
		dng_urational fGPSLongitude [3];
		uint32	      fGPSAltitudeRef;
		dng_urational fGPSAltitude;
		dng_urational fGPSTimeStamp [3];
		dng_string    fGPSSatellites;
		dng_string    fGPSStatus;
		dng_string    fGPSMeasureMode;
		dng_urational fGPSDOP;
		dng_string    fGPSSpeedRef;
		dng_urational fGPSSpeed;
		dng_string    fGPSTrackRef;
		dng_urational fGPSTrack;
		dng_string    fGPSImgDirectionRef;
		dng_urational fGPSImgDirection;
		dng_string    fGPSMapDatum;
		dng_string    fGPSDestLatitudeRef;
		dng_urational fGPSDestLatitude [3];
		dng_string    fGPSDestLongitudeRef;
		dng_urational fGPSDestLongitude [3];
		dng_string    fGPSDestBearingRef;
		dng_urational fGPSDestBearing;
		dng_string    fGPSDestDistanceRef;
		dng_urational fGPSDestDistance;
		dng_string    fGPSProcessingMethod;
		dng_string    fGPSAreaInformation;
		dng_string    fGPSDateStamp;
		uint32 	      fGPSDifferential;
		dng_urational fGPSHPositioningError;
		
		dng_string fInteroperabilityIndex;
		
		uint32 fInteroperabilityVersion;
		
		dng_string fRelatedImageFileFormat;
		
		uint32 fRelatedImageWidth;	
		uint32 fRelatedImageLength;

		dng_string fCameraSerialNumber;		 // EXIF 2.3: BodySerialNumber.
		
		dng_urational fLensInfo [4];		 // EXIF 2.3: LensSpecification.
		
		dng_string fLensID;
		dng_string fLensMake;
		dng_string fLensName;				 // EXIF 2.3: LensModel.
		dng_string fLensSerialNumber;
		
		// Was the lens name field read from a LensModel tag?
		
		bool fLensNameWasReadFromExif;

		// Private field to hold the approximate focus distance of the lens, in
		// meters. This value is often coarsely measured/reported and hence should be
		// interpreted only as a rough estimate of the true distance from the plane
		// of focus (in object space) to the focal plane. It is still useful for the
		// purposes of applying lens corrections.

		dng_urational fApproxFocusDistance;
	
		dng_srational fFlashCompensation;
		
		dng_string fOwnerName;				 // EXIF 2.3: CameraOwnerName.
		dng_string fFirmware;
		
	public:
	
		dng_exif ();
		
		virtual ~dng_exif ();

		/// Make clone.
		
		virtual dng_exif * Clone () const;

		/// Clear all EXIF fields.
		
		void SetEmpty ();

		/// Copy all GPS-related fields.
		/// \param exif Source object from which to copy GPS fields.
		
		void CopyGPSFrom (const dng_exif &exif);

		/// Utility to fix up common errors and rounding issues with EXIF exposure
		/// times.

		static real64 SnapExposureTime (real64 et);

		/// Set exposure time and shutter speed fields. Optionally fix up common
		/// errors and rounding issues with EXIF exposure times.
		/// \param et Exposure time in seconds.
		/// \param snap Set to true to fix up common errors and rounding issues with
		/// EXIF exposure times.
		
		void SetExposureTime (real64 et,
							  bool snap = true);

		/// Set shutter speed value (APEX units) and exposure time.
		/// \param Shutter speed in APEX units.
		
		void SetShutterSpeedValue (real64 ss);

		/// Utility to encode f-number as a rational.
		/// \param fs The f-number to encode.
		
		static dng_urational EncodeFNumber (real64 fs);

		/// Set the FNumber and ApertureValue fields.
		/// \param fs The f-number to set.
		
		void SetFNumber (real64 fs);
		
		/// Set the FNumber and ApertureValue fields.
		/// \param av The aperture value (APEX units).
		
		void SetApertureValue (real64 av);

		/// Utility to convert aperture value (APEX units) to f-number.
		/// \param av The aperture value (APEX units) to convert.
		
		static real64 ApertureValueToFNumber (real64 av);

		/// Utility to convert aperture value (APEX units) to f-number.
		/// \param av The aperture value (APEX units) to convert.
		
		static real64 ApertureValueToFNumber (const dng_urational &av);

		/// Utility to convert f-number to aperture value (APEX units).
		/// \param fNumber The f-number to convert.
		
		static real64 FNumberToApertureValue (real64 fNumber);

		/// Utility to convert f-number to aperture value (APEX units).
		/// \param fNumber The f-number to convert.
		
		static real64 FNumberToApertureValue (const dng_urational &fNumber);

		/// Set the DateTime field.
		/// \param dt The DateTime value.
							   
		void UpdateDateTime (const dng_date_time_info &dt);

		/// Returns true iff the EXIF version is at least 2.3.

		bool AtLeastVersion0230 () const;
		
		virtual bool ParseTag (dng_stream &stream,
							   dng_shared &shared,
							   uint32 parentCode,
							   bool isMainIFD,
							   uint32 tagCode,
							   uint32 tagType,
							   uint32 tagCount,
							   uint64 tagOffset);
							   
		virtual void PostParse (dng_host &host,
								dng_shared &shared);
								
	protected:
		
		virtual bool Parse_ifd0 (dng_stream &stream,
							     dng_shared &shared,
							 	 uint32 parentCode,
							 	 uint32 tagCode,
							 	 uint32 tagType,
							 	 uint32 tagCount,
							 	 uint64 tagOffset);
							 		 
		virtual bool Parse_ifd0_main (dng_stream &stream,
							          dng_shared &shared,
						 		 	  uint32 parentCode,
						 		 	  uint32 tagCode,
						 		 	  uint32 tagType,
						 		 	  uint32 tagCount,
						 		 	  uint64 tagOffset);

		virtual bool Parse_ifd0_exif (dng_stream &stream,
							          dng_shared &shared,
						 		 	  uint32 parentCode,
						 		 	  uint32 tagCode,
						 		 	  uint32 tagType,
						 		 	  uint32 tagCount,
						 		 	  uint64 tagOffset);
	
		virtual bool Parse_gps (dng_stream &stream,
							    dng_shared &shared,
						 		uint32 parentCode,
						 		uint32 tagCode,
						 		uint32 tagType,
						 		uint32 tagCount,
						 		uint64 tagOffset);
	
		virtual bool Parse_interoperability (dng_stream &stream,
							    			 dng_shared &shared,
						 					 uint32 parentCode,
											 uint32 tagCode,
											 uint32 tagType,
											 uint32 tagCount,
											 uint64 tagOffset);
	
	};
	
/*****************************************************************************/

#endif
	
/*****************************************************************************/