| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /*
- ** SPDX-License-Identifier: BSD-3-Clause
- ** Copyright Contributors to the OpenEXR Project.
- */
- #ifndef OPENEXR_BASE_H
- #define OPENEXR_BASE_H
- #include "openexr_conf.h"
- #include <stddef.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- /** @file */
- /** @brief Retrieve the current library version. The @p extra string is for
- * custom installs, and is a static string, do not free the returned
- * pointer.
- */
- EXR_EXPORT void
- exr_get_library_version (int* maj, int* min, int* patch, const char** extra);
- /**
- * @defgroup SafetyChecks Controls for internal safety checks
- * @{
- */
- /** @brief Limit the size of image allowed to be parsed or created by
- * the library.
- *
- * This is used as a safety check against corrupt files, but can also
- * serve to avoid potential issues on machines which have very
- * constrained RAM.
- *
- * These values are among the only globals in the core layer of
- * OpenEXR. The intended use is for applications to define a global
- * default, which will be combined with the values provided to the
- * individual context creation routine. The values are used to check
- * against parsed header values. This adds some level of safety from
- * memory overruns where a corrupt file given to the system may cause
- * a large allocation to happen, enabling buffer overruns or other
- * potential security issue.
- *
- * These global values are combined with the values in
- * \ref exr_context_initializer_t using the following rules:
- *
- * 1. negative values are ignored.
- *
- * 2. if either value has a positive (non-zero) value, and the other
- * has 0, the positive value is preferred.
- *
- * 3. If both are positive (non-zero), the minimum value is used.
- *
- * 4. If both values are 0, this disables the constrained size checks.
- *
- * This function does not fail.
- */
- EXR_EXPORT void exr_set_default_maximum_image_size (int w, int h);
- /** @brief Retrieve the global default maximum image size.
- *
- * This function does not fail.
- */
- EXR_EXPORT void exr_get_default_maximum_image_size (int* w, int* h);
- /** @brief Limit the size of an image tile allowed to be parsed or
- * created by the library.
- *
- * Similar to image size, this places constraints on the maximum tile
- * size as a safety check against bad file data
- *
- * This is used as a safety check against corrupt files, but can also
- * serve to avoid potential issues on machines which have very
- * constrained RAM
- *
- * These values are among the only globals in the core layer of
- * OpenEXR. The intended use is for applications to define a global
- * default, which will be combined with the values provided to the
- * individual context creation routine. The values are used to check
- * against parsed header values. This adds some level of safety from
- * memory overruns where a corrupt file given to the system may cause
- * a large allocation to happen, enabling buffer overruns or other
- * potential security issue.
- *
- * These global values are combined with the values in
- * \ref exr_context_initializer_t using the following rules:
- *
- * 1. negative values are ignored.
- *
- * 2. if either value has a positive (non-zero) value, and the other
- * has 0, the positive value is preferred.
- *
- * 3. If both are positive (non-zero), the minimum value is used.
- *
- * 4. If both values are 0, this disables the constrained size checks.
- *
- * This function does not fail.
- */
- EXR_EXPORT void exr_set_default_maximum_tile_size (int w, int h);
- /** @brief Retrieve the global maximum tile size.
- *
- * This function does not fail.
- */
- EXR_EXPORT void exr_get_default_maximum_tile_size (int* w, int* h);
- /** @} */
- /**
- * @defgroup CompressionDefaults Provides default compression settings
- * @{
- */
- /** @brief Assigns a default zip compression level.
- *
- * This value may be controlled separately on each part, but this
- * global control determines the initial value.
- */
- EXR_EXPORT void exr_set_default_zip_compression_level (int l);
- /** @brief Retrieve the global default zip compression value
- */
- EXR_EXPORT void exr_get_default_zip_compression_level (int* l);
- /** @brief Assigns a default DWA compression quality level.
- *
- * This value may be controlled separately on each part, but this
- * global control determines the initial value.
- */
- EXR_EXPORT void exr_set_default_dwa_compression_quality (float q);
- /** @brief Retrieve the global default dwa compression quality
- */
- EXR_EXPORT void exr_get_default_dwa_compression_quality (float* q);
- /** @} */
- /**
- * @defgroup MemoryAllocators Provides global control over memory allocators
- * @{
- */
- /** @brief Function pointer used to hold a malloc-like routine.
- *
- * Providing these to a context will override what memory is used to
- * allocate the context itself, as well as any allocations which
- * happen during processing of a file or stream. This can be used by
- * systems which provide rich malloc tracking routines to override the
- * internal allocations performed by the library.
- *
- * This function is expected to allocate and return a new memory
- * handle, or `NULL` if allocation failed (which the library will then
- * handle and return an out-of-memory error).
- *
- * If one is provided, both should be provided.
- * @sa exr_memory_free_func_t
- */
- typedef void* (*exr_memory_allocation_func_t) (size_t bytes);
- /** @brief Function pointer used to hold a free-like routine.
- *
- * Providing these to a context will override what memory is used to
- * allocate the context itself, as well as any allocations which
- * happen during processing of a file or stream. This can be used by
- * systems which provide rich malloc tracking routines to override the
- * internal allocations performed by the library.
- *
- * This function is expected to return memory to the system, ala free
- * from the C library.
- *
- * If providing one, probably need to provide both routines.
- * @sa exr_memory_allocation_func_t
- */
- typedef void (*exr_memory_free_func_t) (void* ptr);
- /** @brief Allow the user to override default allocator used internal
- * allocations necessary for files, attributes, and other temporary
- * memory.
- *
- * These routines may be overridden when creating a specific context,
- * however this provides global defaults such that the default can be
- * applied.
- *
- * If either pointer is 0, the appropriate malloc/free routine will be
- * substituted.
- *
- * This function does not fail.
- */
- EXR_EXPORT void exr_set_default_memory_routines (
- exr_memory_allocation_func_t alloc_func, exr_memory_free_func_t free_func);
- /** @} */
- #ifdef __cplusplus
- } /* extern "C" */
- #endif
- #endif /* OPENEXR_BASE_H */
|