Update OpenEXRCore to 3.3

This commit is contained in:
gingerBill
2025-01-31 09:04:26 +00:00
parent 539a74c2a9
commit 61cd0f4de9
12 changed files with 226 additions and 83 deletions

Binary file not shown.

View File

@@ -293,36 +293,37 @@ attr_opaquedata_t :: struct {
* attributes.
*/
attribute_type_t :: enum c.int {
UNKNOWN = 0, // Type indicating an error or uninitialized attribute.
BOX2I, // Integer region definition. @see attr_box2i_t.
BOX2F, // Float region definition. @see attr_box2f_t.
CHLIST, // Definition of channels in file @see chlist_entry.
CHROMATICITIES, // Values to specify color space of colors in file @see attr_chromaticities_t.
COMPRESSION, // ``u8`` declaring compression present.
DOUBLE, // Double precision floating point number.
ENVMAP, // ``u8`` declaring environment map type.
FLOAT, // Normal (4 byte) precision floating point number.
FLOAT_VECTOR, // List of normal (4 byte) precision floating point numbers.
INT, // 32-bit signed integer value.
KEYCODE, // Struct recording keycode @see attr_keycode_t.
LINEORDER, // ``u8`` declaring scanline ordering.
M33F, // 9 32-bit floats representing a 3x3 matrix.
M33D, // 9 64-bit floats representing a 3x3 matrix.
M44F, // 16 32-bit floats representing a 4x4 matrix.
M44D, // 16 64-bit floats representing a 4x4 matrix.
PREVIEW, // 2 ``unsigned ints`` followed by 4 x w x h ``u8`` image.
RATIONAL, // \c int followed by ``unsigned int``
STRING, // ``int`` (length) followed by char string data.
STRING_VECTOR, // 0 or more text strings (int + string). number is based on attribute size.
TILEDESC, // 2 ``unsigned ints`` ``xSize``, ``ySize`` followed by mode.
TIMECODE, // 2 ``unsigned ints`` time and flags, user data.
V2I, // Pair of 32-bit integers.
V2F, // Pair of 32-bit floats.
V2D, // Pair of 64-bit floats.
V3I, // Set of 3 32-bit integers.
V3F, // Set of 3 32-bit floats.
V3D, // Set of 3 64-bit floats.
OPAQUE, // User/unknown provided type.
UNKNOWN = 0, // Type indicating an error or uninitialized attribute.
BOX2I, // Integer region definition. @see attr_box2i_t.
BOX2F, // Float region definition. @see attr_box2f_t.
CHLIST, // Definition of channels in file @see chlist_entry.
CHROMATICITIES, // Values to specify color space of colors in file @see attr_chromaticities_t.
COMPRESSION, // ``u8`` declaring compression present.
DOUBLE, // Double precision floating point number.
ENVMAP, // ``u8`` declaring environment map type.
FLOAT, // Normal (4 byte) precision floating point number.
FLOAT_VECTOR, // List of normal (4 byte) precision floating point numbers.
INT, // 32-bit signed integer value.
KEYCODE, // Struct recording keycode @see attr_keycode_t.
LINEORDER, // ``u8`` declaring scanline ordering.
M33F, // 9 32-bit floats representing a 3x3 matrix.
M33D, // 9 64-bit floats representing a 3x3 matrix.
M44F, // 16 32-bit floats representing a 4x4 matrix.
M44D, // 16 64-bit floats representing a 4x4 matrix.
PREVIEW, // 2 ``unsigned ints`` followed by 4 x w x h ``u8`` image.
RATIONAL, // \c int followed by ``unsigned int``
STRING, // ``int`` (length) followed by char string data.
STRING_VECTOR, // 0 or more text strings (int + string). number is based on attribute size.
TILEDESC, // 2 ``unsigned ints`` ``xSize``, ``ySize`` followed by mode.
TIMECODE, // 2 ``unsigned ints`` time and flags, user data.
V2I, // Pair of 32-bit integers.
V2F, // Pair of 32-bit floats.
V2D, // Pair of 64-bit floats.
V3I, // Set of 3 32-bit integers.
V3F, // Set of 3 32-bit floats.
V3D, // Set of 3 64-bit floats.
DEEP_IMAGE_STATE, // ``uint8_t`` declaring deep image state.
OPAQUE, // User/unknown provided type.
}
/** @brief Storage, name and type information for an attribute.

View File

@@ -6,12 +6,14 @@ when ODIN_OS == .Windows {
when OPENEXRCORE_SHARED {
#panic("Dynamic linking is not supported for OpenEXRCore yet")
} else {
foreign import lib "OpenEXRCore-3_1.lib"
foreign import lib_ "OpenEXRCore-3_3.lib"
}
} else {
foreign import lib "system:OpenEXRCore-3_1"
foreign import lib_ "system:OpenEXRCore-3_3"
}
lib :: lib_
import "core:c"
/** @brief Function pointer used to hold a malloc-like routine.

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
/**
@@ -41,6 +35,20 @@ chunk_info_t :: struct {
@(link_prefix="exr_", default_calling_convention="c")
foreign lib {
/** @brief Retrieve the chunk table offset for the part in question.
*/
get_chunk_table_offset :: proc(ctxt: const_context_t , part_index: c.int, chunk_offset_out: ^c.uint64_t) -> result_t ---
/** initialize chunk info with the default values from the specified part
*
* The 'x' and 'y' parameters are used to indicate the starting position
* of the chunk being initialized. This does not perform any I/O to validate
* and so the values are only indicative. (but can be used to do things
* like compress / decompress a chunk without having a file to actually
* read
*/
chunk_default_initialize :: proc(ctxt: context_t, part_index: c.int, box: ^attr_box2i_t, levelx: c.int, levely: c.int, cinfo: ^chunk_info_t) -> result_t ---
read_scanline_chunk_info :: proc(ctxt: const_context_t, part_index: c.int, y: c.int, cinfo: ^chunk_info_t) -> result_t ---
read_tile_chunk_info :: proc(

View File

@@ -116,4 +116,4 @@ coding_channel_info_t :: struct {
decode_to_ptr: ^u8,
encode_from_ptr: ^u8,
},
}
}

