| 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 |
* DNG image file directory support. |
| 11 |
*/ |
| 12 |
|
| 13 |
/*****************************************************************************/ |
| 14 |
|
| 15 |
#ifndef __dng_ifd__ |
| 16 |
#define __dng_ifd__ |
| 17 |
|
| 18 |
/*****************************************************************************/ |
| 19 |
|
| 20 |
#include "dng_classes.h" |
| 21 |
#include "dng_fingerprint.h" |
| 22 |
#include "dng_negative.h" |
| 23 |
#include "dng_rect.h" |
| 24 |
#include "dng_shared.h" |
| 25 |
#include "dng_stream.h" |
| 26 |
#include "dng_string.h" |
| 27 |
#include "dng_sdk_limits.h" |
| 28 |
#include "dng_tag_values.h" |
| 29 |
|
| 30 |
#include <memory> |
| 31 |
|
| 32 |
#include "jxl/color_encoding.h" |
| 33 |
|
| 34 |
/*****************************************************************************/ |
| 35 |
|
| 36 |
class dng_preview_info |
| 37 |
{ |
| 38 |
|
| 39 |
public: |
| 40 |
|
| 41 |
bool fIsPrimary; |
| 42 |
|
| 43 |
dng_string fApplicationName; |
| 44 |
|
| 45 |
dng_string fApplicationVersion; |
| 46 |
|
| 47 |
dng_string fSettingsName; |
| 48 |
|
| 49 |
dng_fingerprint fSettingsDigest; |
| 50 |
|
| 51 |
PreviewColorSpaceEnum fColorSpace; |
| 52 |
|
| 53 |
dng_string fDateTime; |
| 54 |
|
| 55 |
real64 fRawToPreviewGain; |
| 56 |
|
| 57 |
uint32 fCacheVersion; |
| 58 |
|
| 59 |
public: |
| 60 |
|
| 61 |
dng_preview_info (); |
| 62 |
|
| 63 |
~dng_preview_info (); |
| 64 |
|
| 65 |
}; |
| 66 |
|
| 67 |
/*****************************************************************************/ |
| 68 |
|
| 69 |
/// @brief Container for a single image file directory of a digital negative. |
| 70 |
/// |
| 71 |
/// See \ref spec_dng "DNG 1.1.0 specification" for documentation of specific tags. |
| 72 |
|
| 73 |
class dng_ifd |
| 74 |
{ |
| 75 |
|
| 76 |
public: |
| 77 |
|
| 78 |
bool fUsesNewSubFileType; |
| 79 |
|
| 80 |
uint32 fNewSubFileType; |
| 81 |
|
| 82 |
uint32 fImageWidth; |
| 83 |
uint32 fImageLength; |
| 84 |
|
| 85 |
uint32 fBitsPerSample [kMaxSamplesPerPixel]; |
| 86 |
|
| 87 |
uint32 fCompression; |
| 88 |
|
| 89 |
uint32 fPredictor; |
| 90 |
|
| 91 |
uint32 fPhotometricInterpretation; |
| 92 |
|
| 93 |
uint32 fFillOrder; |
| 94 |
|
| 95 |
uint32 fOrientation; |
| 96 |
uint32 fOrientationType; |
| 97 |
uint64 fOrientationOffset; |
| 98 |
bool fOrientationBigEndian; |
| 99 |
|
| 100 |
uint32 fSamplesPerPixel; |
| 101 |
|
| 102 |
uint32 fPlanarConfiguration; |
| 103 |
|
| 104 |
real64 fXResolution; |
| 105 |
real64 fYResolution; |
| 106 |
|
| 107 |
uint32 fResolutionUnit; |
| 108 |
|
| 109 |
bool fUsesStrips; |
| 110 |
bool fUsesTiles; |
| 111 |
|
| 112 |
uint32 fTileWidth; |
| 113 |
uint32 fTileLength; |
| 114 |
|
| 115 |
enum |
| 116 |
{ |
| 117 |
kMaxTileInfo = 32 |
| 118 |
}; |
| 119 |
|
| 120 |
uint32 fTileOffsetsType; |
| 121 |
uint32 fTileOffsetsCount; |
| 122 |
uint64 fTileOffsetsOffset; |
| 123 |
uint64 fTileOffset [kMaxTileInfo]; |
| 124 |
|
| 125 |
uint32 fTileByteCountsType; |
| 126 |
uint32 fTileByteCountsCount; |
| 127 |
uint64 fTileByteCountsOffset; |
| 128 |
uint64 fTileByteCount [kMaxTileInfo]; |
| 129 |
|
| 130 |
uint32 fSubIFDsType; |
| 131 |
uint32 fSubIFDsCount; |
| 132 |
uint64 fSubIFDsOffset; |
| 133 |
|
| 134 |
uint32 fExtraSamplesCount; |
| 135 |
uint32 fExtraSamples [kMaxSamplesPerPixel]; |
| 136 |
|
| 137 |
uint32 fSampleFormat [kMaxSamplesPerPixel]; |
| 138 |
|
| 139 |
uint32 fJPEGTablesCount; |
| 140 |
uint64 fJPEGTablesOffset; |
| 141 |
|
| 142 |
uint64 fJPEGInterchangeFormat; |
| 143 |
uint32 fJPEGInterchangeFormatLength; |
| 144 |
|
| 145 |
real64 fYCbCrCoefficientR; |
| 146 |
real64 fYCbCrCoefficientG; |
| 147 |
real64 fYCbCrCoefficientB; |
| 148 |
|
| 149 |
uint32 fYCbCrSubSampleH; |
| 150 |
uint32 fYCbCrSubSampleV; |
| 151 |
|
| 152 |
uint32 fYCbCrPositioning; |
| 153 |
|
| 154 |
real64 fReferenceBlackWhite [6]; |
| 155 |
|
| 156 |
uint32 fCFARepeatPatternRows; |
| 157 |
uint32 fCFARepeatPatternCols; |
| 158 |
|
| 159 |
uint8 fCFAPattern [kMaxCFAPattern] [kMaxCFAPattern]; |
| 160 |
|
| 161 |
uint8 fCFAPlaneColor [kMaxColorPlanes]; |
| 162 |
|
| 163 |
uint32 fCFALayout; |
| 164 |
|
| 165 |
uint32 fLinearizationTableType; |
| 166 |
uint32 fLinearizationTableCount; |
| 167 |
uint64 fLinearizationTableOffset; |
| 168 |
|
| 169 |
uint32 fBlackLevelRepeatRows; |
| 170 |
uint32 fBlackLevelRepeatCols; |
| 171 |
|
| 172 |
real64 fBlackLevel [kMaxBlackPattern] [kMaxBlackPattern] [kMaxColorPlanes]; |
| 173 |
|
| 174 |
uint32 fBlackLevelDeltaHType; |
| 175 |
uint32 fBlackLevelDeltaHCount; |
| 176 |
uint64 fBlackLevelDeltaHOffset; |
| 177 |
|
| 178 |
uint32 fBlackLevelDeltaVType; |
| 179 |
uint32 fBlackLevelDeltaVCount; |
| 180 |
uint64 fBlackLevelDeltaVOffset; |
| 181 |
|
| 182 |
real64 fWhiteLevel [kMaxColorPlanes]; |
| 183 |
|
| 184 |
dng_urational fDefaultScaleH; |
| 185 |
dng_urational fDefaultScaleV; |
| 186 |
|
| 187 |
dng_urational fBestQualityScale; |
| 188 |
|
| 189 |
dng_urational fDefaultCropOriginH; |
| 190 |
dng_urational fDefaultCropOriginV; |
| 191 |
|
| 192 |
dng_urational fDefaultCropSizeH; |
| 193 |
dng_urational fDefaultCropSizeV; |
| 194 |
|
| 195 |
dng_urational fDefaultUserCropT; |
| 196 |
dng_urational fDefaultUserCropL; |
| 197 |
dng_urational fDefaultUserCropB; |
| 198 |
dng_urational fDefaultUserCropR; |
| 199 |
|
| 200 |
uint32 fBayerGreenSplit; |
| 201 |
|
| 202 |
dng_urational fChromaBlurRadius; |
| 203 |
|
| 204 |
dng_urational fAntiAliasStrength; |
| 205 |
|
| 206 |
dng_rect fActiveArea; |
| 207 |
|
| 208 |
uint32 fMaskedAreaCount; |
| 209 |
dng_rect fMaskedArea [kMaxMaskedAreas]; |
| 210 |
|
| 211 |
uint32 fRowInterleaveFactor; |
| 212 |
uint32 fColumnInterleaveFactor; |
| 213 |
|
| 214 |
uint32 fSubTileBlockRows; |
| 215 |
uint32 fSubTileBlockCols; |
| 216 |
|
| 217 |
dng_preview_info fPreviewInfo; |
| 218 |
|
| 219 |
uint32 fOpcodeList1Count; |
| 220 |
uint64 fOpcodeList1Offset; |
| 221 |
|
| 222 |
uint32 fOpcodeList2Count; |
| 223 |
uint64 fOpcodeList2Offset; |
| 224 |
|
| 225 |
uint32 fOpcodeList3Count; |
| 226 |
uint64 fOpcodeList3Offset; |
| 227 |
|
| 228 |
dng_noise_profile fNoiseProfile; |
| 229 |
|
| 230 |
dng_string fEnhanceParams; |
| 231 |
|
| 232 |
dng_urational fBaselineSharpness; |
| 233 |
|
| 234 |
dng_urational fNoiseReductionApplied; |
| 235 |
|
| 236 |
bool fLosslessJPEGBug16; |
| 237 |
|
| 238 |
uint32 fSampleBitShift; |
| 239 |
|
| 240 |
uint64 fThisIFD; |
| 241 |
uint64 fNextIFD; |
| 242 |
|
| 243 |
int32 fCompressionQuality; |
| 244 |
|
| 245 |
// For JPEG XL (compression type ccJXL), use fJXLEncodeSettings |
| 246 |
// instead of fCompressionQuality. |
| 247 |
|
| 248 |
std::shared_ptr<const dng_jxl_encode_settings> fJXLEncodeSettings; |
| 249 |
|
| 250 |
std::shared_ptr<const JxlColorEncoding> fJXLColorEncoding; |
| 251 |
|
| 252 |
bool fPatchFirstJPEGByte; |
| 253 |
|
| 254 |
dng_string fSemanticName; |
| 255 |
dng_string fSemanticInstanceID; |
| 256 |
std::shared_ptr<const dng_memory_block> fSemanticXMP; |
| 257 |
uint32 fMaskSubArea [4]; |
| 258 |
|
| 259 |
std::shared_ptr<const dng_gain_table_map> fProfileGainTableMap; |
| 260 |
|
| 261 |
uint32 fProfileGainTableMap_TagVersion = 1; |
| 262 |
|
| 263 |
dng_image_stats fImageStats; |
| 264 |
|
| 265 |
real32 fJXLDistance = -1.0f; |
| 266 |
int32 fJXLEffort = -1; |
| 267 |
int32 fJXLDecodeSpeed = -1; |
| 268 |
|
| 269 |
public: |
| 270 |
|
| 271 |
dng_ifd (); |
| 272 |
|
| 273 |
virtual ~dng_ifd (); |
| 274 |
|
| 275 |
virtual dng_ifd * Clone () const; |
| 276 |
|
| 277 |
virtual bool ParseTag (dng_host &host, |
| 278 |
dng_stream &stream, |
| 279 |
uint32 parentCode, |
| 280 |
uint32 tagCode, |
| 281 |
uint32 tagType, |
| 282 |
uint32 tagCount, |
| 283 |
uint64 tagOffset); |
| 284 |
|
| 285 |
virtual void PostParse (); |
| 286 |
|
| 287 |
virtual bool IsValidDNG (dng_shared &shared, |
| 288 |
uint32 parentCode); |
| 289 |
|
| 290 |
dng_rect Bounds () const |
| 291 |
{ |
| 292 |
return dng_rect (0, |
| 293 |
0, |
| 294 |
fImageLength, |
| 295 |
fImageWidth); |
| 296 |
} |
| 297 |
|
| 298 |
uint32 TilesAcross () const; |
| 299 |
|
| 300 |
uint32 TilesDown () const; |
| 301 |
|
| 302 |
uint32 TilesPerImage () const; |
| 303 |
|
| 304 |
dng_rect TileArea (uint32 rowIndex, |
| 305 |
uint32 colIndex) const; |
| 306 |
|
| 307 |
virtual uint32 TileByteCount (const dng_rect &tile) const; |
| 308 |
|
| 309 |
virtual uint64 MaxImageDataByteCount () const; |
| 310 |
|
| 311 |
void SetSingleStrip (); |
| 312 |
|
| 313 |
void FindTileSize (uint32 bytesPerTile = 128 * 1024, |
| 314 |
uint32 cellH = 16, |
| 315 |
uint32 cellV = 16); |
| 316 |
|
| 317 |
void FindStripSize (uint32 bytesPerStrip = 128 * 1024, |
| 318 |
uint32 cellV = 16); |
| 319 |
|
| 320 |
virtual uint32 PixelType () const; |
| 321 |
|
| 322 |
virtual bool IsBaselineJPEG () const; |
| 323 |
|
| 324 |
virtual bool CanRead () const; |
| 325 |
|
| 326 |
virtual void ReadImage (dng_host &host, |
| 327 |
dng_stream &stream, |
| 328 |
dng_image &image, |
| 329 |
dng_lossy_compressed_image *lossyImage = NULL, |
| 330 |
dng_fingerprint *lossyDigest = NULL) const; |
| 331 |
|
| 332 |
protected: |
| 333 |
|
| 334 |
virtual bool IsValidCFA (dng_shared &shared, |
| 335 |
uint32 parentCode); |
| 336 |
|
| 337 |
}; |
| 338 |
|
| 339 |
/*****************************************************************************/ |
| 340 |
|
| 341 |
#endif |
| 342 |
|
| 343 |
/*****************************************************************************/ |