Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_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 * Class for holding top-level information about a DNG image.
11 */
12
13 /*****************************************************************************/
14
15 #ifndef __dng_info__
16 #define __dng_info__
17
18 /*****************************************************************************/
19
20 #include "dng_auto_ptr.h"
21 #include "dng_classes.h"
22 #include "dng_errors.h"
23 #include "dng_exif.h"
24 #include "dng_ifd.h"
25 #include "dng_sdk_limits.h"
26 #include "dng_shared.h"
27 #include "dng_uncopyable.h"
28
29 #include <vector>
30
31 /*****************************************************************************/
32
33 /// @brief Top-level structure of DNG file with access to metadata.
34 ///
35 /// See \ref spec_dng "DNG 1.1.0 specification" for information on member fields of this class.
36
37 class dng_info: private dng_uncopyable
38 {
39
40 public:
41
42 uint64 fTIFFBlockOffset;
43
44 uint64 fTIFFBlockOriginalOffset;
45
46 bool fBigEndian;
47
48 uint32 fMagic;
49
50 AutoPtr<dng_exif> fExif;
51
52 AutoPtr<dng_shared> fShared;
53
54 int32 fMainIndex;
55
56 int32 fMaskIndex;
57
58 int32 fDepthIndex;
59
60 int32 fEnhancedIndex;
61
62 std::vector<uint32> fSemanticMaskIndices;
63
64 std::vector <dng_ifd *> fIFD;
65
66 std::vector <dng_ifd *> fChainedIFD;
67
68 std::vector <std::vector <dng_ifd *> > fChainedSubIFD;
69
70 AutoPtr<dng_memory_block> fXMPBlock;
71
72 protected:
73
74 uint32 fMakerNoteNextIFD;
75
76 uint32 fParseDepth = 0;
77
78 public:
79
80 dng_info ();
81
82 virtual ~dng_info ();
83
84 /// Returns the number of parsed SubIFDs (including the main IFD).
85
86 uint32 IFDCount () const
87 {
88 return (uint32) fIFD.size ();
89 }
90
91 /// Returns the number of chained IFDs.
92
93 uint32 ChainedIFDCount () const
94 {
95 return (uint32) fChainedIFD.size ();
96 }
97
98 /// Returns number SubIFDs for a chained IFD.
99
100 uint32 ChainedSubIFDCount (uint32 chainIndex) const
101 {
102 if (chainIndex >= fChainedSubIFD.size ())
103 return 0;
104 else
105 return (uint32) fChainedSubIFD [chainIndex].size ();
106 }
107
108 /// Read dng_info from a dng_stream
109 /// \param host DNG host used for progress updating, abort testing, buffer allocation, etc.
110 /// \param stream Stream to read DNG data from.
111
112 virtual void Parse (dng_host &host,
113 dng_stream &stream);
114
115 /// Must be called immediately after a successful Parse operation.
116
117 virtual void PostParse (dng_host &host);
118
119 /// Test validity of DNG data.
120 /// \retval true if stream provided a valid DNG.
121
122 virtual bool IsValidDNG ();
123
124 protected:
125
126 virtual void ValidateMagic ();
127
128 virtual void ParseTag (dng_host &host,
129 dng_stream &stream,
130 dng_exif *exif,
131 dng_shared *shared,
132 dng_ifd *ifd,
133 uint32 parentCode,
134 uint32 tagCode,
135 uint32 tagType,
136 uint32 tagCount,
137 uint64 tagOffset,
138 int64 offsetDelta);
139
140 virtual bool ValidateIFD (dng_stream &stream,
141 uint64 ifdOffset,
142 int64 offsetDelta);
143
144 virtual void ParseIFD (dng_host &host,
145 dng_stream &stream,
146 dng_exif *exif,
147 dng_shared *shared,
148 dng_ifd *ifd,
149 uint64 ifdOffset,
150 int64 offsetDelta,
151 uint32 parentCode);
152
153 virtual bool ParseMakerNoteIFD (dng_host &host,
154 dng_stream &stream,
155 uint64 ifdSize,
156 uint64 ifdOffset,
157 int64 offsetDelta,
158 uint64 minOffset,
159 uint64 maxOffset,
160 uint32 parentCode);
161
162 virtual void ParseMakerNote (dng_host &host,
163 dng_stream &stream,
164 uint32 makerNoteCount,
165 uint64 makerNoteOffset,
166 int64 offsetDelta,
167 uint64 minOffset,
168 uint64 maxOffset);
169
170 virtual void ParseSonyPrivateData (dng_host &host,
171 dng_stream &stream,
172 uint64 count,
173 uint64 oldOffset,
174 uint64 newOffset);
175
176 virtual void ParseDNGPrivateData (dng_host &host,
177 dng_stream &stream);
178
179 protected:
180
181 class RecursionProtector
182 {
183
184 private:
185
186 uint32 &fDepth;
187
188 public:
189
190 RecursionProtector (uint32 &depth)
191 : fDepth (depth)
192 {
193 fDepth++;
194 }
195
196 ~RecursionProtector ()
197 {
198 fDepth--;
199 }
200
201 };
202
203 };
204
205 /*****************************************************************************/
206
207 #endif
208
209 /*****************************************************************************/