HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openexr_base.h
Go to the documentation of this file.
1 /*
2 ** SPDX-License-Identifier: BSD-3-Clause
3 ** Copyright Contributors to the OpenEXR Project.
4 */
5 
6 #ifndef OPENEXR_BASE_H
7 #define OPENEXR_BASE_H
8 
9 #include "openexr_conf.h"
10 
11 #include <stddef.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /** @file */
18 
19 /** @brief Retrieve the current library version. The @p extra string is for
20  * custom installs, and is a static string, do not free the returned
21  * pointer.
22  */
23 EXR_EXPORT void
24 exr_get_library_version (int* maj, int* min, int* patch, const char** extra);
25 
26 /**
27  * @defgroup SafetyChecks Controls for internal safety checks
28  * @{
29  */
30 
31 /** @brief Limit the size of image allowed to be parsed or created by
32  * the library.
33  *
34  * This is used as a safety check against corrupt files, but can also
35  * serve to avoid potential issues on machines which have very
36  * constrained RAM.
37  *
38  * These values are among the only globals in the core layer of
39  * OpenEXR. The intended use is for applications to define a global
40  * default, which will be combined with the values provided to the
41  * individual context creation routine. The values are used to check
42  * against parsed header values. This adds some level of safety from
43  * memory overruns where a corrupt file given to the system may cause
44  * a large allocation to happen, enabling buffer overruns or other
45  * potential security issue.
46  *
47  * These global values are combined with the values in
48  * \ref exr_context_initializer_t using the following rules:
49  *
50  * 1. negative values are ignored.
51  *
52  * 2. if either value has a positive (non-zero) value, and the other
53  * has 0, the positive value is preferred.
54  *
55  * 3. If both are positive (non-zero), the minimum value is used.
56  *
57  * 4. If both values are 0, this disables the constrained size checks.
58  *
59  * This function does not fail.
60  */
62 
63 /** @brief Retrieve the global default maximum image size.
64  *
65  * This function does not fail.
66  */
68 
69 /** @brief Limit the size of an image tile allowed to be parsed or
70  * created by the library.
71  *
72  * Similar to image size, this places constraints on the maximum tile
73  * size as a safety check against bad file data
74  *
75  * This is used as a safety check against corrupt files, but can also
76  * serve to avoid potential issues on machines which have very
77  * constrained RAM
78  *
79  * These values are among the only globals in the core layer of
80  * OpenEXR. The intended use is for applications to define a global
81  * default, which will be combined with the values provided to the
82  * individual context creation routine. The values are used to check
83  * against parsed header values. This adds some level of safety from
84  * memory overruns where a corrupt file given to the system may cause
85  * a large allocation to happen, enabling buffer overruns or other
86  * potential security issue.
87  *
88  * These global values are combined with the values in
89  * \ref exr_context_initializer_t using the following rules:
90  *
91  * 1. negative values are ignored.
92  *
93  * 2. if either value has a positive (non-zero) value, and the other
94  * has 0, the positive value is preferred.
95  *
96  * 3. If both are positive (non-zero), the minimum value is used.
97  *
98  * 4. If both values are 0, this disables the constrained size checks.
99  *
100  * This function does not fail.
101  */
103 
104 /** @brief Retrieve the global maximum tile size.
105  *
106  * This function does not fail.
107  */
109 
110 /** @} */
111 
112 /**
113  * @defgroup CompressionDefaults Provides default compression settings
114  * @{
115  */
116 
117 /** @brief Assigns a default zip compression level.
118  *
119  * This value may be controlled separately on each part, but this
120  * global control determines the initial value.
121  */
123 
124 /** @brief Retrieve the global default zip compression value
125  */
127 
128 /** @brief Assigns a default DWA compression quality level.
129  *
130  * This value may be controlled separately on each part, but this
131  * global control determines the initial value.
132  */
134 
135 /** @brief Retrieve the global default dwa compression quality
136  */
138 
139 /** @} */
140 
141 /**
142  * @defgroup MemoryAllocators Provides global control over memory allocators
143  * @{
144  */
145 
146 /** @brief Function pointer used to hold a malloc-like routine.
147  *
148  * Providing these to a context will override what memory is used to
149  * allocate the context itself, as well as any allocations which
150  * happen during processing of a file or stream. This can be used by
151  * systems which provide rich malloc tracking routines to override the
152  * internal allocations performed by the library.
153  *
154  * This function is expected to allocate and return a new memory
155  * handle, or `NULL` if allocation failed (which the library will then
156  * handle and return an out-of-memory error).
157  *
158  * If one is provided, both should be provided.
159  * @sa exr_memory_free_func_t
160  */
161 typedef void* (*exr_memory_allocation_func_t) (size_t bytes);
162 
163 /** @brief Function pointer used to hold a free-like routine.
164  *
165  * Providing these to a context will override what memory is used to
166  * allocate the context itself, as well as any allocations which
167  * happen during processing of a file or stream. This can be used by
168  * systems which provide rich malloc tracking routines to override the
169  * internal allocations performed by the library.
170  *
171  * This function is expected to return memory to the system, ala free
172  * from the C library.
173  *
174  * If providing one, probably need to provide both routines.
175  * @sa exr_memory_allocation_func_t
176  */
177 typedef void (*exr_memory_free_func_t) (void* ptr);
178 
179 /** @brief Allow the user to override default allocator used internal
180  * allocations necessary for files, attributes, and other temporary
181  * memory.
182  *
183  * These routines may be overridden when creating a specific context,
184  * however this provides global defaults such that the default can be
185  * applied.
186  *
187  * If either pointer is 0, the appropriate malloc/free routine will be
188  * substituted.
189  *
190  * This function does not fail.
191  */
194 
195 /** @} */
196 
197 #ifdef __cplusplus
198 } /* extern "C" */
199 #endif
200 
201 #endif /* OPENEXR_BASE_H */
EXR_EXPORT void exr_set_default_zip_compression_level(int l)
Assigns a default zip compression level.
void(* exr_memory_free_func_t)(void *ptr)
Function pointer used to hold a free-like routine.
Definition: openexr_base.h:177
EXR_EXPORT void exr_set_default_maximum_image_size(int w, int h)
Limit the size of image allowed to be parsed or created by the library.
EXR_EXPORT void exr_get_library_version(int *maj, int *min, int *patch, const char **extra)
Retrieve the current library version. The extra string is for custom installs, and is a static string...
void
Definition: png.h:1083
EXR_EXPORT void exr_set_default_memory_routines(exr_memory_allocation_func_t alloc_func, exr_memory_free_func_t free_func)
Allow the user to override default allocator used internal allocations necessary for files...
EXR_EXPORT void exr_get_default_dwa_compression_quality(float *q)
Retrieve the global default dwa compression quality.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLdouble GLdouble GLdouble q
Definition: glad.h:2445
EXR_EXPORT void exr_set_default_dwa_compression_quality(float q)
Assigns a default DWA compression quality level.
EXR_EXPORT void exr_get_default_maximum_tile_size(int *w, int *h)
Retrieve the global maximum tile size.
EXR_EXPORT void exr_set_default_maximum_tile_size(int w, int h)
Limit the size of an image tile allowed to be parsed or created by the library.
#define EXR_EXPORT
Definition: openexr_conf.h:29
EXR_EXPORT void exr_get_default_maximum_image_size(int *w, int *h)
Retrieve the global default maximum image size.
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
void *(* exr_memory_allocation_func_t)(size_t bytes)
Function pointer used to hold a malloc-like routine.
Definition: openexr_base.h:161
auto ptr(T p) -> const void *
Definition: format.h:2448
EXR_EXPORT void exr_get_default_zip_compression_level(int *l)
Retrieve the global default zip compression value.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition: format.h:2459