xrif
A fast lossless compression system
|
Go to the documentation of this file.
91 #ifndef _POSIX_C_SOURCE
92 #define _POSIX_C_SOURCE 199309L
101 #ifndef LZ4_MEMORY_USAGE
102 #define LZ4_MEMORY_USAGE (20)
115 #include "lz4/lz4hc.h"
121 #define XRIF_VERSION (0)
122 #define XRIF_HEADER_SIZE (48)
124 #define XRIF_DIFFERENCE_NONE (-1)
125 #define XRIF_DIFFERENCE_DEFAULT (100)
126 #define XRIF_DIFFERENCE_PREVIOUS (100)
127 #define XRIF_DIFFERENCE_FIRST (200)
128 #define XRIF_DIFFERENCE_PIXEL (300)
130 #define XRIF_REORDER_NONE (-1)
131 #define XRIF_REORDER_DEFAULT (100)
132 #define XRIF_REORDER_BYTEPACK (100)
133 #define XRIF_REORDER_BYTEPACK_RENIBBLE (200)
134 #define XRIF_REORDER_BITPACK (300)
137 #define XRIF_COMPRESS_NONE (-1)
138 #define XRIF_COMPRESS_DEFAULT (100)
139 #define XRIF_COMPRESS_LZ4 (100)
141 #define XRIF_LZ4_ACCEL_MIN (1)
142 #define XRIF_LZ4_ACCEL_MAX (65537)
160 #define XRIF_NOERROR (0)
163 #define XRIF_ERROR_NULLPTR (-5)
166 #define XRIF_ERROR_NOT_SETUP (-10)
169 #define XRIF_ERROR_INVALID_SIZE (-20)
172 #define XRIF_ERROR_INVALID_TYPE (-22)
175 #define XRIF_ERROR_INSUFFICIENT_SIZE (-25)
178 #define XRIF_ERROR_MALLOC (-30)
181 #define XRIF_ERROR_NOTIMPL (-100)
184 #define XRIF_ERROR_BADARG (-110)
187 #define XRIF_ERROR_BADHEADER (-1000)
190 #define XRIF_ERROR_WRONGVERSION (-1010)
193 #define XRIF_ERROR_LIBERR (-10000)
196 #define XRIF_ERROR_PRINT( function, msg ) fprintf(stderr, "%s: %s\n", function, msg)
211 #define XRIF_TYPECODE_UINT8 (1)
213 #define XRIF_TYPECODE_INT8 (2)
215 #define XRIF_TYPECODE_UINT16 (3)
217 #define XRIF_TYPECODE_INT16 (4)
219 #define XRIF_TYPECODE_UINT32 (5)
221 #define XRIF_TYPECODE_INT32 (6)
223 #define XRIF_TYPECODE_UINT64 (7)
225 #define XRIF_TYPECODE_INT64 (8)
227 #define XRIF_TYPECODE_HALF (13)
229 #define XRIF_TYPECODE_FLOAT (9)
231 #define XRIF_TYPECODE_DOUBLE (10)
233 #define XRIF_TYPECODE_COMPLEX_FLOAT (11)
235 #define XRIF_TYPECODE_COMPLEX_DOUBLE (12)
370 struct timespec ts_difference_start;
371 struct timespec ts_reorder_start;
372 struct timespec ts_compress_start;
373 struct timespec ts_compress_done;
375 struct timespec ts_decompress_start;
376 struct timespec ts_unreorder_start;
377 struct timespec ts_undifference_start;
378 struct timespec ts_undifference_done;
431 int difference_method,
499 int difference_method
726 uint32_t * header_size,
1227 struct timespec * ts0
1261 #endif //xrif_xrif_h
xrif_dimension_t xrif_frames(xrif_t handle)
Get the current number of frames of the configured handle.
double compression_ratio
The compression ratio, calculated as output-size/input-size.
xrif_error_t xrif_set_compressed(xrif_t handle, void *reordered, size_t size)
Set the compressed data buffer to a pre-allocated pointer.
double compress_time
Time in seconds taken to compress the data.
xrif_dimension_t width
The width of a single image, in pixels.
char * reordered_buffer
The reordered buffer pointer, contains the reordered data.
int difference_method
The difference method to use.
xrif_error_t xrif_undifference_first(xrif_t handle)
Undifference the images using the first image as a reference.
xrif_error_t xrif_difference_previous(xrif_t handle)
Difference the images using the previous image as a reference.
xrif_error_t xrif_allocate_reordered(xrif_t handle)
Allocate the reordered buffer based on the already set stream dimensions.
double xrif_ts_difference(struct timespec *ts1, struct timespec *ts0)
Calculate the difference between two timespecs.
int compress_method
The compression method used.
size_t xrif_min_raw_size(xrif_t handle)
Calculate the minimum size of the raw buffer.
uint8_t xrif_typecode_t
The type used for storing the ImageStreamIO data type code.
xrif_handle * xrif_t
The xrif handle pointer type. This provides the main interface to the xrif library.
char * compressed_buffer
The compressed buffer pointer, contains the compressed data.
int reorder_method
The method to use for bit reordering.
xrif_dimension_t xrif_depth(xrif_t handle)
Get the current depth of the configured handle.
size_t xrif_min_compressed_size(xrif_t handle)
Calculate the minimum size of the compressed buffer.
xrif_error_t xrif_reorder_bytepack_renibble(xrif_t handle)
xrif_error_t xrif_allocate_raw(xrif_t handle)
Allocate the raw buffer based on the already set stream dimensions.
int lz4_acceleration
LZ4 acceleration parameter, >=1, higher is faster with less comporession. Default is 1.
xrif_error_t xrif_set_compress_method(xrif_t handle, int compress_method)
Set the compress method.
The xrif library configuration structure, organizing various parameters used by the functions.
xrif_dimension_t frames
The number of frames in the stream.
const char * xrif_difference_method_string(int diff_method)
Get a string describing the difference method.
xrif_error_t xrif_set_raw(xrif_t handle, void *raw, size_t size)
Set the raw data buffer to a pre-allocated pointer.
xrif_error_t xrif_set_lz4_acceleration(xrif_t handle, int32_t lz4_accel)
Set the LZ4 acceleration parameter.
xrif_error_t xrif_reorder_bytepack_sint16(xrif_t handle)
Perform bytepack reodering for signed 16 bit ints.
xrif_error_t xrif_undifference_pixel(xrif_t handle)
Undifference the images using the previous pixel as a reference.
unsigned char calc_performance
Flag (true/false) controlling whether performance metrics are calculated. Default is true.
xrif_error_t xrif_decompress_lz4(xrif_t handle)
const char * xrif_reorder_method_string(int reorder_method)
Get a string describing the reordering method.
size_t reordered_buffer_size
double reorder_time
Time in seconds taken to reorder the data.
xrif_error_t xrif_new(xrif_t *handle_ptr)
Allocate a handle and initialize it.
xrif_error_t xrif_unreorder_none(xrif_t handle)
Perform no un-re-ordering, simply copy reordered to raw.
xrif_dimension_t height
The height of a single image, in pixels.
unsigned char own_reordered
Flag (true/false) indicating whether the reordered_buffer pointer is managed by this handle.
xrif_error_t xrif_allocate_compressed(xrif_t handle)
Allocate the compressed buffer based on the already set stream dimensions.
xrif_dimension_t xrif_width(xrif_t handle)
Get the current width of the configured handle.
xrif_error_t xrif_unreorder_bytepack_renibble(xrif_t handle)
xrif_error_t xrif_set_reordered(xrif_t handle, void *reordered, size_t size)
Set the rordered (working) data buffer to a pre-allocated pointer.
xrif_error_t xrif_compress_none(xrif_t handle)
xrif_error_t xrif_set_difference_method(xrif_t handle, int difference_method)
Set the difference method.
unsigned char compress_on_raw
Flag (true/false) indicating whether the raw buffer is used for compression. Default on initializeati...
int xrif_error_t
The error reporting type.
xrif_error_t xrif_difference(xrif_t handle)
Difference the image(s)
xrif_error_t xrif_compress_lz4(xrif_t handle)
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.
xrif_error_t xrif_undifference(xrif_t handle)
Undifference the image(s)
const char * xrif_compress_method_string(int compress_method)
Get a string describing the compression method.
xrif_error_t xrif_decompress_none(xrif_t handle)
xrif_error_t xrif_reorder(xrif_t handle)
Reorder the data using the method specified by reorder_method
double encode_rate
Rate at which the data was encoded in bytes per second.
xrif_error_t xrif_reorder_bytepack(xrif_t handle)
Dispatch bytepack reodering based on type.
xrif_error_t xrif_initialize_handle(xrif_t handle)
Initialize an xrif handle object.
size_t raw_size
Size of the stream before compression. Set dynamically by xrif_set_size or from header.
xrif_error_t xrif_difference_pixel(xrif_t handle)
Difference the images using the previous pixel as a reference.
double encode_time
Time in seconds taken to encode the data.
char * raw_buffer
The raw buffer pointer, contains the image data, and if compress_on_raw == true the compressed data.
xrif_error_t xrif_reset(xrif_t handle)
Reset a handle, restoring it to the initialized state. De-allocates owned pointers and re-initializes...
xrif_error_t xrif_unreorder_bytepack_sint16(xrif_t handle)
Perform bytepack unreodering for signed 16 bit ints.
double reorder_rate
Rate at which the data was reordered in bytes per second.
double difference_time
Time in seconds taken to difference the data.
size_t xrif_min_reordered_size(xrif_t handle)
Calculate the minimum size of the reordered buffer.
xrif_dimension_t depth
The depth of a single image, in pixels.
xrif_error_t xrif_delete(xrif_t handle)
Deallocate a handle, including any memory that it owns.
xrif_error_t xrif_difference_first(xrif_t handle)
Difference the images using the first image as a reference.
xrif_error_t xrif_undifference_previous(xrif_t handle)
Undifference the images using the previous image as a reference.
xrif_error_t xrif_decode(xrif_t handle)
Decode data from the xrif format.
size_t compressed_size
Size of the stream after compression. Set dynamically by compression functions or from header.
xrif_error_t xrif_reorder_bitpack(xrif_t handle)
xrif_error_t xrif_allocate(xrif_t handle)
Allocate all memory buffers according to the configuration specified in the handle.
xrif_error_t xrif_unreorder(xrif_t handle)
Un-reorder the data using the method specified by reorder_method
xrif_error_t xrif_encode(xrif_t handle)
Encode data using the xrif format.
size_t xrif_typesize(xrif_typecode_t type_code)
Return the size of the type specified by the code.
xrif_error_t xrif_reorder_bitpack_sint16(xrif_t handle)
xrif_error_t xrif_set_reorder_method(xrif_t handle, int reorder_method)
Set the reorder method.
size_t compressed_buffer_size
xrif_dimension_t xrif_height(xrif_t handle)
Get the current height of the configured handle.
unsigned char own_raw
Flag (true/false) indicating whether the raw_buffer pointer is managed by this handle.
size_t data_size
The size of the pixels, bytes. This corresponds to sizeof(type).
xrif_error_t xrif_decompress(xrif_t handle)
xrif_error_t xrif_unreorder_bytepack(xrif_t handle)
Dispatch bytepack unreodering based on type.
unsigned char own_compressed
Flag (true/false) indicating whether the compressed_buffer pointer is managed by this handle.
double compress_rate
Rate at which the data was compressed in bytes per second.
xrif_error_t xrif_unreorder_bitpack(xrif_t handle)
xrif_error_t xrif_reorder_bytepack_renibble_sint16(xrif_t handle)
xrif_typecode_t type_code
The code specifying the data type of the pixels.
uint32_t xrif_dimension_t
The type used for storing the width and height and depth dimensions of images.
xrif_error_t xrif_reorder_none(xrif_t handle)
Perform no re-ordering, simply copy raw to reordered.
xrif_error_t xrif_configure(xrif_t handle, int difference_method, int reorder_method, int compress_method)
Configure the difference, reorder, and compression methods.
double difference_rate
Rate at which the data was differenced in bytes per second.
xrif_error_t xrif_compress(xrif_t handle)