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/workarea/stern/camera_raw/dng_sdk/source/dng_negative.h#34 $ */ 00010 /* $DateTime: 2009/06/18 17:47:41 $ */ 00011 /* $Change: 577711 $ */ 00012 /* $Author: stern $ */ 00013 00018 /*****************************************************************************/ 00019 00020 #ifndef __dng_negative__ 00021 #define __dng_negative__ 00022 00023 /*****************************************************************************/ 00024 00025 #include "dng_1d_function.h" 00026 #include "dng_auto_ptr.h" 00027 #include "dng_classes.h" 00028 #include "dng_fingerprint.h" 00029 #include "dng_linearization_info.h" 00030 #include "dng_matrix.h" 00031 #include "dng_mosaic_info.h" 00032 #include "dng_opcode_list.h" 00033 #include "dng_orientation.h" 00034 #include "dng_rational.h" 00035 #include "dng_sdk_limits.h" 00036 #include "dng_string.h" 00037 #include "dng_tag_types.h" 00038 #include "dng_tag_values.h" 00039 #include "dng_types.h" 00040 #include "dng_utils.h" 00041 #include "dng_xy_coord.h" 00042 00043 #include <vector> 00044 00045 /*****************************************************************************/ 00046 00054 00055 class dng_noise_function: public dng_1d_function 00056 { 00057 00058 protected: 00059 00060 real64 fScale; 00061 real64 fOffset; 00062 00063 public: 00064 00065 dng_noise_function () 00066 00067 : fScale (0.0) 00068 , fOffset (0.0) 00069 00070 { 00071 00072 } 00073 00074 dng_noise_function (real64 scale, 00075 real64 offset) 00076 00077 : fScale (scale) 00078 , fOffset (offset) 00079 00080 { 00081 00082 } 00083 00084 virtual real64 Evaluate (real64 x) const 00085 { 00086 return sqrt (fScale * x + fOffset); 00087 } 00088 00089 real64 Scale () const 00090 { 00091 return fScale; 00092 } 00093 00094 real64 Offset () const 00095 { 00096 return fOffset; 00097 } 00098 00099 void SetScale (real64 scale) 00100 { 00101 fScale = scale; 00102 } 00103 00104 void SetOffset (real64 offset) 00105 { 00106 fOffset = offset; 00107 } 00108 00109 bool IsValid () const 00110 { 00111 return (fScale > 0.0 && fOffset >= 0.0); 00112 } 00113 00114 }; 00115 00116 /*****************************************************************************/ 00117 00132 00133 class dng_noise_profile 00134 { 00135 00136 protected: 00137 00138 std::vector<dng_noise_function> fNoiseFunctions; 00139 00140 public: 00141 00142 dng_noise_profile (); 00143 00144 explicit dng_noise_profile (const std::vector<dng_noise_function> &functions); 00145 00146 bool IsValid () const; 00147 00148 bool IsValidForNegative (const dng_negative &negative) const; 00149 00150 const dng_noise_function & NoiseFunction (uint32 plane) const; 00151 00152 uint32 NumFunctions () const; 00153 00154 }; 00155 00156 /*****************************************************************************/ 00157 00159 00160 class dng_negative 00161 { 00162 00163 public: 00164 00165 enum RawImageStageEnum 00166 { 00167 rawImageStagePreOpcode1, 00168 rawImageStagePostOpcode1, 00169 rawImageStagePostOpcode2, 00170 rawImageStagePreOpcode3, 00171 rawImageStagePostOpcode3, 00172 rawImageStageNone 00173 }; 00174 00175 protected: 00176 00177 // The object stores an associated allocator. It does not do 00178 // anything to keep it alive or to release it when the object destructs. 00179 // Hence, clients will need to make sure that the allocator's lifespan 00180 // encompasses that of the dng_negative object. 00181 00182 dng_memory_allocator &fAllocator; 00183 00184 // Non-localized ASCII model name. 00185 00186 dng_string fModelName; 00187 00188 // Localized UTF-8 model name. 00189 00190 dng_string fLocalName; 00191 00192 // Base orientation of both the thumbnail and raw data. This is 00193 // generally based on the EXIF values. 00194 00195 bool fHasBaseOrientation; 00196 00197 dng_orientation fBaseOrientation; 00198 00199 // The area of raw image that should be included in the final converted 00200 // image. This stems from extra pixels around the edges of the sensor 00201 // including both the black mask and some additional padding. 00202 00203 // The default crop can be smaller than the "active" area which includes 00204 // the padding but not the black masked pixels. 00205 00206 dng_urational fDefaultCropSizeH; 00207 dng_urational fDefaultCropSizeV; 00208 00209 dng_urational fDefaultCropOriginH; 00210 dng_urational fDefaultCropOriginV; 00211 00212 // Default scale factors. Generally, 1.0 for square pixel cameras. They 00213 // can compensate for non-square pixels. The choice of exact values will 00214 // generally depend on what the camera does. These are particularly 00215 // interesting for the Nikon D1X and the Fuji diamond mosaic. 00216 00217 dng_urational fDefaultScaleH; 00218 dng_urational fDefaultScaleV; 00219 00220 // Best quality scale factor. Used for the Nikon D1X and Fuji cameras 00221 // to force everything to be a scale up rather than scale down. So, 00222 // generally this is 1.0 / min (fDefaultScaleH, fDefaultScaleV) but 00223 // this isn't used if the scale factors are only slightly different 00224 // from 1.0. 00225 00226 dng_urational fBestQualityScale; 00227 00228 // Scale factors used in demosaic algorithm (calculated). 00229 // Maps raw image coordinates to full image coordinates -- i.e., 00230 // original image coordinates on raw sensor data to coordinates 00231 // in fStage3Image which is the output of the interpolation step. 00232 // So, if we downsample when interpolating, these numbers get 00233 // smaller. 00234 00235 real64 fRawToFullScaleH; 00236 real64 fRawToFullScaleV; 00237 00238 // Relative amount of noise at ISO 100. This is measured per camera model 00239 // based on looking at flat areas of color. 00240 00241 dng_urational fBaselineNoise; 00242 00243 // How much noise reduction has already been applied (0.0 to 1.0) to the 00244 // the raw image data? 0.0 = none, 1.0 = "ideal" amount--i.e. don't apply any 00245 // more by default. 0/0 for unknown. 00246 00247 dng_urational fNoiseReductionApplied; 00248 00249 // Amount of noise for this negative (see dng_noise_profile for details). 00250 00251 dng_noise_profile fNoiseProfile; 00252 00253 // Zero point for the exposure compensation slider. This reflects how 00254 // the manufacturer sets up the camera and its conversions. 00255 00256 dng_srational fBaselineExposure; 00257 00258 // Relative amount of sharpening required. This is chosen per camera 00259 // model based on how strong the anti-alias filter is on the camera 00260 // and the quality of the lenses. This scales the sharpness slider 00261 // value. 00262 00263 dng_urational fBaselineSharpness; 00264 00265 // Chroma blur radius (or 0/0 for auto). Set to 0/1 to disable 00266 // chroma blurring. 00267 00268 dng_urational fChromaBlurRadius; 00269 00270 // Anti-alias filter strength (0.0 to 1.0). Used as a hint 00271 // to the demosaic algorithms. 00272 00273 dng_urational fAntiAliasStrength; 00274 00275 // Linear response limit. The point at which the sensor goes 00276 // non-linear and color information becomes unreliable. Used in 00277 // the highlight-recovery logic. 00278 00279 dng_urational fLinearResponseLimit; 00280 00281 // Scale factor for shadows slider. The Fuji HDR cameras, for example, 00282 // need a more sensitive shadow slider. 00283 00284 dng_urational fShadowScale; 00285 00286 // Colormetric reference. 00287 00288 uint32 fColorimetricReference; 00289 00290 // Number of color channels for this image (e.g. 1, 3, or 4). 00291 00292 uint32 fColorChannels; 00293 00294 // Amount by which each channel has already been scaled. Some cameras 00295 // have analog amplifiers on the color channels and these can result 00296 // in different scalings per channel. This provides some level of 00297 // analog white balancing. The Nikon D1 also did digital scaling but 00298 // this caused problems with highlight recovery. 00299 00300 dng_vector fAnalogBalance; 00301 00302 // The "As Shot" neutral color coordinates in native camera space. 00303 // This overrides fCameraWhiteXY if both are specified. This 00304 // specifies the values per channel that would result in a neutral 00305 // color for the "As Shot" case. This is generally supplied by 00306 // the camera. 00307 00308 dng_vector fCameraNeutral; 00309 00310 // The "As Shot" white balance xy coordinates. Sometimes this is 00311 // supplied by the camera. Sometimes the camera just supplies a name 00312 // for the white balance. 00313 00314 dng_xy_coord fCameraWhiteXY; 00315 00316 // Individual camera calibrations. 00317 00318 // Camera data --> camera calibration --> "inverse" of color matrix 00319 00320 // This will be a 4x4 matrix for a 4-color camera. The defaults are 00321 // almost always the identity matrix and for the cases where they 00322 // aren't, they are diagonal matrices. 00323 00324 dng_matrix fCameraCalibration1; 00325 dng_matrix fCameraCalibration2; 00326 00327 // Signature which allows a profile to announce that it is compatible 00328 // with these calibration matrices. 00329 00330 dng_string fCameraCalibrationSignature; 00331 00332 // List of camera profiles. 00333 00334 std::vector<dng_camera_profile *> fCameraProfile; 00335 00336 // "As shot" camera profile name. 00337 00338 dng_string fAsShotProfileName; 00339 00340 // Raw image data digest. This is a MD5 fingerprint of the raw image data 00341 // in the file, computed using a specific algorithm. It can be used 00342 // verify the raw data has not been corrupted. 00343 00344 mutable dng_fingerprint fRawImageDigest; 00345 00346 // Raw data unique ID. This is an unique identifer for the actual 00347 // raw image data in the file. It can be used to index into caches 00348 // for this data. 00349 00350 mutable dng_fingerprint fRawDataUniqueID; 00351 00352 // Original raw file name. Just the file name, not the full path. 00353 00354 dng_string fOriginalRawFileName; 00355 00356 // Is the original raw file data availaible? 00357 00358 bool fHasOriginalRawFileData; 00359 00360 // The compressed original raw file data. 00361 00362 AutoPtr<dng_memory_block> fOriginalRawFileData; 00363 00364 // MD5 digest of original raw file data block. 00365 00366 mutable dng_fingerprint fOriginalRawFileDigest; 00367 00368 // DNG private data block. 00369 00370 AutoPtr<dng_memory_block> fDNGPrivateData; 00371 00372 // Is the maker note safe to copy from file to file? Defaults to false 00373 // because many maker notes are not safe. 00374 00375 bool fIsMakerNoteSafe; 00376 00377 // MakerNote binary data block. 00378 00379 AutoPtr<dng_memory_block> fMakerNote; 00380 00381 // EXIF data. 00382 00383 AutoPtr<dng_exif> fExif; 00384 00385 // A copy of the EXIF data before is was synchronized with other metadata sources. 00386 00387 AutoPtr<dng_exif> fOriginalExif; 00388 00389 // IPTC binary data block and offset in original file. 00390 00391 AutoPtr<dng_memory_block> fIPTCBlock; 00392 00393 uint64 fIPTCOffset; 00394 00395 // Did the legacy ITPC block use UTF8? 00396 00397 bool fUsedUTF8forIPTC; 00398 00399 // XMP data. 00400 00401 AutoPtr<dng_xmp> fXMP; 00402 00403 // Was there a valid embedded XMP block? 00404 00405 bool fValidEmbeddedXMP; 00406 00407 // Is the XMP data from a sidecar file? 00408 00409 bool fXMPinSidecar; 00410 00411 // If the XMP data is from a sidecar file, is the sidecar file newer 00412 // than the raw file? 00413 00414 bool fXMPisNewer; 00415 00416 // Information required to linearize and range map the raw data. 00417 00418 AutoPtr<dng_linearization_info> fLinearizationInfo; 00419 00420 // Information required to demoasic the raw data. 00421 00422 AutoPtr<dng_mosaic_info> fMosaicInfo; 00423 00424 // Opcode list 1. (Applied to stored data) 00425 00426 dng_opcode_list fOpcodeList1; 00427 00428 // Opcode list 2. (Applied to range mapped data) 00429 00430 dng_opcode_list fOpcodeList2; 00431 00432 // Opcode list 3. (Post demosaic) 00433 00434 dng_opcode_list fOpcodeList3; 00435 00436 // Stage 1 image, which is image data stored in a DNG file. 00437 00438 AutoPtr<dng_image> fStage1Image; 00439 00440 // Stage 2 image, which is the stage 1 image after it has been 00441 // linearized and range mapped. 00442 00443 AutoPtr<dng_image> fStage2Image; 00444 00445 // Stage 3 image, which is the stage 2 image after it has been 00446 // demosaiced. 00447 00448 AutoPtr<dng_image> fStage3Image; 00449 00450 // Additiona gain applied when building the stage 3 image. 00451 00452 real64 fStage3Gain; 00453 00454 // Were any approximations (e.g. downsampling, etc.) applied 00455 // file reading this image? 00456 00457 bool fIsPreview; 00458 00459 // Does the file appear to be damaged? 00460 00461 bool fIsDamaged; 00462 00463 // At what processing stage did we grab a copy of raw image data? 00464 00465 RawImageStageEnum fRawImageStage; 00466 00467 // The raw image data that we grabbed, if any. 00468 00469 AutoPtr<dng_image> fRawImage; 00470 00471 public: 00472 00473 virtual ~dng_negative (); 00474 00475 static dng_negative * Make (dng_memory_allocator &allocator); 00476 00478 00479 dng_memory_allocator & Allocator () const 00480 { 00481 return fAllocator; 00482 } 00483 00485 00486 void SetModelName (const char *name) 00487 { 00488 fModelName.Set_ASCII (name); 00489 } 00490 00492 00493 const dng_string & ModelName () const 00494 { 00495 return fModelName; 00496 } 00497 00499 00500 void SetLocalName (const char *name) 00501 { 00502 fLocalName.Set (name); 00503 } 00504 00506 00507 const dng_string & LocalName () const 00508 { 00509 return fLocalName; 00510 } 00511 00513 00514 void SetBaseOrientation (const dng_orientation &orientation); 00515 00517 00518 bool HasBaseOrientation () const 00519 { 00520 return fHasBaseOrientation; 00521 } 00522 00524 00525 const dng_orientation & BaseOrientation () const 00526 { 00527 return fBaseOrientation; 00528 } 00529 00531 00532 virtual dng_orientation Orientation () const; 00533 00536 00537 void ApplyOrientation (const dng_orientation &orientation); 00538 00540 00541 void SetDefaultCropSize (const dng_urational &sizeH, 00542 const dng_urational &sizeV) 00543 { 00544 fDefaultCropSizeH = sizeH; 00545 fDefaultCropSizeV = sizeV; 00546 } 00547 00549 00550 void SetDefaultCropSize (uint32 sizeH, 00551 uint32 sizeV) 00552 { 00553 SetDefaultCropSize (dng_urational (sizeH, 1), 00554 dng_urational (sizeV, 1)); 00555 } 00556 00558 00559 const dng_urational & DefaultCropSizeH () const 00560 { 00561 return fDefaultCropSizeH; 00562 } 00563 00565 00566 const dng_urational & DefaultCropSizeV () const 00567 { 00568 return fDefaultCropSizeV; 00569 } 00570 00572 00573 void SetDefaultCropOrigin (const dng_urational &originH, 00574 const dng_urational &originV) 00575 { 00576 fDefaultCropOriginH = originH; 00577 fDefaultCropOriginV = originV; 00578 } 00579 00581 00582 void SetDefaultCropOrigin (uint32 originH, 00583 uint32 originV) 00584 { 00585 SetDefaultCropOrigin (dng_urational (originH, 1), 00586 dng_urational (originV, 1)); 00587 } 00588 00590 00591 void SetDefaultCropCentered (const dng_point &rawSize) 00592 { 00593 00594 uint32 sizeH = Round_uint32 (fDefaultCropSizeH.As_real64 ()); 00595 uint32 sizeV = Round_uint32 (fDefaultCropSizeV.As_real64 ()); 00596 00597 SetDefaultCropOrigin ((rawSize.h - sizeH) >> 1, 00598 (rawSize.v - sizeV) >> 1); 00599 00600 } 00601 00603 00604 const dng_urational & DefaultCropOriginH () const 00605 { 00606 return fDefaultCropOriginH; 00607 } 00608 00610 00611 const dng_urational & DefaultCropOriginV () const 00612 { 00613 return fDefaultCropOriginV; 00614 } 00615 00617 00618 void SetDefaultScale (const dng_urational &scaleH, 00619 const dng_urational &scaleV) 00620 { 00621 fDefaultScaleH = scaleH; 00622 fDefaultScaleV = scaleV; 00623 } 00624 00626 00627 const dng_urational & DefaultScaleH () const 00628 { 00629 return fDefaultScaleH; 00630 } 00631 00633 00634 const dng_urational & DefaultScaleV () const 00635 { 00636 return fDefaultScaleV; 00637 } 00638 00640 00641 void SetBestQualityScale (const dng_urational &scale) 00642 { 00643 fBestQualityScale = scale; 00644 } 00645 00647 00648 const dng_urational & BestQualityScale () const 00649 { 00650 return fBestQualityScale; 00651 } 00652 00654 00655 real64 RawToFullScaleH () const 00656 { 00657 return fRawToFullScaleH; 00658 } 00659 00661 00662 real64 RawToFullScaleV () const 00663 { 00664 return fRawToFullScaleV; 00665 } 00666 00671 00672 real64 DefaultScale () const 00673 { 00674 return DefaultScaleH ().As_real64 (); 00675 } 00676 00678 00679 real64 SquareWidth () const 00680 { 00681 return DefaultCropSizeH ().As_real64 (); 00682 } 00683 00685 00686 real64 SquareHeight () const 00687 { 00688 return DefaultCropSizeV ().As_real64 () * 00689 DefaultScaleV ().As_real64 () / 00690 DefaultScaleH ().As_real64 (); 00691 } 00692 00694 00695 real64 AspectRatio () const 00696 { 00697 return SquareWidth () / 00698 SquareHeight (); 00699 } 00700 00702 00703 real64 PixelAspectRatio () const 00704 { 00705 return (DefaultScaleH ().As_real64 () / RawToFullScaleH ()) / 00706 (DefaultScaleV ().As_real64 () / RawToFullScaleV ()); 00707 } 00708 00710 00711 uint32 FinalWidth (real64 scale) const 00712 { 00713 return Round_uint32 (SquareWidth () * scale); 00714 } 00715 00717 00718 uint32 FinalHeight (real64 scale) const 00719 { 00720 return Round_uint32 (SquareHeight () * scale); 00721 } 00722 00724 00725 uint32 DefaultFinalWidth () const 00726 { 00727 return FinalWidth (DefaultScale ()); 00728 } 00729 00731 00732 uint32 DefaultFinalHeight () const 00733 { 00734 return FinalHeight (DefaultScale ()); 00735 } 00736 00740 00741 uint32 BestQualityFinalWidth () const 00742 { 00743 return FinalWidth (DefaultScale () * BestQualityScale ().As_real64 ()); 00744 } 00745 00749 00750 uint32 BestQualityFinalHeight () const 00751 { 00752 return FinalHeight (DefaultScale () * BestQualityScale ().As_real64 ()); 00753 } 00754 00757 00758 dng_rect DefaultCropArea (real64 scaleH = 1.0, 00759 real64 scaleV = 1.0) const; 00760 00762 00763 void SetBaselineNoise (real64 noise) 00764 { 00765 fBaselineNoise.Set_real64 (noise, 100); 00766 } 00767 00769 00770 const dng_urational & BaselineNoiseR () const 00771 { 00772 return fBaselineNoise; 00773 } 00774 00776 00777 real64 BaselineNoise () const 00778 { 00779 return fBaselineNoise.As_real64 (); 00780 } 00781 00783 00784 void SetNoiseReductionApplied (const dng_urational &value) 00785 { 00786 fNoiseReductionApplied = value; 00787 } 00788 00790 00791 const dng_urational & NoiseReductionApplied () const 00792 { 00793 return fNoiseReductionApplied; 00794 } 00795 00797 00798 void SetNoiseProfile (const dng_noise_profile &noiseProfile) 00799 { 00800 fNoiseProfile = noiseProfile; 00801 } 00802 00804 00805 bool HasNoiseProfile () const 00806 { 00807 return fNoiseProfile.IsValidForNegative (*this); 00808 } 00809 00811 00812 const dng_noise_profile & NoiseProfile () const 00813 { 00814 return fNoiseProfile; 00815 } 00816 00818 00819 void SetBaselineExposure (real64 exposure) 00820 { 00821 fBaselineExposure.Set_real64 (exposure, 100); 00822 } 00823 00825 00826 const dng_srational & BaselineExposureR () const 00827 { 00828 return fBaselineExposure; 00829 } 00830 00832 00833 real64 BaselineExposure () const 00834 { 00835 return BaselineExposureR ().As_real64 (); 00836 } 00837 00839 00840 void SetBaselineSharpness (real64 sharpness) 00841 { 00842 fBaselineSharpness.Set_real64 (sharpness, 100); 00843 } 00844 00846 00847 const dng_urational & BaselineSharpnessR () const 00848 { 00849 return fBaselineSharpness; 00850 } 00851 00853 00854 real64 BaselineSharpness () const 00855 { 00856 return BaselineSharpnessR ().As_real64 (); 00857 } 00858 00860 00861 void SetChromaBlurRadius (const dng_urational &radius) 00862 { 00863 fChromaBlurRadius = radius; 00864 } 00865 00867 00868 const dng_urational & ChromaBlurRadius () const 00869 { 00870 return fChromaBlurRadius; 00871 } 00872 00874 00875 void SetAntiAliasStrength (const dng_urational &strength) 00876 { 00877 fAntiAliasStrength = strength; 00878 } 00879 00881 00882 const dng_urational & AntiAliasStrength () const 00883 { 00884 return fAntiAliasStrength; 00885 } 00886 00888 00889 void SetLinearResponseLimit (real64 limit) 00890 { 00891 fLinearResponseLimit.Set_real64 (limit, 100); 00892 } 00893 00895 00896 const dng_urational & LinearResponseLimitR () const 00897 { 00898 return fLinearResponseLimit; 00899 } 00900 00902 00903 real64 LinearResponseLimit () const 00904 { 00905 return LinearResponseLimitR ().As_real64 (); 00906 } 00907 00909 00910 void SetShadowScale (const dng_urational &scale); 00911 00913 00914 const dng_urational & ShadowScaleR () const 00915 { 00916 return fShadowScale; 00917 } 00918 00920 00921 real64 ShadowScale () const 00922 { 00923 return ShadowScaleR ().As_real64 (); 00924 } 00925 00926 // API for ColorimetricReference. 00927 00928 void SetColorimetricReference (uint32 ref) 00929 { 00930 fColorimetricReference = ref; 00931 } 00932 00933 uint32 ColorimetricReference () const 00934 { 00935 return fColorimetricReference; 00936 } 00937 00939 00940 void SetColorChannels (uint32 channels) 00941 { 00942 fColorChannels = channels; 00943 } 00944 00946 00947 uint32 ColorChannels () const 00948 { 00949 return fColorChannels; 00950 } 00951 00953 00954 void SetMonochrome () 00955 { 00956 SetColorChannels (1); 00957 } 00958 00960 00961 bool IsMonochrome () const 00962 { 00963 return ColorChannels () == 1; 00964 } 00965 00967 00968 void SetAnalogBalance (const dng_vector &b); 00969 00971 00972 dng_urational AnalogBalanceR (uint32 channel) const; 00973 00975 00976 real64 AnalogBalance (uint32 channel) const; 00977 00979 00980 void SetCameraNeutral (const dng_vector &n); 00981 00983 00984 void ClearCameraNeutral () 00985 { 00986 fCameraNeutral.Clear (); 00987 } 00988 00990 00991 bool HasCameraNeutral () const 00992 { 00993 return fCameraNeutral.NotEmpty (); 00994 } 00995 00997 00998 const dng_vector & CameraNeutral () const 00999 { 01000 return fCameraNeutral; 01001 } 01002 01003 dng_urational CameraNeutralR (uint32 channel) const; 01004 01006 01007 void SetCameraWhiteXY (const dng_xy_coord &coord); 01008 01009 bool HasCameraWhiteXY () const 01010 { 01011 return fCameraWhiteXY.IsValid (); 01012 } 01013 01014 const dng_xy_coord & CameraWhiteXY () const; 01015 01016 void GetCameraWhiteXY (dng_urational &x, 01017 dng_urational &y) const; 01018 01019 // API for camera calibration: 01020 01029 01030 void SetCameraCalibration1 (const dng_matrix &m); 01031 01040 01041 void SetCameraCalibration2 (const dng_matrix &m); 01042 01044 01045 const dng_matrix & CameraCalibration1 () const 01046 { 01047 return fCameraCalibration1; 01048 } 01049 01051 01052 const dng_matrix & CameraCalibration2 () const 01053 { 01054 return fCameraCalibration2; 01055 } 01056 01057 void SetCameraCalibrationSignature (const char *signature) 01058 { 01059 fCameraCalibrationSignature.Set (signature); 01060 } 01061 01062 const dng_string & CameraCalibrationSignature () const 01063 { 01064 return fCameraCalibrationSignature; 01065 } 01066 01067 // Camera Profile API: 01068 01069 void AddProfile (AutoPtr<dng_camera_profile> &profile); 01070 01071 void ClearProfiles (); 01072 01073 uint32 ProfileCount () const; 01074 01075 const dng_camera_profile & ProfileByIndex (uint32 index) const; 01076 01077 const dng_camera_profile * ProfileByID (const dng_camera_profile_id &id, 01078 bool useDefaultIfNoMatch = true) const; 01079 01080 bool HasProfileID (const dng_camera_profile_id &id) const 01081 { 01082 return ProfileByID (id, false) != NULL; 01083 } 01084 01085 // Returns the camera profile to embed when saving to DNG: 01086 01087 virtual const dng_camera_profile * CameraProfileToEmbed () const; 01088 01089 // API for AsShotProfileName. 01090 01091 void SetAsShotProfileName (const char *name) 01092 { 01093 fAsShotProfileName.Set (name); 01094 } 01095 01096 const dng_string & AsShotProfileName () const 01097 { 01098 return fAsShotProfileName; 01099 } 01100 01101 // Makes a dng_color_spec object for this negative. 01102 01103 virtual dng_color_spec * MakeColorSpec (const dng_camera_profile_id &id) const; 01104 01105 // API for RawImageDigest: 01106 01107 void SetRawImageDigest (const dng_fingerprint &digest) 01108 { 01109 fRawImageDigest = digest; 01110 } 01111 01112 void ClearRawImageDigest () 01113 { 01114 fRawImageDigest.Clear (); 01115 } 01116 01117 const dng_fingerprint & RawImageDigest () const 01118 { 01119 return fRawImageDigest; 01120 } 01121 01122 void FindRawImageDigest (dng_host &host) const; 01123 01124 void ValidateRawImageDigest (dng_host &host); 01125 01126 // API for RawDataUniqueID: 01127 01128 void SetRawDataUniqueID (const dng_fingerprint &id) 01129 { 01130 fRawDataUniqueID = id; 01131 } 01132 01133 const dng_fingerprint & RawDataUniqueID () const 01134 { 01135 return fRawDataUniqueID; 01136 } 01137 01138 void FindRawDataUniqueID (dng_host &host) const; 01139 01140 void RecomputeRawDataUniqueID (dng_host &host); 01141 01142 // API for original raw file name: 01143 01144 void SetOriginalRawFileName (const char *name) 01145 { 01146 fOriginalRawFileName.Set (name); 01147 } 01148 01149 bool HasOriginalRawFileName () const 01150 { 01151 return fOriginalRawFileName.NotEmpty (); 01152 } 01153 01154 const dng_string & OriginalRawFileName () const 01155 { 01156 return fOriginalRawFileName; 01157 } 01158 01159 // API for original raw file data: 01160 01161 void SetHasOriginalRawFileData (bool hasData) 01162 { 01163 fHasOriginalRawFileData = hasData; 01164 } 01165 01166 bool CanEmbedOriginalRaw () const 01167 { 01168 return fHasOriginalRawFileData && HasOriginalRawFileName (); 01169 } 01170 01171 void SetOriginalRawFileData (AutoPtr<dng_memory_block> &data) 01172 { 01173 fOriginalRawFileData.Reset (data.Release ()); 01174 } 01175 01176 const void * OriginalRawFileData () const 01177 { 01178 return fOriginalRawFileData.Get () ? fOriginalRawFileData->Buffer () 01179 : NULL; 01180 } 01181 01182 uint32 OriginalRawFileDataLength () const 01183 { 01184 return fOriginalRawFileData.Get () ? fOriginalRawFileData->LogicalSize () 01185 : 0; 01186 } 01187 01188 // API for original raw file data digest. 01189 01190 void SetOriginalRawFileDigest (const dng_fingerprint &digest) 01191 { 01192 fOriginalRawFileDigest = digest; 01193 } 01194 01195 const dng_fingerprint & OriginalRawFileDigest () const 01196 { 01197 return fOriginalRawFileDigest; 01198 } 01199 01200 void FindOriginalRawFileDigest () const; 01201 01202 void ValidateOriginalRawFileDigest (); 01203 01204 // API for DNG private data: 01205 01206 void SetPrivateData (AutoPtr<dng_memory_block> &block) 01207 { 01208 fDNGPrivateData.Reset (block.Release ()); 01209 } 01210 01211 void ClearPrivateData () 01212 { 01213 fDNGPrivateData.Reset (); 01214 } 01215 01216 const uint8 * PrivateData () const 01217 { 01218 return fDNGPrivateData.Get () ? fDNGPrivateData->Buffer_uint8 () 01219 : NULL; 01220 } 01221 01222 uint32 PrivateLength () const 01223 { 01224 return fDNGPrivateData.Get () ? fDNGPrivateData->LogicalSize () 01225 : 0; 01226 } 01227 01228 // API for MakerNote data: 01229 01230 void SetMakerNoteSafety (bool safe) 01231 { 01232 fIsMakerNoteSafe = safe; 01233 } 01234 01235 bool IsMakerNoteSafe () const 01236 { 01237 return fIsMakerNoteSafe; 01238 } 01239 01240 void SetMakerNote (AutoPtr<dng_memory_block> &block) 01241 { 01242 fMakerNote.Reset (block.Release ()); 01243 } 01244 01245 void ClearMakerNote () 01246 { 01247 fMakerNote.Reset (); 01248 } 01249 01250 const void * MakerNoteData () const 01251 { 01252 return fMakerNote.Get () ? fMakerNote->Buffer () 01253 : NULL; 01254 } 01255 01256 uint32 MakerNoteLength () const 01257 { 01258 return fMakerNote.Get () ? fMakerNote->LogicalSize () 01259 : 0; 01260 } 01261 01262 // API for EXIF metadata: 01263 01264 dng_exif * GetExif () 01265 { 01266 return fExif.Get (); 01267 } 01268 01269 const dng_exif * GetExif () const 01270 { 01271 return fExif.Get (); 01272 } 01273 01274 virtual dng_memory_block * BuildExifBlock (const dng_resolution *resolution = NULL, 01275 bool includeIPTC = false, 01276 bool minimalEXIF = false, 01277 const dng_jpeg_preview *thumbnail = NULL) const; 01278 01279 // API for original EXIF metadata. 01280 01281 dng_exif * GetOriginalExif () 01282 { 01283 return fOriginalExif.Get (); 01284 } 01285 01286 const dng_exif * GetOriginalExif () const 01287 { 01288 return fOriginalExif.Get (); 01289 } 01290 01291 // API for IPTC metadata: 01292 01293 void SetIPTC (AutoPtr<dng_memory_block> &block, 01294 uint64 offset); 01295 01296 void SetIPTC (AutoPtr<dng_memory_block> &block); 01297 01298 void ClearIPTC (); 01299 01300 const void * IPTCData () const; 01301 01302 uint32 IPTCLength () const; 01303 01304 uint64 IPTCOffset () const; 01305 01306 dng_fingerprint IPTCDigest (bool includePadding = true) const; 01307 01308 void RebuildIPTC (bool padForTIFF, 01309 bool forceUTF8); 01310 01311 bool UsedUTF8forIPTC () const 01312 { 01313 return fUsedUTF8forIPTC; 01314 } 01315 01316 void SetUsedUTF8forIPTC (bool used) 01317 { 01318 fUsedUTF8forIPTC = used; 01319 } 01320 01321 // API for XMP metadata: 01322 01323 bool SetXMP (dng_host &host, 01324 const void *buffer, 01325 uint32 count, 01326 bool xmpInSidecar = false, 01327 bool xmpIsNewer = false); 01328 01329 dng_xmp * GetXMP () 01330 { 01331 return fXMP.Get (); 01332 } 01333 01334 const dng_xmp * GetXMP () const 01335 { 01336 return fXMP.Get (); 01337 } 01338 01339 bool XMPinSidecar () const 01340 { 01341 return fXMPinSidecar; 01342 } 01343 01344 // API for linearization information: 01345 01346 const dng_linearization_info * GetLinearizationInfo () const 01347 { 01348 return fLinearizationInfo.Get (); 01349 } 01350 01351 void ClearLinearizationInfo () 01352 { 01353 fLinearizationInfo.Reset (); 01354 } 01355 01356 // Linearization curve. Usually used to increase compression ratios 01357 // by storing the compressed data in a more visually uniform space. 01358 // This is a 16-bit LUT that maps the stored data back to linear. 01359 01360 void SetLinearization (AutoPtr<dng_memory_block> &curve); 01361 01362 // Active area (non-black masked pixels). These pixels are trimmed 01363 // during linearization step. 01364 01365 void SetActiveArea (const dng_rect &area); 01366 01367 // Areas that are known to contain black masked pixels that can 01368 // be used to estimate black levels. 01369 01370 void SetMaskedAreas (uint32 count, 01371 const dng_rect *area); 01372 01373 void SetMaskedArea (const dng_rect &area) 01374 { 01375 SetMaskedAreas (1, &area); 01376 } 01377 01378 // Sensor black level information. 01379 01380 void SetBlackLevel (real64 black, 01381 int32 plane = -1); 01382 01383 void SetQuadBlacks (real64 black0, 01384 real64 black1, 01385 real64 black2, 01386 real64 black3); 01387 01388 void SetRowBlacks (const real64 *blacks, 01389 uint32 count); 01390 01391 void SetColumnBlacks (const real64 *blacks, 01392 uint32 count); 01393 01394 // Sensor white level information. 01395 01396 uint32 WhiteLevel (uint32 plane = 0) const; 01397 01398 void SetWhiteLevel (uint32 white, 01399 int32 plane = -1); 01400 01401 // API for mosaic information: 01402 01403 const dng_mosaic_info * GetMosaicInfo () const 01404 { 01405 return fMosaicInfo.Get (); 01406 } 01407 01408 void ClearMosaicInfo () 01409 { 01410 fMosaicInfo.Reset (); 01411 } 01412 01413 // ColorKeys APIs: 01414 01415 void SetColorKeys (ColorKeyCode color0, 01416 ColorKeyCode color1, 01417 ColorKeyCode color2, 01418 ColorKeyCode color3 = colorKeyMaxEnum); 01419 01420 void SetRGB () 01421 { 01422 01423 SetColorChannels (3); 01424 01425 SetColorKeys (colorKeyRed, 01426 colorKeyGreen, 01427 colorKeyBlue); 01428 01429 } 01430 01431 void SetCMY () 01432 { 01433 01434 SetColorChannels (3); 01435 01436 SetColorKeys (colorKeyCyan, 01437 colorKeyMagenta, 01438 colorKeyYellow); 01439 01440 } 01441 01442 void SetGMCY () 01443 { 01444 01445 SetColorChannels (4); 01446 01447 SetColorKeys (colorKeyGreen, 01448 colorKeyMagenta, 01449 colorKeyCyan, 01450 colorKeyYellow); 01451 01452 } 01453 01454 // APIs to set mosaic patterns. 01455 01456 void SetBayerMosaic (uint32 phase); 01457 01458 void SetFujiMosaic (uint32 phase); 01459 01460 void SetQuadMosaic (uint32 pattern); 01461 01462 // BayerGreenSplit. 01463 01464 void SetGreenSplit (uint32 split); 01465 01466 // APIs for opcode lists. 01467 01468 const dng_opcode_list & OpcodeList1 () const 01469 { 01470 return fOpcodeList1; 01471 } 01472 01473 dng_opcode_list & OpcodeList1 () 01474 { 01475 return fOpcodeList1; 01476 } 01477 01478 const dng_opcode_list & OpcodeList2 () const 01479 { 01480 return fOpcodeList2; 01481 } 01482 01483 dng_opcode_list & OpcodeList2 () 01484 { 01485 return fOpcodeList2; 01486 } 01487 01488 const dng_opcode_list & OpcodeList3 () const 01489 { 01490 return fOpcodeList3; 01491 } 01492 01493 dng_opcode_list & OpcodeList3 () 01494 { 01495 return fOpcodeList3; 01496 } 01497 01498 // First part of parsing logic. 01499 01500 virtual void Parse (dng_host &host, 01501 dng_stream &stream, 01502 dng_info &info); 01503 01504 // Second part of parsing logic. This is split off from the 01505 // first part because these operations are useful when extending 01506 // this sdk to support non-DNG raw formats. 01507 01508 virtual void PostParse (dng_host &host, 01509 dng_stream &stream, 01510 dng_info &info); 01511 01512 // Synchronize metadata sources. 01513 01514 virtual void SynchronizeMetadata (); 01515 01516 // Routines to update the date/time field in the EXIF and XMP 01517 // metadata. 01518 01519 void UpdateDateTime (const dng_date_time_info &dt); 01520 01521 void UpdateDateTimeToNow (); 01522 01523 // Developer's utility function to switch to four color Bayer 01524 // interpolation. This is useful for evaluating how much green 01525 // split a Bayer pattern sensor has. 01526 01527 virtual bool SetFourColorBayer (); 01528 01529 // Access routines for the image stages. 01530 01531 const dng_image * Stage1Image () const 01532 { 01533 return fStage1Image.Get (); 01534 } 01535 01536 const dng_image * Stage2Image () const 01537 { 01538 return fStage2Image.Get (); 01539 } 01540 01541 const dng_image * Stage3Image () const 01542 { 01543 return fStage3Image.Get (); 01544 } 01545 01546 // Returns the processing stage of the raw image data. 01547 01548 RawImageStageEnum RawImageStage () const 01549 { 01550 return fRawImageStage; 01551 } 01552 01553 // Returns the raw image data. 01554 01555 const dng_image & RawImage () const; 01556 01557 // Read the stage 1 image. 01558 01559 virtual void ReadStage1Image (dng_host &host, 01560 dng_stream &stream, 01561 dng_info &info); 01562 01563 // Assign the stage 1 image. 01564 01565 void SetStage1Image (AutoPtr<dng_image> &image); 01566 01567 // Assign the stage 2 image. 01568 01569 void SetStage2Image (AutoPtr<dng_image> &image); 01570 01571 // Assign the stage 3 image. 01572 01573 void SetStage3Image (AutoPtr<dng_image> &image); 01574 01575 // Build the stage 2 (linearized and range mapped) image. 01576 01577 void BuildStage2Image (dng_host &host, 01578 uint32 pixelType = ttShort); 01579 01580 // Build the stage 3 (demosaiced) image. 01581 01582 void BuildStage3Image (dng_host &host, 01583 int32 srcPlane = -1); 01584 01585 // Additional gain applied when building the stage 3 image. 01586 01587 void SetStage3Gain (real64 gain) 01588 { 01589 fStage3Gain = gain; 01590 } 01591 01592 real64 Stage3Gain () const 01593 { 01594 return fStage3Gain; 01595 } 01596 01597 // IsPreview API: 01598 01599 void SetIsPreview (bool preview) 01600 { 01601 fIsPreview = preview; 01602 } 01603 01604 bool IsPreview () const 01605 { 01606 return fIsPreview; 01607 } 01608 01609 // IsDamaged API: 01610 01611 void SetIsDamaged (bool damaged) 01612 { 01613 fIsDamaged = damaged; 01614 } 01615 01616 bool IsDamaged () const 01617 { 01618 return fIsDamaged; 01619 } 01620 01621 protected: 01622 01623 dng_negative (dng_memory_allocator &allocator); 01624 01625 virtual void Initialize (); 01626 01627 virtual dng_exif * MakeExif (); 01628 01629 virtual dng_xmp * MakeXMP (); 01630 01631 virtual dng_linearization_info * MakeLinearizationInfo (); 01632 01633 void NeedLinearizationInfo (); 01634 01635 virtual dng_mosaic_info * MakeMosaicInfo (); 01636 01637 void NeedMosaicInfo (); 01638 01639 virtual void DoBuildStage2 (dng_host &host, 01640 uint32 pixelType); 01641 01642 virtual void DoInterpolateStage3 (dng_host &host, 01643 int32 srcPlane); 01644 01645 virtual void DoMergeStage3 (dng_host &host); 01646 01647 virtual void DoBuildStage3 (dng_host &host, 01648 int32 srcPlane); 01649 01650 }; 01651 01652 /*****************************************************************************/ 01653 01654 #endif 01655 01656 /*****************************************************************************/ |