82
vendor/OpenEXRCore/exr_compression.odin vendored Normal file
View File

@@ -0,0 +1,82 @@
package vendor_openexr
import "core:c"
@(link_prefix="exr_", default_calling_convention="c")
foreign lib {
/** Computes a buffer that will be large enough to hold the compressed
* data. This may include some extra padding for headers / scratch */
compress_max_buffer_size :: proc(in_bytes: c.size_t) -> c.size_t ---
/** Compresses a buffer using a zlib style compression.
*
* If the level is -1, will use the default compression set to the library
* \ref set_default_zip_compression_level
* data. This may include some extra padding for headers / scratch */
compress_buffer :: proc(
ctxt: const_context_t,
level: c.int,
in_: rawptr,
in_bytes: c.size_t,
out: rawptr,
out_bytes_avail: c.size_t,
actual_out: ^c.size_t) -> result_t ---
/** Decompresses a buffer using a zlib style compression. */
uncompress_buffer :: proc(
ctxt: const_context_t,
in_: rawptr,
in_bytes: c.size_t,
out: rawptr,
out_bytes_avail: c.size_t,
actual_out: ^c.size_t) -> result_t ---
/** Apply simple run length encoding and put in the output buffer. */
rle_compress_buffer :: proc(
in_bytes: c.size_t,
in_: rawptr,
out: rawptr,
out_bytes_avail: c.size_t) -> c.size_t ---
/** Decode run length encoding and put in the output buffer. */
rle_uncompress_buffer :: proc(
in_bytes: c.size_t,
max_len: c.size_t,
in_: rawptr,
out: rawptr) -> c.size_t ---
/** Routine to query the lines required per chunk to compress with the
* specified method.
*
* This is only meaningful for scanline encodings, tiled
* representations have a different interpretation of this.
*
* These are constant values, this function returns -1 if the compression
* type is unknown.
*/
compression_lines_per_chunk :: proc(comptype: compression_t) -> c.int ---
/** Exposes a method to apply compression to a chunk of data.
*
* This can be useful for inheriting default behavior of the
* compression stage of an encoding pipeline, or other helper classes
* to expose compression.
*
* NB: As implied, this function will be used during a normal encode
* and write operation but can be used directly with a temporary
* context (i.e. not running the full encode pipeline).
*/
compress_chunk :: proc(encode_state: ^encode_pipeline_t) -> result_t ---
/** Exposes a method to decompress a chunk of data.
*
* This can be useful for inheriting default behavior of the
* uncompression stage of an decoding pipeline, or other helper classes
* to expose compress / uncompress operations.
*
* NB: This function will be used during a normal read and decode
* operation but can be used directly with a temporary context (i.e.
* not running the full decode pipeline).
*/
uncompress_chunk :: proc(decode_state: ^decode_pipeline_t) -> result_t ---
}

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
#assert(size_of(c.int) == size_of(b32))
@@ -282,6 +276,8 @@ context_initializer_t :: struct {
/** Initialize with a bitwise or of the various context flags
*/
flags: c.int,
pad: [4]u8,
}
/** @brief context flag which will enforce strict header validation
@@ -418,19 +414,42 @@ foreign lib {
filename: cstring,
ctxtdata: ^context_initializer_t) -> result_t ---
/** @brief Create a new context for temporary use in memory.
*
* This is a custom mode that does not supporting writing actual image
* data, but one can create one of these, manipulate attributes,
* define additional parts, run validation, etc. without any
* requirement of actual file i/o.
*
* Note that this creates an defines an initial part for use, so one
* can immediately start definining attributes into part index 0.
*
* See the initializer context documentation \ref
* exr_context_initializer_t to be able to provide allocation
* overrides or other controls. The @p ctxtdata parameter is optional,
* if `NULL`, default values will be used.
*/
start_temporary_context :: proc(
ctxt: ^context_t,
context_name: [^]c.char,
ctxtdata: ^context_initializer_t) -> result_t ---
/** @brief Retrieve the file name the context is for as provided
* during the start routine.
*
* Do not free the resulting string.
*/
get_file_name :: proc(ctxt: const_context_t, name: ^cstring) -> result_t ---
/** @brief Retrieve the file version and flags the context is for as
* parsed during the start routine.
*/
get_file_version_and_flags :: proc(ctxt: const_context_t, ver: ^u32) -> result_t ---
/** @brief Query the user data the context was constructed with. This
* is perhaps useful in the error handler callback to jump back into
* an object the user controls.
*/
get_user_data :: proc(ctxt: const_context_t, userdata: ^rawptr) -> result_t ---
/** Any opaque attribute data entry of the specified type is tagged

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
@(link_prefix="exr_", default_calling_convention="c")
foreign lib {
print_context_info :: proc(c: const_context_t, verbose: b32) -> result_t ---

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
/** Can be bit-wise or'ed into the decode_flags in the decode pipeline.
@@ -55,6 +49,12 @@ DECODE_SAMPLE_DATA_ONLY :: u16(1 << 2)
* the same context concurrently.
*/
decode_pipeline_t :: struct {
/** Used for versioning the decode pipeline in the future.
*
* \ref EXR_DECODE_PIPELINE_INITIALIZER
*/
pipe_size: c.size_t,
/** The output channel information for this chunk.
*
* User is expected to fill the channel pointers for the desired
@@ -79,6 +79,20 @@ decode_pipeline_t :: struct {
ctx: const_context_t,
chunk: chunk_info_t,
/** How many lines of the chunk to skip filling, assumes the
* pointer is at the beginning of data (i.e. includes this
* skip so does not need to be adjusted
*/
user_line_begin_skip: i32,
/** How many lines of the chunk to ignore at the end, assumes the
* output is meant to be N lines smaller
*/
user_line_end_ignore: i32,
/** How many bytes were actually decoded when items compressed */
bytes_decompressed: u64,
/** Can be used by the user to pass custom context data through
* the decode pipeline.
*/
@@ -236,7 +250,7 @@ decode_pipeline_t :: struct {
_quick_chan_store: [5]coding_channel_info_t,
}
DECODE_PIPELINE_INITIALIZER :: decode_pipeline_t{}
DECODE_PIPELINE_INITIALIZER :: decode_pipeline_t{ pipe_size = size_of(decode_pipeline_t) }
@(link_prefix="exr_", default_calling_convention="c")

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
/** Can be bit-wise or'ed into the decode_flags in the decode pipeline.
@@ -46,7 +40,13 @@ ENCODE_NON_IMAGE_DATA_AS_POINTERS :: u16(1 << 1)
* meant to be used by separate threads, which can all be accessing
* the same context concurrently.
*/
encode_pipeline_t :: struct {
encode_pipeline_t :: struct {
/** Used for versioning the decode pipeline in the future
*
* \ref EXR_ENCODE_PIPELINE_INITIALIZER
*/
pipe_size: c.size_t,
/** The output channel information for this chunk.
*
* User is expected to fill the channel pointers for the input
@@ -264,7 +264,7 @@ ENCODE_NON_IMAGE_DATA_AS_POINTERS :: u16(1 << 1)
_quick_chan_store: [5]coding_channel_info_t,
}
ENCODE_PIPELINE_INITIALIZER :: encode_pipeline_t{}
ENCODE_PIPELINE_INITIALIZER :: encode_pipeline_t{ pipe_size = size_of(encode_pipeline_t) }
@(link_prefix="exr_", default_calling_convention="c")

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
#assert(size_of(c.int) == size_of(i32))
@@ -37,6 +31,7 @@ result_t :: enum i32 {
ALREADY_WROTE_ATTRS,
BAD_CHUNK_LEADER,
CORRUPT_CHUNK,
INCOMPLETE_CHUNK_TABLE,
INCORRECT_PART,
INCORRECT_CHUNK,
USE_SCAN_DEEP_WRITE,
@@ -64,4 +59,4 @@ foreign lib {
* The string should not be freed (it is compiled into the binary).
*/
get_error_code_as_string :: proc(code: result_t) -> cstring ---
}
}

View File

@@ -1,11 +1,5 @@
package vendor_openexr
when ODIN_OS == .Windows {
foreign import lib "OpenEXRCore-3_1.lib"
} else {
foreign import lib "system:OpenEXRCore-3_1"
}
import "core:c"
attr_list_access_mode_t :: enum c.int {
@@ -73,6 +67,25 @@ foreign lib {
levely: c.int,
tilew: ^i32,
tileh: ^i32) -> result_t ---
/** @brief Query the tile count for a particular level in the specified part.
*
* If the part is a tiled part, fills in the count for the
* specified levels.
*
* Return `ERR_SUCCESS` on success, an error otherwise (i.e. if the part
* is not tiled).
*
* It is valid to pass `NULL` to either of the @p countx or @p county
* arguments, which enables testing if this part is a tiled part, or
* if you don't need both for some reason.
*/
get_tile_counts :: proc(
ctxt: const_context_t,
part_index: c.int,
levelx: c.int,
levely: c.int,
countx: ^i32,
county: ^i32) -> result_t ---
/** @brief Query the data sizes for a particular level in the specified part.
*
@@ -108,6 +121,21 @@ foreign lib {
*/
get_chunk_count :: proc(ctxt: const_context_t, part_index: c.int, out: ^i32) -> result_t ---
/** Return a pointer to the chunk table and the count
*
* TODO: consider removing this prior to release once C++ fully converted
*/
get_chunk_table :: proc(ctxt: const_context_t, part_index: c.int, table: [^][^]u64, count: ^i32) -> result_t ---
/** Return whether the chunk table for this part is completely written.
*
* This only validates that all the offsets are valid.
*
* return EXR_ERR_INCOMPLETE_CHUNK_TABLE when incomplete, EXR_ERR_SUCCESS
* if it appears ok, or another error if otherwise problematic
*/
exr_validate_chunk_table :: proc(ctxt: context_t, part_index: c.int) -> result_t ---
/** Return the number of scanlines chunks for this file part.
*
* When iterating over a scanline file, this may be an easier metric
@@ -303,10 +331,10 @@ foreign lib {
ctxt: context_t,
part_index: c.int,
name: cstring,
ptype: pixel_type_t,
ptype: pixel_type_t,
percept: perceptual_treatment_t,
xsamp: i32,
ysamp: i32) -> c.int ---
ysamp: i32) -> result_t ---
/** @brief Copy the channels from another source.
*