HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfDeepFrameBuffer.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef IMFDEEPFRAMEBUFFER_H_
7 #define IMFDEEPFRAMEBUFFER_H_
8 
9 #include "ImfForward.h"
10 
11 #include "ImfFrameBuffer.h"
12 
14 
15 //--------------------------------------------------------
16 // Description of a single deep slice of the frame buffer:
17 //--------------------------------------------------------
18 
20 {
21  //---------------------------------------------------------------------
22  // The stride for each sample in this slice.
23  //
24  // Memory layout: The address of sample i in pixel (x, y) is
25  //
26  // base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
27  // + i * sampleStride
28  //
29  // where xp and yp are computed as follows:
30  //
31  // * If we are reading or writing a scanline-based file:
32  //
33  // xp = x
34  // yp = y
35  //
36  // * If we are reading a tile whose upper left coorner is at (xt, yt):
37  //
38  // if xTileCoords is true then xp = x - xt, else xp = x
39  // if yTileCoords is true then yp = y - yt, else yp = y
40  //
41  //---------------------------------------------------------------------
42 
44 
45  //------------
46  // Constructor
47  //------------
50  char * base = 0,
51  size_t xStride = 0,
52  size_t yStride = 0,
53  size_t sampleStride = 0,
54  int xSampling = 1,
55  int ySampling = 1,
56  double fillValue = 0.0,
57  bool xTileCoords = false,
58  bool yTileCoords = false);
59 };
60 
61 //-----------------
62 // DeepFrameBuffer.
63 //-----------------
64 
66 {
67  public:
68 
69 
70  //------------
71  // Add a slice
72  //------------
73 
75  void insert (const char name[],
76  const DeepSlice &slice);
77 
79  void insert (const std::string &name,
80  const DeepSlice &slice);
81 
82  //----------------------------------------------------------------
83  // Access to existing slices:
84  //
85  // [n] Returns a reference to the slice with name n.
86  // If no slice with name n exists, an IEX_NAMESPACE::ArgExc
87  // is thrown.
88  //
89  // findSlice(n) Returns a pointer to the slice with name n,
90  // or 0 if no slice with name n exists.
91  //
92  //----------------------------------------------------------------
93 
95  DeepSlice & operator [] (const char name[]);
97  const DeepSlice & operator [] (const char name[]) const;
98 
100  DeepSlice & operator [] (const std::string &name);
101  IMF_EXPORT
102  const DeepSlice & operator [] (const std::string &name) const;
103 
104  IMF_EXPORT
105  DeepSlice * findSlice (const char name[]);
106  IMF_EXPORT
107  const DeepSlice * findSlice (const char name[]) const;
108 
109  IMF_EXPORT
110  DeepSlice * findSlice (const std::string &name);
111  IMF_EXPORT
112  const DeepSlice * findSlice (const std::string &name) const;
113 
114 
115  //-----------------------------------------
116  // Iterator-style access to existing slices
117  //-----------------------------------------
118 
119  typedef std::map <Name, DeepSlice> SliceMap;
120 
121  class Iterator;
122  class ConstIterator;
123 
124  IMF_EXPORT
125  Iterator begin ();
126  IMF_EXPORT
127  ConstIterator begin () const;
128 
129  IMF_EXPORT
130  Iterator end ();
131  IMF_EXPORT
132  ConstIterator end () const;
133 
134  IMF_EXPORT
135  Iterator find (const char name[]);
136  IMF_EXPORT
137  ConstIterator find (const char name[]) const;
138 
139  IMF_EXPORT
140  Iterator find (const std::string &name);
141  IMF_EXPORT
142  ConstIterator find (const std::string &name) const;
143 
144  //----------------------------------------------------
145  // Public function for accessing a sample count slice.
146  //----------------------------------------------------
147 
148  IMF_EXPORT
149  void insertSampleCountSlice(const Slice & slice);
150  IMF_EXPORT
151  const Slice & getSampleCountSlice() const;
152 
153  private:
154 
155  SliceMap _map;
156  Slice _sampleCounts;
157 };
158 
159 //----------
160 // Iterators
161 //----------
162 
163 class IMF_EXPORT_TYPE DeepFrameBuffer::Iterator
164 {
165  public:
166 
167  IMF_EXPORT
168  Iterator ();
169  IMF_EXPORT
170  Iterator (const DeepFrameBuffer::SliceMap::iterator &i);
171 
172  IMF_EXPORT
173  Iterator & operator ++ ();
174  IMF_EXPORT
175  Iterator operator ++ (int);
176 
177  IMF_EXPORT
178  const char * name () const;
179  IMF_EXPORT
180  DeepSlice & slice () const;
181 
182  private:
183 
185 
186  DeepFrameBuffer::SliceMap::iterator _i;
187 };
188 
189 
190 class IMF_EXPORT_TYPE DeepFrameBuffer::ConstIterator
191 {
192  public:
193 
194  IMF_EXPORT
195  ConstIterator ();
196  IMF_EXPORT
197  ConstIterator (const DeepFrameBuffer::SliceMap::const_iterator &i);
198  IMF_EXPORT
199  ConstIterator (const DeepFrameBuffer::Iterator &other);
200 
201  IMF_EXPORT
202  ConstIterator & operator ++ ();
203  IMF_EXPORT
204  ConstIterator operator ++ (int);
205 
206  IMF_EXPORT
207  const char * name () const;
208  IMF_EXPORT
209  const DeepSlice & slice () const;
210 
211  private:
212 
213  friend bool operator == (const ConstIterator &, const ConstIterator &);
214  friend bool operator != (const ConstIterator &, const ConstIterator &);
215 
216  DeepFrameBuffer::SliceMap::const_iterator _i;
217 };
218 
219 
220 //-----------------
221 // Inline Functions
222 //-----------------
223 
224 inline
225 DeepFrameBuffer::Iterator::Iterator (): _i()
226 {
227  // empty
228 }
229 
230 
231 inline
232 DeepFrameBuffer::Iterator::Iterator (const DeepFrameBuffer::SliceMap::iterator &i):
233  _i (i)
234 {
235  // empty
236 }
237 
238 
240 DeepFrameBuffer::Iterator::operator ++ ()
241 {
242  ++_i;
243  return *this;
244 }
245 
246 
248 DeepFrameBuffer::Iterator::operator ++ (int)
249 {
250  Iterator tmp = *this;
251  ++_i;
252  return tmp;
253 }
254 
255 
256 inline const char *
258 {
259  return *_i->first;
260 }
261 
262 
263 inline DeepSlice &
264 DeepFrameBuffer::Iterator::slice () const
265 {
266  return _i->second;
267 }
268 
269 
270 inline
271 DeepFrameBuffer::ConstIterator::ConstIterator (): _i()
272 {
273  // empty
274 }
275 
276 inline
277 DeepFrameBuffer::ConstIterator::ConstIterator
278  (const DeepFrameBuffer::SliceMap::const_iterator &i): _i (i)
279 {
280  // empty
281 }
282 
283 
284 inline
285 DeepFrameBuffer::ConstIterator::ConstIterator (const DeepFrameBuffer::Iterator &other):
286  _i (other._i)
287 {
288  // empty
289 }
290 
292 DeepFrameBuffer::ConstIterator::operator ++ ()
293 {
294  ++_i;
295  return *this;
296 }
297 
298 
300 DeepFrameBuffer::ConstIterator::operator ++ (int)
301 {
302  ConstIterator tmp = *this;
303  ++_i;
304  return tmp;
305 }
306 
307 
308 inline const char *
310 {
311  return *_i->first;
312 }
313 
314 inline const DeepSlice &
315 DeepFrameBuffer::ConstIterator::slice () const
316 {
317  return _i->second;
318 }
319 
320 
321 inline bool
324 {
325  return x._i == y._i;
326 }
327 
328 
329 inline bool
332 {
333  return !(x == y);
334 }
335 
336 
338 
339 
340 
341 
342 
343 
344 #endif /* IMFDEEPFRAMEBUFFER_H_ */
IMF_EXPORT Iterator()
IMF_EXPORT ConstIterator()
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:80
HALF
Definition: ImfPixelType.h:25
GLuint const GLchar * name
Definition: glcorearb.h:786
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
Definition: simd.h:3436
bool operator==(const DeepFrameBuffer::ConstIterator &x, const DeepFrameBuffer::ConstIterator &y)
GLint GLenum GLint x
Definition: glcorearb.h:409
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER enum IMF_EXPORT_ENUM PixelType
Definition: ImfPixelType.h:22
GLuint GLuint end
Definition: glcorearb.h:475
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:570
struct IMF_EXPORT_TYPE DeepSlice
Definition: ImfForward.h:77
#define IMF_EXPORT
Definition: ImfExport.h:54
bool operator!=(const DeepFrameBuffer::ConstIterator &x, const DeepFrameBuffer::ConstIterator &y)
std::map< Name, DeepSlice > SliceMap
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:79
type
Definition: core.h:1059
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
GLint y
Definition: glcorearb.h:103
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2089
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:450