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  //------------
49  DeepSlice (
51  char* base = 0,
52  size_t xStride = 0,
53  size_t yStride = 0,
54  size_t sampleStride = 0,
55  int xSampling = 1,
56  int ySampling = 1,
57  double fillValue = 0.0,
58  bool xTileCoords = false,
59  bool yTileCoords = false);
60 };
61 
62 //-----------------
63 // DeepFrameBuffer.
64 //-----------------
65 
67 {
68 public:
69  //------------
70  // Add a slice
71  //------------
72 
74  void insert (const char name[], const DeepSlice& slice);
75 
77  void insert (const std::string& name, const DeepSlice& slice);
78 
79  //----------------------------------------------------------------
80  // Access to existing slices:
81  //
82  // [n] Returns a reference to the slice with name n.
83  // If no slice with name n exists, an IEX_NAMESPACE::ArgExc
84  // is thrown.
85  //
86  // findSlice(n) Returns a pointer to the slice with name n,
87  // or 0 if no slice with name n exists.
88  //
89  //----------------------------------------------------------------
90 
92  DeepSlice& operator[] (const char name[]);
94  const DeepSlice& operator[] (const char name[]) const;
95 
97  DeepSlice& operator[] (const std::string& name);
99  const DeepSlice& operator[] (const std::string& name) const;
100 
101  IMF_EXPORT
102  DeepSlice* findSlice (const char name[]);
103  IMF_EXPORT
104  const DeepSlice* findSlice (const char name[]) const;
105 
106  IMF_EXPORT
107  DeepSlice* findSlice (const std::string& name);
108  IMF_EXPORT
109  const DeepSlice* findSlice (const std::string& name) const;
110 
111  //-----------------------------------------
112  // Iterator-style access to existing slices
113  //-----------------------------------------
114 
115  typedef std::map<Name, DeepSlice> SliceMap;
116 
117  class Iterator;
118  class ConstIterator;
119 
120  IMF_EXPORT
121  Iterator begin ();
122  IMF_EXPORT
123  ConstIterator begin () const;
124 
125  IMF_EXPORT
126  Iterator end ();
127  IMF_EXPORT
128  ConstIterator end () const;
129 
130  IMF_EXPORT
131  Iterator find (const char name[]);
132  IMF_EXPORT
133  ConstIterator find (const char name[]) const;
134 
135  IMF_EXPORT
136  Iterator find (const std::string& name);
137  IMF_EXPORT
138  ConstIterator find (const std::string& name) const;
139 
140  //----------------------------------------------------
141  // Public function for accessing a sample count slice.
142  //----------------------------------------------------
143 
144  IMF_EXPORT
145  void insertSampleCountSlice (const Slice& slice);
146  IMF_EXPORT
147  const Slice& getSampleCountSlice () const;
148 
149 private:
150  SliceMap _map;
151  Slice _sampleCounts;
152 };
153 
154 //----------
155 // Iterators
156 //----------
157 
158 class IMF_EXPORT_TYPE DeepFrameBuffer::Iterator
159 {
160 public:
161  IMF_EXPORT
162  Iterator ();
163  IMF_EXPORT
164  Iterator (const DeepFrameBuffer::SliceMap::iterator& i);
165 
166  IMF_EXPORT
167  Iterator& operator++ ();
168  IMF_EXPORT
169  Iterator operator++ (int);
170 
171  IMF_EXPORT
172  const char* name () const;
173  IMF_EXPORT
174  DeepSlice& slice () const;
175 
176 private:
178 
179  DeepFrameBuffer::SliceMap::iterator _i;
180 };
181 
182 class IMF_EXPORT_TYPE DeepFrameBuffer::ConstIterator
183 {
184 public:
185  IMF_EXPORT
186  ConstIterator ();
187  IMF_EXPORT
188  ConstIterator (const DeepFrameBuffer::SliceMap::const_iterator& i);
189  IMF_EXPORT
190  ConstIterator (const DeepFrameBuffer::Iterator& other);
191 
192  IMF_EXPORT
193  ConstIterator& operator++ ();
194  IMF_EXPORT
195  ConstIterator operator++ (int);
196 
197  IMF_EXPORT
198  const char* name () const;
199  IMF_EXPORT
200  const DeepSlice& slice () const;
201 
202 private:
203  friend bool operator== (const ConstIterator&, const ConstIterator&);
204  friend bool operator!= (const ConstIterator&, const ConstIterator&);
205 
206  DeepFrameBuffer::SliceMap::const_iterator _i;
207 };
208 
209 //-----------------
210 // Inline Functions
211 //-----------------
212 
213 inline DeepFrameBuffer::Iterator::Iterator () : _i ()
214 {
215  // empty
216 }
217 
218 inline DeepFrameBuffer::Iterator::Iterator (
219  const DeepFrameBuffer::SliceMap::iterator& i)
220  : _i (i)
221 {
222  // empty
223 }
224 
226 DeepFrameBuffer::Iterator::operator++ ()
227 {
228  ++_i;
229  return *this;
230 }
231 
233 DeepFrameBuffer::Iterator::operator++ (int)
234 {
235  Iterator tmp = *this;
236  ++_i;
237  return tmp;
238 }
239 
240 inline const char*
242 {
243  return *_i->first;
244 }
245 
246 inline DeepSlice&
247 DeepFrameBuffer::Iterator::slice () const
248 {
249  return _i->second;
250 }
251 
252 inline DeepFrameBuffer::ConstIterator::ConstIterator () : _i ()
253 {
254  // empty
255 }
256 
257 inline DeepFrameBuffer::ConstIterator::ConstIterator (
258  const DeepFrameBuffer::SliceMap::const_iterator& i)
259  : _i (i)
260 {
261  // empty
262 }
263 
264 inline DeepFrameBuffer::ConstIterator::ConstIterator (
265  const DeepFrameBuffer::Iterator& other)
266  : _i (other._i)
267 {
268  // empty
269 }
270 
272 DeepFrameBuffer::ConstIterator::operator++ ()
273 {
274  ++_i;
275  return *this;
276 }
277 
279 DeepFrameBuffer::ConstIterator::operator++ (int)
280 {
281  ConstIterator tmp = *this;
282  ++_i;
283  return tmp;
284 }
285 
286 inline const char*
288 {
289  return *_i->first;
290 }
291 
292 inline const DeepSlice&
293 DeepFrameBuffer::ConstIterator::slice () const
294 {
295  return _i->second;
296 }
297 
298 inline bool
302 {
303  return x._i == y._i;
304 }
305 
306 inline bool
310 {
311  return !(x == y);
312 }
313 
315 
316 #endif /* IMFDEEPFRAMEBUFFER_H_ */
IMF_EXPORT Iterator()
IMF_EXPORT ConstIterator()
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
HALF
Definition: ImfPixelType.h:23
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLint y
Definition: glcorearb.h:103
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)
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER enum IMF_EXPORT_ENUM PixelType
Definition: ImfPixelType.h:20
GLuint GLuint end
Definition: glcorearb.h:475
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
struct IMF_EXPORT_TYPE DeepSlice
Definition: ImfForward.h:75
#define IMF_EXPORT
Definition: ImfExport.h:54
bool operator!=(const DeepFrameBuffer::ConstIterator &x, const DeepFrameBuffer::ConstIterator &y)
GLuint const GLchar * name
Definition: glcorearb.h:786
GLint GLenum GLint x
Definition: glcorearb.h:409
std::map< Name, DeepSlice > SliceMap
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
type
Definition: core.h:1059
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
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:558