File indexing completed on 2025-01-19 03:55:09
0001 /*****************************************************************************/ 0002 // Copyright 2006-2019 Adobe Systems Incorporated 0003 // All Rights Reserved. 0004 // 0005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 0006 // accordance with the terms of the Adobe license agreement accompanying it. 0007 /*****************************************************************************/ 0008 0009 /** \file 0010 * Functions and classes for working with a digital negative (image data and 0011 * corresponding metadata). 0012 */ 0013 0014 /*****************************************************************************/ 0015 0016 #ifndef __dng_negative__ 0017 #define __dng_negative__ 0018 0019 /*****************************************************************************/ 0020 0021 #include "dng_1d_function.h" 0022 #include "dng_auto_ptr.h" 0023 #include "dng_classes.h" 0024 #include "dng_fingerprint.h" 0025 #include "dng_image.h" 0026 #include "dng_linearization_info.h" 0027 #include "dng_matrix.h" 0028 #include "dng_mosaic_info.h" 0029 #include "dng_mutex.h" 0030 #include "dng_opcode_list.h" 0031 #include "dng_orientation.h" 0032 #include "dng_rational.h" 0033 #include "dng_sdk_limits.h" 0034 #include "dng_string.h" 0035 #include "dng_tag_types.h" 0036 #include "dng_tag_values.h" 0037 #include "dng_types.h" 0038 #include "dng_utils.h" 0039 #include "dng_xy_coord.h" 0040 0041 #include <vector> 0042 0043 /*****************************************************************************/ 0044 0045 // To prevent using the internal metadata when we meant to use override 0046 // metadata, the following definitions allow us to only allow access to 0047 // the internal metadata on non-const negatives. This allows the old API 0048 // to keep working essentially unchanged provided one does not use const 0049 // negatives, but will prevent access to the embedded data on const 0050 // negatives. 0051 0052 #if 1 0053 0054 #define qMetadataOnConst 0 0055 #define METACONST 0056 0057 #else 0058 0059 #define qMetadataOnConst 1 0060 #define METACONST const 0061 0062 #endif 0063 0064 /*****************************************************************************/ 0065 0066 /// \brief Noise model for photon and sensor read noise, assuming that they are 0067 /// independent random variables and spatially invariant. 0068 /// 0069 /// The noise model is N (x) = sqrt (scale*x + offset), where x represents a linear 0070 /// signal value in the range [0,1], and N (x) is the standard deviation (i.e., 0071 /// noise). The parameters scale and offset are both sensor-dependent and 0072 /// ISO-dependent. scale must be positive, and offset must be non-negative. 0073 0074 class dng_noise_function: public dng_1d_function 0075 { 0076 0077 protected: 0078 0079 real64 fScale; 0080 real64 fOffset; 0081 0082 public: 0083 0084 /// Create empty and invalid noise function. 0085 0086 dng_noise_function () 0087 0088 : fScale (0.0) 0089 , fOffset (0.0) 0090 0091 { 0092 0093 } 0094 0095 /// Create noise function with the specified scale and offset. 0096 0097 dng_noise_function (real64 scale, 0098 real64 offset) 0099 0100 : fScale (scale) 0101 , fOffset (offset) 0102 0103 { 0104 0105 } 0106 0107 /// Compute noise (standard deviation) at the specified average signal level 0108 /// x. 0109 0110 virtual real64 Evaluate (real64 x) const 0111 { 0112 return sqrt (fScale * x + fOffset); 0113 } 0114 0115 /// The scale (slope, gain) of the noise function. 0116 0117 real64 Scale () const 0118 { 0119 return fScale; 0120 } 0121 0122 /// The offset (square of the noise floor) of the noise function. 0123 0124 real64 Offset () const 0125 { 0126 return fOffset; 0127 } 0128 0129 /// Set the scale (slope, gain) of the noise function. 0130 0131 void SetScale (real64 scale) 0132 { 0133 fScale = scale; 0134 } 0135 0136 /// Set the offset (square of the noise floor) of the noise function. 0137 0138 void SetOffset (real64 offset) 0139 { 0140 fOffset = offset; 0141 } 0142 0143 /// Is the noise function valid? 0144 0145 bool IsValid () const 0146 { 0147 return (fScale > 0.0 && fOffset >= 0.0); 0148 } 0149 0150 }; 0151 0152 /*****************************************************************************/ 0153 0154 /// \brief Noise profile for a negative. 0155 /// 0156 /// For mosaiced negatives, the noise profile describes the approximate noise 0157 /// characteristics of a mosaic negative after linearization, but prior to 0158 /// demosaicing. For demosaiced negatives (i.e., linear DNGs), the noise profile 0159 /// describes the approximate noise characteristics of the image data immediately 0160 /// following the demosaic step, prior to the processing of opcode list 3. 0161 /// 0162 /// A noise profile may contain 1 or N noise functions, where N is the number of 0163 /// color planes for the negative. Otherwise the noise profile is considered to be 0164 /// invalid for that negative. If the noise profile contains 1 noise function, then 0165 /// it is assumed that this single noise function applies to all color planes of the 0166 /// negative. Otherwise, the N noise functions map to the N planes of the negative in 0167 /// order specified in the CFAPlaneColor tag. 0168 0169 class dng_noise_profile 0170 { 0171 0172 protected: 0173 0174 dng_std_vector<dng_noise_function> fNoiseFunctions; 0175 0176 public: 0177 0178 /// Create empty (invalid) noise profile. 0179 0180 dng_noise_profile (); 0181 0182 /// Create noise profile with the specified noise functions (1 per plane). 0183 0184 explicit dng_noise_profile (const dng_std_vector<dng_noise_function> &functions); 0185 0186 /// Is the noise profile valid? 0187 0188 bool IsValid () const; 0189 0190 /// Is the noise profile valid for the specified negative? 0191 0192 bool IsValidForNegative (const dng_negative &negative) const; 0193 0194 /// The noise function for the specified plane. 0195 0196 const dng_noise_function & NoiseFunction (uint32 plane) const; 0197 0198 /// The number of noise functions in this profile. 0199 0200 uint32 NumFunctions () const; 0201 0202 /// Equality test. 0203 0204 bool operator== (const dng_noise_profile &profile) const; 0205 0206 bool operator!= (const dng_noise_profile &profile) const 0207 { 0208 return !(*this == profile); 0209 } 0210 0211 }; 0212 0213 /*****************************************************************************/ 0214 0215 /// \brief Main class for holding metadata. 0216 0217 class dng_metadata 0218 { 0219 0220 private: 0221 0222 // Base orientation of both the thumbnail and raw data. This is 0223 // generally based on the EXIF values. 0224 0225 bool fHasBaseOrientation; 0226 0227 dng_orientation fBaseOrientation; 0228 0229 // Is the maker note safe to copy from file to file? Defaults to false 0230 // because many maker notes are not safe. 0231 0232 bool fIsMakerNoteSafe; 0233 0234 // MakerNote binary data block. 0235 0236 AutoPtr<dng_memory_block> fMakerNote; 0237 0238 // EXIF data. 0239 0240 AutoPtr<dng_exif> fExif; 0241 0242 // A copy of the EXIF data before is was synchronized with other metadata sources. 0243 0244 AutoPtr<dng_exif> fOriginalExif; 0245 0246 // IPTC binary data block and offset in original file. 0247 0248 AutoPtr<dng_memory_block> fIPTCBlock; 0249 0250 uint64 fIPTCOffset; 0251 0252 // XMP data. 0253 0254 AutoPtr<dng_xmp> fXMP; 0255 0256 // If there a valid embedded XMP block, has is its digest? NULL if no valid 0257 // embedded XMP. 0258 0259 dng_fingerprint fEmbeddedXMPDigest; 0260 0261 // Is the XMP data from a sidecar file? 0262 0263 bool fXMPinSidecar; 0264 0265 // If the XMP data is from a sidecar file, is the sidecar file newer 0266 // than the raw file? 0267 0268 bool fXMPisNewer; 0269 0270 // Source file mimi-type, if known. 0271 0272 dng_string fSourceMIME; 0273 0274 public: 0275 0276 dng_metadata (dng_host &host); 0277 0278 dng_metadata (const dng_metadata &rhs, 0279 dng_memory_allocator &allocator); 0280 0281 virtual ~dng_metadata (); 0282 0283 /// Copy this metadata. 0284 0285 virtual dng_metadata * Clone (dng_memory_allocator &allocator) const; 0286 0287 /// Setter for BaseOrientation. 0288 0289 void SetBaseOrientation (const dng_orientation &orientation); 0290 0291 /// Has BaseOrientation been set? 0292 0293 bool HasBaseOrientation () const 0294 { 0295 return fHasBaseOrientation; 0296 } 0297 0298 /// Getter for BaseOrientation. 0299 0300 const dng_orientation & BaseOrientation () const 0301 { 0302 return fBaseOrientation; 0303 } 0304 0305 /// Logically rotates the image by changing the orientation values. 0306 /// This will also update the XMP data. 0307 0308 void ApplyOrientation (const dng_orientation &orientation); 0309 0310 // API for IPTC metadata: 0311 0312 void SetIPTC (AutoPtr<dng_memory_block> &block, 0313 uint64 offset); 0314 0315 void SetIPTC (AutoPtr<dng_memory_block> &block); 0316 0317 void ClearIPTC (); 0318 0319 const void * IPTCData () const; 0320 0321 uint32 IPTCLength () const; 0322 0323 uint64 IPTCOffset () const; 0324 0325 dng_fingerprint IPTCDigest (bool includePadding = true) const; 0326 0327 void RebuildIPTC (dng_memory_allocator &allocator, 0328 bool padForTIFF); 0329 0330 // API for MakerNote data: 0331 0332 void SetMakerNoteSafety (bool safe) 0333 { 0334 fIsMakerNoteSafe = safe; 0335 } 0336 0337 bool IsMakerNoteSafe () const 0338 { 0339 return fIsMakerNoteSafe; 0340 } 0341 0342 void SetMakerNote (AutoPtr<dng_memory_block> &block) 0343 { 0344 fMakerNote.Reset (block.Release ()); 0345 } 0346 0347 void ClearMakerNote () 0348 { 0349 fIsMakerNoteSafe = false; 0350 fMakerNote.Reset (); 0351 } 0352 0353 const void * MakerNoteData () const 0354 { 0355 return fMakerNote.Get () ? fMakerNote->Buffer () 0356 : NULL; 0357 } 0358 0359 uint32 MakerNoteLength () const 0360 { 0361 return fMakerNote.Get () ? fMakerNote->LogicalSize () 0362 : 0; 0363 } 0364 0365 // API for EXIF metadata: 0366 0367 dng_exif * GetExif () 0368 { 0369 return fExif.Get (); 0370 } 0371 0372 const dng_exif * GetExif () const 0373 { 0374 return fExif.Get (); 0375 } 0376 0377 template< class E > 0378 E & Exif (); 0379 0380 template< class E > 0381 const E & Exif () const; 0382 0383 void ResetExif (dng_exif * newExif); 0384 0385 dng_memory_block * BuildExifBlock (dng_memory_allocator &allocator, 0386 const dng_resolution *resolution = NULL, 0387 bool includeIPTC = false, 0388 const dng_jpeg_preview *thumbnail = NULL) const; 0389 0390 // API for original EXIF metadata. 0391 0392 dng_exif * GetOriginalExif () 0393 { 0394 return fOriginalExif.Get (); 0395 } 0396 0397 const dng_exif * GetOriginalExif () const 0398 { 0399 return fOriginalExif.Get (); 0400 } 0401 0402 // API for XMP metadata: 0403 0404 bool SetXMP (dng_host &host, 0405 const void *buffer, 0406 uint32 count, 0407 bool xmpInSidecar = false, 0408 bool xmpIsNewer = false); 0409 0410 void SetEmbeddedXMP (dng_host &host, 0411 const void *buffer, 0412 uint32 count); 0413 0414 dng_xmp * GetXMP () 0415 { 0416 return fXMP.Get (); 0417 } 0418 0419 const dng_xmp * GetXMP () const 0420 { 0421 return fXMP.Get (); 0422 } 0423 0424 template< class X > 0425 X & XMP (); 0426 0427 template< class X > 0428 const X & XMP () const; 0429 0430 bool XMPinSidecar () const 0431 { 0432 return fXMPinSidecar; 0433 } 0434 0435 const dng_fingerprint & EmbeddedXMPDigest () const 0436 { 0437 return fEmbeddedXMPDigest; 0438 } 0439 0440 bool HaveValidEmbeddedXMP () const 0441 { 0442 return fEmbeddedXMPDigest.IsValid (); 0443 } 0444 0445 void ResetXMP (dng_xmp * newXMP); 0446 0447 void ResetXMPSidecarNewer (dng_xmp * newXMP, bool inSidecar, bool isNewer ); 0448 0449 // Synchronize metadata sources. 0450 0451 void SynchronizeMetadata (); 0452 0453 // Routines to update the date/time field in the EXIF and XMP 0454 // metadata. 0455 0456 void UpdateDateTime (const dng_date_time_info &dt); 0457 0458 void UpdateDateTimeToNow (); 0459 0460 void UpdateMetadataDateTimeToNow (); 0461 0462 // Routines to set and get the source file MIME type. 0463 0464 void SetSourceMIME (const char *s) 0465 { 0466 fSourceMIME.Set (s); 0467 } 0468 0469 const dng_string & SourceMIME () const 0470 { 0471 return fSourceMIME; 0472 } 0473 0474 }; 0475 0476 /*****************************************************************************/ 0477 0478 template< class E > 0479 E & dng_metadata::Exif () 0480 { 0481 dng_exif * exif = GetExif (); 0482 if (!exif) ThrowProgramError ("EXIF object is NULL."); 0483 return dynamic_cast< E & > (*exif); 0484 } 0485 0486 /*****************************************************************************/ 0487 0488 template< class E > 0489 const E & dng_metadata::Exif () const 0490 { 0491 const dng_exif * exif = GetExif (); 0492 if (!exif) ThrowProgramError ("EXIF object is NULL."); 0493 return dynamic_cast< const E & > (*exif); 0494 } 0495 0496 /*****************************************************************************/ 0497 0498 template< class X > 0499 X & dng_metadata::XMP () 0500 { 0501 dng_xmp * xmp = GetXMP (); 0502 if (!xmp) ThrowProgramError ("XMP object is NULL."); 0503 return dynamic_cast< X & > (*xmp); 0504 } 0505 0506 /*****************************************************************************/ 0507 0508 template< class X > 0509 const X & dng_metadata::XMP () const 0510 { 0511 const dng_xmp * xmp = GetXMP (); 0512 if (!xmp) ThrowProgramError ("XMP object is NULL."); 0513 return dynamic_cast< const X & > (*xmp); 0514 } 0515 0516 /*****************************************************************************/ 0517 0518 /// \brief Main class for holding DNG image data and associated metadata. 0519 0520 class dng_negative 0521 { 0522 0523 public: 0524 0525 enum RawImageStageEnum 0526 { 0527 rawImageStagePreOpcode1, 0528 rawImageStagePostOpcode1, 0529 rawImageStagePostOpcode2, 0530 rawImageStagePreOpcode3, 0531 rawImageStagePostOpcode3, 0532 rawImageStageNone 0533 }; 0534 0535 protected: 0536 0537 // The negative stores an associated allocator. It does not do 0538 // anything to keep it alive or to release it when the object destructs. 0539 // Hence, clients will need to make sure that the allocator's lifespan 0540 // encompasses that of the dng_factory object which is generally 0541 // directly bound to the dng_negative object. 0542 0543 dng_memory_allocator &fAllocator; 0544 0545 // Non-localized ASCII model name. 0546 0547 dng_string fModelName; 0548 0549 // Localized UTF-8 model name. 0550 0551 dng_string fLocalName; 0552 0553 // The area of raw image that should be included in the final converted 0554 // image. This stems from extra pixels around the edges of the sensor 0555 // including both the black mask and some additional padding. 0556 0557 // The default crop can be smaller than the "active" area which includes 0558 // the padding but not the black masked pixels. 0559 0560 dng_urational fDefaultCropSizeH; 0561 dng_urational fDefaultCropSizeV; 0562 0563 dng_urational fDefaultCropOriginH; 0564 dng_urational fDefaultCropOriginV; 0565 0566 // Default user crop, in relative coordinates. 0567 0568 dng_urational fDefaultUserCropT; 0569 dng_urational fDefaultUserCropL; 0570 dng_urational fDefaultUserCropB; 0571 dng_urational fDefaultUserCropR; 0572 0573 // Default scale factors. Generally, 1.0 for square pixel cameras. They 0574 // can compensate for non-square pixels. The choice of exact values will 0575 // generally depend on what the camera does. These are particularly 0576 // interesting for the Nikon D1X and the Fuji diamond mosaic. 0577 0578 dng_urational fDefaultScaleH; 0579 dng_urational fDefaultScaleV; 0580 0581 // Best quality scale factor. Used for the Nikon D1X and Fuji cameras 0582 // to force everything to be a scale up rather than scale down. So, 0583 // generally this is 1.0 / min (fDefaultScaleH, fDefaultScaleV) but 0584 // this isn't used if the scale factors are only slightly different 0585 // from 1.0. 0586 0587 dng_urational fBestQualityScale; 0588 0589 // Proxy image support. Remember certain sizes for the original image 0590 // this proxy was derived from. 0591 0592 dng_point fOriginalDefaultFinalSize; 0593 dng_point fOriginalBestQualityFinalSize; 0594 0595 dng_urational fOriginalDefaultCropSizeH; 0596 dng_urational fOriginalDefaultCropSizeV; 0597 0598 // Scale factors used in demosaic algorithm (calculated). 0599 // Maps raw image coordinates to full image coordinates -- i.e., 0600 // original image coordinates on raw sensor data to coordinates 0601 // in fStage3Image which is the output of the interpolation step. 0602 // So, if we downsample when interpolating, these numbers get 0603 // smaller. 0604 0605 real64 fRawToFullScaleH; 0606 real64 fRawToFullScaleV; 0607 0608 // Relative amount of noise at ISO 100. This is measured per camera model 0609 // based on looking at flat areas of color. 0610 0611 dng_urational fBaselineNoise; 0612 0613 // How much noise reduction has already been applied (0.0 to 1.0) to the 0614 // the raw image data? 0.0 = none, 1.0 = "ideal" amount--i.e. don't apply any 0615 // more by default. 0/0 for unknown. 0616 0617 dng_urational fNoiseReductionApplied; 0618 0619 // Enhanced images can change the applied noise reduction, so we 0620 // need to keep around the original value. 0621 0622 dng_urational fRawNoiseReductionApplied; 0623 0624 // Amount of noise for this negative (see dng_noise_profile for details). 0625 0626 dng_noise_profile fNoiseProfile; 0627 0628 // Enhanced images can change the noise profile, so we 0629 // need to keep around the original value. 0630 0631 dng_noise_profile fRawNoiseProfile; 0632 0633 // Zero point for the exposure compensation slider. This reflects how 0634 // the manufacturer sets up the camera and its conversions. 0635 0636 dng_srational fBaselineExposure; 0637 0638 // Relative amount of sharpening required. This is chosen per camera 0639 // model based on how strong the anti-alias filter is on the camera 0640 // and the quality of the lenses. This scales the sharpness slider 0641 // value. 0642 0643 dng_urational fBaselineSharpness; 0644 0645 // Enhanced images can change the baseline sharpness, so we 0646 // need to keep around the original value. 0647 0648 dng_urational fRawBaselineSharpness; 0649 0650 // Chroma blur radius (or 0/0 for auto). Set to 0/1 to disable 0651 // chroma blurring. 0652 0653 dng_urational fChromaBlurRadius; 0654 0655 // Anti-alias filter strength (0.0 to 1.0). Used as a hint 0656 // to the demosaic algorithms. 0657 0658 dng_urational fAntiAliasStrength; 0659 0660 // Linear response limit. The point at which the sensor goes 0661 // non-linear and color information becomes unreliable. Used in 0662 // the highlight-recovery logic. 0663 0664 dng_urational fLinearResponseLimit; 0665 0666 // Scale factor for shadows slider. The Fuji HDR cameras, for example, 0667 // need a more sensitive shadow slider. 0668 0669 dng_urational fShadowScale; 0670 0671 // Colormetric reference. 0672 0673 uint32 fColorimetricReference; 0674 0675 // Is the stage 3 image floating point? 0676 0677 bool fFloatingPoint; 0678 0679 // Number of color channels for this image (e.g. 1, 3, or 4). 0680 0681 uint32 fColorChannels; 0682 0683 // Amount by which each channel has already been scaled. Some cameras 0684 // have analog amplifiers on the color channels and these can result 0685 // in different scalings per channel. This provides some level of 0686 // analog white balancing. The Nikon D1 also did digital scaling but 0687 // this caused problems with highlight recovery. 0688 0689 dng_vector fAnalogBalance; 0690 0691 // The "As Shot" neutral color coordinates in native camera space. 0692 // This overrides fCameraWhiteXY if both are specified. This 0693 // specifies the values per channel that would result in a neutral 0694 // color for the "As Shot" case. This is generally supplied by 0695 // the camera. 0696 0697 dng_vector fCameraNeutral; 0698 0699 // The "As Shot" white balance xy coordinates. Sometimes this is 0700 // supplied by the camera. Sometimes the camera just supplies a name 0701 // for the white balance. 0702 0703 dng_xy_coord fCameraWhiteXY; 0704 0705 // Individual camera calibrations. 0706 0707 // Camera data --> camera calibration --> "inverse" of color matrix 0708 0709 // This will be a 4x4 matrix for a 4-color camera. The defaults are 0710 // almost always the identity matrix and for the cases where they 0711 // aren't, they are diagonal matrices. 0712 0713 dng_matrix fCameraCalibration1; 0714 dng_matrix fCameraCalibration2; 0715 0716 // Signature which allows a profile to announce that it is compatible 0717 // with these calibration matrices. 0718 0719 dng_string fCameraCalibrationSignature; 0720 0721 // List of camera profiles. 0722 0723 dng_std_vector<dng_camera_profile *> fCameraProfile; 0724 0725 // "As shot" camera profile name. 0726 0727 dng_string fAsShotProfileName; 0728 0729 // Raw image data digests. These are MD5 fingerprints of the raw image data 0730 // in the file, computed using a specific algorithms. They can be used 0731 // verify the raw data has not been corrupted. The new version is faster 0732 // to compute on MP machines, and is used starting with DNG version 1.4. 0733 0734 mutable dng_fingerprint fRawImageDigest; 0735 0736 mutable dng_fingerprint fNewRawImageDigest; 0737 0738 // Raw data unique ID. This is an unique identifer for the actual 0739 // raw image data in the file. It can be used to index into caches 0740 // for this data. 0741 0742 mutable dng_fingerprint fRawDataUniqueID; 0743 0744 mutable dng_std_mutex fRawDataUniqueIDMutex; 0745 0746 // Original raw file name. Just the file name, not the full path. 0747 0748 dng_string fOriginalRawFileName; 0749 0750 // Is the original raw file data availaible? 0751 0752 bool fHasOriginalRawFileData; 0753 0754 // The compressed original raw file data. 0755 0756 AutoPtr<dng_memory_block> fOriginalRawFileData; 0757 0758 // MD5 digest of original raw file data block. 0759 0760 mutable dng_fingerprint fOriginalRawFileDigest; 0761 0762 // DNG private data block. 0763 0764 AutoPtr<dng_memory_block> fDNGPrivateData; 0765 0766 // Metadata information (XMP, IPTC, EXIF, orientation) 0767 0768 dng_metadata fMetadata; 0769 0770 // Information required to linearize and range map the raw data. 0771 0772 AutoPtr<dng_linearization_info> fLinearizationInfo; 0773 0774 // Information required to demoasic the raw data. 0775 0776 AutoPtr<dng_mosaic_info> fMosaicInfo; 0777 0778 // Opcode list 1. (Applied to stored data) 0779 0780 dng_opcode_list fOpcodeList1; 0781 0782 // Opcode list 2. (Applied to range mapped data) 0783 0784 dng_opcode_list fOpcodeList2; 0785 0786 // Opcode list 3. (Post demosaic) 0787 0788 dng_opcode_list fOpcodeList3; 0789 0790 // Stage 1 image, which is image data stored in a DNG file. 0791 0792 AutoPtr<dng_image> fStage1Image; 0793 0794 // Stage 2 image, which is the stage 1 image after it has been 0795 // linearized and range mapped. 0796 0797 AutoPtr<dng_image> fStage2Image; 0798 0799 // Stage 3 image, which is the stage 2 image after it has been 0800 // demosaiced. 0801 0802 AutoPtr<dng_image> fStage3Image; 0803 0804 // Additional gain applied when building the stage 3 image. 0805 0806 real64 fStage3Gain; 0807 0808 // Optical black level of stage 3 image (in [0,65535]). 0809 0810 uint16 fStage3BlackLevel; 0811 0812 // Were any approximations (e.g. downsampling, etc.) applied 0813 // file reading this image? 0814 0815 bool fIsPreview; 0816 0817 // Does the file appear to be damaged? 0818 0819 bool fIsDamaged; 0820 0821 // At what processing stage did we grab a copy of raw image data? 0822 0823 RawImageStageEnum fRawImageStage; 0824 0825 // The raw image data that we grabbed, if any. 0826 0827 AutoPtr<dng_image> fRawImage; 0828 0829 // The black level of the raw image (if not encoded by linearization info). 0830 0831 uint16 fRawImageBlackLevel; 0832 0833 // The floating point bit depth of the raw file, if any. 0834 0835 uint32 fRawFloatBitDepth; 0836 0837 // The raw image JPEG data that we grabbed, if any. 0838 0839 AutoPtr<dng_jpeg_image> fRawJPEGImage; 0840 0841 // Keep a separate digest for the compressed JPEG data, if any. 0842 0843 mutable dng_fingerprint fRawJPEGImageDigest; 0844 0845 // Transparency mask image, if any. 0846 0847 AutoPtr<dng_image> fTransparencyMask; 0848 0849 // Grabbed transparency mask, if we are not saving the current mask. 0850 0851 AutoPtr<dng_image> fRawTransparencyMask; 0852 0853 // The bit depth for the raw transparancy mask, if known. 0854 0855 uint32 fRawTransparencyMaskBitDepth; 0856 0857 // We sometimes need to keep of copy of the stage3 image before 0858 // flattening the transparency. 0859 0860 AutoPtr<dng_image> fUnflattenedStage3Image; 0861 0862 // Depth map. 0863 0864 bool fHasDepthMap; 0865 0866 AutoPtr<dng_image> fDepthMap; 0867 0868 // Grabbed depth map, if we are not saving the current map. 0869 0870 AutoPtr<dng_image> fRawDepthMap; 0871 0872 // Depth metadata. 0873 0874 uint32 fDepthFormat; 0875 dng_urational fDepthNear; 0876 dng_urational fDepthFar; 0877 uint32 fDepthUnits; 0878 uint32 fDepthMeasureType; 0879 0880 // Enhance metadata. 0881 0882 dng_string fEnhanceParams; 0883 0884 public: 0885 0886 virtual ~dng_negative (); 0887 0888 static dng_negative * Make (dng_host &host); 0889 0890 /// Provide access to the memory allocator used for this object. 0891 0892 dng_memory_allocator & Allocator () const 0893 { 0894 return fAllocator; 0895 } 0896 0897 /// Getter for ModelName. 0898 0899 void SetModelName (const char *name) 0900 { 0901 fModelName.Set_ASCII (name); 0902 } 0903 0904 /// Setter for ModelName. 0905 0906 const dng_string & ModelName () const 0907 { 0908 return fModelName; 0909 } 0910 0911 /// Setter for LocalName. 0912 0913 void SetLocalName (const char *name) 0914 { 0915 fLocalName.Set (name); 0916 } 0917 0918 /// Getter for LocalName. 0919 0920 const dng_string & LocalName () const 0921 { 0922 return fLocalName; 0923 } 0924 0925 /// Getter for metadata 0926 0927 dng_metadata &Metadata () 0928 { 0929 return fMetadata; 0930 } 0931 0932 #if qMetadataOnConst 0933 0934 const dng_metadata &Metadata () const 0935 { 0936 return fMetadata; 0937 } 0938 0939 #endif // qMetadataOnConst 0940 0941 /// Make a copy of the internal metadata generally as a basis for further 0942 /// changes. 0943 0944 dng_metadata * CloneInternalMetadata () const; 0945 0946 protected: 0947 0948 /// An accessor for the internal metadata that works even when we 0949 /// have general access turned off. This is needed to provide 0950 /// access to EXIF ISO information. 0951 0952 const dng_metadata &InternalMetadata () const 0953 { 0954 return fMetadata; 0955 } 0956 0957 public: 0958 0959 /// Setter for BaseOrientation. 0960 0961 void SetBaseOrientation (const dng_orientation &orientation) 0962 { 0963 Metadata ().SetBaseOrientation (orientation); 0964 } 0965 0966 /// Has BaseOrientation been set? 0967 0968 bool HasBaseOrientation () METACONST 0969 { 0970 return Metadata ().HasBaseOrientation (); 0971 } 0972 0973 /// Getter for BaseOrientation. 0974 0975 const dng_orientation & BaseOrientation () METACONST 0976 { 0977 return Metadata ().BaseOrientation (); 0978 } 0979 0980 /// Hook to allow SDK host code to add additional rotations. 0981 0982 virtual dng_orientation ComputeOrientation (const dng_metadata &metadata) const; 0983 0984 /// For non-const negatives, we simply default to using the metadata attached to the negative. 0985 0986 dng_orientation Orientation () 0987 { 0988 return ComputeOrientation (Metadata ()); 0989 } 0990 0991 /// Logically rotates the image by changing the orientation values. 0992 /// This will also update the XMP data. 0993 0994 void ApplyOrientation (const dng_orientation &orientation) 0995 { 0996 Metadata ().ApplyOrientation (orientation); 0997 } 0998 0999 /// Setter for DefaultCropSize. 1000 1001 void SetDefaultCropSize (const dng_urational &sizeH, 1002 const dng_urational &sizeV) 1003 { 1004 fDefaultCropSizeH = sizeH; 1005 fDefaultCropSizeV = sizeV; 1006 } 1007 1008 /// Setter for DefaultCropSize. 1009 1010 void SetDefaultCropSize (uint32 sizeH, 1011 uint32 sizeV) 1012 { 1013 SetDefaultCropSize (dng_urational (sizeH, 1), 1014 dng_urational (sizeV, 1)); 1015 } 1016 1017 /// Getter for DefaultCropSize horizontal. 1018 1019 const dng_urational & DefaultCropSizeH () const 1020 { 1021 return fDefaultCropSizeH; 1022 } 1023 1024 /// Getter for DefaultCropSize vertical. 1025 1026 const dng_urational & DefaultCropSizeV () const 1027 { 1028 return fDefaultCropSizeV; 1029 } 1030 1031 /// Setter for DefaultCropOrigin. 1032 1033 void SetDefaultCropOrigin (const dng_urational &originH, 1034 const dng_urational &originV) 1035 { 1036 fDefaultCropOriginH = originH; 1037 fDefaultCropOriginV = originV; 1038 } 1039 1040 /// Setter for DefaultCropOrigin. 1041 1042 void SetDefaultCropOrigin (uint32 originH, 1043 uint32 originV) 1044 { 1045 SetDefaultCropOrigin (dng_urational (originH, 1), 1046 dng_urational (originV, 1)); 1047 } 1048 1049 /// Set default crop around center of image. 1050 1051 void SetDefaultCropCentered (const dng_point &rawSize) 1052 { 1053 1054 uint32 sizeH = Round_uint32 (fDefaultCropSizeH.As_real64 ()); 1055 uint32 sizeV = Round_uint32 (fDefaultCropSizeV.As_real64 ()); 1056 1057 SetDefaultCropOrigin ((rawSize.h - sizeH) >> 1, 1058 (rawSize.v - sizeV) >> 1); 1059 1060 } 1061 1062 /// Get default crop origin horizontal value. 1063 1064 const dng_urational & DefaultCropOriginH () const 1065 { 1066 return fDefaultCropOriginH; 1067 } 1068 1069 /// Get default crop origin vertical value. 1070 1071 const dng_urational & DefaultCropOriginV () const 1072 { 1073 return fDefaultCropOriginV; 1074 } 1075 1076 /// Is there a default user crop? 1077 1078 bool HasDefaultUserCrop () const 1079 { 1080 return (fDefaultUserCropT.As_real64 () != 0.0 || 1081 fDefaultUserCropL.As_real64 () != 0.0 || 1082 fDefaultUserCropB.As_real64 () != 1.0 || 1083 fDefaultUserCropR.As_real64 () != 1.0); 1084 } 1085 1086 /// Getter for top coordinate of default user crop. 1087 1088 const dng_urational & DefaultUserCropT () const 1089 { 1090 return fDefaultUserCropT; 1091 } 1092 1093 /// Getter for left coordinate of default user crop. 1094 1095 const dng_urational & DefaultUserCropL () const 1096 { 1097 return fDefaultUserCropL; 1098 } 1099 1100 /// Getter for bottom coordinate of default user crop. 1101 1102 const dng_urational & DefaultUserCropB () const 1103 { 1104 return fDefaultUserCropB; 1105 } 1106 1107 /// Getter for right coordinate of default user crop. 1108 1109 const dng_urational & DefaultUserCropR () const 1110 { 1111 return fDefaultUserCropR; 1112 } 1113 1114 /// Reset default user crop to default crop area. 1115 1116 void ResetDefaultUserCrop () 1117 { 1118 fDefaultUserCropT = dng_urational (0, 1); 1119 fDefaultUserCropL = dng_urational (0, 1); 1120 fDefaultUserCropB = dng_urational (1, 1); 1121 fDefaultUserCropR = dng_urational (1, 1); 1122 } 1123 1124 /// Setter for all 4 coordinates of default user crop. 1125 1126 void SetDefaultUserCrop (const dng_urational &t, 1127 const dng_urational &l, 1128 const dng_urational &b, 1129 const dng_urational &r) 1130 { 1131 fDefaultUserCropT = t; 1132 fDefaultUserCropL = l; 1133 fDefaultUserCropB = b; 1134 fDefaultUserCropR = r; 1135 } 1136 1137 /// Setter for top coordinate of default user crop. 1138 1139 void SetDefaultUserCropT (const dng_urational &value) 1140 { 1141 fDefaultUserCropT = value; 1142 } 1143 1144 /// Setter for left coordinate of default user crop. 1145 1146 void SetDefaultUserCropL (const dng_urational &value) 1147 { 1148 fDefaultUserCropL = value; 1149 } 1150 1151 /// Setter for bottom coordinate of default user crop. 1152 1153 void SetDefaultUserCropB (const dng_urational &value) 1154 { 1155 fDefaultUserCropB = value; 1156 } 1157 1158 /// Setter for right coordinate of default user crop. 1159 1160 void SetDefaultUserCropR (const dng_urational &value) 1161 { 1162 fDefaultUserCropR = value; 1163 } 1164 1165 /// Setter for DefaultScale. 1166 1167 void SetDefaultScale (const dng_urational &scaleH, 1168 const dng_urational &scaleV) 1169 { 1170 fDefaultScaleH = scaleH; 1171 fDefaultScaleV = scaleV; 1172 } 1173 1174 /// Get default scale horizontal value. 1175 1176 const dng_urational & DefaultScaleH () const 1177 { 1178 return fDefaultScaleH; 1179 } 1180 1181 /// Get default scale vertical value. 1182 1183 const dng_urational & DefaultScaleV () const 1184 { 1185 return fDefaultScaleV; 1186 } 1187 1188 /// Setter for BestQualityScale. 1189 1190 void SetBestQualityScale (const dng_urational &scale) 1191 { 1192 fBestQualityScale = scale; 1193 } 1194 1195 /// Getter for BestQualityScale. 1196 1197 const dng_urational & BestQualityScale () const 1198 { 1199 return fBestQualityScale; 1200 } 1201 1202 /// Is the best quality scale different than the default scale? 1203 1204 bool HasBestQualityScale () const 1205 { 1206 return fBestQualityScale.As_real64 () != 1.0; 1207 } 1208 1209 /// API for raw to full image scaling factors horizontal. 1210 1211 real64 RawToFullScaleH () const 1212 { 1213 return fRawToFullScaleH; 1214 } 1215 1216 /// API for raw to full image scaling factors vertical. 1217 1218 real64 RawToFullScaleV () const 1219 { 1220 return fRawToFullScaleV; 1221 } 1222 1223 /// Setter for raw to full scales. 1224 1225 void SetRawToFullScale (real64 scaleH, 1226 real64 scaleV) 1227 { 1228 fRawToFullScaleH = scaleH; 1229 fRawToFullScaleV = scaleV; 1230 } 1231 1232 /// Get default scale factor. 1233 /// When specifing a single scale factor, we use the horizontal 1234 /// scale factor, and let the vertical scale factor be calculated 1235 /// based on the pixel aspect ratio. 1236 1237 real64 DefaultScale () const 1238 { 1239 return DefaultScaleH ().As_real64 (); 1240 } 1241 1242 /// Default cropped image size (at scale == 1.0) width. 1243 1244 real64 SquareWidth () const 1245 { 1246 return DefaultCropSizeH ().As_real64 (); 1247 } 1248 1249 /// Default cropped image size (at scale == 1.0) height. 1250 1251 real64 SquareHeight () const 1252 { 1253 return DefaultCropSizeV ().As_real64 () * 1254 DefaultScaleV ().As_real64 () / 1255 DefaultScaleH ().As_real64 (); 1256 } 1257 1258 /// Default cropped image aspect ratio. 1259 1260 real64 AspectRatio () const 1261 { 1262 return SquareWidth () / 1263 SquareHeight (); 1264 } 1265 1266 /// Pixel aspect ratio of stage 3 image. 1267 1268 real64 PixelAspectRatio () const 1269 { 1270 return (DefaultScaleH ().As_real64 () / RawToFullScaleH ()) / 1271 (DefaultScaleV ().As_real64 () / RawToFullScaleV ()); 1272 } 1273 1274 /// Default cropped image size at given scale factor width. 1275 1276 uint32 FinalWidth (real64 scale) const 1277 { 1278 return Round_uint32 (SquareWidth () * scale); 1279 } 1280 1281 /// Default cropped image size at given scale factor height. 1282 1283 uint32 FinalHeight (real64 scale) const 1284 { 1285 return Round_uint32 (SquareHeight () * scale); 1286 } 1287 1288 /// Default cropped image size at default scale factor width. 1289 1290 uint32 DefaultFinalWidth () const 1291 { 1292 return FinalWidth (DefaultScale ()); 1293 } 1294 1295 /// Default cropped image size at default scale factor height. 1296 1297 uint32 DefaultFinalHeight () const 1298 { 1299 return FinalHeight (DefaultScale ()); 1300 } 1301 1302 /// Get best quality width. 1303 /// For a naive conversion, one could use either the default size, 1304 /// or the best quality size. 1305 1306 uint32 BestQualityFinalWidth () const 1307 { 1308 return FinalWidth (DefaultScale () * BestQualityScale ().As_real64 ()); 1309 } 1310 1311 /// Get best quality height. 1312 /// For a naive conversion, one could use either the default size, 1313 /// or the best quality size. 1314 1315 uint32 BestQualityFinalHeight () const 1316 { 1317 return FinalHeight (DefaultScale () * BestQualityScale ().As_real64 ()); 1318 } 1319 1320 /// Default size of original (non-proxy) image. For non-proxy images, this 1321 /// is equal to DefaultFinalWidth/DefaultFinalHight. For proxy images, this 1322 /// is equal to the DefaultFinalWidth/DefaultFinalHeight of the image this 1323 /// proxy was derived from. 1324 1325 const dng_point & OriginalDefaultFinalSize () const 1326 { 1327 return fOriginalDefaultFinalSize; 1328 } 1329 1330 /// Setter for OriginalDefaultFinalSize. 1331 1332 void SetOriginalDefaultFinalSize (const dng_point &size) 1333 { 1334 fOriginalDefaultFinalSize = size; 1335 } 1336 1337 /// Best quality size of original (non-proxy) image. For non-proxy images, this 1338 /// is equal to BestQualityFinalWidth/BestQualityFinalHeight. For proxy images, this 1339 /// is equal to the BestQualityFinalWidth/BestQualityFinalHeight of the image this 1340 /// proxy was derived from. 1341 1342 const dng_point & OriginalBestQualityFinalSize () const 1343 { 1344 return fOriginalBestQualityFinalSize; 1345 } 1346 1347 /// Setter for OriginalBestQualityFinalSize. 1348 1349 void SetOriginalBestQualityFinalSize (const dng_point &size) 1350 { 1351 fOriginalBestQualityFinalSize = size; 1352 } 1353 1354 /// DefaultCropSize for original (non-proxy) image. For non-proxy images, 1355 /// this is equal to the DefaultCropSize. for proxy images, this is 1356 /// equal size of the DefaultCropSize of the image this proxy was derived from. 1357 1358 const dng_urational & OriginalDefaultCropSizeH () const 1359 { 1360 return fOriginalDefaultCropSizeH; 1361 } 1362 1363 const dng_urational & OriginalDefaultCropSizeV () const 1364 { 1365 return fOriginalDefaultCropSizeV; 1366 } 1367 1368 /// Setter for OriginalDefaultCropSize. 1369 1370 void SetOriginalDefaultCropSize (const dng_urational &sizeH, 1371 const dng_urational &sizeV) 1372 { 1373 fOriginalDefaultCropSizeH = sizeH; 1374 fOriginalDefaultCropSizeV = sizeV; 1375 } 1376 1377 /// If the original size fields are undefined, set them to the 1378 /// current sizes. 1379 1380 void SetDefaultOriginalSizes (); 1381 1382 /// Set all the original size fields to a specific size. 1383 1384 void SetOriginalSizes (const dng_point &size); 1385 1386 /// The default crop area in the stage 3 image coordinates. 1387 1388 dng_rect DefaultCropArea () const; 1389 1390 /// Setter for BaselineNoise. 1391 1392 void SetBaselineNoise (real64 noise) 1393 { 1394 fBaselineNoise.Set_real64 (noise, 100); 1395 } 1396 1397 /// Getter for BaselineNoise as dng_urational. 1398 1399 const dng_urational & BaselineNoiseR () const 1400 { 1401 return fBaselineNoise; 1402 } 1403 1404 /// Getter for BaselineNoise as real64. 1405 1406 real64 BaselineNoise () const 1407 { 1408 return fBaselineNoise.As_real64 (); 1409 } 1410 1411 /// Setter for NoiseReductionApplied. 1412 1413 void SetNoiseReductionApplied (const dng_urational &value) 1414 { 1415 fNoiseReductionApplied = value; 1416 } 1417 1418 /// Getter for NoiseReductionApplied. 1419 1420 const dng_urational & NoiseReductionApplied () const 1421 { 1422 return fNoiseReductionApplied; 1423 } 1424 1425 // Sets the raw noise reduction applied to be a copy of the unenhanced 1426 // noise reduction applied, if not set yet. 1427 1428 void SetRawNoiseReductionApplied () 1429 { 1430 if (fRawNoiseReductionApplied.NotValid ()) 1431 { 1432 fRawNoiseReductionApplied = fNoiseReductionApplied; 1433 } 1434 } 1435 1436 // Gets the raw NoiseReductionApplied value. 1437 1438 const dng_urational & RawNoiseReductionApplied () const 1439 { 1440 return fRawNoiseReductionApplied; 1441 } 1442 1443 /// Setter for noise profile. 1444 1445 void SetNoiseProfile (const dng_noise_profile &noiseProfile) 1446 { 1447 fNoiseProfile = noiseProfile; 1448 } 1449 1450 /// Does this negative have a valid noise profile? 1451 1452 bool HasNoiseProfile () const 1453 { 1454 return fNoiseProfile.IsValidForNegative (*this); 1455 } 1456 1457 /// Getter for noise profile. 1458 1459 const dng_noise_profile & NoiseProfile () const 1460 { 1461 return fNoiseProfile; 1462 } 1463 1464 // Does this negative have a valid raw noise profile? 1465 1466 bool HasRawNoiseProfile () const 1467 { 1468 return fRawNoiseProfile.IsValidForNegative (*this); 1469 } 1470 1471 // Sets the raw noise profile to be a copy of the unenhanced 1472 // noise profile, if not set yet. 1473 1474 void SetRawNoiseProfile () 1475 { 1476 if (!HasRawNoiseProfile ()) 1477 { 1478 fRawNoiseProfile = fNoiseProfile; 1479 } 1480 } 1481 1482 // Getter for raw noise profile. 1483 1484 const dng_noise_profile & RawNoiseProfile () const 1485 { 1486 return fRawNoiseProfile; 1487 } 1488 1489 /// Setter for BaselineExposure. 1490 1491 void SetBaselineExposure (real64 exposure) 1492 { 1493 fBaselineExposure.Set_real64 (exposure, 100); 1494 } 1495 1496 /// Getter for BaselineExposure as dng_urational. 1497 1498 const dng_srational & BaselineExposureR () const 1499 { 1500 return fBaselineExposure; 1501 } 1502 1503 /// Getter for BaselineExposure as real64. 1504 1505 real64 BaselineExposure () const 1506 { 1507 return BaselineExposureR ().As_real64 (); 1508 } 1509 1510 /// Compute total baseline exposure (sum of negative's BaselineExposure and 1511 /// profile's BaselineExposureOffset). 1512 1513 real64 TotalBaselineExposure (const dng_camera_profile_id &profileID) const; 1514 1515 /// Setter for BaselineSharpness. 1516 1517 void SetBaselineSharpness (real64 sharpness) 1518 { 1519 fBaselineSharpness.Set_real64 (sharpness, 100); 1520 } 1521 1522 /// Getter for BaselineSharpness as dng_urational. 1523 1524 const dng_urational & BaselineSharpnessR () const 1525 { 1526 return fBaselineSharpness; 1527 } 1528 1529 /// Getter for BaselineSharpness as real64. 1530 1531 real64 BaselineSharpness () const 1532 { 1533 return BaselineSharpnessR ().As_real64 (); 1534 } 1535 1536 // Sets the raw baseline sharpness to be a copy of the baseline 1537 // sharpness, if not set yet. 1538 1539 void SetRawBaselineSharpness () 1540 { 1541 if (fRawBaselineSharpness.d == 0) 1542 { 1543 fRawBaselineSharpness = fBaselineSharpness; 1544 } 1545 } 1546 1547 // Gets the raw baseline sharpness value. 1548 1549 const dng_urational & RawBaselineSharpness () const 1550 { 1551 if (fRawBaselineSharpness.d != 0) 1552 { 1553 return fRawBaselineSharpness; 1554 } 1555 return fBaselineSharpness; 1556 } 1557 1558 /// Setter for ChromaBlurRadius. 1559 1560 void SetChromaBlurRadius (const dng_urational &radius) 1561 { 1562 fChromaBlurRadius = radius; 1563 } 1564 1565 /// Getter for ChromaBlurRadius as dng_urational. 1566 1567 const dng_urational & ChromaBlurRadius () const 1568 { 1569 return fChromaBlurRadius; 1570 } 1571 1572 /// Setter for AntiAliasStrength. 1573 1574 void SetAntiAliasStrength (const dng_urational &strength) 1575 { 1576 fAntiAliasStrength = strength; 1577 } 1578 1579 /// Getter for AntiAliasStrength as dng_urational. 1580 1581 const dng_urational & AntiAliasStrength () const 1582 { 1583 return fAntiAliasStrength; 1584 } 1585 1586 /// Setter for LinearResponseLimit. 1587 1588 void SetLinearResponseLimit (real64 limit) 1589 { 1590 fLinearResponseLimit.Set_real64 (limit, 100); 1591 } 1592 1593 /// Getter for LinearResponseLimit as dng_urational. 1594 1595 const dng_urational & LinearResponseLimitR () const 1596 { 1597 return fLinearResponseLimit; 1598 } 1599 1600 /// Getter for LinearResponseLimit as real64. 1601 1602 real64 LinearResponseLimit () const 1603 { 1604 return LinearResponseLimitR ().As_real64 (); 1605 } 1606 1607 /// Setter for ShadowScale. 1608 1609 void SetShadowScale (const dng_urational &scale); 1610 1611 /// Getter for ShadowScale as dng_urational. 1612 1613 const dng_urational & ShadowScaleR () const 1614 { 1615 return fShadowScale; 1616 } 1617 1618 /// Getter for ShadowScale as real64. 1619 1620 real64 ShadowScale () const 1621 { 1622 return ShadowScaleR ().As_real64 (); 1623 } 1624 1625 // API for ColorimetricReference. 1626 1627 void SetColorimetricReference (uint32 ref) 1628 { 1629 fColorimetricReference = ref; 1630 } 1631 1632 uint32 ColorimetricReference () const 1633 { 1634 return fColorimetricReference; 1635 } 1636 1637 // Floating point flag. 1638 1639 void SetFloatingPoint (bool isFloatingPoint) 1640 { 1641 fFloatingPoint = isFloatingPoint; 1642 } 1643 1644 bool IsFloatingPoint () const 1645 { 1646 return fFloatingPoint; 1647 } 1648 1649 // HDR/NDR. 1650 1651 bool IsHighDynamicRange () const 1652 { 1653 return IsFloatingPoint () && 1654 ColorimetricReference () == crSceneReferred; 1655 } 1656 1657 bool IsNormalDynamicRange () const 1658 { 1659 return !IsHighDynamicRange (); 1660 } 1661 1662 /// Setter for ColorChannels. 1663 1664 void SetColorChannels (uint32 channels) 1665 { 1666 fColorChannels = channels; 1667 } 1668 1669 /// Getter for ColorChannels. 1670 1671 uint32 ColorChannels () const 1672 { 1673 return fColorChannels; 1674 } 1675 1676 /// Setter for Monochrome. 1677 1678 void SetMonochrome () 1679 { 1680 SetColorChannels (1); 1681 } 1682 1683 /// Getter for Monochrome. 1684 1685 bool IsMonochrome () const 1686 { 1687 return ColorChannels () == 1; 1688 } 1689 1690 /// Setter for AnalogBalance. 1691 1692 void SetAnalogBalance (const dng_vector &b); 1693 1694 /// Getter for AnalogBalance as dng_urational. 1695 1696 dng_urational AnalogBalanceR (uint32 channel) const; 1697 1698 /// Getter for AnalogBalance as real64. 1699 1700 real64 AnalogBalance (uint32 channel) const; 1701 1702 /// Setter for CameraNeutral. 1703 1704 void SetCameraNeutral (const dng_vector &n); 1705 1706 /// Clear CameraNeutral. 1707 1708 void ClearCameraNeutral () 1709 { 1710 fCameraNeutral.Clear (); 1711 } 1712 1713 /// Determine if CameraNeutral has been set but not cleared. 1714 1715 bool HasCameraNeutral () const 1716 { 1717 return fCameraNeutral.NotEmpty (); 1718 } 1719 1720 /// Getter for CameraNeutral. 1721 1722 const dng_vector & CameraNeutral () const 1723 { 1724 return fCameraNeutral; 1725 } 1726 1727 dng_urational CameraNeutralR (uint32 channel) const; 1728 1729 /// Setter for CameraWhiteXY. 1730 1731 void SetCameraWhiteXY (const dng_xy_coord &coord); 1732 1733 bool HasCameraWhiteXY () const 1734 { 1735 return fCameraWhiteXY.IsValid (); 1736 } 1737 1738 const dng_xy_coord & CameraWhiteXY () const; 1739 1740 void GetCameraWhiteXY (dng_urational &x, 1741 dng_urational &y) const; 1742 1743 // API for camera calibration: 1744 1745 /// Setter for first of up to two color matrices used for individual camera calibrations. 1746 /// 1747 /// The sequence of matrix transforms is: 1748 /// Camera data --> camera calibration --> "inverse" of color matrix 1749 /// 1750 /// This will be a 4x4 matrix for a four-color camera. The defaults are 1751 /// almost always the identity matrix, and for the cases where they 1752 /// aren't, they are diagonal matrices. 1753 1754 void SetCameraCalibration1 (const dng_matrix &m); 1755 1756 /// Setter for second of up to two color matrices used for individual camera calibrations. 1757 /// 1758 /// The sequence of matrix transforms is: 1759 /// Camera data --> camera calibration --> "inverse" of color matrix 1760 /// 1761 /// This will be a 4x4 matrix for a four-color camera. The defaults are 1762 /// almost always the identity matrix, and for the cases where they 1763 /// aren't, they are diagonal matrices. 1764 1765 void SetCameraCalibration2 (const dng_matrix &m); 1766 1767 /// Getter for first of up to two color matrices used for individual camera calibrations. 1768 1769 const dng_matrix & CameraCalibration1 () const 1770 { 1771 return fCameraCalibration1; 1772 } 1773 1774 /// Getter for second of up to two color matrices used for individual camera calibrations. 1775 1776 const dng_matrix & CameraCalibration2 () const 1777 { 1778 return fCameraCalibration2; 1779 } 1780 1781 void SetCameraCalibrationSignature (const char *signature) 1782 { 1783 fCameraCalibrationSignature.Set (signature); 1784 } 1785 1786 const dng_string & CameraCalibrationSignature () const 1787 { 1788 return fCameraCalibrationSignature; 1789 } 1790 1791 // Camera Profile API: 1792 1793 void AddProfile (AutoPtr<dng_camera_profile> &profile); 1794 1795 void ClearProfiles (); 1796 1797 void ClearProfiles (bool clearBuiltinMatrixProfiles, 1798 bool clearReadFromDisk); 1799 1800 uint32 ProfileCount () const; 1801 1802 const dng_camera_profile & ProfileByIndex (uint32 index) const; 1803 1804 virtual const dng_camera_profile * ProfileByID (const dng_camera_profile_id &id, 1805 bool useDefaultIfNoMatch = true) const; 1806 1807 bool HasProfileID (const dng_camera_profile_id &id) const 1808 { 1809 return ProfileByID (id, false) != NULL; 1810 } 1811 1812 // Returns the camera profile to embed when saving to DNG: 1813 1814 virtual const dng_camera_profile * ComputeCameraProfileToEmbed 1815 (const dng_metadata &metadata) const; 1816 1817 // For non-const negatives, we can use the embedded metadata. 1818 1819 const dng_camera_profile * CameraProfileToEmbed () 1820 { 1821 return ComputeCameraProfileToEmbed (Metadata ()); 1822 } 1823 1824 // API for AsShotProfileName. 1825 1826 void SetAsShotProfileName (const char *name) 1827 { 1828 fAsShotProfileName.Set (name); 1829 } 1830 1831 const dng_string & AsShotProfileName () const 1832 { 1833 return fAsShotProfileName; 1834 } 1835 1836 // Makes a dng_color_spec object for this negative. 1837 1838 virtual dng_color_spec * MakeColorSpec (const dng_camera_profile_id &id) const; 1839 1840 // Compute a MD5 hash on an image, using a fixed algorithm. 1841 // The results must be stable across different hardware, OSes, 1842 // and software versions. 1843 1844 static dng_fingerprint FindImageDigest (dng_host &host, 1845 const dng_image &image); 1846 1847 // API for RawImageDigest and NewRawImageDigest: 1848 1849 void SetRawImageDigest (const dng_fingerprint &digest) 1850 { 1851 fRawImageDigest = digest; 1852 } 1853 1854 void SetNewRawImageDigest (const dng_fingerprint &digest) 1855 { 1856 fNewRawImageDigest = digest; 1857 } 1858 1859 void ClearRawImageDigest () const 1860 { 1861 fRawImageDigest .Clear (); 1862 fNewRawImageDigest.Clear (); 1863 } 1864 1865 const dng_fingerprint & RawImageDigest () const 1866 { 1867 return fRawImageDigest; 1868 } 1869 1870 const dng_fingerprint & NewRawImageDigest () const 1871 { 1872 return fNewRawImageDigest; 1873 } 1874 1875 void FindRawImageDigest (dng_host &host) const; 1876 1877 void FindNewRawImageDigest (dng_host &host) const; 1878 1879 void ValidateRawImageDigest (dng_host &host); 1880 1881 // API for RawDataUniqueID: 1882 1883 void SetRawDataUniqueID (const dng_fingerprint &id) 1884 { 1885 fRawDataUniqueID = id; 1886 } 1887 1888 dng_fingerprint RawDataUniqueID () const; 1889 1890 void FindRawDataUniqueID (dng_host &host) const; 1891 1892 virtual void RecomputeRawDataUniqueID (dng_host &host); 1893 1894 // API for original raw file name: 1895 1896 void SetOriginalRawFileName (const char *name) 1897 { 1898 fOriginalRawFileName.Set (name); 1899 } 1900 1901 bool HasOriginalRawFileName () const 1902 { 1903 return fOriginalRawFileName.NotEmpty (); 1904 } 1905 1906 const dng_string & OriginalRawFileName () const 1907 { 1908 return fOriginalRawFileName; 1909 } 1910 1911 // API for original raw file data: 1912 1913 void SetHasOriginalRawFileData (bool hasData) 1914 { 1915 fHasOriginalRawFileData = hasData; 1916 } 1917 1918 bool CanEmbedOriginalRaw () const 1919 { 1920 return fHasOriginalRawFileData && HasOriginalRawFileName (); 1921 } 1922 1923 void SetOriginalRawFileData (AutoPtr<dng_memory_block> &data) 1924 { 1925 fOriginalRawFileData.Reset (data.Release ()); 1926 } 1927 1928 const void * OriginalRawFileData () const 1929 { 1930 return fOriginalRawFileData.Get () ? fOriginalRawFileData->Buffer () 1931 : NULL; 1932 } 1933 1934 uint32 OriginalRawFileDataLength () const 1935 { 1936 return fOriginalRawFileData.Get () ? fOriginalRawFileData->LogicalSize () 1937 : 0; 1938 } 1939 1940 // API for original raw file data digest. 1941 1942 void SetOriginalRawFileDigest (const dng_fingerprint &digest) 1943 { 1944 fOriginalRawFileDigest = digest; 1945 } 1946 1947 const dng_fingerprint & OriginalRawFileDigest () const 1948 { 1949 return fOriginalRawFileDigest; 1950 } 1951 1952 void FindOriginalRawFileDigest () const; 1953 1954 void ValidateOriginalRawFileDigest (); 1955 1956 // API for DNG private data: 1957 1958 void SetPrivateData (AutoPtr<dng_memory_block> &block) 1959 { 1960 fDNGPrivateData.Reset (block.Release ()); 1961 } 1962 1963 void ClearPrivateData () 1964 { 1965 fDNGPrivateData.Reset (); 1966 } 1967 1968 const uint8 * PrivateData () const 1969 { 1970 return fDNGPrivateData.Get () ? fDNGPrivateData->Buffer_uint8 () 1971 : NULL; 1972 } 1973 1974 uint32 PrivateLength () const 1975 { 1976 return fDNGPrivateData.Get () ? fDNGPrivateData->LogicalSize () 1977 : 0; 1978 } 1979 1980 // API for MakerNote data: 1981 1982 void SetMakerNoteSafety (bool safe) 1983 { 1984 Metadata ().SetMakerNoteSafety (safe); 1985 } 1986 1987 bool IsMakerNoteSafe () METACONST 1988 { 1989 return Metadata ().IsMakerNoteSafe (); 1990 } 1991 1992 void SetMakerNote (AutoPtr<dng_memory_block> &block) 1993 { 1994 Metadata ().SetMakerNote (block); 1995 } 1996 1997 void ClearMakerNote () 1998 { 1999 Metadata ().ClearMakerNote (); 2000 } 2001 2002 const void * MakerNoteData () METACONST 2003 { 2004 return Metadata ().MakerNoteData (); 2005 } 2006 2007 uint32 MakerNoteLength () METACONST 2008 { 2009 return Metadata ().MakerNoteLength (); 2010 } 2011 2012 // API for EXIF metadata: 2013 2014 dng_exif * GetExif () 2015 { 2016 return Metadata ().GetExif (); 2017 } 2018 2019 #if qMetadataOnConst 2020 2021 const dng_exif * GetExif () const 2022 { 2023 return Metadata ().GetExif (); 2024 } 2025 2026 #endif // qMetadataOnConst 2027 2028 void ResetExif (dng_exif * newExif) 2029 { 2030 Metadata ().ResetExif (newExif); 2031 } 2032 2033 // API for original EXIF metadata. 2034 2035 dng_exif * GetOriginalExif () 2036 { 2037 return Metadata ().GetOriginalExif (); 2038 } 2039 2040 #if qMetadataOnConst 2041 2042 const dng_exif * GetOriginalExif () const 2043 { 2044 return Metadata ().GetOriginalExif (); 2045 } 2046 2047 #endif // qMetadataOnConst 2048 2049 // API for IPTC metadata: 2050 2051 void SetIPTC (AutoPtr<dng_memory_block> &block, 2052 uint64 offset) 2053 { 2054 Metadata ().SetIPTC (block, offset); 2055 } 2056 2057 void SetIPTC (AutoPtr<dng_memory_block> &block) 2058 { 2059 Metadata ().SetIPTC (block); 2060 } 2061 2062 void ClearIPTC () 2063 { 2064 Metadata ().ClearIPTC (); 2065 } 2066 2067 const void * IPTCData () METACONST 2068 { 2069 return Metadata ().IPTCData (); 2070 } 2071 2072 uint32 IPTCLength () METACONST 2073 { 2074 return Metadata ().IPTCLength (); 2075 } 2076 2077 uint64 IPTCOffset () METACONST 2078 { 2079 return Metadata ().IPTCOffset (); 2080 } 2081 2082 dng_fingerprint IPTCDigest (bool includePadding = true) METACONST 2083 { 2084 return Metadata ().IPTCDigest (includePadding); 2085 } 2086 2087 void RebuildIPTC (bool padForTIFF) 2088 { 2089 Metadata ().RebuildIPTC (Allocator (), padForTIFF); 2090 } 2091 2092 // API for XMP metadata: 2093 2094 bool SetXMP (dng_host &host, 2095 const void *buffer, 2096 uint32 count, 2097 bool xmpInSidecar = false, 2098 bool xmpIsNewer = false) 2099 { 2100 return Metadata ().SetXMP (host, 2101 buffer, 2102 count, 2103 xmpInSidecar, 2104 xmpIsNewer); 2105 } 2106 2107 dng_xmp * GetXMP () 2108 { 2109 return Metadata ().GetXMP (); 2110 } 2111 2112 #if qMetadataOnConst 2113 2114 const dng_xmp * GetXMP () const 2115 { 2116 return Metadata ().GetXMP (); 2117 } 2118 2119 #endif // qMetadataOnConst 2120 2121 bool XMPinSidecar () METACONST 2122 { 2123 return Metadata ().XMPinSidecar (); 2124 } 2125 2126 void ResetXMP (dng_xmp * newXMP) 2127 { 2128 Metadata ().ResetXMP (newXMP); 2129 } 2130 2131 void ResetXMPSidecarNewer (dng_xmp * newXMP, bool inSidecar, bool isNewer ) 2132 { 2133 Metadata ().ResetXMPSidecarNewer (newXMP, inSidecar, isNewer); 2134 } 2135 2136 bool HaveValidEmbeddedXMP () METACONST 2137 { 2138 return Metadata ().HaveValidEmbeddedXMP (); 2139 } 2140 2141 // API for source MIME type. 2142 2143 void SetSourceMIME (const char *s) 2144 { 2145 Metadata ().SetSourceMIME (s); 2146 } 2147 2148 // API for linearization information: 2149 2150 const dng_linearization_info * GetLinearizationInfo () const 2151 { 2152 return fLinearizationInfo.Get (); 2153 } 2154 2155 void ClearLinearizationInfo () 2156 { 2157 fLinearizationInfo.Reset (); 2158 } 2159 2160 // Linearization curve. Usually used to increase compression ratios 2161 // by storing the compressed data in a more visually uniform space. 2162 // This is a 16-bit LUT that maps the stored data back to linear. 2163 2164 void SetLinearization (AutoPtr<dng_memory_block> &curve); 2165 2166 // Active area (non-black masked pixels). These pixels are trimmed 2167 // during linearization step. 2168 2169 void SetActiveArea (const dng_rect &area); 2170 2171 // Areas that are known to contain black masked pixels that can 2172 // be used to estimate black levels. 2173 2174 void SetMaskedAreas (uint32 count, 2175 const dng_rect *area); 2176 2177 void SetMaskedArea (const dng_rect &area) 2178 { 2179 SetMaskedAreas (1, &area); 2180 } 2181 2182 // Sensor black level information. 2183 2184 void SetBlackLevel (real64 black, 2185 int32 plane = -1); 2186 2187 void SetQuadBlacks (real64 black0, 2188 real64 black1, 2189 real64 black2, 2190 real64 black3, 2191 int32 plane = -1); 2192 2193 void Set6x6Blacks (real64 blacks6x6 [36], 2194 int32 plane = -1); 2195 2196 void SetRowBlacks (const real64 *blacks, 2197 uint32 count); 2198 2199 void SetColumnBlacks (const real64 *blacks, 2200 uint32 count); 2201 2202 // Sensor white level information. 2203 2204 uint32 WhiteLevel (uint32 plane = 0) const; 2205 2206 void SetWhiteLevel (uint32 white, 2207 int32 plane = -1); 2208 2209 // API for mosaic information: 2210 2211 const dng_mosaic_info * GetMosaicInfo () const 2212 { 2213 return fMosaicInfo.Get (); 2214 } 2215 2216 void ClearMosaicInfo () 2217 { 2218 fMosaicInfo.Reset (); 2219 } 2220 2221 // ColorKeys APIs: 2222 2223 void SetColorKeys (ColorKeyCode color0, 2224 ColorKeyCode color1, 2225 ColorKeyCode color2, 2226 ColorKeyCode color3 = colorKeyMaxEnum); 2227 2228 void SetRGB () 2229 { 2230 2231 SetColorChannels (3); 2232 2233 SetColorKeys (colorKeyRed, 2234 colorKeyGreen, 2235 colorKeyBlue); 2236 2237 } 2238 2239 void SetCMY () 2240 { 2241 2242 SetColorChannels (3); 2243 2244 SetColorKeys (colorKeyCyan, 2245 colorKeyMagenta, 2246 colorKeyYellow); 2247 2248 } 2249 2250 void SetGMCY () 2251 { 2252 2253 SetColorChannels (4); 2254 2255 SetColorKeys (colorKeyGreen, 2256 colorKeyMagenta, 2257 colorKeyCyan, 2258 colorKeyYellow); 2259 2260 } 2261 2262 // APIs to set mosaic patterns. 2263 2264 void SetBayerMosaic (uint32 phase); 2265 2266 void SetFujiMosaic (uint32 phase); 2267 2268 void SetFujiMosaic6x6 (uint32 phase); 2269 2270 void SetQuadMosaic (uint32 pattern); 2271 2272 // BayerGreenSplit. 2273 2274 void SetGreenSplit (uint32 split); 2275 2276 // APIs for opcode lists. 2277 2278 const dng_opcode_list & OpcodeList1 () const 2279 { 2280 return fOpcodeList1; 2281 } 2282 2283 dng_opcode_list & OpcodeList1 () 2284 { 2285 return fOpcodeList1; 2286 } 2287 2288 const dng_opcode_list & OpcodeList2 () const 2289 { 2290 return fOpcodeList2; 2291 } 2292 2293 dng_opcode_list & OpcodeList2 () 2294 { 2295 return fOpcodeList2; 2296 } 2297 2298 const dng_opcode_list & OpcodeList3 () const 2299 { 2300 return fOpcodeList3; 2301 } 2302 2303 dng_opcode_list & OpcodeList3 () 2304 { 2305 return fOpcodeList3; 2306 } 2307 2308 // First part of parsing logic. 2309 2310 virtual void Parse (dng_host &host, 2311 dng_stream &stream, 2312 dng_info &info); 2313 2314 // Second part of parsing logic. This is split off from the 2315 // first part because these operations are useful when extending 2316 // this sdk to support non-DNG raw formats. 2317 2318 virtual void PostParse (dng_host &host, 2319 dng_stream &stream, 2320 dng_info &info); 2321 2322 // Synchronize metadata sources. 2323 2324 void SynchronizeMetadata () 2325 { 2326 Metadata ().SynchronizeMetadata (); 2327 } 2328 2329 // Routines to update the date/time field in the EXIF and XMP 2330 // metadata. 2331 2332 void UpdateDateTime (const dng_date_time_info &dt) 2333 { 2334 Metadata ().UpdateDateTime (dt); 2335 } 2336 2337 void UpdateDateTimeToNow () 2338 { 2339 Metadata ().UpdateDateTimeToNow (); 2340 } 2341 2342 // Developer's utility function to switch to four color Bayer 2343 // interpolation. This is useful for evaluating how much green 2344 // split a Bayer pattern sensor has. 2345 2346 virtual bool SetFourColorBayer (); 2347 2348 // Access routines for the image stages. 2349 2350 const dng_image * Stage1Image () const 2351 { 2352 return fStage1Image.Get (); 2353 } 2354 2355 const dng_image * Stage2Image () const 2356 { 2357 return fStage2Image.Get (); 2358 } 2359 2360 const dng_image * Stage3Image () const 2361 { 2362 return fStage3Image.Get (); 2363 } 2364 2365 // Returns the processing stage of the raw image data. 2366 2367 RawImageStageEnum RawImageStage () const 2368 { 2369 return fRawImageStage; 2370 } 2371 2372 // Returns the raw image data. 2373 2374 const dng_image & RawImage () const; 2375 2376 // Returns the raw image black level in 16-bit space. 2377 2378 uint16 RawImageBlackLevel () const; 2379 2380 // API for raw floating point bit depth. 2381 2382 uint32 RawFloatBitDepth () const 2383 { 2384 return fRawFloatBitDepth; 2385 } 2386 2387 void SetRawFloatBitDepth (uint32 bitDepth) 2388 { 2389 fRawFloatBitDepth = bitDepth; 2390 } 2391 2392 // API for raw jpeg image. 2393 2394 const dng_jpeg_image * RawJPEGImage () const; 2395 2396 void SetRawJPEGImage (AutoPtr<dng_jpeg_image> &jpegImage); 2397 2398 void ClearRawJPEGImage (); 2399 2400 // API for RawJPEGImageDigest: 2401 2402 void SetRawJPEGImageDigest (const dng_fingerprint &digest) 2403 { 2404 fRawJPEGImageDigest = digest; 2405 } 2406 2407 void ClearRawJPEGImageDigest () const 2408 { 2409 fRawJPEGImageDigest.Clear (); 2410 } 2411 2412 const dng_fingerprint & RawJPEGImageDigest () const 2413 { 2414 return fRawJPEGImageDigest; 2415 } 2416 2417 void FindRawJPEGImageDigest (dng_host &host) const; 2418 2419 // Read the opcode lists. 2420 2421 virtual void ReadOpcodeLists (dng_host &host, 2422 dng_stream &stream, 2423 dng_info &info); 2424 2425 // Read the stage 1 image. 2426 2427 virtual void ReadStage1Image (dng_host &host, 2428 dng_stream &stream, 2429 dng_info &info); 2430 2431 // Read the enhanced image directly into the stage 3 image. 2432 2433 virtual void ReadEnhancedImage (dng_host &host, 2434 dng_stream &stream, 2435 dng_info &info); 2436 2437 // Assign the stage 1 image. 2438 2439 void SetStage1Image (AutoPtr<dng_image> &image); 2440 2441 // Assign the stage 2 image. 2442 2443 void SetStage2Image (AutoPtr<dng_image> &image); 2444 2445 // Assign the stage 3 image. 2446 2447 void SetStage3Image (AutoPtr<dng_image> &image); 2448 2449 // Build the stage 2 (linearized and range mapped) image. 2450 2451 void BuildStage2Image (dng_host &host); 2452 2453 // Build the stage 3 (demosaiced) image. 2454 2455 void BuildStage3Image (dng_host &host, 2456 int32 srcPlane = -1); 2457 2458 // Additional gain applied when building the stage 3 image. 2459 2460 void SetStage3Gain (real64 gain) 2461 { 2462 fStage3Gain = gain; 2463 } 2464 2465 real64 Stage3Gain () const 2466 { 2467 return fStage3Gain; 2468 } 2469 2470 // Optical black level of stage 3 image (in [0,65535]). 2471 2472 void SetStage3BlackLevel (uint16 level) 2473 { 2474 fStage3BlackLevel = level; 2475 } 2476 2477 uint16 Stage3BlackLevel () const 2478 { 2479 return fStage3BlackLevel; 2480 } 2481 2482 // Optical black level of stage 3 image (in [0,1]). 2483 2484 real64 Stage3BlackLevelNormalized () const 2485 { 2486 return fStage3BlackLevel * (1.0 / 65535.0); 2487 } 2488 2489 // Is this negative permitted to support deferred black subtraction 2490 // (by preserving offset or negative black values in the stage 3 2491 // image)? 2492 // 2493 // If false, then fStage3BlackLevel must be zero. 2494 // If true, then fStage3BlackLevel may or may not be zero. 2495 // 2496 // Default implementation return false. 2497 2498 virtual bool SupportsPreservedBlackLevels (dng_host &host); 2499 2500 // Adaptively encode a proxy image down to 8-bits/channel. 2501 2502 dng_image * EncodeRawProxy (dng_host &host, 2503 const dng_image &srcImage, 2504 dng_opcode_list &opcodeList, 2505 real64 *blackLevel) const; 2506 2507 // Convert to a proxy negative. 2508 2509 void ConvertToProxy (dng_host &host, 2510 dng_image_writer &writer, 2511 uint32 proxySize = 0, 2512 uint64 proxyCount = 0); 2513 2514 // IsProxy API: 2515 2516 bool IsProxy () const; 2517 2518 // IsPreview API: 2519 2520 void SetIsPreview (bool preview) 2521 { 2522 fIsPreview = preview; 2523 } 2524 2525 bool IsPreview () const 2526 { 2527 return fIsPreview; 2528 } 2529 2530 // IsDamaged API: 2531 2532 void SetIsDamaged (bool damaged) 2533 { 2534 fIsDamaged = damaged; 2535 } 2536 2537 bool IsDamaged () const 2538 { 2539 return fIsDamaged; 2540 } 2541 2542 // Transparancy Mask API: 2543 2544 void SetTransparencyMask (AutoPtr<dng_image> &image, 2545 uint32 bitDepth = 0); 2546 2547 const dng_image * TransparencyMask () const; 2548 2549 const dng_image * RawTransparencyMask () const; 2550 2551 uint32 RawTransparencyMaskBitDepth () const; 2552 2553 void ReadTransparencyMask (dng_host &host, 2554 dng_stream &stream, 2555 dng_info &info); 2556 2557 virtual void ResizeTransparencyToMatchStage3 (dng_host &host, 2558 bool convertTo8Bit = false); 2559 2560 virtual bool NeedFlattenTransparency (dng_host &host); 2561 2562 virtual void FlattenTransparency (dng_host &host); 2563 2564 const dng_image * UnflattenedStage3Image () const; 2565 2566 // Depth map API: 2567 2568 bool HasDepthMap () const 2569 { 2570 return fHasDepthMap; 2571 } 2572 2573 void SetHasDepthMap (bool hasDepthMap) 2574 { 2575 fHasDepthMap = hasDepthMap; 2576 } 2577 2578 const dng_image * DepthMap () const 2579 { 2580 return fDepthMap.Get (); 2581 } 2582 2583 void SetDepthMap (AutoPtr<dng_image> &depthMap); 2584 2585 bool HasDepthMapImage () const 2586 { 2587 return (fDepthMap.Get () != NULL); 2588 } 2589 2590 const dng_image * RawDepthMap () const 2591 { 2592 if (fRawDepthMap.Get ()) 2593 { 2594 return fRawDepthMap.Get (); 2595 } 2596 return DepthMap (); 2597 } 2598 2599 void ReadDepthMap (dng_host &host, 2600 dng_stream &stream, 2601 dng_info &info); 2602 2603 virtual void ResizeDepthToMatchStage3 (dng_host &host); 2604 2605 uint32 DepthFormat () const 2606 { 2607 return fDepthFormat; 2608 } 2609 2610 void SetDepthFormat (uint32 format) 2611 { 2612 fDepthFormat = format; 2613 } 2614 2615 const dng_urational & DepthNear () const 2616 { 2617 return fDepthNear; 2618 } 2619 2620 void SetDepthNear (const dng_urational &dist) 2621 { 2622 fDepthNear = dist; 2623 } 2624 2625 const dng_urational & DepthFar () const 2626 { 2627 return fDepthFar; 2628 } 2629 2630 void SetDepthFar (const dng_urational &dist) 2631 { 2632 fDepthFar = dist; 2633 } 2634 2635 uint32 DepthUnits () const 2636 { 2637 return fDepthUnits; 2638 } 2639 2640 void SetDepthUnits (uint32 units) 2641 { 2642 fDepthUnits = units; 2643 } 2644 2645 uint32 DepthMeasureType () const 2646 { 2647 return fDepthMeasureType; 2648 } 2649 2650 void SetDepthMeasureType (uint32 measure) 2651 { 2652 fDepthMeasureType = measure; 2653 } 2654 2655 // EnhanceParams API: 2656 2657 const dng_string & EnhanceParams () const 2658 { 2659 return fEnhanceParams; 2660 } 2661 2662 void SetEnhanceParams (const dng_string &s) 2663 { 2664 fEnhanceParams = s; 2665 } 2666 2667 void SetEnhanceParams (const char *s) 2668 { 2669 fEnhanceParams.Set (s); 2670 } 2671 2672 protected: 2673 2674 dng_negative (dng_host &host); 2675 2676 virtual void Initialize (); 2677 2678 virtual dng_linearization_info * MakeLinearizationInfo (); 2679 2680 void NeedLinearizationInfo (); 2681 2682 virtual dng_mosaic_info * MakeMosaicInfo (); 2683 2684 void NeedMosaicInfo (); 2685 2686 virtual void DoBuildStage2 (dng_host &host); 2687 2688 virtual void DoPostOpcodeList2 (dng_host &host); 2689 2690 virtual bool NeedDefloatStage2 (dng_host &host); 2691 2692 virtual void DefloatStage2 (dng_host &host); 2693 2694 virtual void DoInterpolateStage3 (dng_host &host, 2695 int32 srcPlane, 2696 dng_matrix *scaleTransforms); 2697 2698 virtual void DoMergeStage3 (dng_host &host, 2699 dng_matrix *scaleTransforms); 2700 2701 virtual void DoBuildStage3 (dng_host &host, 2702 int32 srcPlane, 2703 dng_matrix *scaleTransforms); 2704 2705 virtual void AdjustProfileForStage3 (); 2706 2707 }; 2708 2709 /*****************************************************************************/ 2710 2711 #endif 2712 2713 /*****************************************************************************/