Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_mosaic_info.h

raw
1 /*****************************************************************************/
2 // Copyright 2006-2019 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 /** \file
10 * Support for descriptive information about color filter array patterns.
11 */
12
13 /*****************************************************************************/
14
15 #ifndef __dng_mosaic_info__
16 #define __dng_mosaic_info__
17
18 /*****************************************************************************/
19
20 #include "dng_classes.h"
21 #include "dng_rect.h"
22 #include "dng_sdk_limits.h"
23 #include "dng_types.h"
24
25 /*****************************************************************************/
26
27 /// @brief Support for describing color filter array patterns and manipulating mosaic sample data.
28 ///
29 /// See CFAPattern tag in \ref spec_tiff_ep "TIFF/EP specification" and CFAPlaneColor, CFALayout, and BayerGreenSplit
30 /// tags in the \ref spec_dng "DNG 1.1.0 specification".
31
32 class dng_mosaic_info
33 {
34
35 public:
36
37 /// Size of fCFAPattern.
38
39 dng_point fCFAPatternSize;
40
41 /// CFA pattern from CFAPattern tag in the \ref spec_tiff_ep "TIFF/EP specification."
42
43 uint8 fCFAPattern [kMaxCFAPattern] [kMaxCFAPattern];
44
45 /// Number of color planes in DNG input.
46
47 uint32 fColorPlanes;
48
49 uint8 fCFAPlaneColor [kMaxColorPlanes];
50
51 /// Value of CFALayout tag in the \ref spec_dng "DNG 1.3 specification."
52 /// CFALayout describes the spatial layout of the CFA. The currently defined values are:
53 /// - 1 = Rectangular (or square) layout.
54 /// - 2 = Staggered layout A: even columns are offset down by 1/2 row.
55 /// - 3 = Staggered layout B: even columns are offset up by 1/2 row.
56 /// - 4 = Staggered layout C: even rows are offset right by 1/2 column.
57 /// - 5 = Staggered layout D: even rows are offset left by 1/2 column.
58 /// - 6 = Staggered layout E: even rows are offset up by 1/2 row, even columns are offset left by 1/2 column.
59 /// - 7 = Staggered layout F: even rows are offset up by 1/2 row, even columns are offset right by 1/2 column.
60 /// - 8 = Staggered layout G: even rows are offset down by 1/2 row, even columns are offset left by 1/2 column.
61 /// - 9 = Staggered layout H: even rows are offset down by 1/2 row, even columns are offset right by 1/2 column.
62
63 uint32 fCFALayout;
64
65 /// Value of BayerGreeSplit tag in DNG file.
66 /// BayerGreenSplit only applies to CFA images using a Bayer pattern filter array. This tag
67 /// specifies, in arbitrary units, how closely the values of the green pixels in the blue/green rows
68 /// track the values of the green pixels in the red/green rows.
69 ///
70 /// A value of zero means the two kinds of green pixels track closely, while a non-zero value
71 /// means they sometimes diverge. The useful range for this tag is from 0 (no divergence) to about
72 /// 5000 (large divergence).
73
74 uint32 fBayerGreenSplit;
75
76 protected:
77
78 dng_point fSrcSize;
79
80 dng_point fCroppedSize;
81
82 real64 fAspectRatio;
83
84 public:
85
86 dng_mosaic_info ();
87
88 virtual ~dng_mosaic_info ();
89
90 virtual void Parse (dng_host &host,
91 dng_stream &stream,
92 dng_info &info);
93
94 virtual void PostParse (dng_host &host,
95 dng_negative &negative);
96
97 /// Returns whether the RAW data in this DNG file from a color filter array (mosaiced) source.
98 /// \retval true if this DNG file is from a color filter array (mosiaced) source.
99
100 bool IsColorFilterArray () const
101 {
102 return fCFAPatternSize != dng_point (0, 0);
103 }
104
105 /// Enable generating four-plane output from three-plane Bayer input.
106 /// Extra plane is a second version of the green channel. First green is produced
107 /// using green mosaic samples from one set of rows/columns (even/odd) and the second
108 /// green channel is produced using the other set of rows/columns. One can compare the
109 /// two versions to judge whether BayerGreenSplit needs to be set for a given input source.
110
111 virtual bool SetFourColorBayer ();
112
113 /// Returns scaling factor relative to input size needed to capture output data.
114 /// Staggered (or rotated) sensing arrays are produced to a larger output than the number of input samples.
115 /// This method indicates how much larger.
116 /// \retval a point with integer scaling factors for the horizotal and vertical dimensions.
117
118 virtual dng_point FullScale () const;
119
120 /// Returns integer factors by which mosaic data must be downsampled to produce an image which is as close
121 /// to prefSize as possible in longer dimension, but no smaller than minSize.
122 /// \param minSize Number of pixels as minium for longer dimension of downsampled image.
123 /// \param prefSize Number of pixels as target for longer dimension of downsampled image.
124 /// \param cropFactor Faction of the image to be used after cropping.
125 /// \retval Point containing integer factors by which image must be downsampled.
126
127 virtual dng_point DownScale (uint32 minSize,
128 uint32 prefSize,
129 real64 cropFactor) const;
130
131 /// Return size of demosaiced image for passed in downscaling factor.
132 /// \param downScale Integer downsampling factor obtained from DownScale method.
133 /// \retval Size of resulting demosaiced image.
134
135 virtual dng_point DstSize (const dng_point &downScale) const;
136
137 /// Demosaic interpolation of a single plane for non-downsampled case.
138 /// \param host dng_host to use for buffer allocation requests, user cancellation testing, and progress updates.
139 /// \param negative DNG negative of mosaiced data.
140 /// \param srcImage Source image for mosaiced data.
141 /// \param dstImage Destination image for resulting interpolated data.
142 /// \param srcPlane Which plane to interpolate.
143
144 virtual void InterpolateGeneric (dng_host &host,
145 dng_negative &negative,
146 const dng_image &srcImage,
147 dng_image &dstImage,
148 uint32 srcPlane = 0) const;
149
150 /// Demosaic interpolation of a single plane for downsampled case.
151 /// \param host dng_host to use for buffer allocation requests, user cancellation testing, and progress updates.
152 /// \param negative DNG negative of mosaiced data.
153 /// \param srcImage Source image for mosaiced data.
154 /// \param dstImage Destination image for resulting interpolated data.
155 /// \param downScale Amount (in horizontal and vertical) by which to subsample image.
156 /// \param srcPlane Which plane to interpolate.
157
158 virtual void InterpolateFast (dng_host &host,
159 dng_negative &negative,
160 const dng_image &srcImage,
161 dng_image &dstImage,
162 const dng_point &downScale,
163 uint32 srcPlane = 0) const;
164
165 /// Demosaic interpolation of a single plane. Chooses between generic and fast interpolators based on parameters.
166 /// \param host dng_host to use for buffer allocation requests, user cancellation testing, and progress updates.
167 /// \param negative DNG negative of mosaiced data.
168 /// \param srcImage Source image for mosaiced data.
169 /// \param dstImage Destination image for resulting interpolated data.
170 /// \param downScale Amount (in horizontal and vertical) by which to subsample image.
171 /// \param srcPlane Which plane to interpolate.
172
173 virtual void Interpolate (dng_host &host,
174 dng_negative &negative,
175 const dng_image &srcImage,
176 dng_image &dstImage,
177 const dng_point &downScale,
178 uint32 srcPlane = 0,
179 dng_matrix *scaleTransforms = NULL) const;
180
181 virtual bool SupportsPreservedBlackLevels () const;
182
183 protected:
184
185 virtual bool IsSafeDownScale (const dng_point &downScale) const;
186
187 uint32 SizeForDownScale (const dng_point &downScale) const;
188
189 virtual bool ValidSizeDownScale (const dng_point &downScale,
190 uint32 minSize) const;
191
192 };
193
194 /*****************************************************************************/
195
196 #endif
197
198 /*****************************************************************************/