DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_negative.hGo to the documentation of this file.00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_negative.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00018 /*****************************************************************************/ 00019 00020 #ifndef __dng_negative__ 00021 #define __dng_negative__ 00022 00023 /*****************************************************************************/ 00024 00025 #include "dng_auto_ptr.h" 00026 #include "dng_classes.h" 00027 #include "dng_fingerprint.h" 00028 #include "dng_linearization_info.h" 00029 #include "dng_matrix.h" 00030 #include "dng_mosaic_info.h" 00031 #include "dng_orientation.h" 00032 #include "dng_rational.h" 00033 #include "dng_string.h" 00034 #include "dng_tag_types.h" 00035 #include "dng_tag_values.h" 00036 #include "dng_types.h" 00037 #include "dng_utils.h" 00038 #include "dng_xy_coord.h" 00039 00040 #include <vector> 00041 00042 /*****************************************************************************/ 00043 00045 00046 class dng_negative 00047 { 00048 00049 protected: 00050 00051 // The object stores an associated allocator. It does not do 00052 // anything to keep it alive or to release it when the object destructs. 00053 // Hence, clients will need to make sure that the allocator's lifespan 00054 // encompasses that of the dng_negative object. 00055 00056 dng_memory_allocator &fAllocator; 00057 00058 // Non-localized ASCII model name. 00059 00060 dng_string fModelName; 00061 00062 // Localized UTF-8 model name. 00063 00064 dng_string fLocalName; 00065 00066 // Base orientation of both the thumbnail and raw data. This is 00067 // generally based on the EXIF values. 00068 00069 bool fHasBaseOrientation; 00070 00071 dng_orientation fBaseOrientation; 00072 00073 // The area of raw image that should be included in the final converted 00074 // image. This stems from extra pixels around the edges of the sensor 00075 // including both the black mask and some additional padding. 00076 00077 // The default crop can be smaller than the "active" area which includes 00078 // the padding but not the black masked pixels. 00079 00080 dng_urational fDefaultCropSizeH; 00081 dng_urational fDefaultCropSizeV; 00082 00083 dng_urational fDefaultCropOriginH; 00084 dng_urational fDefaultCropOriginV; 00085 00086 // Default scale factors. Generally, 1.0 for square pixel cameras. They 00087 // can compensate for non-square pixels. The choice of exact values will 00088 // generally depend on what the camera does. These are particularly 00089 // interesting for the Nikon D1X and the Fuji diamond mosaic. 00090 00091 dng_urational fDefaultScaleH; 00092 dng_urational fDefaultScaleV; 00093 00094 // Best quality scale factor. Used for the Nikon D1X and Fuji cameras 00095 // to force everything to be a scale up rather than scale down. So, 00096 // generally this is 1.0 / min (fDefaultScaleH, fDefaultScaleV) but 00097 // this isn't used if the scale factors are only slightly different 00098 // from 1.0. 00099 00100 dng_urational fBestQualityScale; 00101 00102 // Scale factors used in demosaic algorithm (calculated). 00103 // Maps raw image coordinates to full image coordinates -- i.e., 00104 // original image coordinates on raw sensor data to coordinates 00105 // in fStage3Image which is the output of the interpolation step. 00106 // So, if we downsample when interpolating, these numbers get 00107 // smaller. 00108 00109 real64 fRawToFullScaleH; 00110 real64 fRawToFullScaleV; 00111 00112 // Relative amount of noise at ISO 100. This is measured per camera model 00113 // based on looking at flat areas of color. 00114 00115 dng_urational fBaselineNoise; 00116 00117 // How much noise reduction has already been applied (0.0 to 1.0) to the 00118 // the raw image data? 0.0 = none, 1.0 = "ideal" amount--i.e. don't apply any 00119 // more by default. 0/0 for unknown. 00120 00121 dng_urational fNoiseReductionApplied; 00122 00123 // Zero point for the exposure compensation slider. This reflects how 00124 // the manufacturer sets up the camera and its conversions. 00125 00126 dng_srational fBaselineExposure; 00127 00128 // Relative amount of sharpening required. This is chosen per camera 00129 // model based on how strong the anti-alias filter is on the camera 00130 // and the quality of the lenses. This scales the sharpness slider 00131 // value. 00132 00133 dng_urational fBaselineSharpness; 00134 00135 // Chroma blur radius (or 0/0 for auto). Set to 0/1 to disable 00136 // chroma blurring. 00137 00138 dng_urational fChromaBlurRadius; 00139 00140 // Anti-alias filter strength (0.0 to 1.0). Used as a hint 00141 // to the demosaic algorithms. 00142 00143 dng_urational fAntiAliasStrength; 00144 00145 // Linear response limit. The point at which the sensor goes 00146 // non-linear and color information becomes unreliable. Used in 00147 // the highlight-recovery logic. 00148 00149 dng_urational fLinearResponseLimit; 00150 00151 // Scale factor for shadows slider. The Fuji HDR cameras, for example, 00152 // need a more sensitive shadow slider. 00153 00154 dng_urational fShadowScale; 00155 00156 // Colormetric reference. 00157 00158 uint32 fColorimetricReference; 00159 00160 // Number of color channels for this image (e.g. 1, 3, or 4). 00161 00162 uint32 fColorChannels; 00163 00164 // Amount by which each channel has already been scaled. Some cameras 00165 // have analog amplifiers on the color channels and these can result 00166 // in different scalings per channel. This provides some level of 00167 // analog white balancing. The Nikon D1 also did digital scaling but 00168 // this caused problems with highlight recovery. 00169 00170 dng_vector fAnalogBalance; 00171 00172 // The "As Shot" neutral color coordinates in native camera space. 00173 // This overrides fCameraWhiteXY if both are specified. This 00174 // specifies the values per channel that would result in a neutral 00175 // color for the "As Shot" case. This is generally supplied by 00176 // the camera. 00177 00178 dng_vector fCameraNeutral; 00179 00180 // The "As Shot" white balance xy coordinates. Sometimes this is 00181 // supplied by the camera. Sometimes the camera just supplies a name 00182 // for the white balance. 00183 00184 dng_xy_coord fCameraWhiteXY; 00185 00186 // Individual camera calibrations. 00187 00188 // Camera data --> camera calibration --> "inverse" of color matrix 00189 00190 // This will be a 4x4 matrix for a 4-color camera. The defaults are 00191 // almost always the identity matrix and for the cases where they 00192 // aren't, they are diagonal matrices. 00193 00194 dng_matrix fCameraCalibration1; 00195 dng_matrix fCameraCalibration2; 00196 00197 // Signature which allows a profile to announce that it is compatible 00198 // with these calibration matrices. 00199 00200 dng_string fCameraCalibrationSignature; 00201 00202 // List of camera profiles. 00203 00204 std::vector<dng_camera_profile *> fCameraProfile; 00205 00206 // "As shot" camera profile name. 00207 00208 dng_string fAsShotProfileName; 00209 00210 // Raw image data digest. This is a MD5 fingerprint of the raw image data 00211 // in the file, computed using a specific algorithm. It can be used 00212 // verify the raw data has not been corrupted. 00213 00214 mutable dng_fingerprint fRawImageDigest; 00215 00216 // Raw data unique ID. This is an unique identifer for the actual 00217 // raw image data in the file. It can be used to index into caches 00218 // for this data. 00219 00220 mutable dng_fingerprint fRawDataUniqueID; 00221 00222 // Original raw file name. Just the file name, not the full path. 00223 00224 dng_string fOriginalRawFileName; 00225 00226 // Is the original raw file data availaible? 00227 00228 bool fHasOriginalRawFileData; 00229 00230 // The compressed original raw file data. 00231 00232 AutoPtr<dng_memory_block> fOriginalRawFileData; 00233 00234 // MD5 digest of original raw file data block. 00235 00236 mutable dng_fingerprint fOriginalRawFileDigest; 00237 00238 // DNG private data block. 00239 00240 AutoPtr<dng_memory_block> fDNGPrivateData; 00241 00242 // Is the maker note safe to copy from file to file? Defaults to false 00243 // because many maker notes are not safe. 00244 00245 bool fIsMakerNoteSafe; 00246 00247 // MakerNote binary data block. 00248 00249 AutoPtr<dng_memory_block> fMakerNote; 00250 00251 // EXIF data. 00252 00253 AutoPtr<dng_exif> fExif; 00254 00255 // A copy of the EXIF data before is was synchronized with other metadata sources. 00256 00257 AutoPtr<dng_exif> fOriginalExif; 00258 00259 // IPTC binary data block and offset in original file. 00260 00261 AutoPtr<dng_memory_block> fIPTCBlock; 00262 00263 uint64 fIPTCOffset; 00264 00265 // XMP data. 00266 00267 AutoPtr<dng_xmp> fXMP; 00268 00269 // Was there a valid embedded XMP block? 00270 00271 bool fValidEmbeddedXMP; 00272 00273 // Is the XMP data from a sidecar file? 00274 00275 bool fXMPinSidecar; 00276 00277 // If the XMP data is from a sidecar file, is the sidecar file newer 00278 // than the raw file? 00279 00280 bool fXMPisNewer; 00281 00282 // Information required to linearize and range map the raw data. 00283 00284 AutoPtr<dng_linearization_info> fLinearizationInfo; 00285 00286 // Information required to demoasic the raw data. 00287 00288 AutoPtr<dng_mosaic_info> fMosaicInfo; 00289 00290 // Stage 1 image, which is image data stored in a DNG file. 00291 00292 AutoPtr<dng_image> fStage1Image; 00293 00294 // Stage 2 image, which is the stage 1 image after it has been 00295 // linearized and range mapped. 00296 00297 AutoPtr<dng_image> fStage2Image; 00298 00299 // Stage 3 image, which is the stage 2 image after it has been 00300 // demosaiced. 00301 00302 AutoPtr<dng_image> fStage3Image; 00303 00304 // Additiona gain applied when building the stage 3 image. 00305 00306 real64 fStage3Gain; 00307 00308 // Were any approximations (e.g. downsampling, etc.) applied 00309 // file reading this image? 00310 00311 bool fIsPreview; 00312 00313 public: 00314 00315 virtual ~dng_negative (); 00316 00317 static dng_negative * Make (dng_memory_allocator &allocator); 00318 00320 00321 dng_memory_allocator & Allocator () const 00322 { 00323 return fAllocator; 00324 } 00325 00327 00328 void SetModelName (const char *name) 00329 { 00330 fModelName.Set_ASCII (name); 00331 } 00332 00334 00335 const dng_string & ModelName () const 00336 { 00337 return fModelName; 00338 } 00339 00341 00342 void SetLocalName (const char *name) 00343 { 00344 fLocalName.Set (name); 00345 } 00346 00348 00349 const dng_string & LocalName () const 00350 { 00351 return fLocalName; 00352 } 00353 00355 00356 void SetBaseOrientation (const dng_orientation &orientation); 00357 00359 00360 bool HasBaseOrientation () const 00361 { 00362 return fHasBaseOrientation; 00363 } 00364 00366 00367 const dng_orientation & BaseOrientation () const 00368 { 00369 return fBaseOrientation; 00370 } 00371 00373 00374 virtual dng_orientation Orientation () const; 00375 00378 00379 void ApplyOrientation (const dng_orientation &orientation); 00380 00382 00383 void SetDefaultCropSize (const dng_urational &sizeH, 00384 const dng_urational &sizeV) 00385 { 00386 fDefaultCropSizeH = sizeH; 00387 fDefaultCropSizeV = sizeV; 00388 } 00389 00391 00392 void SetDefaultCropSize (uint32 sizeH, 00393 uint32 sizeV) 00394 { 00395 SetDefaultCropSize (dng_urational (sizeH, 1), 00396 dng_urational (sizeV, 1)); 00397 } 00398 00400 00401 const dng_urational & DefaultCropSizeH () const 00402 { 00403 return fDefaultCropSizeH; 00404 } 00405 00407 00408 const dng_urational & DefaultCropSizeV () const 00409 { 00410 return fDefaultCropSizeV; 00411 } 00412 00414 00415 void SetDefaultCropOrigin (const dng_urational &originH, 00416 const dng_urational &originV) 00417 { 00418 fDefaultCropOriginH = originH; 00419 fDefaultCropOriginV = originV; 00420 } 00421 00423 00424 void SetDefaultCropOrigin (uint32 originH, 00425 uint32 originV) 00426 { 00427 SetDefaultCropOrigin (dng_urational (originH, 1), 00428 dng_urational (originV, 1)); 00429 } 00430 00432 00433 void SetDefaultCropCentered (const dng_point &rawSize) 00434 { 00435 00436 uint32 sizeH = Round_uint32 (fDefaultCropSizeH.As_real64 ()); 00437 uint32 sizeV = Round_uint32 (fDefaultCropSizeV.As_real64 ()); 00438 00439 SetDefaultCropOrigin ((rawSize.h - sizeH) >> 1, 00440 (rawSize.v - sizeV) >> 1); 00441 00442 } 00443 00445 00446 const dng_urational & DefaultCropOriginH () const 00447 { 00448 return fDefaultCropOriginH; 00449 } 00450 00452 00453 const dng_urational & DefaultCropOriginV () const 00454 { 00455 return fDefaultCropOriginV; 00456 } 00457 00459 00460 void SetDefaultScale (const dng_urational &scaleH, 00461 const dng_urational &scaleV) 00462 { 00463 fDefaultScaleH = scaleH; 00464 fDefaultScaleV = scaleV; 00465 } 00466 00468 00469 const dng_urational & DefaultScaleH () const 00470 { 00471 return fDefaultScaleH; 00472 } 00473 00475 00476 const dng_urational & DefaultScaleV () const 00477 { 00478 return fDefaultScaleV; 00479 } 00480 00482 00483 void SetBestQualityScale (const dng_urational &scale) 00484 { 00485 fBestQualityScale = scale; 00486 } 00487 00489 00490 const dng_urational & BestQualityScale () const 00491 { 00492 return fBestQualityScale; 00493 } 00494 00496 00497 real64 RawToFullScaleH () const 00498 { 00499 return fRawToFullScaleH; 00500 } 00501 00503 00504 real64 RawToFullScaleV () const 00505 { 00506 return fRawToFullScaleV; 00507 } 00508 00513 00514 real64 DefaultScale () const 00515 { 00516 return DefaultScaleH ().As_real64 (); 00517 } 00518 00520 00521 real64 SquareWidth () const 00522 { 00523 return DefaultCropSizeH ().As_real64 (); 00524 } 00525 00527 00528 real64 SquareHeight () const 00529 { 00530 return DefaultCropSizeV ().As_real64 () * 00531 DefaultScaleV ().As_real64 () / 00532 DefaultScaleH ().As_real64 (); 00533 } 00534 00536 00537 real64 AspectRatio () const 00538 { 00539 return SquareWidth () / 00540 SquareHeight (); 00541 } 00542 00544 00545 uint32 FinalWidth (real64 scale) const 00546 { 00547 return Round_uint32 (SquareWidth () * scale); 00548 } 00549 00551 00552 uint32 FinalHeight (real64 scale) const 00553 { 00554 return Round_uint32 (SquareHeight () * scale); 00555 } 00556 00558 00559 uint32 DefaultFinalWidth () const 00560 { 00561 return FinalWidth (DefaultScale ()); 00562 } 00563 00565 00566 uint32 DefaultFinalHeight () const 00567 { 00568 return FinalHeight (DefaultScale ()); 00569 } 00570 00574 00575 uint32 BestQualityFinalWidth () const 00576 { 00577 return FinalWidth (DefaultScale () * BestQualityScale ().As_real64 ()); 00578 } 00579 00583 00584 uint32 BestQualityFinalHeight () const 00585 { 00586 return FinalHeight (DefaultScale () * BestQualityScale ().As_real64 ()); 00587 } 00588 00591 00592 dng_rect DefaultCropArea (real64 scaleH = 1.0, 00593 real64 scaleV = 1.0) const; 00594 00596 00597 void SetBaselineNoise (real64 noise) 00598 { 00599 fBaselineNoise.Set_real64 (noise, 100); 00600 } 00601 00603 00604 const dng_urational & BaselineNoiseR () const 00605 { 00606 return fBaselineNoise; 00607 } 00608 00610 00611 real64 BaselineNoise () const 00612 { 00613 return fBaselineNoise.As_real64 (); 00614 } 00615 00617 00618 void SetNoiseReductionApplied (const dng_urational &value) 00619 { 00620 fNoiseReductionApplied = value; 00621 } 00622 00624 00625 const dng_urational & NoiseReductionApplied () const 00626 { 00627 return fNoiseReductionApplied; 00628 } 00629 00631 00632 void SetBaselineExposure (real64 exposure) 00633 { 00634 fBaselineExposure.Set_real64 (exposure, 100); 00635 } 00636 00638 00639 const dng_srational & BaselineExposureR () const 00640 { 00641 return fBaselineExposure; 00642 } 00643 00645 00646 real64 BaselineExposure () const 00647 { 00648 return BaselineExposureR ().As_real64 (); 00649 } 00650 00652 00653 void SetBaselineSharpness (real64 sharpness) 00654 { 00655 fBaselineSharpness.Set_real64 (sharpness, 100); 00656 } 00657 00659 00660 const dng_urational & BaselineSharpnessR () const 00661 { 00662 return fBaselineSharpness; 00663 } 00664 00666 00667 real64 BaselineSharpness () const 00668 { 00669 return BaselineSharpnessR ().As_real64 (); 00670 } 00671 00673 00674 void SetChromaBlurRadius (const dng_urational &radius) 00675 { 00676 fChromaBlurRadius = radius; 00677 } 00678 00680 00681 const dng_urational & ChromaBlurRadius () const 00682 { 00683 return fChromaBlurRadius; 00684 } 00685 00687 00688 void SetAntiAliasStrength (const dng_urational &strength) 00689 { 00690 fAntiAliasStrength = strength; 00691 } 00692 00694 00695 const dng_urational & AntiAliasStrength () const 00696 { 00697 return fAntiAliasStrength; 00698 } 00699 00701 00702 void SetLinearResponseLimit (real64 limit) 00703 { 00704 fLinearResponseLimit.Set_real64 (limit, 100); 00705 } 00706 00708 00709 const dng_urational & LinearResponseLimitR () const 00710 { 00711 return fLinearResponseLimit; 00712 } 00713 00715 00716 real64 LinearResponseLimit () const 00717 { 00718 return LinearResponseLimitR ().As_real64 (); 00719 } 00720 00722 00723 void SetShadowScale (const dng_urational &scale); 00724 00726 00727 const dng_urational & ShadowScaleR () const 00728 { 00729 return fShadowScale; 00730 } 00731 00733 00734 real64 ShadowScale () const 00735 { 00736 return ShadowScaleR ().As_real64 (); 00737 } 00738 00739 // API for ColorimetricReference. 00740 00741 void SetColorimetricReference (uint32 ref) 00742 { 00743 fColorimetricReference = ref; 00744 } 00745 00746 uint32 ColorimetricReference () const 00747 { 00748 return fColorimetricReference; 00749 } 00750 00752 00753 void SetColorChannels (uint32 channels) 00754 { 00755 fColorChannels = channels; 00756 } 00757 00759 00760 uint32 ColorChannels () const 00761 { 00762 return fColorChannels; 00763 } 00764 00766 00767 void SetMonochrome () 00768 { 00769 SetColorChannels (1); 00770 } 00771 00773 00774 bool IsMonochrome () const 00775 { 00776 return ColorChannels () == 1; 00777 } 00778 00780 00781 void SetAnalogBalance (const dng_vector &b); 00782 00784 00785 dng_urational AnalogBalanceR (uint32 channel) const; 00786 00788 00789 real64 AnalogBalance (uint32 channel) const; 00790 00792 00793 void SetCameraNeutral (const dng_vector &n); 00794 00796 00797 void ClearCameraNeutral () 00798 { 00799 fCameraNeutral.Clear (); 00800 } 00801 00803 00804 bool HasCameraNeutral () const 00805 { 00806 return fCameraNeutral.NotEmpty (); 00807 } 00808 00810 00811 const dng_vector & CameraNeutral () const 00812 { 00813 return fCameraNeutral; 00814 } 00815 00816 dng_urational CameraNeutralR (uint32 channel) const; 00817 00819 00820 void SetCameraWhiteXY (const dng_xy_coord &coord); 00821 00822 bool HasCameraWhiteXY () const 00823 { 00824 return fCameraWhiteXY.IsValid (); 00825 } 00826 00827 const dng_xy_coord & CameraWhiteXY () const; 00828 00829 void GetCameraWhiteXY (dng_urational &x, 00830 dng_urational &y) const; 00831 00832 // API for camera calibration: 00833 00842 00843 void SetCameraCalibration1 (const dng_matrix &m); 00844 00853 00854 void SetCameraCalibration2 (const dng_matrix &m); 00855 00857 00858 const dng_matrix & CameraCalibration1 () const 00859 { 00860 return fCameraCalibration1; 00861 } 00862 00864 00865 const dng_matrix & CameraCalibration2 () const 00866 { 00867 return fCameraCalibration2; 00868 } 00869 00870 void SetCameraCalibrationSignature (const char *signature) 00871 { 00872 fCameraCalibrationSignature.Set (signature); 00873 } 00874 00875 const dng_string & CameraCalibrationSignature () const 00876 { 00877 return fCameraCalibrationSignature; 00878 } 00879 00880 // Camera Profile API: 00881 00882 void AddProfile (AutoPtr<dng_camera_profile> &profile); 00883 00884 void ClearProfiles (); 00885 00886 uint32 ProfileCount () const; 00887 00888 const dng_camera_profile & ProfileByIndex (uint32 index) const; 00889 00890 const dng_camera_profile * ProfileByID (const dng_camera_profile_id &id, 00891 bool useDefaultIfNoMatch = true) const; 00892 00893 bool HasProfileID (const dng_camera_profile_id &id) const 00894 { 00895 return ProfileByID (id, false) != NULL; 00896 } 00897 00898 // Returns the camera profile to embed when saving to DNG: 00899 00900 virtual const dng_camera_profile * CameraProfileToEmbed () const; 00901 00902 // API for AsShotProfileName. 00903 00904 void SetAsShotProfileName (const char *name) 00905 { 00906 fAsShotProfileName.Set (name); 00907 } 00908 00909 const dng_string & AsShotProfileName () const 00910 { 00911 return fAsShotProfileName; 00912 } 00913 00914 // Makes a dng_color_spec object for this negative. 00915 00916 virtual dng_color_spec * MakeColorSpec (const dng_camera_profile_id &id) const; 00917 00918 // API for RawImageDigest: 00919 00920 void SetRawImageDigest (const dng_fingerprint &digest) 00921 { 00922 fRawImageDigest = digest; 00923 } 00924 00925 void ClearRawImageDigest () 00926 { 00927 fRawImageDigest.Clear (); 00928 } 00929 00930 const dng_fingerprint RawImageDigest () const 00931 { 00932 return fRawImageDigest; 00933 } 00934 00935 void FindRawImageDigest (dng_host &host) const; 00936 00937 void ValidateRawImageDigest (dng_host &host) const; 00938 00939 // API for RawDataUniqueID: 00940 00941 void SetRawDataUniqueID (const dng_fingerprint &id) 00942 { 00943 fRawDataUniqueID = id; 00944 } 00945 00946 const dng_fingerprint & RawDataUniqueID () const 00947 { 00948 return fRawDataUniqueID; 00949 } 00950 00951 void FindRawDataUniqueID (dng_host &host) const; 00952 00953 // API for original raw file name: 00954 00955 void SetOriginalRawFileName (const char *name) 00956 { 00957 fOriginalRawFileName.Set (name); 00958 } 00959 00960 bool HasOriginalRawFileName () const 00961 { 00962 return fOriginalRawFileName.NotEmpty (); 00963 } 00964 00965 const dng_string & OriginalRawFileName () const 00966 { 00967 return fOriginalRawFileName; 00968 } 00969 00970 // API for original raw file data: 00971 00972 void SetHasOriginalRawFileData (bool hasData) 00973 { 00974 fHasOriginalRawFileData = hasData; 00975 } 00976 00977 bool CanEmbedOriginalRaw () const 00978 { 00979 return fHasOriginalRawFileData && HasOriginalRawFileName (); 00980 } 00981 00982 void SetOriginalRawFileData (AutoPtr<dng_memory_block> &data) 00983 { 00984 fOriginalRawFileData.Reset (data.Release ()); 00985 } 00986 00987 const void * OriginalRawFileData () const 00988 { 00989 return fOriginalRawFileData.Get () ? fOriginalRawFileData->Buffer () 00990 : NULL; 00991 } 00992 00993 uint32 OriginalRawFileDataLength () const 00994 { 00995 return fOriginalRawFileData.Get () ? fOriginalRawFileData->LogicalSize () 00996 : 0; 00997 } 00998 00999 // API for original raw file data digest. 01000 01001 void SetOriginalRawFileDigest (const dng_fingerprint &digest) 01002 { 01003 fOriginalRawFileDigest = digest; 01004 } 01005 01006 const dng_fingerprint & OriginalRawFileDigest () const 01007 { 01008 return fOriginalRawFileDigest; 01009 } 01010 01011 void FindOriginalRawFileDigest () const; 01012 01013 void ValidateOriginalRawFileDigest () const; 01014 01015 // API for DNG private data: 01016 01017 void SetPrivateData (AutoPtr<dng_memory_block> &block) 01018 { 01019 fDNGPrivateData.Reset (block.Release ()); 01020 } 01021 01022 void ClearPrivateData () 01023 { 01024 fDNGPrivateData.Reset (); 01025 } 01026 01027 const uint8 * PrivateData () const 01028 { 01029 return fDNGPrivateData.Get () ? fDNGPrivateData->Buffer_uint8 () 01030 : NULL; 01031 } 01032 01033 uint32 PrivateLength () const 01034 { 01035 return fDNGPrivateData.Get () ? fDNGPrivateData->LogicalSize () 01036 : 0; 01037 } 01038 01039 // API for MakerNote data: 01040 01041 void SetMakerNoteSafety (bool safe) 01042 { 01043 fIsMakerNoteSafe = safe; 01044 } 01045 01046 bool IsMakerNoteSafe () const 01047 { 01048 return fIsMakerNoteSafe; 01049 } 01050 01051 void SetMakerNote (AutoPtr<dng_memory_block> &block) 01052 { 01053 fMakerNote.Reset (block.Release ()); 01054 } 01055 01056 void ClearMakerNote () 01057 { 01058 fMakerNote.Reset (); 01059 } 01060 01061 const void * MakerNoteData () const 01062 { 01063 return fMakerNote.Get () ? fMakerNote->Buffer () 01064 : NULL; 01065 } 01066 01067 uint32 MakerNoteLength () const 01068 { 01069 return fMakerNote.Get () ? fMakerNote->LogicalSize () 01070 : 0; 01071 } 01072 01073 // API for EXIF metadata: 01074 01075 dng_exif * GetExif () 01076 { 01077 return fExif.Get (); 01078 } 01079 01080 const dng_exif * GetExif () const 01081 { 01082 return fExif.Get (); 01083 } 01084 01085 virtual dng_memory_block * BuildExifBlock (const dng_resolution *resolution = NULL, 01086 bool includeIPTC = false) const; 01087 01088 // API for original EXIF metadata. 01089 01090 dng_exif * GetOriginalExif () 01091 { 01092 return fOriginalExif.Get (); 01093 } 01094 01095 const dng_exif * GetOriginalExif () const 01096 { 01097 return fOriginalExif.Get (); 01098 } 01099 01100 // API for IPTC metadata: 01101 01102 void SetIPTC (AutoPtr<dng_memory_block> &block, 01103 uint64 offset); 01104 01105 void SetIPTC (AutoPtr<dng_memory_block> &block); 01106 01107 void ClearIPTC (); 01108 01109 const void * IPTCData () const; 01110 01111 uint32 IPTCLength () const; 01112 01113 uint64 IPTCOffset () const; 01114 01115 dng_fingerprint IPTCDigest () const; 01116 01117 void RebuildIPTC (); 01118 01119 // API for XMP metadata: 01120 01121 bool SetXMP (dng_host &host, 01122 const void *buffer, 01123 uint32 count, 01124 bool xmpInSidecar = false, 01125 bool xmpIsNewer = false); 01126 01127 dng_xmp * GetXMP () 01128 { 01129 return fXMP.Get (); 01130 } 01131 01132 const dng_xmp * GetXMP () const 01133 { 01134 return fXMP.Get (); 01135 } 01136 01137 bool XMPinSidecar () const 01138 { 01139 return fXMPinSidecar; 01140 } 01141 01142 // API for linearization information: 01143 01144 const dng_linearization_info * GetLinearizationInfo () const 01145 { 01146 return fLinearizationInfo.Get (); 01147 } 01148 01149 void ClearLinearizationInfo () 01150 { 01151 fLinearizationInfo.Reset (); 01152 } 01153 01154 // Linearization curve. Usually used to increase compression ratios 01155 // by storing the compressed data in a more visually uniform space. 01156 // This is a 16-bit LUT that maps the stored data back to linear. 01157 01158 void SetLinearization (AutoPtr<dng_memory_block> &curve); 01159 01160 // Active area (non-black masked pixels). These pixels are trimmed 01161 // during linearization step. 01162 01163 void SetActiveArea (const dng_rect &area); 01164 01165 // Areas that are known to contain black masked pixels that can 01166 // be used to estimate black levels. 01167 01168 void SetMaskedAreas (uint32 count, 01169 const dng_rect *area); 01170 01171 void SetMaskedArea (const dng_rect &area) 01172 { 01173 SetMaskedAreas (1, &area); 01174 } 01175 01176 // Sensor black level information. 01177 01178 void SetBlackLevel (real64 black, 01179 int32 plane = -1); 01180 01181 void SetQuadBlacks (real64 black0, 01182 real64 black1, 01183 real64 black2, 01184 real64 black3); 01185 01186 void SetRowBlacks (const real64 *blacks, 01187 uint32 count); 01188 01189 void SetColumnBlacks (const real64 *blacks, 01190 uint32 count); 01191 01192 // Sensor white level information. 01193 01194 uint32 WhiteLevel (uint32 plane = 0) const; 01195 01196 void SetWhiteLevel (uint32 white, 01197 int32 plane = -1); 01198 01199 // API for mosaic information: 01200 01201 const dng_mosaic_info * GetMosaicInfo () const 01202 { 01203 return fMosaicInfo.Get (); 01204 } 01205 01206 void ClearMosaicInfo () 01207 { 01208 fMosaicInfo.Reset (); 01209 } 01210 01211 // ColorKeys APIs: 01212 01213 void SetColorKeys (ColorKeyCode color0, 01214 ColorKeyCode color1, 01215 ColorKeyCode color2, 01216 ColorKeyCode color3 = colorKeyMaxEnum); 01217 01218 void SetRGB () 01219 { 01220 01221 SetColorChannels (3); 01222 01223 SetColorKeys (colorKeyRed, 01224 colorKeyGreen, 01225 colorKeyBlue); 01226 01227 } 01228 01229 void SetCMY () 01230 { 01231 01232 SetColorChannels (3); 01233 01234 SetColorKeys (colorKeyCyan, 01235 colorKeyMagenta, 01236 colorKeyYellow); 01237 01238 } 01239 01240 void SetGMCY () 01241 { 01242 01243 SetColorChannels (4); 01244 01245 SetColorKeys (colorKeyGreen, 01246 colorKeyMagenta, 01247 colorKeyCyan, 01248 colorKeyYellow); 01249 01250 } 01251 01252 // APIs to set mosaic patterns. 01253 01254 void SetBayerMosaic (uint32 phase); 01255 01256 void SetFujiMosaic (uint32 phase); 01257 01258 void SetQuadMosaic (uint32 pattern); 01259 01260 // BayerGreenSplit. 01261 01262 void SetGreenSplit (uint32 split); 01263 01264 // First part of parsing logic. 01265 01266 virtual void Parse (dng_host &host, 01267 dng_stream &stream, 01268 dng_info &info); 01269 01270 // Second part of parsing logic. This is split off from the 01271 // first part because these operations are useful when extending 01272 // this sdk to support non-DNG raw formats. 01273 01274 virtual void PostParse (dng_host &host, 01275 dng_stream &stream, 01276 dng_info &info); 01277 01278 // Synchronize metadata sources. 01279 01280 virtual void SynchronizeMetadata (); 01281 01282 // Routines to update the date/time field in the EXIF and XMP 01283 // metadata. 01284 01285 void UpdateDateTime (const dng_date_time_info &dt); 01286 01287 void UpdateDateTimeToNow (); 01288 01289 // Developer's utility function to switch to four color Bayer 01290 // interpolation. This is useful for evaluating how much green 01291 // split a Bayer pattern sensor has. 01292 01293 virtual bool SetFourColorBayer (); 01294 01295 // Access routines for the image stages. 01296 01297 const dng_image * Stage1Image () const 01298 { 01299 return fStage1Image.Get (); 01300 } 01301 01302 const dng_image * Stage2Image () const 01303 { 01304 return fStage2Image.Get (); 01305 } 01306 01307 const dng_image * Stage3Image () const 01308 { 01309 return fStage3Image.Get (); 01310 } 01311 01312 // Returns the most "raw" of the image stages. 01313 01314 const dng_image & RawImage () const; 01315 01316 // Read the stage 1 image. 01317 01318 virtual void ReadStage1Image (dng_host &host, 01319 dng_stream &stream, 01320 dng_info &info); 01321 01322 // Assign the stage 1 image. 01323 01324 void SetStage1Image (AutoPtr<dng_image> &image); 01325 01326 // Build the stage 2 (linearized and range mapped) image. 01327 01328 virtual void BuildStage2Image (dng_host &host, 01329 uint32 pixelType = ttShort); 01330 01331 // Discard the stage 1 image and the linearization info. 01332 01333 virtual void ClearStage1 (); 01334 01335 // Build the stage 3 (demosaiced) image. 01336 01337 virtual void BuildStage3Image (dng_host &host, 01338 int32 srcPlane = -1); 01339 01340 // Additional gain applied when building the stage 3 image. 01341 01342 void SetStage3Gain (real64 gain) 01343 { 01344 fStage3Gain = gain; 01345 } 01346 01347 real64 Stage3Gain () const 01348 { 01349 return fStage3Gain; 01350 } 01351 01352 // Discard the stage 2 image and the mosaic info. 01353 01354 virtual void ClearStage2 (); 01355 01356 // Discard the stage 3 image. 01357 01358 virtual void ClearStage3 (); 01359 01360 // IsPreview API: 01361 01362 void SetIsPreview (bool preview) 01363 { 01364 fIsPreview = preview; 01365 } 01366 01367 bool IsPreview () const 01368 { 01369 return fIsPreview; 01370 } 01371 01372 protected: 01373 01374 dng_negative (dng_memory_allocator &allocator); 01375 01376 virtual void Initialize (); 01377 01378 virtual dng_exif * MakeExif (); 01379 01380 virtual dng_xmp * MakeXMP (); 01381 01382 virtual dng_linearization_info * MakeLinearizationInfo (); 01383 01384 void NeedLinearizationInfo (); 01385 01386 virtual dng_mosaic_info * MakeMosaicInfo (); 01387 01388 void NeedMosaicInfo (); 01389 01390 virtual void DoBuildStage2 (dng_host &host, 01391 uint32 pixelType); 01392 01393 virtual void DoBuildStage3 (dng_host &host, 01394 int32 srcPlane); 01395 01396 virtual void DoMergeStage3 (dng_host &host); 01397 01398 }; 01399 01400 /*****************************************************************************/ 01401 01402 #endif 01403 01404 /*****************************************************************************/ | |||
