1 | /*****************************************************************************/ |
2 | // Copyright 2006-2012 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_negative.h#4 $ */ |
10 | /* $DateTime: 2012/08/02 06:09:06 $ */ |
11 | /* $Change: 841096 $ */ |
12 | /* $Author: erichan $ */ |
13 | |
14 | /** \file |
15 | * Functions and classes for working with a digital negative (image data and |
16 | * corresponding metadata). |
17 | */ |
18 | |
19 | /*****************************************************************************/ |
20 | |
21 | #ifndef __dng_negative__ |
22 | #define __dng_negative__ |
23 | |
24 | /*****************************************************************************/ |
25 | |
26 | #include "dng_1d_function.h" |
27 | #include "dng_auto_ptr.h" |
28 | #include "dng_classes.h" |
29 | #include "dng_fingerprint.h" |
30 | #include "dng_image.h" |
31 | #include "dng_linearization_info.h" |
32 | #include "dng_matrix.h" |
33 | #include "dng_memory.h" |
34 | #include "dng_mosaic_info.h" |
35 | #include "dng_opcode_list.h" |
36 | #include "dng_orientation.h" |
37 | #include "dng_rational.h" |
38 | #include "dng_sdk_limits.h" |
39 | #include "dng_string.h" |
40 | #include "dng_tag_types.h" |
41 | #include "dng_tag_values.h" |
42 | #include "dng_types.h" |
43 | #include "dng_utils.h" |
44 | #include "dng_xy_coord.h" |
45 | |
46 | #include <vector> |
47 | |
48 | /*****************************************************************************/ |
49 | |
50 | // To prevent using the internal metadata when we meant to use override |
51 | // metadata, the following definitions allow us to only allow access to |
52 | // the internal metadata on non-const negatives. This allows the old API |
53 | // to keep working essentially unchanged provided one does not use const |
54 | // negatives, but will prevent access to the embedded data on const |
55 | // negatives. |
56 | |
57 | #if 1 |
58 | |
59 | #define qMetadataOnConst 0 |
60 | #define METACONST |
61 | |
62 | #else |
63 | |
64 | #define qMetadataOnConst 1 |
65 | #define METACONST const |
66 | |
67 | #endif |
68 | |
69 | /*****************************************************************************/ |
70 | |
71 | /// \brief Noise model for photon and sensor read noise, assuming that they are |
72 | /// independent random variables and spatially invariant. |
73 | /// |
74 | /// The noise model is N (x) = sqrt (scale*x + offset), where x represents a linear |
75 | /// signal value in the range [0,1], and N (x) is the standard deviation (i.e., |
76 | /// noise). The parameters scale and offset are both sensor-dependent and |
77 | /// ISO-dependent. scale must be positive, and offset must be non-negative. |
78 | |
79 | class dng_noise_function: public dng_1d_function |
80 | { |
81 | |
82 | protected: |
83 | |
84 | real64 fScale; |
85 | real64 fOffset; |
86 | |
87 | public: |
88 | |
89 | /// Create empty and invalid noise function. |
90 | |
91 | dng_noise_function () |
92 | |
93 | : fScale (0.0) |
94 | , fOffset (0.0) |
95 | |
96 | { |
97 | |
98 | } |
99 | |
100 | /// Create noise function with the specified scale and offset. |
101 | |
102 | dng_noise_function (real64 scale, |
103 | real64 offset) |
104 | |
105 | : fScale (scale) |
106 | , fOffset (offset) |
107 | |
108 | { |
109 | |
110 | } |
111 | |
112 | /// Compute noise (standard deviation) at the specified average signal level |
113 | /// x. |
114 | |
115 | virtual real64 Evaluate (real64 x) const |
116 | { |
117 | return sqrt (fScale * x + fOffset); |
118 | } |
119 | |
120 | /// The scale (slope, gain) of the noise function. |
121 | |
122 | real64 Scale () const |
123 | { |
124 | return fScale; |
125 | } |
126 | |
127 | /// The offset (square of the noise floor) of the noise function. |
128 | |
129 | real64 Offset () const |
130 | { |
131 | return fOffset; |
132 | } |
133 | |
134 | /// Set the scale (slope, gain) of the noise function. |
135 | |
136 | void SetScale (real64 scale) |
137 | { |
138 | fScale = scale; |
139 | } |
140 | |
141 | /// Set the offset (square of the noise floor) of the noise function. |
142 | |
143 | void SetOffset (real64 offset) |
144 | { |
145 | fOffset = offset; |
146 | } |
147 | |
148 | /// Is the noise function valid? |
149 | |
150 | bool IsValid () const |
151 | { |
152 | return (fScale > 0.0 && fOffset >= 0.0); |
153 | } |
154 | |
155 | }; |
156 | |
157 | /*****************************************************************************/ |
158 | |
159 | /// \brief Noise profile for a negative. |
160 | /// |
161 | /// For mosaiced negatives, the noise profile describes the approximate noise |
162 | /// characteristics of a mosaic negative after linearization, but prior to |
163 | /// demosaicing. For demosaiced negatives (i.e., linear DNGs), the noise profile |
164 | /// describes the approximate noise characteristics of the image data immediately |
165 | /// following the demosaic step, prior to the processing of opcode list 3. |
166 | /// |
167 | /// A noise profile may contain 1 or N noise functions, where N is the number of |
168 | /// color planes for the negative. Otherwise the noise profile is considered to be |
169 | /// invalid for that negative. If the noise profile contains 1 noise function, then |
170 | /// it is assumed that this single noise function applies to all color planes of the |
171 | /// negative. Otherwise, the N noise functions map to the N planes of the negative in |
172 | /// order specified in the CFAPlaneColor tag. |
173 | |
174 | class dng_noise_profile |
175 | { |
176 | |
177 | protected: |
178 | |
179 | dng_std_vector<dng_noise_function> fNoiseFunctions; |
180 | |
181 | public: |
182 | |
183 | /// Create empty (invalid) noise profile. |
184 | |
185 | dng_noise_profile (); |
186 | |
187 | /// Create noise profile with the specified noise functions (1 per plane). |
188 | |
189 | explicit dng_noise_profile (const dng_std_vector<dng_noise_function> &functions); |
190 | |
191 | /// Is the noise profile valid? |
192 | |
193 | bool IsValid () const; |
194 | |
195 | /// Is the noise profile valid for the specified negative? |
196 | |
197 | bool IsValidForNegative (const dng_negative &negative) const; |
198 | |
199 | /// The noise function for the specified plane. |
200 | |
201 | const dng_noise_function & NoiseFunction (uint32 plane) const; |
202 | |
203 | /// The number of noise functions in this profile. |
204 | |
205 | uint32 NumFunctions () const; |
206 | |
207 | }; |
208 | |
209 | /*****************************************************************************/ |
210 | |
211 | /// \brief Main class for holding metadata. |
212 | |
213 | class dng_metadata |
214 | { |
215 | |
216 | private: |
217 | |
218 | // Base orientation of both the thumbnail and raw data. This is |
219 | // generally based on the EXIF values. |
220 | |
221 | bool fHasBaseOrientation; |
222 | |
223 | dng_orientation fBaseOrientation; |
224 | |
225 | // Is the maker note safe to copy from file to file? Defaults to false |
226 | // because many maker notes are not safe. |
227 | |
228 | bool fIsMakerNoteSafe; |
229 | |
230 | // MakerNote binary data block. |
231 | |
232 | AutoPtr<dng_memory_block> fMakerNote; |
233 | |
234 | // EXIF data. |
235 | |
236 | AutoPtr<dng_exif> fExif; |
237 | |
238 | // A copy of the EXIF data before is was synchronized with other metadata sources. |
239 | |
240 | AutoPtr<dng_exif> fOriginalExif; |
241 | |
242 | // IPTC binary data block and offset in original file. |
243 | |
244 | AutoPtr<dng_memory_block> fIPTCBlock; |
245 | |
246 | uint64 fIPTCOffset; |
247 | |
248 | // XMP data. |
249 | |
250 | #if qDNGUseXMP |
251 | |
252 | AutoPtr<dng_xmp> fXMP; |
253 | |
254 | #endif |
255 | |
256 | // If there a valid embedded XMP block, has is its digest? NULL if no valid |
257 | // embedded XMP. |
258 | |
259 | dng_fingerprint fEmbeddedXMPDigest; |
260 | |
261 | // Is the XMP data from a sidecar file? |
262 | |
263 | bool fXMPinSidecar; |
264 | |
265 | // If the XMP data is from a sidecar file, is the sidecar file newer |
266 | // than the raw file? |
267 | |
268 | bool fXMPisNewer; |
269 | |
270 | // Source file mimi-type, if known. |
271 | |
272 | dng_string fSourceMIMI; |
273 | |
274 | public: |
275 | |
276 | dng_metadata (dng_host &host); |
277 | |
278 | dng_metadata (const dng_metadata &rhs, |
279 | dng_memory_allocator &allocator); |
280 | |
281 | virtual ~dng_metadata (); |
282 | |
283 | /// Copy this metadata. |
284 | |
285 | virtual dng_metadata * Clone (dng_memory_allocator &allocator) const; |
286 | |
287 | /// Setter for BaseOrientation. |
288 | |
289 | void SetBaseOrientation (const dng_orientation &orientation); |
290 | |
291 | /// Has BaseOrientation been set? |
292 | |
293 | bool HasBaseOrientation () const |
294 | { |
295 | return fHasBaseOrientation; |
296 | } |
297 | |
298 | /// Getter for BaseOrientation. |
299 | |
300 | const dng_orientation & BaseOrientation () const |
301 | { |
302 | return fBaseOrientation; |
303 | } |
304 | |
305 | /// Logically rotates the image by changing the orientation values. |
306 | /// This will also update the XMP data. |
307 | |
308 | void ApplyOrientation (const dng_orientation &orientation); |
309 | |
310 | // API for IPTC metadata: |
311 | |
312 | void SetIPTC (AutoPtr<dng_memory_block> &block, |
313 | uint64 offset); |
314 | |
315 | void SetIPTC (AutoPtr<dng_memory_block> &block); |
316 | |
317 | void ClearIPTC (); |
318 | |
319 | const void * IPTCData () const; |
320 | |
321 | uint32 IPTCLength () const; |
322 | |
323 | uint64 IPTCOffset () const; |
324 | |
325 | dng_fingerprint IPTCDigest (bool includePadding = true) const; |
326 | |
327 | void RebuildIPTC (dng_memory_allocator &allocator, |
328 | bool padForTIFF); |
329 | |
330 | // API for MakerNote data: |
331 | |
332 | void SetMakerNoteSafety (bool safe) |
333 | { |
334 | fIsMakerNoteSafe = safe; |
335 | } |
336 | |
337 | bool IsMakerNoteSafe () const |
338 | { |
339 | return fIsMakerNoteSafe; |
340 | } |
341 | |
342 | void SetMakerNote (AutoPtr<dng_memory_block> &block) |
343 | { |
344 | fMakerNote.Reset (block.Release ()); |
345 | } |
346 | |
347 | void ClearMakerNote () |
348 | { |
349 | fIsMakerNoteSafe = false; |
350 | fMakerNote.Reset (); |
351 | } |
352 | |
353 | const void * MakerNoteData () const |
354 | { |
355 | return fMakerNote.Get () ? fMakerNote->Buffer () |
356 | : NULL; |
357 | } |
358 | |
359 | uint32 MakerNoteLength () const |
360 | { |
361 | return fMakerNote.Get () ? fMakerNote->LogicalSize () |
362 | : 0; |
363 | } |
364 | |
365 | // API for EXIF metadata: |
366 | |
367 | dng_exif * GetExif () |
368 | { |
369 | return fExif.Get (); |
370 | } |
371 | |
372 | const dng_exif * GetExif () const |
373 | { |
374 | return fExif.Get (); |
375 | } |
376 | |
377 | template< class E > |
378 | E & Exif (); |
379 | |
380 | template< class E > |
381 | const E & Exif () const; |
382 | |
383 | void ResetExif (dng_exif * newExif); |
384 | |
385 | dng_memory_block * BuildExifBlock (dng_memory_allocator &allocator, |
386 | const dng_resolution *resolution = NULL, |
387 | bool includeIPTC = false, |
388 | const dng_jpeg_preview *thumbnail = NULL) const; |
389 | |
390 | // API for original EXIF metadata. |
391 | |
392 | dng_exif * GetOriginalExif () |
393 | { |
394 | return fOriginalExif.Get (); |
395 | } |
396 | |
397 | const dng_exif * GetOriginalExif () const |
398 | { |
399 | return fOriginalExif.Get (); |
400 | } |
401 | |
402 | // API for XMP metadata: |
403 | |
404 | #if qDNGUseXMP |
405 | |
406 | bool SetXMP (dng_host &host, |
407 | const void *buffer, |
408 | uint32 count, |
409 | bool xmpInSidecar = false, |
410 | bool xmpIsNewer = false); |
411 | |
412 | void SetEmbeddedXMP (dng_host &host, |
413 | const void *buffer, |
414 | uint32 count); |
415 | |
416 | dng_xmp * GetXMP () |
417 | { |
418 | return fXMP.Get (); |
419 | } |
420 | |
421 | const dng_xmp * GetXMP () const |
422 | { |
423 | return fXMP.Get (); |
424 | } |
425 | |
426 | template< class X > |
427 | X & XMP (); |
428 | |
429 | template< class X > |
430 | const X & XMP () const; |
431 | |
432 | bool XMPinSidecar () const |
433 | { |
434 | return fXMPinSidecar; |
435 | } |
436 | |
437 | const dng_fingerprint & EmbeddedXMPDigest () const |
438 | { |
439 | return fEmbeddedXMPDigest; |
440 | } |
441 | |
442 | bool HaveValidEmbeddedXMP () const |
443 | { |
444 | return fEmbeddedXMPDigest.IsValid (); |
445 | } |
446 | |
447 | void ResetXMP (dng_xmp * newXMP); |
448 | |
449 | void ResetXMPSidecarNewer (dng_xmp * newXMP, bool inSidecar, bool isNewer ); |
450 | |
451 | #endif |
452 | |
453 | // Synchronize metadata sources. |
454 | |
455 | void SynchronizeMetadata (); |
456 | |
457 | // Routines to update the date/time field in the EXIF and XMP |
458 | // metadata. |
459 | |
460 | void UpdateDateTime (const dng_date_time_info &dt); |
461 | |
462 | void UpdateDateTimeToNow (); |
463 | |
464 | void UpdateMetadataDateTimeToNow (); |
465 | |
466 | // Routines to set and get the source file MIMI type. |
467 | |
468 | void SetSourceMIMI (const char *s) |
469 | { |
470 | fSourceMIMI.Set (s); |
471 | } |
472 | |
473 | const dng_string & SourceMIMI () const |
474 | { |
475 | return fSourceMIMI; |
476 | } |
477 | |
478 | }; |
479 | |
480 | /*****************************************************************************/ |
481 | |
482 | template< class E > |
483 | E & dng_metadata::Exif () |
484 | { |
485 | dng_exif * exif = GetExif (); |
486 | if (!exif) ThrowProgramError ("EXIF object is NULL." ); |
487 | return dynamic_cast< E & > (*exif); |
488 | } |
489 | |
490 | /*****************************************************************************/ |
491 | |
492 | template< class E > |
493 | const E & dng_metadata::Exif () const |
494 | { |
495 | const dng_exif * exif = GetExif (); |
496 | if (!exif) ThrowProgramError ("EXIF object is NULL." ); |
497 | return dynamic_cast< const E & > (*exif); |
498 | } |
499 | |
500 | /*****************************************************************************/ |
501 | |
502 | #if qDNGUseXMP |
503 | |
504 | template< class X > |
505 | X & dng_metadata::XMP () |
506 | { |
507 | dng_xmp * xmp = GetXMP (); |
508 | if (!xmp) ThrowProgramError ("XMP object is NULL." ); |
509 | return dynamic_cast< X & > (*xmp); |
510 | } |
511 | |
512 | /*****************************************************************************/ |
513 | |
514 | template< class X > |
515 | const X & dng_metadata::XMP () const |
516 | { |
517 | const dng_xmp * xmp = GetXMP (); |
518 | if (!xmp) ThrowProgramError ("XMP object is NULL." ); |
519 | return dynamic_cast< const X & > (*xmp); |
520 | } |
521 | |
522 | #endif |
523 | |
524 | /*****************************************************************************/ |
525 | |
526 | /// \brief Main class for holding DNG image data and associated metadata. |
527 | |
528 | class dng_negative |
529 | { |
530 | |
531 | public: |
532 | |
533 | enum RawImageStageEnum |
534 | { |
535 | rawImageStagePreOpcode1, |
536 | rawImageStagePostOpcode1, |
537 | rawImageStagePostOpcode2, |
538 | rawImageStagePreOpcode3, |
539 | rawImageStagePostOpcode3, |
540 | rawImageStageNone |
541 | }; |
542 | |
543 | protected: |
544 | |
545 | // The negative stores an associated allocator. It does not do |
546 | // anything to keep it alive or to release it when the object destructs. |
547 | // Hence, clients will need to make sure that the allocator's lifespan |
548 | // encompasses that of the dng_factory object which is generally |
549 | // directly bound to the dng_negative object. |
550 | |
551 | dng_memory_allocator &fAllocator; |
552 | |
553 | // Non-localized ASCII model name. |
554 | |
555 | dng_string fModelName; |
556 | |
557 | // Localized UTF-8 model name. |
558 | |
559 | dng_string fLocalName; |
560 | |
561 | // The area of raw image that should be included in the final converted |
562 | // image. This stems from extra pixels around the edges of the sensor |
563 | // including both the black mask and some additional padding. |
564 | |
565 | // The default crop can be smaller than the "active" area which includes |
566 | // the padding but not the black masked pixels. |
567 | |
568 | dng_urational fDefaultCropSizeH; |
569 | dng_urational fDefaultCropSizeV; |
570 | |
571 | dng_urational fDefaultCropOriginH; |
572 | dng_urational fDefaultCropOriginV; |
573 | |
574 | // Default user crop, in relative coordinates. |
575 | |
576 | dng_urational fDefaultUserCropT; |
577 | dng_urational fDefaultUserCropL; |
578 | dng_urational fDefaultUserCropB; |
579 | dng_urational fDefaultUserCropR; |
580 | |
581 | // Default scale factors. Generally, 1.0 for square pixel cameras. They |
582 | // can compensate for non-square pixels. The choice of exact values will |
583 | // generally depend on what the camera does. These are particularly |
584 | // interesting for the Nikon D1X and the Fuji diamond mosaic. |
585 | |
586 | dng_urational fDefaultScaleH; |
587 | dng_urational fDefaultScaleV; |
588 | |
589 | // Best quality scale factor. Used for the Nikon D1X and Fuji cameras |
590 | // to force everything to be a scale up rather than scale down. So, |
591 | // generally this is 1.0 / min (fDefaultScaleH, fDefaultScaleV) but |
592 | // this isn't used if the scale factors are only slightly different |
593 | // from 1.0. |
594 | |
595 | dng_urational fBestQualityScale; |
596 | |
597 | // Proxy image support. Remember certain sizes for the original image |
598 | // this proxy was derived from. |
599 | |
600 | dng_point fOriginalDefaultFinalSize; |
601 | dng_point fOriginalBestQualityFinalSize; |
602 | |
603 | dng_urational fOriginalDefaultCropSizeH; |
604 | dng_urational fOriginalDefaultCropSizeV; |
605 | |
606 | // Scale factors used in demosaic algorithm (calculated). |
607 | // Maps raw image coordinates to full image coordinates -- i.e., |
608 | // original image coordinates on raw sensor data to coordinates |
609 | // in fStage3Image which is the output of the interpolation step. |
610 | // So, if we downsample when interpolating, these numbers get |
611 | // smaller. |
612 | |
613 | real64 fRawToFullScaleH; |
614 | real64 fRawToFullScaleV; |
615 | |
616 | // Relative amount of noise at ISO 100. This is measured per camera model |
617 | // based on looking at flat areas of color. |
618 | |
619 | dng_urational fBaselineNoise; |
620 | |
621 | // How much noise reduction has already been applied (0.0 to 1.0) to the |
622 | // the raw image data? 0.0 = none, 1.0 = "ideal" amount--i.e. don't apply any |
623 | // more by default. 0/0 for unknown. |
624 | |
625 | dng_urational fNoiseReductionApplied; |
626 | |
627 | // Amount of noise for this negative (see dng_noise_profile for details). |
628 | |
629 | dng_noise_profile fNoiseProfile; |
630 | |
631 | // Zero point for the exposure compensation slider. This reflects how |
632 | // the manufacturer sets up the camera and its conversions. |
633 | |
634 | dng_srational fBaselineExposure; |
635 | |
636 | // Relative amount of sharpening required. This is chosen per camera |
637 | // model based on how strong the anti-alias filter is on the camera |
638 | // and the quality of the lenses. This scales the sharpness slider |
639 | // value. |
640 | |
641 | dng_urational fBaselineSharpness; |
642 | |
643 | // Chroma blur radius (or 0/0 for auto). Set to 0/1 to disable |
644 | // chroma blurring. |
645 | |
646 | dng_urational fChromaBlurRadius; |
647 | |
648 | // Anti-alias filter strength (0.0 to 1.0). Used as a hint |
649 | // to the demosaic algorithms. |
650 | |
651 | dng_urational fAntiAliasStrength; |
652 | |
653 | // Linear response limit. The point at which the sensor goes |
654 | // non-linear and color information becomes unreliable. Used in |
655 | // the highlight-recovery logic. |
656 | |
657 | dng_urational fLinearResponseLimit; |
658 | |
659 | // Scale factor for shadows slider. The Fuji HDR cameras, for example, |
660 | // need a more sensitive shadow slider. |
661 | |
662 | dng_urational fShadowScale; |
663 | |
664 | // Colormetric reference. |
665 | |
666 | uint32 fColorimetricReference; |
667 | |
668 | // Number of color channels for this image (e.g. 1, 3, or 4). |
669 | |
670 | uint32 fColorChannels; |
671 | |
672 | // Amount by which each channel has already been scaled. Some cameras |
673 | // have analog amplifiers on the color channels and these can result |
674 | // in different scalings per channel. This provides some level of |
675 | // analog white balancing. The Nikon D1 also did digital scaling but |
676 | // this caused problems with highlight recovery. |
677 | |
678 | dng_vector fAnalogBalance; |
679 | |
680 | // The "As Shot" neutral color coordinates in native camera space. |
681 | // This overrides fCameraWhiteXY if both are specified. This |
682 | // specifies the values per channel that would result in a neutral |
683 | // color for the "As Shot" case. This is generally supplied by |
684 | // the camera. |
685 | |
686 | dng_vector fCameraNeutral; |
687 | |
688 | // The "As Shot" white balance xy coordinates. Sometimes this is |
689 | // supplied by the camera. Sometimes the camera just supplies a name |
690 | // for the white balance. |
691 | |
692 | dng_xy_coord fCameraWhiteXY; |
693 | |
694 | // Individual camera calibrations. |
695 | |
696 | // Camera data --> camera calibration --> "inverse" of color matrix |
697 | |
698 | // This will be a 4x4 matrix for a 4-color camera. The defaults are |
699 | // almost always the identity matrix and for the cases where they |
700 | // aren't, they are diagonal matrices. |
701 | |
702 | dng_matrix fCameraCalibration1; |
703 | dng_matrix fCameraCalibration2; |
704 | |
705 | // Signature which allows a profile to announce that it is compatible |
706 | // with these calibration matrices. |
707 | |
708 | dng_string fCameraCalibrationSignature; |
709 | |
710 | // List of camera profiles. |
711 | |
712 | dng_std_vector<dng_camera_profile *> fCameraProfile; |
713 | |
714 | // "As shot" camera profile name. |
715 | |
716 | dng_string fAsShotProfileName; |
717 | |
718 | // Raw image data digests. These are MD5 fingerprints of the raw image data |
719 | // in the file, computed using a specific algorithms. They can be used |
720 | // verify the raw data has not been corrupted. The new version is faster |
721 | // to compute on MP machines, and is used starting with DNG version 1.4. |
722 | |
723 | mutable dng_fingerprint fRawImageDigest; |
724 | |
725 | mutable dng_fingerprint fNewRawImageDigest; |
726 | |
727 | // Raw data unique ID. This is an unique identifer for the actual |
728 | // raw image data in the file. It can be used to index into caches |
729 | // for this data. |
730 | |
731 | mutable dng_fingerprint fRawDataUniqueID; |
732 | |
733 | // Original raw file name. Just the file name, not the full path. |
734 | |
735 | dng_string fOriginalRawFileName; |
736 | |
737 | // Is the original raw file data availaible? |
738 | |
739 | bool fHasOriginalRawFileData; |
740 | |
741 | // The compressed original raw file data. |
742 | |
743 | AutoPtr<dng_memory_block> fOriginalRawFileData; |
744 | |
745 | // MD5 digest of original raw file data block. |
746 | |
747 | mutable dng_fingerprint fOriginalRawFileDigest; |
748 | |
749 | // DNG private data block. |
750 | |
751 | AutoPtr<dng_memory_block> fDNGPrivateData; |
752 | |
753 | // Metadata information (XMP, IPTC, EXIF, orientation) |
754 | |
755 | dng_metadata fMetadata; |
756 | |
757 | // Information required to linearize and range map the raw data. |
758 | |
759 | AutoPtr<dng_linearization_info> fLinearizationInfo; |
760 | |
761 | // Information required to demoasic the raw data. |
762 | |
763 | AutoPtr<dng_mosaic_info> fMosaicInfo; |
764 | |
765 | // Opcode list 1. (Applied to stored data) |
766 | |
767 | dng_opcode_list fOpcodeList1; |
768 | |
769 | // Opcode list 2. (Applied to range mapped data) |
770 | |
771 | dng_opcode_list fOpcodeList2; |
772 | |
773 | // Opcode list 3. (Post demosaic) |
774 | |
775 | dng_opcode_list fOpcodeList3; |
776 | |
777 | // Stage 1 image, which is image data stored in a DNG file. |
778 | |
779 | AutoPtr<dng_image> fStage1Image; |
780 | |
781 | // Stage 2 image, which is the stage 1 image after it has been |
782 | // linearized and range mapped. |
783 | |
784 | AutoPtr<dng_image> fStage2Image; |
785 | |
786 | // Stage 3 image, which is the stage 2 image after it has been |
787 | // demosaiced. |
788 | |
789 | AutoPtr<dng_image> fStage3Image; |
790 | |
791 | // Additiona gain applied when building the stage 3 image. |
792 | |
793 | real64 fStage3Gain; |
794 | |
795 | // Were any approximations (e.g. downsampling, etc.) applied |
796 | // file reading this image? |
797 | |
798 | bool fIsPreview; |
799 | |
800 | // Does the file appear to be damaged? |
801 | |
802 | bool fIsDamaged; |
803 | |
804 | // At what processing stage did we grab a copy of raw image data? |
805 | |
806 | RawImageStageEnum fRawImageStage; |
807 | |
808 | // The raw image data that we grabbed, if any. |
809 | |
810 | AutoPtr<dng_image> fRawImage; |
811 | |
812 | // The floating point bit depth of the raw file, if any. |
813 | |
814 | uint32 fRawFloatBitDepth; |
815 | |
816 | // The raw image JPEG data that we grabbed, if any. |
817 | |
818 | AutoPtr<dng_jpeg_image> fRawJPEGImage; |
819 | |
820 | // Keep a separate digest for the compressed JPEG data, if any. |
821 | |
822 | mutable dng_fingerprint fRawJPEGImageDigest; |
823 | |
824 | // Transparency mask image, if any. |
825 | |
826 | AutoPtr<dng_image> fTransparencyMask; |
827 | |
828 | // Grabbed transparency mask, if we are not saving the current mask. |
829 | |
830 | AutoPtr<dng_image> fRawTransparencyMask; |
831 | |
832 | // The bit depth for the raw transparancy mask, if known. |
833 | |
834 | uint32 fRawTransparencyMaskBitDepth; |
835 | |
836 | // We sometimes need to keep of copy of the stage3 image before |
837 | // flattening the transparency. |
838 | |
839 | AutoPtr<dng_image> fUnflattenedStage3Image; |
840 | |
841 | public: |
842 | |
843 | virtual ~dng_negative (); |
844 | |
845 | static dng_negative * Make (dng_host &host); |
846 | |
847 | /// Provide access to the memory allocator used for this object. |
848 | |
849 | dng_memory_allocator & Allocator () const |
850 | { |
851 | return fAllocator; |
852 | } |
853 | |
854 | /// Getter for ModelName. |
855 | |
856 | void SetModelName (const char *name) |
857 | { |
858 | fModelName.Set_ASCII (name); |
859 | } |
860 | |
861 | /// Setter for ModelName. |
862 | |
863 | const dng_string & ModelName () const |
864 | { |
865 | return fModelName; |
866 | } |
867 | |
868 | /// Setter for LocalName. |
869 | |
870 | void SetLocalName (const char *name) |
871 | { |
872 | fLocalName.Set (name); |
873 | } |
874 | |
875 | /// Getter for LocalName. |
876 | |
877 | const dng_string & LocalName () const |
878 | { |
879 | return fLocalName; |
880 | } |
881 | |
882 | /// Getter for metadata |
883 | |
884 | dng_metadata &Metadata () |
885 | { |
886 | return fMetadata; |
887 | } |
888 | |
889 | #if qMetadataOnConst |
890 | |
891 | const dng_metadata &Metadata () const |
892 | { |
893 | return fMetadata; |
894 | } |
895 | |
896 | #endif // qMetadataOnConst |
897 | |
898 | /// Make a copy of the internal metadata generally as a basis for further |
899 | /// changes. |
900 | |
901 | dng_metadata * CloneInternalMetadata () const; |
902 | |
903 | protected: |
904 | |
905 | /// An accessor for the internal metadata that works even when we |
906 | /// have general access turned off. This is needed to provide |
907 | /// access to EXIF ISO information. |
908 | |
909 | const dng_metadata &InternalMetadata () const |
910 | { |
911 | return fMetadata; |
912 | } |
913 | |
914 | public: |
915 | |
916 | /// Setter for BaseOrientation. |
917 | |
918 | void SetBaseOrientation (const dng_orientation &orientation) |
919 | { |
920 | Metadata ().SetBaseOrientation (orientation); |
921 | } |
922 | |
923 | /// Has BaseOrientation been set? |
924 | |
925 | bool HasBaseOrientation () METACONST |
926 | { |
927 | return Metadata ().HasBaseOrientation (); |
928 | } |
929 | |
930 | /// Getter for BaseOrientation. |
931 | |
932 | const dng_orientation & BaseOrientation () METACONST |
933 | { |
934 | return Metadata ().BaseOrientation (); |
935 | } |
936 | |
937 | /// Hook to allow SDK host code to add additional rotations. |
938 | |
939 | virtual dng_orientation ComputeOrientation (const dng_metadata &metadata) const; |
940 | |
941 | /// For non-const negatives, we simply default to using the metadata attached to the negative. |
942 | |
943 | dng_orientation Orientation () |
944 | { |
945 | return ComputeOrientation (Metadata ()); |
946 | } |
947 | |
948 | /// Logically rotates the image by changing the orientation values. |
949 | /// This will also update the XMP data. |
950 | |
951 | void ApplyOrientation (const dng_orientation &orientation) |
952 | { |
953 | Metadata ().ApplyOrientation (orientation); |
954 | } |
955 | |
956 | /// Setter for DefaultCropSize. |
957 | |
958 | void SetDefaultCropSize (const dng_urational &sizeH, |
959 | const dng_urational &sizeV) |
960 | { |
961 | fDefaultCropSizeH = sizeH; |
962 | fDefaultCropSizeV = sizeV; |
963 | } |
964 | |
965 | /// Setter for DefaultCropSize. |
966 | |
967 | void SetDefaultCropSize (uint32 sizeH, |
968 | uint32 sizeV) |
969 | { |
970 | SetDefaultCropSize (dng_urational (sizeH, 1), |
971 | dng_urational (sizeV, 1)); |
972 | } |
973 | |
974 | /// Getter for DefaultCropSize horizontal. |
975 | |
976 | const dng_urational & DefaultCropSizeH () const |
977 | { |
978 | return fDefaultCropSizeH; |
979 | } |
980 | |
981 | /// Getter for DefaultCropSize vertical. |
982 | |
983 | const dng_urational & DefaultCropSizeV () const |
984 | { |
985 | return fDefaultCropSizeV; |
986 | } |
987 | |
988 | /// Setter for DefaultCropOrigin. |
989 | |
990 | void SetDefaultCropOrigin (const dng_urational &originH, |
991 | const dng_urational &originV) |
992 | { |
993 | fDefaultCropOriginH = originH; |
994 | fDefaultCropOriginV = originV; |
995 | } |
996 | |
997 | /// Setter for DefaultCropOrigin. |
998 | |
999 | void SetDefaultCropOrigin (uint32 originH, |
1000 | uint32 originV) |
1001 | { |
1002 | SetDefaultCropOrigin (dng_urational (originH, 1), |
1003 | dng_urational (originV, 1)); |
1004 | } |
1005 | |
1006 | /// Set default crop around center of image. |
1007 | |
1008 | void SetDefaultCropCentered (const dng_point &rawSize) |
1009 | { |
1010 | |
1011 | uint32 sizeH = Round_uint32 (fDefaultCropSizeH.As_real64 ()); |
1012 | uint32 sizeV = Round_uint32 (fDefaultCropSizeV.As_real64 ()); |
1013 | |
1014 | SetDefaultCropOrigin ((rawSize.h - sizeH) >> 1, |
1015 | (rawSize.v - sizeV) >> 1); |
1016 | |
1017 | } |
1018 | |
1019 | /// Get default crop origin horizontal value. |
1020 | |
1021 | const dng_urational & DefaultCropOriginH () const |
1022 | { |
1023 | return fDefaultCropOriginH; |
1024 | } |
1025 | |
1026 | /// Get default crop origin vertical value. |
1027 | |
1028 | const dng_urational & DefaultCropOriginV () const |
1029 | { |
1030 | return fDefaultCropOriginV; |
1031 | } |
1032 | |
1033 | /// Getter for top coordinate of default user crop. |
1034 | |
1035 | const dng_urational & DefaultUserCropT () const |
1036 | { |
1037 | return fDefaultUserCropT; |
1038 | } |
1039 | |
1040 | /// Getter for left coordinate of default user crop. |
1041 | |
1042 | const dng_urational & DefaultUserCropL () const |
1043 | { |
1044 | return fDefaultUserCropL; |
1045 | } |
1046 | |
1047 | /// Getter for bottom coordinate of default user crop. |
1048 | |
1049 | const dng_urational & DefaultUserCropB () const |
1050 | { |
1051 | return fDefaultUserCropB; |
1052 | } |
1053 | |
1054 | /// Getter for right coordinate of default user crop. |
1055 | |
1056 | const dng_urational & DefaultUserCropR () const |
1057 | { |
1058 | return fDefaultUserCropR; |
1059 | } |
1060 | |
1061 | /// Reset default user crop to default crop area. |
1062 | |
1063 | void ResetDefaultUserCrop () |
1064 | { |
1065 | fDefaultUserCropT = dng_urational (0, 1); |
1066 | fDefaultUserCropL = dng_urational (0, 1); |
1067 | fDefaultUserCropB = dng_urational (1, 1); |
1068 | fDefaultUserCropR = dng_urational (1, 1); |
1069 | } |
1070 | |
1071 | /// Setter for all 4 coordinates of default user crop. |
1072 | |
1073 | void SetDefaultUserCrop (const dng_urational &t, |
1074 | const dng_urational &l, |
1075 | const dng_urational &b, |
1076 | const dng_urational &r) |
1077 | { |
1078 | fDefaultUserCropT = t; |
1079 | fDefaultUserCropL = l; |
1080 | fDefaultUserCropB = b; |
1081 | fDefaultUserCropR = r; |
1082 | } |
1083 | |
1084 | /// Setter for top coordinate of default user crop. |
1085 | |
1086 | void SetDefaultUserCropT (const dng_urational &value) |
1087 | { |
1088 | fDefaultUserCropT = value; |
1089 | } |
1090 | |
1091 | /// Setter for left coordinate of default user crop. |
1092 | |
1093 | void SetDefaultUserCropL (const dng_urational &value) |
1094 | { |
1095 | fDefaultUserCropL = value; |
1096 | } |
1097 | |
1098 | /// Setter for bottom coordinate of default user crop. |
1099 | |
1100 | void SetDefaultUserCropB (const dng_urational &value) |
1101 | { |
1102 | fDefaultUserCropB = value; |
1103 | } |
1104 | |
1105 | /// Setter for right coordinate of default user crop. |
1106 | |
1107 | void SetDefaultUserCropR (const dng_urational &value) |
1108 | { |
1109 | fDefaultUserCropR = value; |
1110 | } |
1111 | |
1112 | /// Setter for DefaultScale. |
1113 | |
1114 | void SetDefaultScale (const dng_urational &scaleH, |
1115 | const dng_urational &scaleV) |
1116 | { |
1117 | fDefaultScaleH = scaleH; |
1118 | fDefaultScaleV = scaleV; |
1119 | } |
1120 | |
1121 | /// Get default scale horizontal value. |
1122 | |
1123 | const dng_urational & DefaultScaleH () const |
1124 | { |
1125 | return fDefaultScaleH; |
1126 | } |
1127 | |
1128 | /// Get default scale vertical value. |
1129 | |
1130 | const dng_urational & DefaultScaleV () const |
1131 | { |
1132 | return fDefaultScaleV; |
1133 | } |
1134 | |
1135 | /// Setter for BestQualityScale. |
1136 | |
1137 | void SetBestQualityScale (const dng_urational &scale) |
1138 | { |
1139 | fBestQualityScale = scale; |
1140 | } |
1141 | |
1142 | /// Getter for BestQualityScale. |
1143 | |
1144 | const dng_urational & BestQualityScale () const |
1145 | { |
1146 | return fBestQualityScale; |
1147 | } |
1148 | |
1149 | /// API for raw to full image scaling factors horizontal. |
1150 | |
1151 | real64 RawToFullScaleH () const |
1152 | { |
1153 | return fRawToFullScaleH; |
1154 | } |
1155 | |
1156 | /// API for raw to full image scaling factors vertical. |
1157 | |
1158 | real64 RawToFullScaleV () const |
1159 | { |
1160 | return fRawToFullScaleV; |
1161 | } |
1162 | |
1163 | /// Setter for raw to full scales. |
1164 | |
1165 | void SetRawToFullScale (real64 scaleH, |
1166 | real64 scaleV) |
1167 | { |
1168 | fRawToFullScaleH = scaleH; |
1169 | fRawToFullScaleV = scaleV; |
1170 | } |
1171 | |
1172 | /// Get default scale factor. |
1173 | /// When specifing a single scale factor, we use the horizontal |
1174 | /// scale factor, and let the vertical scale factor be calculated |
1175 | /// based on the pixel aspect ratio. |
1176 | |
1177 | real64 DefaultScale () const |
1178 | { |
1179 | return DefaultScaleH ().As_real64 (); |
1180 | } |
1181 | |
1182 | /// Default cropped image size (at scale == 1.0) width. |
1183 | |
1184 | real64 SquareWidth () const |
1185 | { |
1186 | return DefaultCropSizeH ().As_real64 (); |
1187 | } |
1188 | |
1189 | /// Default cropped image size (at scale == 1.0) height. |
1190 | |
1191 | real64 SquareHeight () const |
1192 | { |
1193 | return DefaultCropSizeV ().As_real64 () * |
1194 | DefaultScaleV ().As_real64 () / |
1195 | DefaultScaleH ().As_real64 (); |
1196 | } |
1197 | |
1198 | /// Default cropped image aspect ratio. |
1199 | |
1200 | real64 AspectRatio () const |
1201 | { |
1202 | return SquareWidth () / |
1203 | SquareHeight (); |
1204 | } |
1205 | |
1206 | /// Pixel aspect ratio of stage 3 image. |
1207 | |
1208 | real64 PixelAspectRatio () const |
1209 | { |
1210 | return (DefaultScaleH ().As_real64 () / RawToFullScaleH ()) / |
1211 | (DefaultScaleV ().As_real64 () / RawToFullScaleV ()); |
1212 | } |
1213 | |
1214 | /// Default cropped image size at given scale factor width. |
1215 | |
1216 | uint32 FinalWidth (real64 scale) const |
1217 | { |
1218 | return Round_uint32 (SquareWidth () * scale); |
1219 | } |
1220 | |
1221 | /// Default cropped image size at given scale factor height. |
1222 | |
1223 | uint32 FinalHeight (real64 scale) const |
1224 | { |
1225 | return Round_uint32 (SquareHeight () * scale); |
1226 | } |
1227 | |
1228 | /// Default cropped image size at default scale factor width. |
1229 | |
1230 | uint32 DefaultFinalWidth () const |
1231 | { |
1232 | return FinalWidth (DefaultScale ()); |
1233 | } |
1234 | |
1235 | /// Default cropped image size at default scale factor height. |
1236 | |
1237 | uint32 DefaultFinalHeight () const |
1238 | { |
1239 | return FinalHeight (DefaultScale ()); |
1240 | } |
1241 | |
1242 | /// Get best quality width. |
1243 | /// For a naive conversion, one could use either the default size, |
1244 | /// or the best quality size. |
1245 | |
1246 | uint32 BestQualityFinalWidth () const |
1247 | { |
1248 | return FinalWidth (DefaultScale () * BestQualityScale ().As_real64 ()); |
1249 | } |
1250 | |
1251 | /// Get best quality height. |
1252 | /// For a naive conversion, one could use either the default size, |
1253 | /// or the best quality size. |
1254 | |
1255 | uint32 BestQualityFinalHeight () const |
1256 | { |
1257 | return FinalHeight (DefaultScale () * BestQualityScale ().As_real64 ()); |
1258 | } |
1259 | |
1260 | /// Default size of original (non-proxy) image. For non-proxy images, this |
1261 | /// is equal to DefaultFinalWidth/DefaultFinalHight. For proxy images, this |
1262 | /// is equal to the DefaultFinalWidth/DefaultFinalHeight of the image this |
1263 | /// proxy was derived from. |
1264 | |
1265 | const dng_point & OriginalDefaultFinalSize () const |
1266 | { |
1267 | return fOriginalDefaultFinalSize; |
1268 | } |
1269 | |
1270 | /// Setter for OriginalDefaultFinalSize. |
1271 | |
1272 | void SetOriginalDefaultFinalSize (const dng_point &size) |
1273 | { |
1274 | fOriginalDefaultFinalSize = size; |
1275 | } |
1276 | |
1277 | /// Best quality size of original (non-proxy) image. For non-proxy images, this |
1278 | /// is equal to BestQualityFinalWidth/BestQualityFinalHeight. For proxy images, this |
1279 | /// is equal to the BestQualityFinalWidth/BestQualityFinalHeight of the image this |
1280 | /// proxy was derived from. |
1281 | |
1282 | const dng_point & OriginalBestQualityFinalSize () const |
1283 | { |
1284 | return fOriginalBestQualityFinalSize; |
1285 | } |
1286 | |
1287 | /// Setter for OriginalBestQualityFinalSize. |
1288 | |
1289 | void SetOriginalBestQualityFinalSize (const dng_point &size) |
1290 | { |
1291 | fOriginalBestQualityFinalSize = size; |
1292 | } |
1293 | |
1294 | /// DefaultCropSize for original (non-proxy) image. For non-proxy images, |
1295 | /// this is equal to the DefaultCropSize. for proxy images, this is |
1296 | /// equal size of the DefaultCropSize of the image this proxy was derived from. |
1297 | |
1298 | const dng_urational & OriginalDefaultCropSizeH () const |
1299 | { |
1300 | return fOriginalDefaultCropSizeH; |
1301 | } |
1302 | |
1303 | const dng_urational & OriginalDefaultCropSizeV () const |
1304 | { |
1305 | return fOriginalDefaultCropSizeV; |
1306 | } |
1307 | |
1308 | /// Setter for OriginalDefaultCropSize. |
1309 | |
1310 | void SetOriginalDefaultCropSize (const dng_urational &sizeH, |
1311 | const dng_urational &sizeV) |
1312 | { |
1313 | fOriginalDefaultCropSizeH = sizeH; |
1314 | fOriginalDefaultCropSizeV = sizeV; |
1315 | } |
1316 | |
1317 | /// If the original size fields are undefined, set them to the |
1318 | /// current sizes. |
1319 | |
1320 | void SetDefaultOriginalSizes (); |
1321 | |
1322 | /// The default crop area in the stage 3 image coordinates. |
1323 | |
1324 | dng_rect DefaultCropArea () const; |
1325 | |
1326 | /// Setter for BaselineNoise. |
1327 | |
1328 | void SetBaselineNoise (real64 noise) |
1329 | { |
1330 | fBaselineNoise.Set_real64 (noise, 100); |
1331 | } |
1332 | |
1333 | /// Getter for BaselineNoise as dng_urational. |
1334 | |
1335 | const dng_urational & BaselineNoiseR () const |
1336 | { |
1337 | return fBaselineNoise; |
1338 | } |
1339 | |
1340 | /// Getter for BaselineNoise as real64. |
1341 | |
1342 | real64 BaselineNoise () const |
1343 | { |
1344 | return fBaselineNoise.As_real64 (); |
1345 | } |
1346 | |
1347 | /// Setter for NoiseReductionApplied. |
1348 | |
1349 | void SetNoiseReductionApplied (const dng_urational &value) |
1350 | { |
1351 | fNoiseReductionApplied = value; |
1352 | } |
1353 | |
1354 | /// Getter for NoiseReductionApplied. |
1355 | |
1356 | const dng_urational & NoiseReductionApplied () const |
1357 | { |
1358 | return fNoiseReductionApplied; |
1359 | } |
1360 | |
1361 | /// Setter for noise profile. |
1362 | |
1363 | void SetNoiseProfile (const dng_noise_profile &noiseProfile) |
1364 | { |
1365 | fNoiseProfile = noiseProfile; |
1366 | } |
1367 | |
1368 | /// Does this negative have a valid noise profile? |
1369 | |
1370 | bool HasNoiseProfile () const |
1371 | { |
1372 | return fNoiseProfile.IsValidForNegative (*this); |
1373 | } |
1374 | |
1375 | /// Getter for noise profile. |
1376 | |
1377 | const dng_noise_profile & NoiseProfile () const |
1378 | { |
1379 | return fNoiseProfile; |
1380 | } |
1381 | |
1382 | /// Setter for BaselineExposure. |
1383 | |
1384 | void SetBaselineExposure (real64 exposure) |
1385 | { |
1386 | fBaselineExposure.Set_real64 (exposure, 100); |
1387 | } |
1388 | |
1389 | /// Getter for BaselineExposure as dng_urational. |
1390 | |
1391 | const dng_srational & BaselineExposureR () const |
1392 | { |
1393 | return fBaselineExposure; |
1394 | } |
1395 | |
1396 | /// Getter for BaselineExposure as real64. |
1397 | |
1398 | real64 BaselineExposure () const |
1399 | { |
1400 | return BaselineExposureR ().As_real64 (); |
1401 | } |
1402 | |
1403 | /// Compute total baseline exposure (sum of negative's BaselineExposure and |
1404 | /// profile's BaselineExposureOffset). |
1405 | |
1406 | real64 TotalBaselineExposure (const dng_camera_profile_id &profileID) const; |
1407 | |
1408 | /// Setter for BaselineSharpness. |
1409 | |
1410 | void SetBaselineSharpness (real64 sharpness) |
1411 | { |
1412 | fBaselineSharpness.Set_real64 (sharpness, 100); |
1413 | } |
1414 | |
1415 | /// Getter for BaselineSharpness as dng_urational. |
1416 | |
1417 | const dng_urational & BaselineSharpnessR () const |
1418 | { |
1419 | return fBaselineSharpness; |
1420 | } |
1421 | |
1422 | /// Getter for BaselineSharpness as real64. |
1423 | |
1424 | real64 BaselineSharpness () const |
1425 | { |
1426 | return BaselineSharpnessR ().As_real64 (); |
1427 | } |
1428 | |
1429 | /// Setter for ChromaBlurRadius. |
1430 | |
1431 | void SetChromaBlurRadius (const dng_urational &radius) |
1432 | { |
1433 | fChromaBlurRadius = radius; |
1434 | } |
1435 | |
1436 | /// Getter for ChromaBlurRadius as dng_urational. |
1437 | |
1438 | const dng_urational & ChromaBlurRadius () const |
1439 | { |
1440 | return fChromaBlurRadius; |
1441 | } |
1442 | |
1443 | /// Setter for AntiAliasStrength. |
1444 | |
1445 | void SetAntiAliasStrength (const dng_urational &strength) |
1446 | { |
1447 | fAntiAliasStrength = strength; |
1448 | } |
1449 | |
1450 | /// Getter for AntiAliasStrength as dng_urational. |
1451 | |
1452 | const dng_urational & AntiAliasStrength () const |
1453 | { |
1454 | return fAntiAliasStrength; |
1455 | } |
1456 | |
1457 | /// Setter for LinearResponseLimit. |
1458 | |
1459 | void SetLinearResponseLimit (real64 limit) |
1460 | { |
1461 | fLinearResponseLimit.Set_real64 (limit, 100); |
1462 | } |
1463 | |
1464 | /// Getter for LinearResponseLimit as dng_urational. |
1465 | |
1466 | const dng_urational & LinearResponseLimitR () const |
1467 | { |
1468 | return fLinearResponseLimit; |
1469 | } |
1470 | |
1471 | /// Getter for LinearResponseLimit as real64. |
1472 | |
1473 | real64 LinearResponseLimit () const |
1474 | { |
1475 | return LinearResponseLimitR ().As_real64 (); |
1476 | } |
1477 | |
1478 | /// Setter for ShadowScale. |
1479 | |
1480 | void SetShadowScale (const dng_urational &scale); |
1481 | |
1482 | /// Getter for ShadowScale as dng_urational. |
1483 | |
1484 | const dng_urational & ShadowScaleR () const |
1485 | { |
1486 | return fShadowScale; |
1487 | } |
1488 | |
1489 | /// Getter for ShadowScale as real64. |
1490 | |
1491 | real64 ShadowScale () const |
1492 | { |
1493 | return ShadowScaleR ().As_real64 (); |
1494 | } |
1495 | |
1496 | // API for ColorimetricReference. |
1497 | |
1498 | void SetColorimetricReference (uint32 ref) |
1499 | { |
1500 | fColorimetricReference = ref; |
1501 | } |
1502 | |
1503 | uint32 ColorimetricReference () const |
1504 | { |
1505 | return fColorimetricReference; |
1506 | } |
1507 | |
1508 | /// Setter for ColorChannels. |
1509 | |
1510 | void SetColorChannels (uint32 channels) |
1511 | { |
1512 | fColorChannels = channels; |
1513 | } |
1514 | |
1515 | /// Getter for ColorChannels. |
1516 | |
1517 | uint32 ColorChannels () const |
1518 | { |
1519 | return fColorChannels; |
1520 | } |
1521 | |
1522 | /// Setter for Monochrome. |
1523 | |
1524 | void SetMonochrome () |
1525 | { |
1526 | SetColorChannels (1); |
1527 | } |
1528 | |
1529 | /// Getter for Monochrome. |
1530 | |
1531 | bool IsMonochrome () const |
1532 | { |
1533 | return ColorChannels () == 1; |
1534 | } |
1535 | |
1536 | /// Setter for AnalogBalance. |
1537 | |
1538 | void SetAnalogBalance (const dng_vector &b); |
1539 | |
1540 | /// Getter for AnalogBalance as dng_urational. |
1541 | |
1542 | dng_urational AnalogBalanceR (uint32 channel) const; |
1543 | |
1544 | /// Getter for AnalogBalance as real64. |
1545 | |
1546 | real64 AnalogBalance (uint32 channel) const; |
1547 | |
1548 | /// Setter for CameraNeutral. |
1549 | |
1550 | void SetCameraNeutral (const dng_vector &n); |
1551 | |
1552 | /// Clear CameraNeutral. |
1553 | |
1554 | void ClearCameraNeutral () |
1555 | { |
1556 | fCameraNeutral.Clear (); |
1557 | } |
1558 | |
1559 | /// Determine if CameraNeutral has been set but not cleared. |
1560 | |
1561 | bool HasCameraNeutral () const |
1562 | { |
1563 | return fCameraNeutral.NotEmpty (); |
1564 | } |
1565 | |
1566 | /// Getter for CameraNeutral. |
1567 | |
1568 | const dng_vector & CameraNeutral () const |
1569 | { |
1570 | return fCameraNeutral; |
1571 | } |
1572 | |
1573 | dng_urational CameraNeutralR (uint32 channel) const; |
1574 | |
1575 | /// Setter for CameraWhiteXY. |
1576 | |
1577 | void SetCameraWhiteXY (const dng_xy_coord &coord); |
1578 | |
1579 | bool HasCameraWhiteXY () const |
1580 | { |
1581 | return fCameraWhiteXY.IsValid (); |
1582 | } |
1583 | |
1584 | const dng_xy_coord & CameraWhiteXY () const; |
1585 | |
1586 | void GetCameraWhiteXY (dng_urational &x, |
1587 | dng_urational &y) const; |
1588 | |
1589 | // API for camera calibration: |
1590 | |
1591 | /// Setter for first of up to two color matrices used for individual camera calibrations. |
1592 | /// |
1593 | /// The sequence of matrix transforms is: |
1594 | /// Camera data --> camera calibration --> "inverse" of color matrix |
1595 | /// |
1596 | /// This will be a 4x4 matrix for a four-color camera. The defaults are |
1597 | /// almost always the identity matrix, and for the cases where they |
1598 | /// aren't, they are diagonal matrices. |
1599 | |
1600 | void SetCameraCalibration1 (const dng_matrix &m); |
1601 | |
1602 | /// Setter for second of up to two color matrices used for individual camera calibrations. |
1603 | /// |
1604 | /// The sequence of matrix transforms is: |
1605 | /// Camera data --> camera calibration --> "inverse" of color matrix |
1606 | /// |
1607 | /// This will be a 4x4 matrix for a four-color camera. The defaults are |
1608 | /// almost always the identity matrix, and for the cases where they |
1609 | /// aren't, they are diagonal matrices. |
1610 | |
1611 | void SetCameraCalibration2 (const dng_matrix &m); |
1612 | |
1613 | /// Getter for first of up to two color matrices used for individual camera calibrations. |
1614 | |
1615 | const dng_matrix & CameraCalibration1 () const |
1616 | { |
1617 | return fCameraCalibration1; |
1618 | } |
1619 | |
1620 | /// Getter for second of up to two color matrices used for individual camera calibrations. |
1621 | |
1622 | const dng_matrix & CameraCalibration2 () const |
1623 | { |
1624 | return fCameraCalibration2; |
1625 | } |
1626 | |
1627 | void SetCameraCalibrationSignature (const char *signature) |
1628 | { |
1629 | fCameraCalibrationSignature.Set (signature); |
1630 | } |
1631 | |
1632 | const dng_string & CameraCalibrationSignature () const |
1633 | { |
1634 | return fCameraCalibrationSignature; |
1635 | } |
1636 | |
1637 | // Camera Profile API: |
1638 | |
1639 | void AddProfile (AutoPtr<dng_camera_profile> &profile); |
1640 | |
1641 | void ClearProfiles (); |
1642 | |
1643 | void ClearProfiles (bool clearBuiltinMatrixProfiles, |
1644 | bool clearReadFromDisk); |
1645 | |
1646 | uint32 ProfileCount () const; |
1647 | |
1648 | const dng_camera_profile & ProfileByIndex (uint32 index) const; |
1649 | |
1650 | virtual const dng_camera_profile * ProfileByID (const dng_camera_profile_id &id, |
1651 | bool useDefaultIfNoMatch = true) const; |
1652 | |
1653 | bool HasProfileID (const dng_camera_profile_id &id) const |
1654 | { |
1655 | return ProfileByID (id, false) != NULL; |
1656 | } |
1657 | |
1658 | // Returns the camera profile to embed when saving to DNG: |
1659 | |
1660 | virtual const dng_camera_profile * ComputeCameraProfileToEmbed |
1661 | (const dng_metadata &metadata) const; |
1662 | |
1663 | // For non-const negatives, we can use the embedded metadata. |
1664 | |
1665 | const dng_camera_profile * CameraProfileToEmbed () |
1666 | { |
1667 | return ComputeCameraProfileToEmbed (Metadata ()); |
1668 | } |
1669 | |
1670 | // API for AsShotProfileName. |
1671 | |
1672 | void SetAsShotProfileName (const char *name) |
1673 | { |
1674 | fAsShotProfileName.Set (name); |
1675 | } |
1676 | |
1677 | const dng_string & AsShotProfileName () const |
1678 | { |
1679 | return fAsShotProfileName; |
1680 | } |
1681 | |
1682 | // Makes a dng_color_spec object for this negative. |
1683 | |
1684 | virtual dng_color_spec * MakeColorSpec (const dng_camera_profile_id &id) const; |
1685 | |
1686 | // Compute a MD5 hash on an image, using a fixed algorithm. |
1687 | // The results must be stable across different hardware, OSes, |
1688 | // and software versions. |
1689 | |
1690 | dng_fingerprint FindImageDigest (dng_host &host, |
1691 | const dng_image &image) const; |
1692 | |
1693 | // API for RawImageDigest and NewRawImageDigest: |
1694 | |
1695 | void SetRawImageDigest (const dng_fingerprint &digest) |
1696 | { |
1697 | fRawImageDigest = digest; |
1698 | } |
1699 | |
1700 | void SetNewRawImageDigest (const dng_fingerprint &digest) |
1701 | { |
1702 | fNewRawImageDigest = digest; |
1703 | } |
1704 | |
1705 | void ClearRawImageDigest () const |
1706 | { |
1707 | fRawImageDigest .Clear (); |
1708 | fNewRawImageDigest.Clear (); |
1709 | } |
1710 | |
1711 | const dng_fingerprint & RawImageDigest () const |
1712 | { |
1713 | return fRawImageDigest; |
1714 | } |
1715 | |
1716 | const dng_fingerprint & NewRawImageDigest () const |
1717 | { |
1718 | return fNewRawImageDigest; |
1719 | } |
1720 | |
1721 | void FindRawImageDigest (dng_host &host) const; |
1722 | |
1723 | void FindNewRawImageDigest (dng_host &host) const; |
1724 | |
1725 | void ValidateRawImageDigest (dng_host &host); |
1726 | |
1727 | // API for RawDataUniqueID: |
1728 | |
1729 | void SetRawDataUniqueID (const dng_fingerprint &id) |
1730 | { |
1731 | fRawDataUniqueID = id; |
1732 | } |
1733 | |
1734 | const dng_fingerprint & RawDataUniqueID () const |
1735 | { |
1736 | return fRawDataUniqueID; |
1737 | } |
1738 | |
1739 | void FindRawDataUniqueID (dng_host &host) const; |
1740 | |
1741 | void RecomputeRawDataUniqueID (dng_host &host); |
1742 | |
1743 | // API for original raw file name: |
1744 | |
1745 | void SetOriginalRawFileName (const char *name) |
1746 | { |
1747 | fOriginalRawFileName.Set (name); |
1748 | } |
1749 | |
1750 | bool HasOriginalRawFileName () const |
1751 | { |
1752 | return fOriginalRawFileName.NotEmpty (); |
1753 | } |
1754 | |
1755 | const dng_string & OriginalRawFileName () const |
1756 | { |
1757 | return fOriginalRawFileName; |
1758 | } |
1759 | |
1760 | // API for original raw file data: |
1761 | |
1762 | void SetHasOriginalRawFileData (bool hasData) |
1763 | { |
1764 | fHasOriginalRawFileData = hasData; |
1765 | } |
1766 | |
1767 | bool CanEmbedOriginalRaw () const |
1768 | { |
1769 | return fHasOriginalRawFileData && HasOriginalRawFileName (); |
1770 | } |
1771 | |
1772 | void SetOriginalRawFileData (AutoPtr<dng_memory_block> &data) |
1773 | { |
1774 | fOriginalRawFileData.Reset (data.Release ()); |
1775 | } |
1776 | |
1777 | const void * OriginalRawFileData () const |
1778 | { |
1779 | return fOriginalRawFileData.Get () ? fOriginalRawFileData->Buffer () |
1780 | : NULL; |
1781 | } |
1782 | |
1783 | uint32 OriginalRawFileDataLength () const |
1784 | { |
1785 | return fOriginalRawFileData.Get () ? fOriginalRawFileData->LogicalSize () |
1786 | : 0; |
1787 | } |
1788 | |
1789 | // API for original raw file data digest. |
1790 | |
1791 | void SetOriginalRawFileDigest (const dng_fingerprint &digest) |
1792 | { |
1793 | fOriginalRawFileDigest = digest; |
1794 | } |
1795 | |
1796 | const dng_fingerprint & OriginalRawFileDigest () const |
1797 | { |
1798 | return fOriginalRawFileDigest; |
1799 | } |
1800 | |
1801 | void FindOriginalRawFileDigest () const; |
1802 | |
1803 | void ValidateOriginalRawFileDigest (); |
1804 | |
1805 | // API for DNG private data: |
1806 | |
1807 | void SetPrivateData (AutoPtr<dng_memory_block> &block) |
1808 | { |
1809 | fDNGPrivateData.Reset (block.Release ()); |
1810 | } |
1811 | |
1812 | void ClearPrivateData () |
1813 | { |
1814 | fDNGPrivateData.Reset (); |
1815 | } |
1816 | |
1817 | const uint8 * PrivateData () const |
1818 | { |
1819 | return fDNGPrivateData.Get () ? fDNGPrivateData->Buffer_uint8 () |
1820 | : NULL; |
1821 | } |
1822 | |
1823 | uint32 PrivateLength () const |
1824 | { |
1825 | return fDNGPrivateData.Get () ? fDNGPrivateData->LogicalSize () |
1826 | : 0; |
1827 | } |
1828 | |
1829 | // API for MakerNote data: |
1830 | |
1831 | void SetMakerNoteSafety (bool safe) |
1832 | { |
1833 | Metadata ().SetMakerNoteSafety (safe); |
1834 | } |
1835 | |
1836 | bool IsMakerNoteSafe () METACONST |
1837 | { |
1838 | return Metadata ().IsMakerNoteSafe (); |
1839 | } |
1840 | |
1841 | void SetMakerNote (AutoPtr<dng_memory_block> &block) |
1842 | { |
1843 | Metadata ().SetMakerNote (block); |
1844 | } |
1845 | |
1846 | void ClearMakerNote () |
1847 | { |
1848 | Metadata ().ClearMakerNote (); |
1849 | } |
1850 | |
1851 | const void * MakerNoteData () METACONST |
1852 | { |
1853 | return Metadata ().MakerNoteData (); |
1854 | } |
1855 | |
1856 | uint32 MakerNoteLength () METACONST |
1857 | { |
1858 | return Metadata ().MakerNoteLength (); |
1859 | } |
1860 | |
1861 | // API for EXIF metadata: |
1862 | |
1863 | dng_exif * GetExif () |
1864 | { |
1865 | return Metadata ().GetExif (); |
1866 | } |
1867 | |
1868 | #if qMetadataOnConst |
1869 | |
1870 | const dng_exif * GetExif () const |
1871 | { |
1872 | return Metadata ().GetExif (); |
1873 | } |
1874 | |
1875 | #endif // qMetadataOnConst |
1876 | |
1877 | void ResetExif (dng_exif * newExif) |
1878 | { |
1879 | Metadata ().ResetExif (newExif); |
1880 | } |
1881 | |
1882 | // API for original EXIF metadata. |
1883 | |
1884 | dng_exif * GetOriginalExif () |
1885 | { |
1886 | return Metadata ().GetOriginalExif (); |
1887 | } |
1888 | |
1889 | #if qMetadataOnConst |
1890 | |
1891 | const dng_exif * GetOriginalExif () const |
1892 | { |
1893 | return Metadata ().GetOriginalExif (); |
1894 | } |
1895 | |
1896 | #endif // qMetadataOnConst |
1897 | |
1898 | // API for IPTC metadata: |
1899 | |
1900 | void SetIPTC (AutoPtr<dng_memory_block> &block, |
1901 | uint64 offset) |
1902 | { |
1903 | Metadata ().SetIPTC (block, offset); |
1904 | } |
1905 | |
1906 | void SetIPTC (AutoPtr<dng_memory_block> &block) |
1907 | { |
1908 | Metadata ().SetIPTC (block); |
1909 | } |
1910 | |
1911 | void ClearIPTC () |
1912 | { |
1913 | Metadata ().ClearIPTC (); |
1914 | } |
1915 | |
1916 | const void * IPTCData () METACONST |
1917 | { |
1918 | return Metadata ().IPTCData (); |
1919 | } |
1920 | |
1921 | uint32 IPTCLength () METACONST |
1922 | { |
1923 | return Metadata ().IPTCLength (); |
1924 | } |
1925 | |
1926 | uint64 IPTCOffset () METACONST |
1927 | { |
1928 | return Metadata ().IPTCOffset (); |
1929 | } |
1930 | |
1931 | dng_fingerprint IPTCDigest (bool includePadding = true) METACONST |
1932 | { |
1933 | return Metadata ().IPTCDigest (includePadding); |
1934 | } |
1935 | |
1936 | void RebuildIPTC (bool padForTIFF) |
1937 | { |
1938 | Metadata ().RebuildIPTC (Allocator (), padForTIFF); |
1939 | } |
1940 | |
1941 | // API for XMP metadata: |
1942 | |
1943 | #if qDNGUseXMP |
1944 | |
1945 | bool SetXMP (dng_host &host, |
1946 | const void *buffer, |
1947 | uint32 count, |
1948 | bool xmpInSidecar = false, |
1949 | bool xmpIsNewer = false) |
1950 | { |
1951 | return Metadata ().SetXMP (host, |
1952 | buffer, |
1953 | count, |
1954 | xmpInSidecar, |
1955 | xmpIsNewer); |
1956 | } |
1957 | |
1958 | dng_xmp * GetXMP () |
1959 | { |
1960 | return Metadata ().GetXMP (); |
1961 | } |
1962 | |
1963 | #if qMetadataOnConst |
1964 | |
1965 | const dng_xmp * GetXMP () const |
1966 | { |
1967 | return Metadata ().GetXMP (); |
1968 | } |
1969 | |
1970 | #endif // qMetadataOnConst |
1971 | |
1972 | bool XMPinSidecar () METACONST |
1973 | { |
1974 | return Metadata ().XMPinSidecar (); |
1975 | } |
1976 | |
1977 | void ResetXMP (dng_xmp * newXMP) |
1978 | { |
1979 | Metadata ().ResetXMP (newXMP); |
1980 | } |
1981 | |
1982 | void ResetXMPSidecarNewer (dng_xmp * newXMP, bool inSidecar, bool isNewer ) |
1983 | { |
1984 | Metadata ().ResetXMPSidecarNewer (newXMP, inSidecar, isNewer); |
1985 | } |
1986 | |
1987 | bool HaveValidEmbeddedXMP () METACONST |
1988 | { |
1989 | return Metadata ().HaveValidEmbeddedXMP (); |
1990 | } |
1991 | |
1992 | #endif |
1993 | |
1994 | // API for source MIMI type. |
1995 | |
1996 | void SetSourceMIMI (const char *s) |
1997 | { |
1998 | Metadata ().SetSourceMIMI (s); |
1999 | } |
2000 | |
2001 | // API for linearization information: |
2002 | |
2003 | const dng_linearization_info * GetLinearizationInfo () const |
2004 | { |
2005 | return fLinearizationInfo.Get (); |
2006 | } |
2007 | |
2008 | void ClearLinearizationInfo () |
2009 | { |
2010 | fLinearizationInfo.Reset (); |
2011 | } |
2012 | |
2013 | // Linearization curve. Usually used to increase compression ratios |
2014 | // by storing the compressed data in a more visually uniform space. |
2015 | // This is a 16-bit LUT that maps the stored data back to linear. |
2016 | |
2017 | void SetLinearization (AutoPtr<dng_memory_block> &curve); |
2018 | |
2019 | // Active area (non-black masked pixels). These pixels are trimmed |
2020 | // during linearization step. |
2021 | |
2022 | void SetActiveArea (const dng_rect &area); |
2023 | |
2024 | // Areas that are known to contain black masked pixels that can |
2025 | // be used to estimate black levels. |
2026 | |
2027 | void SetMaskedAreas (uint32 count, |
2028 | const dng_rect *area); |
2029 | |
2030 | void SetMaskedArea (const dng_rect &area) |
2031 | { |
2032 | SetMaskedAreas (1, &area); |
2033 | } |
2034 | |
2035 | // Sensor black level information. |
2036 | |
2037 | void SetBlackLevel (real64 black, |
2038 | int32 plane = -1); |
2039 | |
2040 | void SetQuadBlacks (real64 black0, |
2041 | real64 black1, |
2042 | real64 black2, |
2043 | real64 black3, |
2044 | int32 plane = -1); |
2045 | |
2046 | void SetRowBlacks (const real64 *blacks, |
2047 | uint32 count); |
2048 | |
2049 | void SetColumnBlacks (const real64 *blacks, |
2050 | uint32 count); |
2051 | |
2052 | // Sensor white level information. |
2053 | |
2054 | uint32 WhiteLevel (uint32 plane = 0) const; |
2055 | |
2056 | void SetWhiteLevel (uint32 white, |
2057 | int32 plane = -1); |
2058 | |
2059 | // API for mosaic information: |
2060 | |
2061 | const dng_mosaic_info * GetMosaicInfo () const |
2062 | { |
2063 | return fMosaicInfo.Get (); |
2064 | } |
2065 | |
2066 | void ClearMosaicInfo () |
2067 | { |
2068 | fMosaicInfo.Reset (); |
2069 | } |
2070 | |
2071 | // ColorKeys APIs: |
2072 | |
2073 | void SetColorKeys (ColorKeyCode color0, |
2074 | ColorKeyCode color1, |
2075 | ColorKeyCode color2, |
2076 | ColorKeyCode color3 = colorKeyMaxEnum); |
2077 | |
2078 | void SetRGB () |
2079 | { |
2080 | |
2081 | SetColorChannels (3); |
2082 | |
2083 | SetColorKeys (colorKeyRed, |
2084 | colorKeyGreen, |
2085 | colorKeyBlue); |
2086 | |
2087 | } |
2088 | |
2089 | void SetCMY () |
2090 | { |
2091 | |
2092 | SetColorChannels (3); |
2093 | |
2094 | SetColorKeys (colorKeyCyan, |
2095 | colorKeyMagenta, |
2096 | colorKeyYellow); |
2097 | |
2098 | } |
2099 | |
2100 | void SetGMCY () |
2101 | { |
2102 | |
2103 | SetColorChannels (4); |
2104 | |
2105 | SetColorKeys (colorKeyGreen, |
2106 | colorKeyMagenta, |
2107 | colorKeyCyan, |
2108 | colorKeyYellow); |
2109 | |
2110 | } |
2111 | |
2112 | // APIs to set mosaic patterns. |
2113 | |
2114 | void SetBayerMosaic (uint32 phase); |
2115 | |
2116 | void SetFujiMosaic (uint32 phase); |
2117 | |
2118 | void SetFujiMosaic6x6 (uint32 phase); |
2119 | |
2120 | void SetQuadMosaic (uint32 pattern); |
2121 | |
2122 | // BayerGreenSplit. |
2123 | |
2124 | void SetGreenSplit (uint32 split); |
2125 | |
2126 | // APIs for opcode lists. |
2127 | |
2128 | const dng_opcode_list & OpcodeList1 () const |
2129 | { |
2130 | return fOpcodeList1; |
2131 | } |
2132 | |
2133 | dng_opcode_list & OpcodeList1 () |
2134 | { |
2135 | return fOpcodeList1; |
2136 | } |
2137 | |
2138 | const dng_opcode_list & OpcodeList2 () const |
2139 | { |
2140 | return fOpcodeList2; |
2141 | } |
2142 | |
2143 | dng_opcode_list & OpcodeList2 () |
2144 | { |
2145 | return fOpcodeList2; |
2146 | } |
2147 | |
2148 | const dng_opcode_list & OpcodeList3 () const |
2149 | { |
2150 | return fOpcodeList3; |
2151 | } |
2152 | |
2153 | dng_opcode_list & OpcodeList3 () |
2154 | { |
2155 | return fOpcodeList3; |
2156 | } |
2157 | |
2158 | // First part of parsing logic. |
2159 | |
2160 | virtual void Parse (dng_host &host, |
2161 | dng_stream &stream, |
2162 | dng_info &info); |
2163 | |
2164 | // Second part of parsing logic. This is split off from the |
2165 | // first part because these operations are useful when extending |
2166 | // this sdk to support non-DNG raw formats. |
2167 | |
2168 | virtual void PostParse (dng_host &host, |
2169 | dng_stream &stream, |
2170 | dng_info &info); |
2171 | |
2172 | // Synchronize metadata sources. |
2173 | |
2174 | void SynchronizeMetadata () |
2175 | { |
2176 | Metadata ().SynchronizeMetadata (); |
2177 | } |
2178 | |
2179 | // Routines to update the date/time field in the EXIF and XMP |
2180 | // metadata. |
2181 | |
2182 | void UpdateDateTime (const dng_date_time_info &dt) |
2183 | { |
2184 | Metadata ().UpdateDateTime (dt); |
2185 | } |
2186 | |
2187 | void UpdateDateTimeToNow () |
2188 | { |
2189 | Metadata ().UpdateDateTimeToNow (); |
2190 | } |
2191 | |
2192 | // Developer's utility function to switch to four color Bayer |
2193 | // interpolation. This is useful for evaluating how much green |
2194 | // split a Bayer pattern sensor has. |
2195 | |
2196 | virtual bool SetFourColorBayer (); |
2197 | |
2198 | // Access routines for the image stages. |
2199 | |
2200 | const dng_image * Stage1Image () const |
2201 | { |
2202 | return fStage1Image.Get (); |
2203 | } |
2204 | |
2205 | const dng_image * Stage2Image () const |
2206 | { |
2207 | return fStage2Image.Get (); |
2208 | } |
2209 | |
2210 | const dng_image * Stage3Image () const |
2211 | { |
2212 | return fStage3Image.Get (); |
2213 | } |
2214 | |
2215 | // Returns the processing stage of the raw image data. |
2216 | |
2217 | RawImageStageEnum RawImageStage () const |
2218 | { |
2219 | return fRawImageStage; |
2220 | } |
2221 | |
2222 | // Returns the raw image data. |
2223 | |
2224 | const dng_image & RawImage () const; |
2225 | |
2226 | // API for raw floating point bit depth. |
2227 | |
2228 | uint32 RawFloatBitDepth () const |
2229 | { |
2230 | return fRawFloatBitDepth; |
2231 | } |
2232 | |
2233 | void SetRawFloatBitDepth (uint32 bitDepth) |
2234 | { |
2235 | fRawFloatBitDepth = bitDepth; |
2236 | } |
2237 | |
2238 | // API for raw jpeg image. |
2239 | |
2240 | const dng_jpeg_image * RawJPEGImage () const; |
2241 | |
2242 | void SetRawJPEGImage (AutoPtr<dng_jpeg_image> &jpegImage); |
2243 | |
2244 | void ClearRawJPEGImage (); |
2245 | |
2246 | // API for RawJPEGImageDigest: |
2247 | |
2248 | void SetRawJPEGImageDigest (const dng_fingerprint &digest) |
2249 | { |
2250 | fRawJPEGImageDigest = digest; |
2251 | } |
2252 | |
2253 | void ClearRawJPEGImageDigest () const |
2254 | { |
2255 | fRawJPEGImageDigest.Clear (); |
2256 | } |
2257 | |
2258 | const dng_fingerprint & RawJPEGImageDigest () const |
2259 | { |
2260 | return fRawJPEGImageDigest; |
2261 | } |
2262 | |
2263 | void FindRawJPEGImageDigest (dng_host &host) const; |
2264 | |
2265 | // Read the stage 1 image. |
2266 | |
2267 | virtual void ReadStage1Image (dng_host &host, |
2268 | dng_stream &stream, |
2269 | dng_info &info); |
2270 | |
2271 | // Assign the stage 1 image. |
2272 | |
2273 | void SetStage1Image (AutoPtr<dng_image> &image); |
2274 | |
2275 | // Assign the stage 2 image. |
2276 | |
2277 | void SetStage2Image (AutoPtr<dng_image> &image); |
2278 | |
2279 | // Assign the stage 3 image. |
2280 | |
2281 | void SetStage3Image (AutoPtr<dng_image> &image); |
2282 | |
2283 | // Build the stage 2 (linearized and range mapped) image. |
2284 | |
2285 | void BuildStage2Image (dng_host &host); |
2286 | |
2287 | // Build the stage 3 (demosaiced) image. |
2288 | |
2289 | void BuildStage3Image (dng_host &host, |
2290 | int32 srcPlane = -1); |
2291 | |
2292 | // Additional gain applied when building the stage 3 image. |
2293 | |
2294 | void SetStage3Gain (real64 gain) |
2295 | { |
2296 | fStage3Gain = gain; |
2297 | } |
2298 | |
2299 | real64 Stage3Gain () const |
2300 | { |
2301 | return fStage3Gain; |
2302 | } |
2303 | |
2304 | // Adaptively encode a proxy image down to 8-bits/channel. |
2305 | |
2306 | dng_image * EncodeRawProxy (dng_host &host, |
2307 | const dng_image &srcImage, |
2308 | dng_opcode_list &opcodeList) const; |
2309 | |
2310 | // Convert to a proxy negative. |
2311 | |
2312 | void ConvertToProxy (dng_host &host, |
2313 | dng_image_writer &writer, |
2314 | uint32 proxySize = 0, |
2315 | uint64 proxyCount = 0); |
2316 | |
2317 | // IsPreview API: |
2318 | |
2319 | void SetIsPreview (bool preview) |
2320 | { |
2321 | fIsPreview = preview; |
2322 | } |
2323 | |
2324 | bool IsPreview () const |
2325 | { |
2326 | return fIsPreview; |
2327 | } |
2328 | |
2329 | // IsDamaged API: |
2330 | |
2331 | void SetIsDamaged (bool damaged) |
2332 | { |
2333 | fIsDamaged = damaged; |
2334 | } |
2335 | |
2336 | bool IsDamaged () const |
2337 | { |
2338 | return fIsDamaged; |
2339 | } |
2340 | |
2341 | // Transparancy Mask API: |
2342 | |
2343 | void SetTransparencyMask (AutoPtr<dng_image> &image, |
2344 | uint32 bitDepth = 0); |
2345 | |
2346 | const dng_image * TransparencyMask () const; |
2347 | |
2348 | const dng_image * RawTransparencyMask () const; |
2349 | |
2350 | uint32 RawTransparencyMaskBitDepth () const; |
2351 | |
2352 | void ReadTransparencyMask (dng_host &host, |
2353 | dng_stream &stream, |
2354 | dng_info &info); |
2355 | |
2356 | virtual bool NeedFlattenTransparency (dng_host &host); |
2357 | |
2358 | virtual void FlattenTransparency (dng_host &host); |
2359 | |
2360 | const dng_image * UnflattenedStage3Image () const; |
2361 | |
2362 | protected: |
2363 | |
2364 | dng_negative (dng_host &host); |
2365 | |
2366 | virtual void Initialize (); |
2367 | |
2368 | virtual dng_linearization_info * MakeLinearizationInfo (); |
2369 | |
2370 | void NeedLinearizationInfo (); |
2371 | |
2372 | virtual dng_mosaic_info * MakeMosaicInfo (); |
2373 | |
2374 | void NeedMosaicInfo (); |
2375 | |
2376 | virtual void DoBuildStage2 (dng_host &host); |
2377 | |
2378 | virtual void DoPostOpcodeList2 (dng_host &host); |
2379 | |
2380 | virtual bool NeedDefloatStage2 (dng_host &host); |
2381 | |
2382 | virtual void DefloatStage2 (dng_host &host); |
2383 | |
2384 | virtual void DoInterpolateStage3 (dng_host &host, |
2385 | int32 srcPlane); |
2386 | |
2387 | virtual void DoMergeStage3 (dng_host &host); |
2388 | |
2389 | virtual void DoBuildStage3 (dng_host &host, |
2390 | int32 srcPlane); |
2391 | |
2392 | virtual void AdjustProfileForStage3 (); |
2393 | |
2394 | virtual void ResizeTransparencyToMatchStage3 (dng_host &host, |
2395 | bool convertTo8Bit = false); |
2396 | |
2397 | }; |
2398 | |
2399 | /*****************************************************************************/ |
2400 | |
2401 | #endif |
2402 | |
2403 | /*****************************************************************************/ |
2404 | |