/src/skia/third_party/externals/dng_sdk/source/dng_camera_profile.h
Line | Count | Source (jump to first uncovered line) |
1 | | /******************************************************************************/ |
2 | | // Copyright 2006-2007 Adobe Systems Incorporated |
3 | | // All Rights Reserved. |
4 | | // |
5 | | // NOTICE: Adobe permits you to use, modify, and distribute this file in |
6 | | // accordance with the terms of the Adobe license agreement accompanying it. |
7 | | /******************************************************************************/ |
8 | | |
9 | | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_camera_profile.h#2 $ */ |
10 | | /* $DateTime: 2012/07/11 10:36:56 $ */ |
11 | | /* $Change: 838485 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /** \file |
15 | | * Support for DNG camera color profile information. |
16 | | * Per the \ref spec_dng "DNG 1.1.0 specification", a DNG file can store up to |
17 | | * two sets of color profile information for a camera in the DNG file from that |
18 | | * camera. The second set is optional and when there are two sets, they represent |
19 | | * profiles made under different illumination. |
20 | | * |
21 | | * Profiling information is optionally separated into two parts. One part represents |
22 | | * a profile for a reference camera. (ColorMatrix1 and ColorMatrix2 here.) The |
23 | | * second is a per-camera calibration that takes into account unit-to-unit variation. |
24 | | * This is designed to allow replacing the reference color matrix with one of one's |
25 | | * own construction while maintaining any unit-specific calibration the camera |
26 | | * manufacturer may have provided. |
27 | | * |
28 | | * See Appendix 6 of the \ref spec_dng "DNG 1.1.0 specification" for more information. |
29 | | */ |
30 | | |
31 | | #ifndef __dng_camera_profile__ |
32 | | #define __dng_camera_profile__ |
33 | | |
34 | | /******************************************************************************/ |
35 | | |
36 | | #include "dng_auto_ptr.h" |
37 | | #include "dng_assertions.h" |
38 | | #include "dng_classes.h" |
39 | | #include "dng_fingerprint.h" |
40 | | #include "dng_hue_sat_map.h" |
41 | | #include "dng_matrix.h" |
42 | | #include "dng_string.h" |
43 | | #include "dng_tag_values.h" |
44 | | #include "dng_tone_curve.h" |
45 | | |
46 | | /******************************************************************************/ |
47 | | |
48 | | extern const char * kProfileName_Embedded; |
49 | | |
50 | | extern const char * kAdobeCalibrationSignature; |
51 | | |
52 | | /******************************************************************************/ |
53 | | |
54 | | /// \brief An ID for a camera profile consisting of a name and optional fingerprint. |
55 | | |
56 | | class dng_camera_profile_id |
57 | | { |
58 | | |
59 | | private: |
60 | | |
61 | | dng_string fName; |
62 | | |
63 | | dng_fingerprint fFingerprint; |
64 | | |
65 | | public: |
66 | | |
67 | | /// Construct an invalid camera profile ID (empty name and fingerprint). |
68 | | |
69 | | dng_camera_profile_id () |
70 | | |
71 | | : fName () |
72 | | , fFingerprint () |
73 | | |
74 | 0 | { |
75 | 0 | } |
76 | | |
77 | | /// Construct a camera profile ID with the specified name and no fingerprint. |
78 | | /// \param name The name of the camera profile ID. |
79 | | |
80 | | dng_camera_profile_id (const char *name) |
81 | | |
82 | | : fName () |
83 | | , fFingerprint () |
84 | | |
85 | 0 | { |
86 | 0 | fName.Set (name); |
87 | 0 | } |
88 | | |
89 | | /// Construct a camera profile ID with the specified name and no fingerprint. |
90 | | /// \param name The name of the camera profile ID. |
91 | | |
92 | | dng_camera_profile_id (const dng_string &name) |
93 | | |
94 | | : fName (name) |
95 | | , fFingerprint () |
96 | | |
97 | 0 | { |
98 | 0 | } |
99 | | |
100 | | /// Construct a camera profile ID with the specified name and fingerprint. |
101 | | /// \param name The name of the camera profile ID. |
102 | | /// \param fingerprint The fingerprint of the camera profile ID. |
103 | | |
104 | | dng_camera_profile_id (const char *name, |
105 | | const dng_fingerprint &fingerprint) |
106 | | |
107 | | : fName () |
108 | | , fFingerprint (fingerprint) |
109 | | |
110 | 0 | { |
111 | 0 | fName.Set (name); |
112 | 0 | DNG_ASSERT (!fFingerprint.IsValid () || fName.NotEmpty (), |
113 | 0 | "Cannot have profile fingerprint without name"); |
114 | 0 | } |
115 | | |
116 | | /// Construct a camera profile ID with the specified name and fingerprint. |
117 | | /// \param name The name of the camera profile ID. |
118 | | /// \param fingerprint The fingerprint of the camera profile ID. |
119 | | |
120 | | dng_camera_profile_id (const dng_string &name, |
121 | | const dng_fingerprint &fingerprint) |
122 | | |
123 | | : fName (name) |
124 | | , fFingerprint (fingerprint) |
125 | | |
126 | 0 | { |
127 | 0 | DNG_ASSERT (!fFingerprint.IsValid () || fName.NotEmpty (), |
128 | 0 | "Cannot have profile fingerprint without name"); |
129 | 0 | } |
130 | | |
131 | | /// Getter for the name of the camera profile ID. |
132 | | /// \retval The name of the camera profile ID. |
133 | | |
134 | | const dng_string & Name () const |
135 | 0 | { |
136 | 0 | return fName; |
137 | 0 | } |
138 | | |
139 | | /// Getter for the fingerprint of the camera profile ID. |
140 | | /// \retval The fingerprint of the camera profile ID. |
141 | | |
142 | | const dng_fingerprint & Fingerprint () const |
143 | 0 | { |
144 | 0 | return fFingerprint; |
145 | 0 | } |
146 | | |
147 | | /// Test for equality of two camera profile IDs. |
148 | | /// \param The id of the camera profile ID to compare. |
149 | | |
150 | | bool operator== (const dng_camera_profile_id &id) const |
151 | 0 | { |
152 | 0 | return fName == id.fName && |
153 | 0 | fFingerprint == id.fFingerprint; |
154 | 0 | } |
155 | | |
156 | | /// Test for inequality of two camera profile IDs. |
157 | | /// \param The id of the camera profile ID to compare. |
158 | | |
159 | | bool operator!= (const dng_camera_profile_id &id) const |
160 | 0 | { |
161 | 0 | return !(*this == id); |
162 | 0 | } |
163 | | |
164 | | /// Returns true iff the camera profile ID is valid. |
165 | | |
166 | | bool IsValid () const |
167 | 0 | { |
168 | 0 | return fName.NotEmpty (); // Fingerprint is optional. |
169 | 0 | } |
170 | | |
171 | | /// Resets the name and fingerprint, thereby making this camera profile ID |
172 | | /// invalid. |
173 | | |
174 | | void Clear () |
175 | 0 | { |
176 | 0 | *this = dng_camera_profile_id (); |
177 | 0 | } |
178 | | |
179 | | }; |
180 | | |
181 | | /******************************************************************************/ |
182 | | |
183 | | /// \brief Container for DNG camera color profile and calibration data. |
184 | | |
185 | | class dng_camera_profile |
186 | | { |
187 | | |
188 | | protected: |
189 | | |
190 | | // Name of this camera profile. |
191 | | |
192 | | dng_string fName; |
193 | | |
194 | | // Light sources for up to two calibrations. These use the EXIF |
195 | | // encodings for illuminant and are used to distinguish which |
196 | | // matrix to use. |
197 | | |
198 | | uint32 fCalibrationIlluminant1; |
199 | | uint32 fCalibrationIlluminant2; |
200 | | |
201 | | // Color matrices for up to two calibrations. |
202 | | |
203 | | // These matrices map XYZ values to non-white balanced camera values. |
204 | | // Adobe needs to go that direction in order to determine the clipping |
205 | | // points for highlight recovery logic based on the white point. If |
206 | | // cameras were all 3-color, the matrix could be stored as a forward matrix, |
207 | | // but we need the backwards matrix to deal with 4-color cameras. |
208 | | |
209 | | dng_matrix fColorMatrix1; |
210 | | dng_matrix fColorMatrix2; |
211 | | |
212 | | // These matrices map white balanced camera values to XYZ chromatically |
213 | | // adapted to D50 (the ICC profile PCS white point). If the matrices |
214 | | // exist, then this implies that white balancing should be done by scaling |
215 | | // camera values with a diagonal matrix. |
216 | | |
217 | | dng_matrix fForwardMatrix1; |
218 | | dng_matrix fForwardMatrix2; |
219 | | |
220 | | // Dimensionality reduction hints for more than three color cameras. |
221 | | // This is an optional matrix that maps the camera's color components |
222 | | // to 3 components. These are only used if the forward matrices don't |
223 | | // exist, and are used invert the color matrices. |
224 | | |
225 | | dng_matrix fReductionMatrix1; |
226 | | dng_matrix fReductionMatrix2; |
227 | | |
228 | | // MD5 hash for all data bits of the profile. |
229 | | |
230 | | mutable dng_fingerprint fFingerprint; |
231 | | |
232 | | // Copyright notice from creator of profile. |
233 | | |
234 | | dng_string fCopyright; |
235 | | |
236 | | // Rules for how this profile can be embedded and/or copied. |
237 | | |
238 | | uint32 fEmbedPolicy; |
239 | | |
240 | | // 2-D (or 3-D) hue/sat tables to modify colors. |
241 | | |
242 | | dng_hue_sat_map fHueSatDeltas1; |
243 | | dng_hue_sat_map fHueSatDeltas2; |
244 | | |
245 | | // Value (V of HSV) encoding for hue/sat tables. |
246 | | |
247 | | uint32 fHueSatMapEncoding; |
248 | | |
249 | | // 3-D hue/sat table to apply a "look". |
250 | | |
251 | | dng_hue_sat_map fLookTable; |
252 | | |
253 | | // Value (V of HSV) encoding for look table. |
254 | | |
255 | | uint32 fLookTableEncoding; |
256 | | |
257 | | // Baseline exposure offset. When using this profile, this offset value is |
258 | | // added to the BaselineExposure value for the negative to determine the |
259 | | // overall baseline exposure to apply. |
260 | | |
261 | | dng_srational fBaselineExposureOffset; |
262 | | |
263 | | // Default black rendering. |
264 | | |
265 | | uint32 fDefaultBlackRender; |
266 | | |
267 | | // The "as shot" tone curve for this profile. Check IsValid method |
268 | | // to tell if one exists in profile. |
269 | | |
270 | | dng_tone_curve fToneCurve; |
271 | | |
272 | | // If this string matches the fCameraCalibrationSignature of the |
273 | | // negative, then use the calibration matrix values from the negative. |
274 | | |
275 | | dng_string fProfileCalibrationSignature; |
276 | | |
277 | | // If non-empty, only allow use of this profile with camera having |
278 | | // same unique model name. |
279 | | |
280 | | dng_string fUniqueCameraModelRestriction; |
281 | | |
282 | | // Was this profile read from inside a DNG file? (If so, we wnat |
283 | | // to be sure to include it again when writing out an updated |
284 | | // DNG file) |
285 | | |
286 | | bool fWasReadFromDNG; |
287 | | |
288 | | // Was this profile read from disk (i.e., an external profile)? (If so, we |
289 | | // may need to refresh when changes are made externally to the profile |
290 | | // directory.) |
291 | | |
292 | | bool fWasReadFromDisk; |
293 | | |
294 | | // Was this profile a built-in "Matrix" profile? (If so, we may need to |
295 | | // refresh -- i.e., remove it from the list of available profiles -- when |
296 | | // changes are made externally to the profile directory.) |
297 | | |
298 | | bool fWasBuiltinMatrix; |
299 | | |
300 | | // Was this profile stubbed to save memory (and no longer valid |
301 | | // for building color conversion tables)? |
302 | | |
303 | | bool fWasStubbed; |
304 | | |
305 | | public: |
306 | | |
307 | | dng_camera_profile (); |
308 | | |
309 | | virtual ~dng_camera_profile (); |
310 | | |
311 | | // API for profile name: |
312 | | |
313 | | /// Setter for camera profile name. |
314 | | /// \param name Name to use for this camera profile. |
315 | | |
316 | | void SetName (const char *name) |
317 | 0 | { |
318 | 0 | fName.Set (name); |
319 | 0 | ClearFingerprint (); |
320 | 0 | } |
321 | | |
322 | | /// Getter for camera profile name. |
323 | | /// \retval Name of profile. |
324 | | |
325 | | const dng_string & Name () const |
326 | 0 | { |
327 | 0 | return fName; |
328 | 0 | } |
329 | | |
330 | | /// Test if this name is embedded. |
331 | | /// \retval true if the name matches the name of the embedded camera profile. |
332 | | |
333 | | bool NameIsEmbedded () const |
334 | 0 | { |
335 | 0 | return fName.Matches (kProfileName_Embedded, true); |
336 | 0 | } |
337 | | |
338 | | // API for calibration illuminants: |
339 | | |
340 | | /// Setter for first of up to two light sources used for calibration. |
341 | | /// Uses the EXIF encodings for illuminant and is used to distinguish which |
342 | | /// matrix to use. |
343 | | /// Corresponds to the DNG CalibrationIlluminant1 tag. |
344 | | |
345 | | void SetCalibrationIlluminant1 (uint32 light) |
346 | 0 | { |
347 | 0 | fCalibrationIlluminant1 = light; |
348 | 0 | ClearFingerprint (); |
349 | 0 | } |
350 | | |
351 | | /// Setter for second of up to two light sources used for calibration. |
352 | | /// Uses the EXIF encodings for illuminant and is used to distinguish which |
353 | | /// matrix to use. |
354 | | /// Corresponds to the DNG CalibrationIlluminant2 tag. |
355 | | |
356 | | void SetCalibrationIlluminant2 (uint32 light) |
357 | 0 | { |
358 | 0 | fCalibrationIlluminant2 = light; |
359 | 0 | ClearFingerprint (); |
360 | 0 | } |
361 | | |
362 | | /// Getter for first of up to two light sources used for calibration. |
363 | | /// Uses the EXIF encodings for illuminant and is used to distinguish which |
364 | | /// matrix to use. |
365 | | /// Corresponds to the DNG CalibrationIlluminant1 tag. |
366 | | |
367 | | uint32 CalibrationIlluminant1 () const |
368 | 0 | { |
369 | 0 | return fCalibrationIlluminant1; |
370 | 0 | } |
371 | | |
372 | | /// Getter for second of up to two light sources used for calibration. |
373 | | /// Uses the EXIF encodings for illuminant and is used to distinguish which |
374 | | /// matrix to use. |
375 | | /// Corresponds to the DNG CalibrationIlluminant2 tag. |
376 | | |
377 | | uint32 CalibrationIlluminant2 () const |
378 | 0 | { |
379 | 0 | return fCalibrationIlluminant2; |
380 | 0 | } |
381 | | |
382 | | /// Getter for first of up to two light sources used for calibration, returning |
383 | | /// result as color temperature. |
384 | | |
385 | | real64 CalibrationTemperature1 () const |
386 | 0 | { |
387 | 0 | return IlluminantToTemperature (CalibrationIlluminant1 ()); |
388 | 0 | } |
389 | | |
390 | | /// Getter for second of up to two light sources used for calibration, returning |
391 | | /// result as color temperature. |
392 | | |
393 | | real64 CalibrationTemperature2 () const |
394 | 0 | { |
395 | 0 | return IlluminantToTemperature (CalibrationIlluminant2 ()); |
396 | 0 | } |
397 | | |
398 | | // API for color matrices: |
399 | | |
400 | | /// Utility function to normalize the scale of the color matrix. |
401 | | |
402 | | static void NormalizeColorMatrix (dng_matrix &m); |
403 | | |
404 | | /// Setter for first of up to two color matrices used for reference camera calibrations. |
405 | | /// These matrices map XYZ values to camera values. The DNG SDK needs to map colors |
406 | | /// that direction in order to determine the clipping points for |
407 | | /// highlight recovery logic based on the white point. If cameras |
408 | | /// were all three-color, the matrix could be stored as a forward matrix. |
409 | | /// The inverse matrix is requried to support four-color cameras. |
410 | | |
411 | | void SetColorMatrix1 (const dng_matrix &m); |
412 | | |
413 | | /// Setter for second of up to two color matrices used for reference camera calibrations. |
414 | | /// These matrices map XYZ values to camera values. The DNG SDK needs to map colors |
415 | | /// that direction in order to determine the clipping points for |
416 | | /// highlight recovery logic based on the white point. If cameras |
417 | | /// were all three-color, the matrix could be stored as a forward matrix. |
418 | | /// The inverse matrix is requried to support four-color cameras. |
419 | | |
420 | | void SetColorMatrix2 (const dng_matrix &m); |
421 | | |
422 | | /// Predicate to test if first camera matrix is set |
423 | | |
424 | | bool HasColorMatrix1 () const; |
425 | | |
426 | | /// Predicate to test if second camera matrix is set |
427 | | |
428 | | bool HasColorMatrix2 () const; |
429 | | |
430 | | /// Getter for first of up to two color matrices used for calibrations. |
431 | | |
432 | | const dng_matrix & ColorMatrix1 () const |
433 | 0 | { |
434 | 0 | return fColorMatrix1; |
435 | 0 | } |
436 | | |
437 | | /// Getter for second of up to two color matrices used for calibrations. |
438 | | |
439 | | const dng_matrix & ColorMatrix2 () const |
440 | 0 | { |
441 | 0 | return fColorMatrix2; |
442 | 0 | } |
443 | | |
444 | | // API for forward matrices: |
445 | | |
446 | | /// Utility function to normalize the scale of the forward matrix. |
447 | | |
448 | | static void NormalizeForwardMatrix (dng_matrix &m); |
449 | | |
450 | | /// Setter for first of up to two forward matrices used for calibrations. |
451 | | |
452 | | void SetForwardMatrix1 (const dng_matrix &m); |
453 | | |
454 | | /// Setter for second of up to two forward matrices used for calibrations. |
455 | | |
456 | | void SetForwardMatrix2 (const dng_matrix &m); |
457 | | |
458 | | /// Getter for first of up to two forward matrices used for calibrations. |
459 | | |
460 | | const dng_matrix & ForwardMatrix1 () const |
461 | 0 | { |
462 | 0 | return fForwardMatrix1; |
463 | 0 | } |
464 | | |
465 | | /// Getter for second of up to two forward matrices used for calibrations. |
466 | | |
467 | | const dng_matrix & ForwardMatrix2 () const |
468 | 0 | { |
469 | 0 | return fForwardMatrix2; |
470 | 0 | } |
471 | | |
472 | | // API for reduction matrices: |
473 | | |
474 | | /// Setter for first of up to two dimensionality reduction hints for four-color cameras. |
475 | | /// This is an optional matrix that maps four components to three. |
476 | | /// See Appendix 6 of the \ref spec_dng "DNG 1.1.0 specification." |
477 | | |
478 | | void SetReductionMatrix1 (const dng_matrix &m); |
479 | | |
480 | | /// Setter for second of up to two dimensionality reduction hints for four-color cameras. |
481 | | /// This is an optional matrix that maps four components to three. |
482 | | /// See Appendix 6 of the \ref spec_dng "DNG 1.1.0 specification." |
483 | | |
484 | | void SetReductionMatrix2 (const dng_matrix &m); |
485 | | |
486 | | /// Getter for first of up to two dimensionality reduction hints for four color cameras. |
487 | | |
488 | | const dng_matrix & ReductionMatrix1 () const |
489 | 0 | { |
490 | 0 | return fReductionMatrix1; |
491 | 0 | } |
492 | | |
493 | | /// Getter for second of up to two dimensionality reduction hints for four color cameras. |
494 | | |
495 | | const dng_matrix & ReductionMatrix2 () const |
496 | 0 | { |
497 | 0 | return fReductionMatrix2; |
498 | 0 | } |
499 | | |
500 | | /// Getter function from profile fingerprint. |
501 | | |
502 | | const dng_fingerprint &Fingerprint () const |
503 | 0 | { |
504 | |
|
505 | 0 | if (!fFingerprint.IsValid ()) |
506 | 0 | CalculateFingerprint (); |
507 | |
|
508 | 0 | return fFingerprint; |
509 | |
|
510 | 0 | } |
511 | | |
512 | | /// Getter for camera profile id. |
513 | | /// \retval ID of profile. |
514 | | |
515 | | dng_camera_profile_id ProfileID () const |
516 | 0 | { |
517 | 0 | return dng_camera_profile_id (Name (), Fingerprint ()); |
518 | 0 | } |
519 | | |
520 | | /// Setter for camera profile copyright. |
521 | | /// \param copyright Copyright string to use for this camera profile. |
522 | | |
523 | | void SetCopyright (const char *copyright) |
524 | 0 | { |
525 | 0 | fCopyright.Set (copyright); |
526 | 0 | ClearFingerprint (); |
527 | 0 | } |
528 | | |
529 | | /// Getter for camera profile copyright. |
530 | | /// \retval Copyright string for profile. |
531 | | |
532 | | const dng_string & Copyright () const |
533 | 0 | { |
534 | 0 | return fCopyright; |
535 | 0 | } |
536 | | |
537 | | // Accessors for embed policy. |
538 | | |
539 | | /// Setter for camera profile embed policy. |
540 | | /// \param policy Policy to use for this camera profile. |
541 | | |
542 | | void SetEmbedPolicy (uint32 policy) |
543 | 0 | { |
544 | 0 | fEmbedPolicy = policy; |
545 | 0 | ClearFingerprint (); |
546 | 0 | } |
547 | | |
548 | | /// Getter for camera profile embed policy. |
549 | | /// \param Policy for profile. |
550 | | |
551 | | uint32 EmbedPolicy () const |
552 | 0 | { |
553 | 0 | return fEmbedPolicy; |
554 | 0 | } |
555 | | |
556 | | /// Returns true iff the profile is legal to embed in a DNG, per the |
557 | | /// profile's embed policy. |
558 | | |
559 | | bool IsLegalToEmbed () const |
560 | 0 | { |
561 | 0 | return WasReadFromDNG () || |
562 | 0 | EmbedPolicy () == pepAllowCopying || |
563 | 0 | EmbedPolicy () == pepEmbedIfUsed || |
564 | 0 | EmbedPolicy () == pepNoRestrictions; |
565 | 0 | } |
566 | | |
567 | | // Accessors for hue sat maps. |
568 | | |
569 | | /// Returns true iff the profile has a valid HueSatMap color table. |
570 | | |
571 | | bool HasHueSatDeltas () const |
572 | 0 | { |
573 | 0 | return fHueSatDeltas1.IsValid (); |
574 | 0 | } |
575 | | |
576 | | /// Getter for first HueSatMap color table (for calibration illuminant 1). |
577 | | |
578 | | const dng_hue_sat_map & HueSatDeltas1 () const |
579 | 0 | { |
580 | 0 | return fHueSatDeltas1; |
581 | 0 | } |
582 | | |
583 | | /// Setter for first HueSatMap color table (for calibration illuminant 1). |
584 | | |
585 | | void SetHueSatDeltas1 (const dng_hue_sat_map &deltas1); |
586 | | |
587 | | /// Getter for second HueSatMap color table (for calibration illuminant 2). |
588 | | |
589 | | const dng_hue_sat_map & HueSatDeltas2 () const |
590 | 0 | { |
591 | 0 | return fHueSatDeltas2; |
592 | 0 | } |
593 | | |
594 | | /// Setter for second HueSatMap color table (for calibration illuminant 2). |
595 | | |
596 | | void SetHueSatDeltas2 (const dng_hue_sat_map &deltas2); |
597 | | |
598 | | // Accessors for hue sat map encoding. |
599 | | |
600 | | /// Returns the hue sat map encoding (see ProfileHueSatMapEncoding tag). |
601 | | |
602 | | uint32 HueSatMapEncoding () const |
603 | 0 | { |
604 | 0 | return fHueSatMapEncoding; |
605 | 0 | } |
606 | | |
607 | | /// Sets the hue sat map encoding (see ProfileHueSatMapEncoding tag) to the |
608 | | /// specified encoding. |
609 | | |
610 | | void SetHueSatMapEncoding (uint32 encoding) |
611 | 0 | { |
612 | 0 | fHueSatMapEncoding = encoding; |
613 | 0 | ClearFingerprint (); |
614 | 0 | } |
615 | | |
616 | | // Accessors for look table. |
617 | | |
618 | | /// Returns true if the profile has a LookTable. |
619 | | |
620 | | bool HasLookTable () const |
621 | 0 | { |
622 | 0 | return fLookTable.IsValid (); |
623 | 0 | } |
624 | | |
625 | | /// Getter for LookTable. |
626 | | |
627 | | const dng_hue_sat_map & LookTable () const |
628 | 0 | { |
629 | 0 | return fLookTable; |
630 | 0 | } |
631 | | |
632 | | /// Setter for LookTable. |
633 | | |
634 | | void SetLookTable (const dng_hue_sat_map &table); |
635 | | |
636 | | // Accessors for look table encoding. |
637 | | |
638 | | /// Returns the LookTable encoding (see ProfileLookTableEncoding tag). |
639 | | |
640 | | uint32 LookTableEncoding () const |
641 | 0 | { |
642 | 0 | return fLookTableEncoding; |
643 | 0 | } |
644 | | |
645 | | /// Sets the LookTable encoding (see ProfileLookTableEncoding tag) to the |
646 | | /// specified encoding. |
647 | | |
648 | | void SetLookTableEncoding (uint32 encoding) |
649 | 0 | { |
650 | 0 | fLookTableEncoding = encoding; |
651 | 0 | ClearFingerprint (); |
652 | 0 | } |
653 | | |
654 | | // Accessors for baseline exposure offset. |
655 | | |
656 | | /// Sets the baseline exposure offset of the profile (see |
657 | | /// BaselineExposureOffset tag) to the specified value. |
658 | | |
659 | | void SetBaselineExposureOffset (real64 exposureOffset) |
660 | 0 | { |
661 | 0 | fBaselineExposureOffset.Set_real64 (exposureOffset, 100); |
662 | 0 | ClearFingerprint (); |
663 | 0 | } |
664 | | |
665 | | /// Returns the baseline exposure offset of the profile (see |
666 | | /// BaselineExposureOffset tag). |
667 | | |
668 | | const dng_srational & BaselineExposureOffset () const |
669 | 0 | { |
670 | 0 | return fBaselineExposureOffset; |
671 | 0 | } |
672 | | |
673 | | // Accessors for default black render. |
674 | | |
675 | | /// Sets the default black render of the profile (see DefaultBlackRender tag) |
676 | | /// to the specified option. |
677 | | |
678 | | void SetDefaultBlackRender (uint32 defaultBlackRender) |
679 | 0 | { |
680 | 0 | fDefaultBlackRender = defaultBlackRender; |
681 | 0 | ClearFingerprint (); |
682 | 0 | } |
683 | | |
684 | | /// Returns the default black render of the profile (see DefaultBlackRender |
685 | | /// tag). |
686 | | |
687 | | uint32 DefaultBlackRender () const |
688 | 0 | { |
689 | 0 | return fDefaultBlackRender; |
690 | 0 | } |
691 | | |
692 | | // Accessors for tone curve. |
693 | | |
694 | | /// Returns the tone curve of the profile. |
695 | | |
696 | | const dng_tone_curve & ToneCurve () const |
697 | 0 | { |
698 | 0 | return fToneCurve; |
699 | 0 | } |
700 | | |
701 | | /// Sets the tone curve of the profile to the specified curve. |
702 | | |
703 | | void SetToneCurve (const dng_tone_curve &curve) |
704 | 0 | { |
705 | 0 | fToneCurve = curve; |
706 | 0 | ClearFingerprint (); |
707 | 0 | } |
708 | | |
709 | | // Accessors for profile calibration signature. |
710 | | |
711 | | /// Sets the profile calibration signature (see ProfileCalibrationSignature |
712 | | /// tag) to the specified string. |
713 | | |
714 | | void SetProfileCalibrationSignature (const char *signature) |
715 | 0 | { |
716 | 0 | fProfileCalibrationSignature.Set (signature); |
717 | 0 | } |
718 | | |
719 | | /// Returns the profile calibration signature (see ProfileCalibrationSignature |
720 | | /// tag) of the profile. |
721 | | |
722 | | const dng_string & ProfileCalibrationSignature () const |
723 | 0 | { |
724 | 0 | return fProfileCalibrationSignature; |
725 | 0 | } |
726 | | |
727 | | /// Setter for camera unique model name to restrict use of this profile. |
728 | | /// \param camera Camera unique model name designating only camera this |
729 | | /// profile can be used with. (Empty string for no restriction.) |
730 | | |
731 | | void SetUniqueCameraModelRestriction (const char *camera) |
732 | 0 | { |
733 | 0 | fUniqueCameraModelRestriction.Set (camera); |
734 | | // Not included in fingerprint, so don't need ClearFingerprint (). |
735 | 0 | } |
736 | | |
737 | | /// Getter for camera unique model name to restrict use of this profile. |
738 | | /// \retval Unique model name of only camera this profile can be used with |
739 | | /// or empty if no restriction. |
740 | | |
741 | | const dng_string & UniqueCameraModelRestriction () const |
742 | 0 | { |
743 | 0 | return fUniqueCameraModelRestriction; |
744 | 0 | } |
745 | | |
746 | | // Accessors for was read from DNG flag. |
747 | | |
748 | | /// Sets internal flag to indicate this profile was originally read from a |
749 | | /// DNG file. |
750 | | |
751 | | void SetWasReadFromDNG (bool state = true) |
752 | 0 | { |
753 | 0 | fWasReadFromDNG = state; |
754 | 0 | } |
755 | | |
756 | | /// Was this profile read from a DNG? |
757 | | |
758 | | bool WasReadFromDNG () const |
759 | 0 | { |
760 | 0 | return fWasReadFromDNG; |
761 | 0 | } |
762 | | |
763 | | // Accessors for was read from disk flag. |
764 | | |
765 | | /// Sets internal flag to indicate this profile was originally read from |
766 | | /// disk. |
767 | | |
768 | | void SetWasReadFromDisk (bool state = true) |
769 | 0 | { |
770 | 0 | fWasReadFromDisk = state; |
771 | 0 | } |
772 | | |
773 | | /// Was this profile read from disk? |
774 | | |
775 | | bool WasReadFromDisk () const |
776 | 0 | { |
777 | 0 | return fWasReadFromDisk; |
778 | 0 | } |
779 | | |
780 | | // Accessors for was built-in matrix flag. |
781 | | |
782 | | /// Sets internal flag to indicate this profile was originally a built-in |
783 | | /// matrix profile. |
784 | | |
785 | | void SetWasBuiltinMatrix (bool state = true) |
786 | 0 | { |
787 | 0 | fWasBuiltinMatrix = state; |
788 | 0 | } |
789 | | |
790 | | /// Was this profile a built-in matrix profile? |
791 | | |
792 | | bool WasBuiltinMatrix () const |
793 | 0 | { |
794 | 0 | return fWasBuiltinMatrix; |
795 | 0 | } |
796 | | |
797 | | /// Determines if this a valid profile for this number of color channels? |
798 | | /// \retval true if the profile is valid. |
799 | | |
800 | | bool IsValid (uint32 channels) const; |
801 | | |
802 | | /// Predicate to check if two camera profiles are colorwise equal, thus ignores |
803 | | /// the profile name. |
804 | | /// \param profile Camera profile to compare to. |
805 | | |
806 | | bool EqualData (const dng_camera_profile &profile) const; |
807 | | |
808 | | /// Parse profile from dng_camera_profile_info data. |
809 | | |
810 | | void Parse (dng_stream &stream, |
811 | | dng_camera_profile_info &profileInfo); |
812 | | |
813 | | /// Parse from an extended profile stream, which is similar to stand alone |
814 | | /// TIFF file. |
815 | | |
816 | | bool ParseExtended (dng_stream &stream); |
817 | | |
818 | | /// Convert from a three-color to a four-color Bayer profile. |
819 | | |
820 | | virtual void SetFourColorBayer (); |
821 | | |
822 | | /// Find the hue/sat table to use for a given white point, if any. |
823 | | /// The calling routine owns the resulting table. |
824 | | |
825 | | dng_hue_sat_map * HueSatMapForWhite (const dng_xy_coord &white) const; |
826 | | |
827 | | /// Stub out the profile (free memory used by large tables). |
828 | | |
829 | | void Stub (); |
830 | | |
831 | | /// Was this profile stubbed? |
832 | | |
833 | | bool WasStubbed () const |
834 | 0 | { |
835 | 0 | return fWasStubbed; |
836 | 0 | } |
837 | | |
838 | | protected: |
839 | | |
840 | | static real64 IlluminantToTemperature (uint32 light); |
841 | | |
842 | | void ClearFingerprint () |
843 | 0 | { |
844 | 0 | fFingerprint.Clear (); |
845 | 0 | } |
846 | | |
847 | | void CalculateFingerprint () const; |
848 | | |
849 | | static bool ValidForwardMatrix (const dng_matrix &m); |
850 | | |
851 | | static void ReadHueSatMap (dng_stream &stream, |
852 | | dng_hue_sat_map &hueSatMap, |
853 | | uint32 hues, |
854 | | uint32 sats, |
855 | | uint32 vals, |
856 | | bool skipSat0); |
857 | | |
858 | | }; |
859 | | |
860 | | /******************************************************************************/ |
861 | | |
862 | | void SplitCameraProfileName (const dng_string &name, |
863 | | dng_string &baseName, |
864 | | int32 &version); |
865 | | |
866 | | /*****************************************************************************/ |
867 | | |
868 | | void BuildHueSatMapEncodingTable (dng_memory_allocator &allocator, |
869 | | uint32 encoding, |
870 | | AutoPtr<dng_1d_table> &encodeTable, |
871 | | AutoPtr<dng_1d_table> &decodeTable, |
872 | | bool subSample); |
873 | | |
874 | | /******************************************************************************/ |
875 | | |
876 | | #endif |
877 | | |
878 | | /******************************************************************************/ |