xrif
A fast lossless compression system
Initialization, Setup, and Allocation

Collaboration diagram for Initialization, Setup, and Allocation:

Modules

 Fine-grained Initialization, Setup, and Allocation
 

Functions

xrif_error_t xrif_new (xrif_t *handle_ptr)
 Allocate a handle and initialize it. More...
 
xrif_error_t xrif_set_size (xrif_t handle, xrif_dimension_t w, xrif_dimension_t h, xrif_dimension_t d, xrif_dimension_t f, xrif_typecode_t c)
 Set the basic parameters of an xrif handle. More...
 
xrif_error_t xrif_configure (xrif_t handle, int difference_method, int reorder_method, int compress_method)
 Configure the difference, reorder, and compression methods. More...
 
xrif_error_t xrif_allocate (xrif_t handle)
 Allocate all memory buffers according to the configuration specified in the handle. More...
 
xrif_error_t xrif_reset (xrif_t handle)
 Reset a handle, restoring it to the initialized state. De-allocates owned pointers and re-initializes. More...
 
xrif_error_t xrif_delete (xrif_t handle)
 Deallocate a handle, including any memory that it owns. More...
 

Function Documentation

◆ xrif_allocate()

xrif_error_t xrif_allocate ( xrif_t  handle)

Allocate all memory buffers according to the configuration specified in the handle.

You must call xrif_set_size and xrif_configure prior to calling this function.

Returns
XRIF_ERROR_NULLPTR if handle is a null pointer
XRIF_ERROR_NOT_SETUP if the handle has not been configured
XRIF_ERROR_MALLOC on an error from malloc
XRIF_NOERROR on success.
Parameters
[in,out]handle[in/out] the xrif object to be allocated

Definition at line 199 of file xrif.c.

References xrif_handle::compress_on_raw, xrif_handle::data_size, xrif_handle::depth, xrif_handle::frames, xrif_handle::height, xrif_handle::width, xrif_allocate_compressed(), xrif_allocate_raw(), xrif_allocate_reordered(), XRIF_ERROR_NOT_SETUP, XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, and XRIF_NOERROR.

◆ xrif_configure()

xrif_error_t xrif_configure ( xrif_t  handle,
int  difference_method,
int  reorder_method,
int  compress_method 
)

Configure the difference, reorder, and compression methods.

Sets the difference_method, reorder_method, and compress_method members of handle.

Returns
XRIF_ERROR_NULLPTR if handle is a NULL pointer
XRIF_ERROR_BADARG if difference_method, reorder_method, or compress_method is not a valid method. Will set that method its default.
XRIF_NOERROR on success.
Parameters
[in,out]handle[in/out] the xrif handle to be configured
[in]difference_method[in] the new reorder method
[in]reorder_method[in] the new reorder method
[in]compress_method[in] the new compress method

Definition at line 172 of file xrif.c.

References XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, XRIF_NOERROR, xrif_set_compress_method(), xrif_set_difference_method(), and xrif_set_reorder_method().

◆ xrif_delete()

xrif_error_t xrif_delete ( xrif_t  handle)

Deallocate a handle, including any memory that it owns.

Returns
XRIF_ERROR_NULLPTR if a null pointer is passed
XRIF_NOERROR on success
See also
xrif_new, xrif_reset
Parameters
[in]handle[in] an xrif handle which has been initialized with xrif_new

Definition at line 277 of file xrif.c.

References XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, and xrif_reset().

◆ xrif_new()

xrif_error_t xrif_new ( xrif_t handle_ptr)

Allocate a handle and initialize it.

The argument is a pointer to xrif_t, making it the address of an xrif_handle pointer.

Returns
XRIF_ERROR_NULLPTR if a null pointer is passed
XRIF_ERROR_MALLOC on an allocation error
XRIF_NOERROR on success
See also
xrif_reset, xrif_delete
Parameters
[out]handle_ptr[out] a pointer to an xrif handle.

Definition at line 107 of file xrif.c.

References XRIF_ERROR_MALLOC, XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, and xrif_initialize_handle().

Referenced by START_TEST().

◆ xrif_reset()

xrif_error_t xrif_reset ( xrif_t  handle)

Reset a handle, restoring it to the initialized state. De-allocates owned pointers and re-initializes.

Free()s the raw and reordered buffers (if owned by this handle) and calls xrif_initialize_handle(). All defaults will be set.

Returns
XRIF_ERROR_NULLPTR if handle is a null pointer
XRIF_NOERROR on success.
See also
xrif_new, xrif_delete
Parameters
[in,out]handle[in/out] the xrif handle

Definition at line 243 of file xrif.c.

References xrif_handle::compressed_buffer, xrif_handle::own_compressed, xrif_handle::own_raw, xrif_handle::own_reordered, xrif_handle::raw_buffer, xrif_handle::reordered_buffer, XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, xrif_initialize_handle(), and XRIF_NOERROR.

Referenced by xrif_delete().

◆ xrif_set_size()

Set the basic parameters of an xrif handle.

After setting these parameters, a call to one of the allocate or set functions will succceed.

Returns
XRIF_ERROR_NULLPTR if handle is a NULL pointer
XRIF_ERROR_INVALID_SIZE if any of w, h, d, or f are 0.
XRIF_ERROR_INVALID_TYPE if c specifies an invalid type code
XRIF_NOERROR on success
Parameters
[in,out]handle[in/out] the xrif handle to be set up
[in]w[in] the width of a single frame of data, in pixels
[in]h[in] the height of a single frame of data, in pixels
[in]d[in] the depth of a single frame of data, in pixels
[in]f[in] the number of frames of data, each frame having w X h x d pixels
[in]c[in] the code specifying the data type

Definition at line 128 of file xrif.c.

References xrif_handle::data_size, xrif_handle::depth, xrif_handle::frames, xrif_handle::height, xrif_handle::raw_size, xrif_handle::type_code, xrif_handle::width, XRIF_ERROR_INVALID_SIZE, XRIF_ERROR_INVALID_TYPE, XRIF_ERROR_NULLPTR, XRIF_ERROR_PRINT, XRIF_NOERROR, and xrif_typesize().