| 1 |
/*****************************************************************************/ |
| 2 |
// Copyright 2006-2023 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 |
#ifndef __dng_shared__ |
| 10 |
#define __dng_shared__ |
| 11 |
|
| 12 |
/*****************************************************************************/ |
| 13 |
|
| 14 |
#include "dng_classes.h" |
| 15 |
#include "dng_fingerprint.h" |
| 16 |
#include "dng_matrix.h" |
| 17 |
#include "dng_memory.h" |
| 18 |
#include "dng_negative.h" |
| 19 |
#include "dng_rational.h" |
| 20 |
#include "dng_string.h" |
| 21 |
#include "dng_stream.h" |
| 22 |
#include "dng_sdk_limits.h" |
| 23 |
#include "dng_types.h" |
| 24 |
#include "dng_utils.h" |
| 25 |
#include "dng_xy_coord.h" |
| 26 |
|
| 27 |
#include <map> |
| 28 |
#include <vector> |
| 29 |
|
| 30 |
/*****************************************************************************/ |
| 31 |
|
| 32 |
class dng_camera_profile_dynamic_range |
| 33 |
{ |
| 34 |
|
| 35 |
public: |
| 36 |
|
| 37 |
uint16 fVersion = 1; |
| 38 |
|
| 39 |
// 0 = Standard Dynamic Range. |
| 40 |
// 1 = High Dynamic Range. |
| 41 |
|
| 42 |
uint16 fDynamicRange = 0; |
| 43 |
|
| 44 |
// Hint for intended maximum output pixel value (linear gamma). |
| 45 |
|
| 46 |
real32 fHintMaxOutputValue = 0.0f; |
| 47 |
|
| 48 |
public: |
| 49 |
|
| 50 |
bool IsValid () const; |
| 51 |
|
| 52 |
bool IsSDR () const |
| 53 |
{ |
| 54 |
return (fDynamicRange == 0); |
| 55 |
} |
| 56 |
|
| 57 |
bool IsHDR () const |
| 58 |
{ |
| 59 |
return !IsSDR (); |
| 60 |
} |
| 61 |
|
| 62 |
void PutStream (dng_stream &stream) const; |
| 63 |
|
| 64 |
#if qDNGValidate |
| 65 |
void Dump () const; |
| 66 |
#endif |
| 67 |
|
| 68 |
bool operator== (const dng_camera_profile_dynamic_range &src) const |
| 69 |
{ |
| 70 |
return (fVersion == src.fVersion && |
| 71 |
fDynamicRange == src.fDynamicRange && |
| 72 |
fHintMaxOutputValue == src.fHintMaxOutputValue); |
| 73 |
} |
| 74 |
|
| 75 |
bool operator!= (const dng_camera_profile_dynamic_range &src) const |
| 76 |
{ |
| 77 |
return !(*this == src); |
| 78 |
} |
| 79 |
|
| 80 |
}; |
| 81 |
|
| 82 |
/*****************************************************************************/ |
| 83 |
|
| 84 |
class dng_camera_profile_info |
| 85 |
{ |
| 86 |
|
| 87 |
public: |
| 88 |
|
| 89 |
bool fBigEndian; |
| 90 |
|
| 91 |
uint32 fColorPlanes; |
| 92 |
|
| 93 |
uint32 fCalibrationIlluminant1; |
| 94 |
uint32 fCalibrationIlluminant2; |
| 95 |
uint32 fCalibrationIlluminant3; |
| 96 |
|
| 97 |
dng_illuminant_data fIlluminantData1; |
| 98 |
dng_illuminant_data fIlluminantData2; |
| 99 |
dng_illuminant_data fIlluminantData3; |
| 100 |
|
| 101 |
dng_matrix fColorMatrix1; |
| 102 |
dng_matrix fColorMatrix2; |
| 103 |
dng_matrix fColorMatrix3; |
| 104 |
|
| 105 |
dng_matrix fForwardMatrix1; |
| 106 |
dng_matrix fForwardMatrix2; |
| 107 |
dng_matrix fForwardMatrix3; |
| 108 |
|
| 109 |
dng_matrix fReductionMatrix1; |
| 110 |
dng_matrix fReductionMatrix2; |
| 111 |
dng_matrix fReductionMatrix3; |
| 112 |
|
| 113 |
dng_string fProfileCalibrationSignature; |
| 114 |
|
| 115 |
dng_string fProfileName; |
| 116 |
|
| 117 |
dng_string fProfileCopyright; |
| 118 |
|
| 119 |
uint32 fEmbedPolicy; |
| 120 |
|
| 121 |
uint32 fProfileHues; |
| 122 |
uint32 fProfileSats; |
| 123 |
uint32 fProfileVals; |
| 124 |
|
| 125 |
uint64 fHueSatDeltas1Offset; |
| 126 |
uint32 fHueSatDeltas1Count; |
| 127 |
|
| 128 |
uint64 fHueSatDeltas2Offset; |
| 129 |
uint32 fHueSatDeltas2Count; |
| 130 |
|
| 131 |
uint64 fHueSatDeltas3Offset; |
| 132 |
uint32 fHueSatDeltas3Count; |
| 133 |
|
| 134 |
uint32 fHueSatMapEncoding; |
| 135 |
|
| 136 |
uint32 fLookTableHues; |
| 137 |
uint32 fLookTableSats; |
| 138 |
uint32 fLookTableVals; |
| 139 |
|
| 140 |
uint64 fLookTableOffset; |
| 141 |
uint32 fLookTableCount; |
| 142 |
|
| 143 |
uint32 fLookTableEncoding; |
| 144 |
|
| 145 |
dng_srational fBaselineExposureOffset; |
| 146 |
|
| 147 |
uint32 fDefaultBlackRender; |
| 148 |
|
| 149 |
uint64 fToneCurveOffset; |
| 150 |
uint32 fToneCurveCount; |
| 151 |
|
| 152 |
uint32 fToneMethod; |
| 153 |
|
| 154 |
dng_string fUniqueCameraModel; |
| 155 |
|
| 156 |
std::shared_ptr<const dng_gain_table_map> fProfileGainTableMap; |
| 157 |
|
| 158 |
dng_camera_profile_dynamic_range fProfileDynamicRange; |
| 159 |
|
| 160 |
dng_string fProfileGroupName; |
| 161 |
|
| 162 |
std::shared_ptr<const dng_masked_rgb_tables> fMaskedRGBTables; |
| 163 |
|
| 164 |
public: |
| 165 |
|
| 166 |
dng_camera_profile_info (); |
| 167 |
|
| 168 |
~dng_camera_profile_info (); |
| 169 |
|
| 170 |
bool ParseTag (dng_stream &stream, |
| 171 |
uint32 parentCode, |
| 172 |
uint32 tagCode, |
| 173 |
uint32 tagType, |
| 174 |
uint32 tagCount, |
| 175 |
uint64 tagOffset); |
| 176 |
|
| 177 |
bool ParseExtended (dng_stream &stream); |
| 178 |
|
| 179 |
}; |
| 180 |
|
| 181 |
/*****************************************************************************/ |
| 182 |
|
| 183 |
class dng_shared |
| 184 |
{ |
| 185 |
|
| 186 |
public: |
| 187 |
|
| 188 |
uint64 fExifIFD; |
| 189 |
uint64 fGPSInfo; |
| 190 |
uint64 fInteroperabilityIFD; |
| 191 |
uint64 fKodakDCRPrivateIFD; |
| 192 |
uint64 fKodakKDCPrivateIFD; |
| 193 |
|
| 194 |
uint32 fXMPCount; |
| 195 |
uint64 fXMPOffset; |
| 196 |
|
| 197 |
uint32 fIPTC_NAA_Count; |
| 198 |
uint64 fIPTC_NAA_Offset; |
| 199 |
|
| 200 |
uint32 fMakerNoteCount; |
| 201 |
uint64 fMakerNoteOffset; |
| 202 |
uint32 fMakerNoteSafety; |
| 203 |
|
| 204 |
uint32 fDNGVersion; |
| 205 |
uint32 fDNGBackwardVersion; |
| 206 |
|
| 207 |
dng_string fUniqueCameraModel; |
| 208 |
dng_string fLocalizedCameraModel; |
| 209 |
|
| 210 |
dng_camera_profile_info fCameraProfile; |
| 211 |
|
| 212 |
dng_std_vector<dng_camera_profile_info> fExtraCameraProfiles; |
| 213 |
|
| 214 |
dng_matrix fCameraCalibration1; |
| 215 |
dng_matrix fCameraCalibration2; |
| 216 |
dng_matrix fCameraCalibration3; |
| 217 |
|
| 218 |
dng_string fCameraCalibrationSignature; |
| 219 |
|
| 220 |
dng_vector fAnalogBalance; |
| 221 |
|
| 222 |
dng_vector fAsShotNeutral; |
| 223 |
|
| 224 |
dng_xy_coord fAsShotWhiteXY; |
| 225 |
|
| 226 |
dng_srational fBaselineExposure; |
| 227 |
dng_urational fBaselineNoise; |
| 228 |
dng_urational fBaselineSharpness; |
| 229 |
dng_urational fLinearResponseLimit; |
| 230 |
dng_urational fShadowScale; |
| 231 |
|
| 232 |
bool fHasBaselineExposure; |
| 233 |
bool fHasShadowScale; |
| 234 |
|
| 235 |
uint32 fDNGPrivateDataCount; |
| 236 |
uint64 fDNGPrivateDataOffset; |
| 237 |
|
| 238 |
dng_fingerprint fRawImageDigest; |
| 239 |
dng_fingerprint fNewRawImageDigest; |
| 240 |
|
| 241 |
dng_fingerprint fRawDataUniqueID; |
| 242 |
|
| 243 |
dng_string fOriginalRawFileName; |
| 244 |
|
| 245 |
uint32 fOriginalRawFileDataCount; |
| 246 |
uint64 fOriginalRawFileDataOffset; |
| 247 |
|
| 248 |
dng_fingerprint fOriginalRawFileDigest; |
| 249 |
|
| 250 |
uint32 fAsShotICCProfileCount; |
| 251 |
uint64 fAsShotICCProfileOffset; |
| 252 |
|
| 253 |
dng_matrix fAsShotPreProfileMatrix; |
| 254 |
|
| 255 |
uint32 fCurrentICCProfileCount; |
| 256 |
uint64 fCurrentICCProfileOffset; |
| 257 |
|
| 258 |
dng_matrix fCurrentPreProfileMatrix; |
| 259 |
|
| 260 |
uint32 fColorimetricReference; |
| 261 |
|
| 262 |
dng_string fAsShotProfileName; |
| 263 |
|
| 264 |
dng_point fOriginalDefaultFinalSize; |
| 265 |
dng_point fOriginalBestQualityFinalSize; |
| 266 |
|
| 267 |
dng_urational fOriginalDefaultCropSizeH; |
| 268 |
dng_urational fOriginalDefaultCropSizeV; |
| 269 |
|
| 270 |
uint32 fDepthFormat; |
| 271 |
dng_urational fDepthNear; |
| 272 |
dng_urational fDepthFar; |
| 273 |
uint32 fDepthUnits; |
| 274 |
uint32 fDepthMeasureType; |
| 275 |
|
| 276 |
dng_std_vector<dng_fingerprint> fBigTableDigests; |
| 277 |
dng_std_vector<uint64> fBigTableOffsets; |
| 278 |
dng_std_vector<uint32> fBigTableByteCounts; |
| 279 |
|
| 280 |
std::map<dng_fingerprint, |
| 281 |
dng_fingerprint> fBigTableGroupIndex; |
| 282 |
|
| 283 |
dng_image_sequence_info fImageSequenceInfo; |
| 284 |
|
| 285 |
public: |
| 286 |
|
| 287 |
dng_shared (); |
| 288 |
|
| 289 |
virtual ~dng_shared (); |
| 290 |
|
| 291 |
virtual bool ParseTag (dng_stream &stream, |
| 292 |
dng_exif &exif, |
| 293 |
uint32 parentCode, |
| 294 |
bool isMainIFD, |
| 295 |
uint32 tagCode, |
| 296 |
uint32 tagType, |
| 297 |
uint32 tagCount, |
| 298 |
uint64 tagOffset, |
| 299 |
int64 offsetDelta); |
| 300 |
|
| 301 |
virtual void PostParse (dng_host &host, |
| 302 |
dng_exif &exif); |
| 303 |
|
| 304 |
virtual bool IsValidDNG (); |
| 305 |
|
| 306 |
protected: |
| 307 |
|
| 308 |
virtual bool Parse_ifd0 (dng_stream &stream, |
| 309 |
dng_exif &exif, |
| 310 |
uint32 parentCode, |
| 311 |
uint32 tagCode, |
| 312 |
uint32 tagType, |
| 313 |
uint32 tagCount, |
| 314 |
uint64 tagOffset); |
| 315 |
|
| 316 |
virtual bool Parse_ifd0_exif (dng_stream &stream, |
| 317 |
dng_exif &exif, |
| 318 |
uint32 parentCode, |
| 319 |
uint32 tagCode, |
| 320 |
uint32 tagType, |
| 321 |
uint32 tagCount, |
| 322 |
uint64 tagOffset); |
| 323 |
|
| 324 |
}; |
| 325 |
|
| 326 |
/*****************************************************************************/ |
| 327 |
|
| 328 |
#endif |
| 329 |
|
| 330 |
/*****************************************************************************/ |