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_camera_profile.hGo to the documentation of this file.00001 /******************************************************************************/ 00002 // Copyright 2006-2007 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_camera_profile.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00031 #ifndef __dng_camera_profile__ 00032 #define __dng_camera_profile__ 00033 00034 /******************************************************************************/ 00035 00036 #include "dng_assertions.h" 00037 #include "dng_classes.h" 00038 #include "dng_fingerprint.h" 00039 #include "dng_hue_sat_map.h" 00040 #include "dng_matrix.h" 00041 #include "dng_string.h" 00042 #include "dng_tag_values.h" 00043 #include "dng_tone_curve.h" 00044 00045 /******************************************************************************/ 00046 00047 extern const char * kProfileName_Embedded; 00048 00049 extern const char * kAdobeCalibrationSignature; 00050 00051 /******************************************************************************/ 00052 00053 class dng_camera_profile_id 00054 { 00055 00056 private: 00057 00058 dng_string fName; 00059 00060 dng_fingerprint fFingerprint; 00061 00062 public: 00063 00064 dng_camera_profile_id () 00065 00066 : fName () 00067 , fFingerprint () 00068 00069 { 00070 } 00071 00072 dng_camera_profile_id (const char *name) 00073 00074 : fName () 00075 , fFingerprint () 00076 00077 { 00078 fName.Set (name); 00079 } 00080 00081 dng_camera_profile_id (const dng_string &name) 00082 00083 : fName (name) 00084 , fFingerprint () 00085 00086 { 00087 } 00088 00089 dng_camera_profile_id (const char *name, 00090 const dng_fingerprint &fingerprint) 00091 00092 : fName () 00093 , fFingerprint (fingerprint) 00094 00095 { 00096 fName.Set (name); 00097 DNG_ASSERT (!fFingerprint.IsValid () || fName.NotEmpty (), 00098 "Cannot have profile fingerprint without name"); 00099 } 00100 00101 dng_camera_profile_id (const dng_string &name, 00102 const dng_fingerprint &fingerprint) 00103 00104 : fName (name) 00105 , fFingerprint (fingerprint) 00106 00107 { 00108 DNG_ASSERT (!fFingerprint.IsValid () || fName.NotEmpty (), 00109 "Cannot have profile fingerprint without name"); 00110 } 00111 00112 const dng_string & Name () const 00113 { 00114 return fName; 00115 } 00116 00117 const dng_fingerprint & Fingerprint () const 00118 { 00119 return fFingerprint; 00120 } 00121 00122 bool operator== (const dng_camera_profile_id &id) const 00123 { 00124 return fName == id.fName && 00125 fFingerprint == id.fFingerprint; 00126 } 00127 00128 bool operator!= (const dng_camera_profile_id &id) const 00129 { 00130 return !(*this == id); 00131 } 00132 00133 bool IsValid () const 00134 { 00135 return fName.NotEmpty (); // Fingerprint is optional. 00136 } 00137 00138 void Clear () 00139 { 00140 *this = dng_camera_profile_id (); 00141 } 00142 00143 }; 00144 00145 /******************************************************************************/ 00146 00148 00149 class dng_camera_profile 00150 { 00151 00152 protected: 00153 00154 // Name of this camera profile. 00155 00156 dng_string fName; 00157 00158 // Light sources for up to two calibrations. These use the EXIF 00159 // encodings for illuminant and are used to distinguish which 00160 // matrix to use. 00161 00162 uint32 fCalibrationIlluminant1; 00163 uint32 fCalibrationIlluminant2; 00164 00165 // Color matrices for up to two calibrations. 00166 00167 // These matrices map XYZ values to non-white balanced camera values. 00168 // Adobe needs to go that direction in order to determine the clipping 00169 // points for highlight recovery logic based on the white point. If 00170 // cameras were all 3-color, the matrix could be stored as a forward matrix, 00171 // but we need the backwards matrix to deal with 4-color cameras. 00172 00173 dng_matrix fColorMatrix1; 00174 dng_matrix fColorMatrix2; 00175 00176 // These matrices map white balanced camera values to XYZ chromatically 00177 // adapted to D50 (the ICC profile PCS white point). If the matrices 00178 // exist, then this implies that white balancing should be done by scaling 00179 // camera values with a diagonal matrix. 00180 00181 dng_matrix fForwardMatrix1; 00182 dng_matrix fForwardMatrix2; 00183 00184 // Dimensionality reduction hints for more than three color cameras. 00185 // This is an optional matrix that maps the camera's color components 00186 // to 3 components. These are only used if the forward matrices don't 00187 // exist, and are used invert the color matrices. 00188 00189 dng_matrix fReductionMatrix1; 00190 dng_matrix fReductionMatrix2; 00191 00192 // MD5 hash for all data bits of the profile. 00193 00194 mutable dng_fingerprint fFingerprint; 00195 00196 // Copyright notice from creator of profile. 00197 00198 dng_string fCopyright; 00199 00200 // Rules for how this profile can be embedded and/or copied. 00201 00202 uint32 fEmbedPolicy; 00203 00204 // 2-D hue/sat tables to modify colors. 00205 00206 dng_hue_sat_map fHueSatDeltas1; 00207 dng_hue_sat_map fHueSatDeltas2; 00208 00209 // The "as shot" tone curve for this profile. Check IsValid method 00210 // to tell if one exists in profile. 00211 00212 dng_tone_curve fToneCurve; 00213 00214 // If this string matches the fCameraCalibrationSignature of the 00215 // negative, then use the calibration matrix values from the negative. 00216 00217 dng_string fProfileCalibrationSignature; 00218 00219 // If non-empty, only allow use of this profile with camera having 00220 // same unique model name. 00221 00222 dng_string fUniqueCameraModelRestriction; 00223 00224 // Was this profile read from inside a DNG file? (If so, we wnat 00225 // to be sure to include it again when writing out an updated 00226 // DNG file) 00227 00228 bool fWasReadFromDNG; 00229 00230 public: 00231 00232 dng_camera_profile (); 00233 00234 virtual ~dng_camera_profile (); 00235 00236 // API for profile name: 00237 00240 00241 void SetName (const char *name) 00242 { 00243 fName.Set (name); 00244 ClearFingerprint (); 00245 } 00246 00249 00250 const dng_string & Name () const 00251 { 00252 return fName; 00253 } 00254 00257 00258 bool NameIsEmbedded () const 00259 { 00260 return fName.Matches (kProfileName_Embedded, true); 00261 } 00262 00263 // API for calibration illuminants: 00264 00269 00270 void SetCalibrationIlluminant1 (uint32 light) 00271 { 00272 fCalibrationIlluminant1 = light; 00273 ClearFingerprint (); 00274 } 00275 00280 00281 void SetCalibrationIlluminant2 (uint32 light) 00282 { 00283 fCalibrationIlluminant2 = light; 00284 ClearFingerprint (); 00285 } 00286 00291 00292 uint32 CalibrationIlluminant1 () const 00293 { 00294 return fCalibrationIlluminant1; 00295 } 00296 00301 00302 uint32 CalibrationIlluminant2 () const 00303 { 00304 return fCalibrationIlluminant2; 00305 } 00306 00309 00310 real64 CalibrationTemperature1 () const 00311 { 00312 return IlluminantToTemperature (CalibrationIlluminant1 ()); 00313 } 00314 00317 00318 real64 CalibrationTemperature2 () const 00319 { 00320 return IlluminantToTemperature (CalibrationIlluminant2 ()); 00321 } 00322 00323 // API for color matrices: 00324 00326 00327 static void NormalizeColorMatrix (dng_matrix &m); 00328 00335 00336 void SetColorMatrix1 (const dng_matrix &m); 00337 00344 00345 void SetColorMatrix2 (const dng_matrix &m); 00346 00348 00349 bool HasColorMatrix1 () const; 00350 00352 00353 bool HasColorMatrix2 () const; 00354 00356 00357 const dng_matrix & ColorMatrix1 () const 00358 { 00359 return fColorMatrix1; 00360 } 00361 00363 00364 const dng_matrix & ColorMatrix2 () const 00365 { 00366 return fColorMatrix2; 00367 } 00368 00369 // API for forward matrices: 00370 00372 00373 static void NormalizeForwardMatrix (dng_matrix &m); 00374 00376 00377 void SetForwardMatrix1 (const dng_matrix &m); 00378 00380 00381 void SetForwardMatrix2 (const dng_matrix &m); 00382 00384 00385 const dng_matrix & ForwardMatrix1 () const 00386 { 00387 return fForwardMatrix1; 00388 } 00389 00391 00392 const dng_matrix & ForwardMatrix2 () const 00393 { 00394 return fForwardMatrix2; 00395 } 00396 00397 // API for reduction matrices: 00398 00402 00403 void SetReductionMatrix1 (const dng_matrix &m); 00404 00408 00409 void SetReductionMatrix2 (const dng_matrix &m); 00410 00412 00413 const dng_matrix & ReductionMatrix1 () const 00414 { 00415 return fReductionMatrix1; 00416 } 00417 00419 00420 const dng_matrix & ReductionMatrix2 () const 00421 { 00422 return fReductionMatrix2; 00423 } 00424 00426 00427 const dng_fingerprint &Fingerprint () const 00428 { 00429 00430 if (!fFingerprint.IsValid ()) 00431 CalculateFingerprint (); 00432 00433 return fFingerprint; 00434 00435 } 00436 00439 00440 dng_camera_profile_id ProfileID () const 00441 { 00442 return dng_camera_profile_id (Name (), Fingerprint ()); 00443 } 00444 00447 00448 void SetCopyright (const char *copyright) 00449 { 00450 fCopyright.Set (copyright); 00451 ClearFingerprint (); 00452 } 00453 00456 00457 const dng_string & Copyright () const 00458 { 00459 return fCopyright; 00460 } 00461 00462 // Accessors for embed policy. 00463 00464 void SetEmbedPolicy (uint32 policy) 00465 { 00466 fEmbedPolicy = policy; 00467 ClearFingerprint (); 00468 } 00469 00470 uint32 EmbedPolicy () const 00471 { 00472 return fEmbedPolicy; 00473 } 00474 00475 bool IsLegalToEmbed () const 00476 { 00477 return WasReadFromDNG () || 00478 EmbedPolicy () == pepAllowCopying || 00479 EmbedPolicy () == pepEmbedIfUsed || 00480 EmbedPolicy () == pepNoRestrictions; 00481 } 00482 00483 // Accessors for hue sat maps. 00484 00485 bool HasHueSatDeltas () const 00486 { 00487 return fHueSatDeltas1.IsValid (); 00488 } 00489 00490 const dng_hue_sat_map &HueSatDeltas1 () const 00491 { 00492 return fHueSatDeltas1; 00493 } 00494 00495 void SetHueSatDeltas1 (dng_hue_sat_map &deltas1); 00496 00497 const dng_hue_sat_map &HueSatDeltas2 () const 00498 { 00499 return fHueSatDeltas2; 00500 } 00501 00502 void SetHueSatDeltas2 (dng_hue_sat_map &deltas2); 00503 00504 // Accessors for tone curve. 00505 00506 const dng_tone_curve & ToneCurve () const 00507 { 00508 return fToneCurve; 00509 } 00510 00511 void SetToneCurve (const dng_tone_curve &curve) 00512 { 00513 fToneCurve = curve; 00514 ClearFingerprint (); 00515 } 00516 00517 // Accessors for profile calibration signature. 00518 00519 void SetProfileCalibrationSignature (const char *signature) 00520 { 00521 fProfileCalibrationSignature.Set (signature); 00522 } 00523 00524 const dng_string & ProfileCalibrationSignature () const 00525 { 00526 return fProfileCalibrationSignature; 00527 } 00528 00532 00533 void SetUniqueCameraModelRestriction (const char *camera) 00534 { 00535 fUniqueCameraModelRestriction.Set (camera); 00536 // Not included in fingerprint, so don't need ClearFingerprint (). 00537 } 00538 00542 00543 const dng_string & UniqueCameraModelRestriction () const 00544 { 00545 return fUniqueCameraModelRestriction; 00546 } 00547 00548 // Accessors for was read from DNG flag. 00549 00550 void SetWasReadFromDNG (bool state = true) 00551 { 00552 fWasReadFromDNG = state; 00553 } 00554 00555 bool WasReadFromDNG () const 00556 { 00557 return fWasReadFromDNG; 00558 } 00559 00562 00563 bool IsValid (uint32 channels) const; 00564 00568 00569 bool EqualData (const dng_camera_profile &profile) const; 00570 00572 00573 void Parse (dng_stream &stream, 00574 dng_camera_profile_info &profileInfo); 00575 00578 00579 bool ParseExtended (dng_stream &stream); 00580 00582 00583 virtual void SetFourColorBayer (); 00584 00587 00588 dng_hue_sat_map * HueSatMapForWhite (const dng_xy_coord &white) const; 00589 00590 protected: 00591 00592 static real64 IlluminantToTemperature (uint32 light); 00593 00594 void ClearFingerprint () 00595 { 00596 fFingerprint.Clear (); 00597 } 00598 00599 void CalculateFingerprint () const; 00600 00601 static bool ValidForwardMatrix (const dng_matrix &m); 00602 00603 static void ReadHueSatMap (dng_stream &stream, 00604 dng_hue_sat_map &hueSatMap, 00605 uint32 hues, 00606 uint32 sats, 00607 uint32 vals, 00608 bool skipSat0); 00609 00610 }; 00611 00612 /******************************************************************************/ 00613 00614 #endif 00615 00616 /******************************************************************************/ | |||
