Coverage Report

Created: 2021-08-22 09:07

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