HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
c-deepdata.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenImageIO project.
2 // SPDX-License-Identifier: BSD-3-Clause
3 // https://github.com/OpenImageIO/oiio
4 
5 #pragma once
6 
7 #include <OpenImageIO/export.h>
8 
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
17 
18 /// Construct an empty DeepData.
19 ///
20 /// Equivalent C++: `new OIIO::DeepData`
23 
24 /// Construct and init from an ImageSpec.
25 ///
26 /// Equivalent C++: `new OIIO::DeepData(is)`
29 
30 /// Copy constructor
31 ///
32 /// Equivalent C++: `new OIIO::DeepData(dd)`
35 
36 /// Delete
37 ///
38 /// Equivalent C++: `delete dd`
39 OIIOC_API void
41 
42 /// Reset the `DeepData` to be equivalent to its empty initial state.
43 ///
44 /// Equivalent C++: `dd->clear()`
45 OIIOC_API void
47 
48 /// Reset the `DeepData` to be equivalent to its empty initial state and also
49 /// ensure that all allocated memory has been truly freed
50 ///
51 /// Equivalent C++: `dd->free()`
52 OIIOC_API void
54 
55 /// Initialize the `DeepData` with the specified number of pixels,
56 /// channels, channel types, and channel names, and allocate memory for
57 /// all the data.
58 ///
59 /// Equivalent C++: `dd->init(npix, nchan, {nchanneltypes, channeltypes}, {nchannelnames, channelnames})`
60 ///
61 OIIOC_API void
62 OIIO_DeepData_init(OIIO_DeepData* dd, int64_t npix, int nchan,
63  const OIIO_TypeDesc* channeltypes, int nchanneltypes,
64  const char** channelnames, int nchannelnames);
65 
66 /// Initialize the `DeepData` based on the `ImageSpec`'s total number of
67 /// pixels, number and types of channels. At this stage, all pixels are
68 /// assumed to have 0 samples, and no sample data is allocated.
69 ///
70 /// Equivalent C++: `dd->init(*is)`
71 ///
72 OIIOC_API void
74 
75 /// Is the DeepData initialized?
76 ///
77 /// Equivalent C++: `dd->initialized()`
78 ///
79 OIIOC_API bool
81 
82 /// Is the DeepData allocated
83 ///
84 /// Equivalent C++: `dd->allocated()`
85 ///
86 OIIOC_API bool
88 
89 /// Retrieve the total number of pixels.
90 ///
91 /// Equivalent C++: `dd->pixels()`
92 ///
93 OIIOC_API int64_t
95 
96 /// Retrieve the total number of channels
97 ///
98 /// Equivalent C++: `dd->channels()`
99 ///
100 OIIOC_API int
102 
103 /// Retrieve the index of the Z channel
104 ///
105 /// Equivalent C++: `dd->Z_channel()`
106 ///
107 OIIOC_API int
109 
110 // Retrieve the index of the Zback channel, which will return the
111 // Z channel if no Zback exists.
112 ///
113 /// Equivalent C++: `dd->Zback_channel()`
114 ///
115 OIIOC_API int
117 
118 /// Retrieve the index of the alpha (A) channel
119 ///
120 /// Equivalent C++: `dd->A_channel()`
121 ///
122 OIIOC_API int
124 
125 // Retrieve the index of the AR channel. If it does not exist, the A
126 // channel (which always exists) will be returned.
127 ///
128 /// Equivalent C++: `dd->AR_channel()`
129 ///
130 OIIOC_API int
132 
133 // Retrieve the index of the AG channel. If it does not exist, the A
134 // channel (which always exists) will be returned.
135 ///
136 /// Equivalent C++: `dd->AG_channel()`
137 ///
138 OIIOC_API int
140 
141 // Retrieve the index of the AB channel. If it does not exist, the A
142 // channel (which always exists) will be returned.
143 ///
144 /// Equivalent C++: `dd->AB_channel()`
145 ///
146 OIIOC_API int
148 
149 /// Return the name of channel c.
150 ///
151 /// Equivalent C++: `dd->channelname(c)`
152 ///
153 OIIOC_API const char*
155 
156 /// Return the type of channel c.
157 ///
158 /// Equivalent C++: `dd->channeltype(c)`
159 ///
162 
163 /// Return the size (in bytes) of one sample datum of channel `c`.
164 ///
165 /// Equivalent C++: `dd->channelsize(c)`
166 ///
167 OIIOC_API size_t
169 
170 /// Return the size (in bytes) for all channels of one sample.
171 ///
172 /// Equivalent C++: `dd->samplesize()`
173 ///
174 OIIOC_API size_t
176 
177 /// Retrieve the number of samples for the given pixel index.
178 ///
179 /// Equivalent C++: `dd->samples(pixel)`
180 ///
181 OIIOC_API int
182 OIIO_DeepData_samples(const OIIO_DeepData* dd, int64_t pixel);
183 
184 /// Set the number of samples for the given pixel. This must be called
185 /// after init().
186 ///
187 /// Equivalent C++: `dd->set_samples(pixel, samps)`
188 ///
189 OIIOC_API void
190 OIIO_DeepData_set_samples(OIIO_DeepData* dd, int64_t pixel, int samps);
191 
192 /// Set the number of samples for all pixels. nsamples is
193 /// required to match pixels().
194 ///
195 /// Equivalent C++: `dd->set_all_samples(pixel, samples, nsamples)`
196 ///
197 OIIOC_API void
199  int nsamples);
200 
201 /// Set the capacity of samples for the given pixel. This must be called
202 /// after init().
203 ///
204 /// Equivalent C++: `dd->set_capacity(pixel, samps)`
205 ///
206 OIIOC_API void
207 OIIO_DeepData_set_capacity(OIIO_DeepData* dd, int64_t pixel, int samps);
208 
209 /// Insert `n` samples of the specified pixel, betinning at the sample
210 /// position index. After insertion, the new samples will have
211 /// uninitialized values.
212 ///
213 /// Equivalent C++: `dd->insert_samples(pixel, samplepos, n)`
214 ///
215 OIIOC_API void
216 OIIO_DeepData_insert_samples(OIIO_DeepData* dd, int64_t pixel, int samplepos,
217  int n);
218 
219 /// Erase `n` samples of the specified pixel, betinning at the sample
220 /// position index.
221 ///
222 /// Equivalent C++: `dd->insert_samples(pixel, samplepos, n)`
223 ///
224 OIIOC_API void
225 OIIO_DeepData_erase_samples(OIIO_DeepData* dd, int64_t pixel, int samplepos,
226  int n);
227 
228 /// Retrieve the value of the given pixel, channel, and sample index,
229 /// cast to a `float`.
230 ///
231 /// Equivalent C++: `dd->deep_value(pixel, channel, sample)`
232 ///
233 OIIOC_API float
234 OIIO_DeepData_deep_value(const OIIO_DeepData* dd, int64_t pixel, int channel,
235  int sample);
236 
237 /// Retrieve the value of the given pixel, channel, and sample index,
238 /// cast to a `uint32`.
239 ///
240 /// Equivalent C++: `dd->deep_value_uint(pixel, channel, sample)`
241 ///
242 OIIOC_API uint32_t
243 OIIO_DeepData_deep_value_uint(const OIIO_DeepData* dd, int64_t pixel,
244  int channel, int sample);
245 
246 /// Set the value of the given pixel, channel, and sample index, for
247 /// floating-point channels.
248 ///
249 /// Equivalent C++: `dd->set_deep_value(pixel, channel, sample, value)`
250 ///
251 OIIOC_API void
252 OIIO_DeepData_set_deep_value(OIIO_DeepData* dd, int64_t pixel, int channel,
253  int sample, float value);
254 
255 /// Set the value of the given pixel, channel, and sample index, for
256 /// integer channels.
257 ///
258 /// Equivalent C++: `dd->set_deep_value(pixel, channel, sample, value)`
259 ///
260 OIIOC_API void
261 OIIO_DeepData_set_deep_value_uint(OIIO_DeepData* dd, int64_t pixel, int channel,
262  int sample, uint32_t value);
263 
264 /// Retrieve the pointer to a given pixel/channel/sample, or NULL if
265 /// there are no samples for that pixel. Use with care, and note that
266 /// calls to insert_samples and erase_samples can invalidate pointers
267 /// returned by prior calls to data_ptr.
268 ///
269 /// Equivalent C++: `dd->data_ptr(pixel, channel, sample)`
270 ///
271 OIIOC_API void*
272 OIIO_DeepData_data_ptr(OIIO_DeepData* dd, int64_t pixel, int channel,
273  int sample);
274 
275 ///
276 /// Equivalent C++: `dd->all_channeltypes()`
277 ///
278 OIIOC_API void
280  const OIIO_TypeDesc** channeltypes,
281  int* nchanneltypes);
282 
283 ///
284 /// Equivalent C++: `dd->all_samples()`
285 ///
286 OIIOC_API void
287 OIIO_DeepData_all_samples(const OIIO_DeepData* dd, const uint32_t** samples,
288  int* nsamples);
289 
290 ///
291 /// Equivalent C++: `dd->all_data()`
292 ///
293 OIIOC_API void
294 OIIO_DeepData_all_data(const OIIO_DeepData* dd, const char** bytes,
295  int* nbytes);
296 
297 /// TODO: (AL) get_pointers
298 
299 /// Copy a deep sample from `src` to this `DeepData`. They must have the
300 /// same channel layout. Return `true` if ok, `false` if the operation
301 /// could not be performed.
302 ///
303 /// Equivalent C++: `dd->copy_deep_sample(pixel, sample, *src, srcpixel, srcsample)`
304 ///
305 OIIOC_API bool
306 OIIO_DeepData_copy_deep_sample(OIIO_DeepData* dd, int64_t pixel, int sample,
307  const OIIO_DeepData* src, int64_t srcpixel,
308  int srcsample);
309 
310 /// Copy an entire deep pixel from `src` to this `DeepData`, completely
311 /// replacing any pixel data for that pixel. They must have the same
312 /// channel layout. Return `true` if ok, `false` if the operation could
313 /// not be performed.
314 ///
315 /// Equivalent C++: `dd->copy_deep_pixel(pixel, *src, srcpixel)`
316 ///
317 OIIOC_API bool
319  const OIIO_DeepData* src, int64_t srcpixel);
320 
321 /// Split all samples of that pixel at the given depth zsplit.
322 ///
323 /// Equivalent C++: `dd->split(pixel, depth)`
324 ///
325 OIIOC_API bool
326 OIIO_DeepData_split(OIIO_DeepData* dd, int64_t pixel, float depth);
327 
328 /// Sort the samples of the pixel by their `Z` depth.
329 ///
330 /// Equivalent C++: `dd->sort(pixel)`
331 ///
332 OIIOC_API void
333 OIIO_DeepData_sort(OIIO_DeepData* dd, int64_t pixel);
334 
335 /// Merge any adjacent samples in the pixel that exactly overlap in z
336 /// range.
337 ///
338 /// Equivalent C++: `dd->merge_overlaps(pixel)`
339 ///
340 OIIOC_API void
341 OIIO_DeepData_merge_overlaps(OIIO_DeepData* dd, int64_t pixel);
342 
343 /// Merge the samples of `src`'s pixel into this `DeepData`'s pixel.
344 ///
345 /// Equivalent C++: `dd->merge_deep_pixels(pixel, *src, srcpixel)`
346 ///
347 OIIOC_API void
349  const OIIO_DeepData* src, int64_t srcpixel);
350 
351 /// Return the z depth at which the pixel reaches full opacity.
352 ///
353 /// Equivalent C++: `dd->opaque_z(pixel)`
354 ///
355 OIIOC_API float
356 OIIO_DeepData_opaque_z(const OIIO_DeepData* dd, int64_t pixel);
357 
358 /// Remove any samples hidden behind opaque samples.
359 ///
360 /// Equivalent C++: `dd->occlusion_cull(pixel)`
361 ///
362 OIIOC_API void
363 OIIO_DeepData_occlusion_cull(OIIO_DeepData* dd, int64_t pixel);
364 
365 #ifdef __cplusplus
366 }
367 #endif
OIIOC_API void OIIO_DeepData_set_all_samples(OIIO_DeepData *dd, const uint32_t *samples, int nsamples)
OIIOC_API void OIIO_DeepData_set_deep_value(OIIO_DeepData *dd, int64_t pixel, int channel, int sample, float value)
OIIOC_API const char * OIIO_DeepData_channelname(const OIIO_DeepData *dd, int c)
OIIOC_API void OIIO_DeepData_init(OIIO_DeepData *dd, int64_t npix, int nchan, const OIIO_TypeDesc *channeltypes, int nchanneltypes, const char **channelnames, int nchannelnames)
#define OIIOC_API
Definition: export.h:77
OIIOC_API void OIIO_DeepData_all_data(const OIIO_DeepData *dd, const char **bytes, int *nbytes)
OIIOC_API OIIO_DeepData * OIIO_DeepData_new()
OIIOC_API float OIIO_DeepData_opaque_z(const OIIO_DeepData *dd, int64_t pixel)
OIIOC_API int OIIO_DeepData_Z_channel(const OIIO_DeepData *dd)
OIIOC_API void OIIO_DeepData_clear(OIIO_DeepData *dd)
OIIOC_API int OIIO_DeepData_AG_channel(const OIIO_DeepData *dd)
OIIOC_API bool OIIO_DeepData_split(OIIO_DeepData *dd, int64_t pixel, float depth)
OIIOC_API int OIIO_DeepData_samples(const OIIO_DeepData *dd, int64_t pixel)
OIIOC_API void OIIO_DeepData_set_deep_value_uint(OIIO_DeepData *dd, int64_t pixel, int channel, int sample, uint32_t value)
OIIOC_API void OIIO_DeepData_sort(OIIO_DeepData *dd, int64_t pixel)
OIIOC_API OIIO_TypeDesc OIIO_DeepData_channeltype(const OIIO_DeepData *dd, int c)
OIIOC_API bool OIIO_DeepData_initialized(const OIIO_DeepData *dd)
OIIOC_API void OIIO_DeepData_delete(const OIIO_DeepData *dd)
GLdouble n
Definition: glcorearb.h:2008
OIIOC_API void OIIO_DeepData_erase_samples(OIIO_DeepData *dd, int64_t pixel, int samplepos, int n)
OIIOC_API OIIO_DeepData * OIIO_DeepData_new_with_imagespec(const OIIO_ImageSpec *is)
OIIOC_API void OIIO_DeepData_all_channeltypes(const OIIO_DeepData *dd, const OIIO_TypeDesc **channeltypes, int *nchanneltypes)
OIIOC_API void OIIO_DeepData_set_capacity(OIIO_DeepData *dd, int64_t pixel, int samps)
OIIOC_API size_t OIIO_DeepData_samplesize(const OIIO_DeepData *dd)
struct OIIO_DeepData OIIO_DeepData
Definition: c-deepdata.h:15
OIIOC_API void OIIO_DeepData_insert_samples(OIIO_DeepData *dd, int64_t pixel, int samplepos, int n)
OIIOC_API void OIIO_DeepData_all_samples(const OIIO_DeepData *dd, const uint32_t **samples, int *nsamples)
OIIOC_API int OIIO_DeepData_AB_channel(const OIIO_DeepData *dd)
OIIOC_API OIIO_DeepData * OIIO_DeepData_copy(const OIIO_DeepData *dd)
OIIOC_API void * OIIO_DeepData_data_ptr(OIIO_DeepData *dd, int64_t pixel, int channel, int sample)
OIIOC_API void OIIO_DeepData_merge_overlaps(OIIO_DeepData *dd, int64_t pixel)
OIIOC_API bool OIIO_DeepData_copy_deep_sample(OIIO_DeepData *dd, int64_t pixel, int sample, const OIIO_DeepData *src, int64_t srcpixel, int srcsample)
TODO: (AL) get_pointers.
OIIOC_API void OIIO_DeepData_init_with_imagespec(OIIO_DeepData *dd, const OIIO_ImageSpec *is)
GLsizei samples
Definition: glcorearb.h:1298
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:476
OIIOC_API void OIIO_DeepData_set_samples(OIIO_DeepData *dd, int64_t pixel, int samps)
struct OIIO_ImageSpec OIIO_ImageSpec
Definition: c-deepdata.h:16
OIIOC_API bool OIIO_DeepData_allocated(const OIIO_DeepData *dd)
OIIOC_API int OIIO_DeepData_AR_channel(const OIIO_DeepData *dd)
OIIOC_API size_t OIIO_DeepData_channelsize(const OIIO_DeepData *dd, int c)
OIIOC_API void OIIO_DeepData_free(OIIO_DeepData *dd)
Definition: core.h:1131
OIIOC_API uint32_t OIIO_DeepData_deep_value_uint(const OIIO_DeepData *dd, int64_t pixel, int channel, int sample)
OIIOC_API void OIIO_DeepData_merge_deep_pixels(OIIO_DeepData *dd, int64_t pixel, const OIIO_DeepData *src, int64_t srcpixel)
OIIOC_API int OIIO_DeepData_A_channel(const OIIO_DeepData *dd)
OIIOC_API int64_t OIIO_DeepData_pixels(const OIIO_DeepData *dd)
Definition: format.h:2459
OIIOC_API void OIIO_DeepData_occlusion_cull(OIIO_DeepData *dd, int64_t pixel)
OIIOC_API float OIIO_DeepData_deep_value(const OIIO_DeepData *dd, int64_t pixel, int channel, int sample)
OIIOC_API bool OIIO_DeepData_copy_deep_pixel(OIIO_DeepData *dd, int64_t pixel, const OIIO_DeepData *src, int64_t srcpixel)
OIIOC_API int OIIO_DeepData_Zback_channel(const OIIO_DeepData *dd)
OIIOC_API int OIIO_DeepData_channels(const OIIO_DeepData *dd)
GLenum src
Definition: glcorearb.h:1793