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