Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_linearization_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 linearization table and black level tags.
11 */
12
13 /*****************************************************************************/
14
15 #ifndef __dng_linearization_info__
16 #define __dng_linearization_info__
17
18 /*****************************************************************************/
19
20 #include "dng_auto_ptr.h"
21 #include "dng_classes.h"
22 #include "dng_memory.h"
23 #include "dng_rational.h"
24 #include "dng_rect.h"
25 #include "dng_sdk_limits.h"
26
27 /*****************************************************************************/
28
29 /// @brief Class for managing data values related to DNG linearization.
30 ///
31 /// See LinearizationTable, BlackLevel, BlackLevelRepeatDim, BlackLevelDeltaH,
32 /// BlackLevelDeltaV and WhiteLevel tags in the \ref spec_dng "DNG 1.1.0 specification".
33
34 class dng_linearization_info
35 {
36
37 public:
38
39 /// This rectangle defines the active (non-masked) pixels of the sensor.
40 /// The order of the rectangle coordinates is: top, left, bottom, right.
41
42 dng_rect fActiveArea;
43
44 /// Number of rectangles in fMaskedArea
45
46 uint32 fMaskedAreaCount;
47
48 /// List of non-overlapping rectangle coordinates of fully masked pixels.
49 /// Can be optionally used by DNG readers to measure the black encoding level.
50 /// The order of each rectangle's coordinates is: top, left, bottom, right.
51 /// If the raw image data has already had its black encoding level subtracted, then this tag should
52 /// not be used, since the masked pixels are no longer useful.
53 /// Note that DNG writers are still required to include an estimate and store the black encoding level
54 /// using the black level DNG tags. Support for the MaskedAreas tag is not required of DNG
55 /// readers.
56
57 dng_rect fMaskedArea [kMaxMaskedAreas];
58
59 /// A lookup table that maps stored values into linear values.
60 /// This tag is typically used to increase compression ratios by storing the raw data in a non-linear, more
61 /// visually uniform space with fewer total encoding levels.
62 /// If SamplesPerPixel is not equal to one, e.g. Fuji S3 type sensor, this single table applies to all the samples for each
63 /// pixel.
64
65 AutoPtr<dng_memory_block> fLinearizationTable;
66
67 /// Actual number of rows in fBlackLevel pattern
68
69 uint32 fBlackLevelRepeatRows;
70
71 /// Actual number of columns in fBlackLevel pattern
72
73 uint32 fBlackLevelRepeatCols;
74
75 /// Repeating pattern of black level deltas fBlackLevelRepeatRows by fBlackLevelRepeatCols in size.
76
77 real64 fBlackLevel [kMaxBlackPattern] [kMaxBlackPattern] [kMaxColorPlanes];
78
79 /// Memory block of double-precision floating point deltas between baseline black level and a given column's black level
80
81 AutoPtr<dng_memory_block> fBlackDeltaH;
82
83 /// Memory block of double-precision floating point deltas between baseline black level and a given row's black level
84
85 AutoPtr<dng_memory_block> fBlackDeltaV;
86
87 /// Single white level (maximum sensor value) for each sample plane.
88
89 real64 fWhiteLevel [kMaxColorPlanes];
90
91 protected:
92
93 int32 fBlackDenom;
94
95 public:
96
97 dng_linearization_info ();
98
99 virtual ~dng_linearization_info ();
100
101 void RoundBlacks ();
102
103 virtual void Parse (dng_host &host,
104 dng_stream &stream,
105 dng_info &info);
106
107 virtual void PostParse (dng_host &host,
108 dng_negative &negative);
109
110 /// Compute the maximum black level for a given sample plane taking into account base
111 /// black level, repeated black level patter, and row/column delta maps.
112
113 real64 MaxBlackLevel (uint32 plane) const;
114
115 /// Convert raw data from in-file format to a true linear image using linearization data from DNG.
116 /// \param host Used to allocate buffers, check for aborts, and post progress updates.
117 /// \param negative Used to remember preserved black point.
118 /// \param srcImage Input pre-linearization RAW samples.
119 /// \param dstImage Output linearized image.
120
121 virtual void Linearize (dng_host &host,
122 dng_negative &negative,
123 const dng_image &srcImage,
124 dng_image &dstImage);
125
126 /// Compute black level for one coordinate and sample plane in the image.
127 /// \param row Row to compute black level for.
128 /// \param col Column to compute black level for.
129 /// \param plane Sample plane to compute black level for.
130
131 dng_urational BlackLevel (uint32 row,
132 uint32 col,
133 uint32 plane) const;
134
135 /// Number of per-row black level deltas in fBlackDeltaV.
136
137 uint32 RowBlackCount () const;
138
139 /// Lookup black level delta for a given row.
140 /// \param row Row to get black level for.
141 /// \retval black level for indicated row.
142
143 dng_srational RowBlack (uint32 row) const;
144
145 /// Number of per-column black level deltas in fBlackDeltaV.
146
147 uint32 ColumnBlackCount () const;
148
149 /// Lookup black level delta for a given column.
150 /// \param col Column to get black level for.
151 /// \retval black level for indicated column.
152
153 dng_srational ColumnBlack (uint32 col) const;
154
155 };
156
157 /*****************************************************************************/
158
159 #endif
160
161 /*****************************************************************************/