xrif
A fast lossless compression system
xrif.h
Go to the documentation of this file.
1 /** \file xrif.h
2  * \brief The eXtreme-ao Reordered Image Format: Declarations
3  *
4  * \author Jared R. Males (jaredmales@gmail.com)
5  *
6  * \ingroup xrif_files
7  */
8 
9 /* This file is part of the xrif library.
10 
11 Copyright (c) 2019, 2020, The Arizona Board of Regents on behalf of The
12 University of Arizona
13 
14 All rights reserved.
15 
16 Developed by: The Arizona Board of Regents on behalf of the
17 University of Arizona.
18 
19 Redistribution and use for noncommercial purposes in source and
20 binary forms, with or without modification, are permitted provided
21 that the following conditions are met:
22 
23 1. The software is used solely for noncommercial purposes.
24 
25 2. Redistributions of source code must retain the above copyright
26 notice, terms and conditions specified herein and the disclaimer
27 specified in Section 4 below.
28 
29 3. Redistributions in binary form must reproduce the above
30 copyright notice, this list of conditions and the following
31 disclaimer in the documentation and/or other materials provided
32 with the distribution.
33 
34 4. Neither the name of the Arizona Board of Regents, the University
35 of Arizona nor the names of other contributors may be used to
36 endorse or promote products derived from this software without
37 specific prior written permission.
38 
39 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
43 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
44 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
45 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
46 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 OF THE POSSIBILITY OF SUCH DAMAGE.
51 
52 Arizona Required Clauses:
53 
54 1.1. Arbitration. The parties agree that if a dispute arises
55 between them concerning this Agreement, the parties may be required
56 to submit the matter to arbitration pursuant to Arizona law.
57 
58 1.2. Applicable Law and Venue. This Agreement shall be interpreted
59 pursuant to the laws of the State of Arizona. Any arbitration or
60 litigation between the Parties shall be conducted in Pima County,
61 ARIZONA, and LICENSEE hereby submits to venue and jurisdiction in
62 Pima County, ARIZONA.
63 
64 1.3. Non-Discrimination. The Parties agree to be bound by state and
65 federal laws and regulations governing equal opportunity and non-
66 discrimination and immigration.
67 
68 1.4. Appropriation of Funds. The Parties recognize that performance
69 by ARIZONA may depend upon appropriation of funds by the State
70 Legislature of ARIZONA. If the Legislature fails to appropriate the
71 necessary funds, or if ARIZONA’S appropriation is reduced during
72 the fiscal year, ARIZONA may cancel this Agreement without further
73 duty or obligation. ARIZONA will notify LICENSEE as soon as
74 reasonably possible after it knows of the loss of funds.
75 
76 1.5. Conflict of Interest. This Agreement is subject to the
77 provisions of A.R.S. 38-511 and other conflict of interest
78 regulations. Within three years of the EFFECTIVE DATE, ARIZONA may
79 cancel this Agreement if any person significantly involved in
80 initiating, negotiating, drafting, securing, or creating this
81 Agreement for or on behalf of ARIZONA becomes an employee or
82 consultant in any capacity of LICENSEE with respect to the subject
83 matter of this Agreement.
84 
85 */
86 
87 #ifndef xrif_xrif_h
88 #define xrif_xrif_h
89 
90 //Needed for CLOCK_REALTIME:
91 #ifndef _POSIX_C_SOURCE
92 #define _POSIX_C_SOURCE 199309L
93 #endif
94 
95 #ifdef __cplusplus
96 extern "C"
97 {
98 #endif
99 
100 
101 #ifndef LZ4_MEMORY_USAGE
102 #define LZ4_MEMORY_USAGE (20)
103 #endif
104 
105 #include <stdlib.h>
106 #include <string.h>
107 #include <time.h>
108 
109 #include <stdio.h> //just for debug
110 
111 
112 //#include <complex.h>
113 
114 #include "lz4/lz4.h"
115 #include "lz4/lz4hc.h"
116 
117 
118 
119 
120 
121 #define XRIF_VERSION (0)
122 #define XRIF_HEADER_SIZE (48)
123 
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)
129 
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)
135 
136 
137 #define XRIF_COMPRESS_NONE (-1)
138 #define XRIF_COMPRESS_DEFAULT (100)
139 #define XRIF_COMPRESS_LZ4 (100)
140 
141 #define XRIF_LZ4_ACCEL_MIN (1)
142 #define XRIF_LZ4_ACCEL_MAX (65537)
143 
144 /// The type used for storing the width and height and depth dimensions of images.
145 typedef uint32_t xrif_dimension_t;
146 
147 /** \defgroup error_codes Error Codes
148  * \brief Error codes used by the xrif library
149  *
150  * This library defines an error code type (merely an int) and a number of codes, all less than zero, to report errors.
151  * In general we avoid in-band error reporting, with a few exceptions (e.g. xrif_typesize).
152  *
153  * @{
154  */
155 
156 /// The error reporting type.
157 typedef int xrif_error_t;
158 
159 /// Return code for success.
160 #define XRIF_NOERROR (0)
161 
162 /// Return code indicating that a NULL pointer was passed.
163 #define XRIF_ERROR_NULLPTR (-5)
164 
165 /// Return code indicating that the handle was not setup.
166 #define XRIF_ERROR_NOT_SETUP (-10)
167 
168 /// Return code indicating that an invalid size was passed.
169 #define XRIF_ERROR_INVALID_SIZE (-20)
170 
171 /// Return code indicating that an invalid type was passed.
172 #define XRIF_ERROR_INVALID_TYPE (-22)
173 
174 /// Return code indicating that an insufficient size was given.
175 #define XRIF_ERROR_INSUFFICIENT_SIZE (-25)
176 
177 /// Return code indicating a malloc failure.
178 #define XRIF_ERROR_MALLOC (-30)
179 
180 /// Return code indicating that the requested feature is not available.
181 #define XRIF_ERROR_NOTIMPL (-100)
182 
183 /// Return code indicating that a bad argument was passed.
184 #define XRIF_ERROR_BADARG (-110)
185 
186 /// Return code indicating that the header is bad.
187 #define XRIF_ERROR_BADHEADER (-1000)
188 
189 /// Return code indicating that a wrong version was specified.
190 #define XRIF_ERROR_WRONGVERSION (-1010)
191 
192 /// Return code indicating a library returned an error (e.g. LZ4). The library error code may be added to this.
193 #define XRIF_ERROR_LIBERR (-10000)
194 
195 /// Standard error report.
196 #define XRIF_ERROR_PRINT( function, msg ) fprintf(stderr, "%s: %s\n", function, msg)
197 
198 ///@}
199 
200 /** \defgroup typecodes Type Codes
201  * \brief Type codes for storing the type of the data.
202  *
203  * These are identical to the ImageStreamIO data types.
204  * @{
205  */
206 
207 /// The type used for storing the ImageStreamIO data type code.
208 typedef uint8_t xrif_typecode_t;
209 
210 /// 8-bit unsigned integer
211 #define XRIF_TYPECODE_UINT8 (1)
212 /// 8-bit signed integer
213 #define XRIF_TYPECODE_INT8 (2)
214 /// 16-bit unsigned integer
215 #define XRIF_TYPECODE_UINT16 (3)
216 /// 16-bit signed integer
217 #define XRIF_TYPECODE_INT16 (4)
218 /// 32-bit unsigned integer
219 #define XRIF_TYPECODE_UINT32 (5)
220 /// 32-bit signed integer
221 #define XRIF_TYPECODE_INT32 (6)
222 /// 64-bit unsigned integer
223 #define XRIF_TYPECODE_UINT64 (7)
224 /// 64-bit signed integer
225 #define XRIF_TYPECODE_INT64 (8)
226 /// IEEE 754 half-precision 16-bit (uses uint16_t for storage)
227 #define XRIF_TYPECODE_HALF (13)
228 /// IEEE 754 single-precision binary floating-point format: binary32
229 #define XRIF_TYPECODE_FLOAT (9)
230 /// IEEE 754 double-precision binary floating-point format: binary64
231 #define XRIF_TYPECODE_DOUBLE (10)
232 /// complex float
233 #define XRIF_TYPECODE_COMPLEX_FLOAT (11)
234 /// complex double
235 #define XRIF_TYPECODE_COMPLEX_DOUBLE (12)
236 
237 /// @}
238 
239 
240 /** \defgroup xrif_interface Top-level interface
241  * The top-level interface to the XRIF library.
242  *
243  * The following code illustrates how the XRIF library shoud used to compress data under most circumstances.
244  * Lower level access is provided if fine-grain control is needed.
245  *
246  * First, create the xrif library handle:
247  * \code
248  * xrif_error_t rv;
249  * xrif_t handle; //note: this is a pointer type
250  * rv = xrif_new(&handle); //note: the argument is a pointer to pointer
251  * //check rv for errors here . . .
252  * \endcode
253  * You now have an initialized xrif handle. The `xrif_t` type can not be used until `xrif_new` has been called on it.
254  * Never call `xrif_new` twice on the same handle, unless `xrif_delete` (see below) has been called.
255  *
256  * Next you need to configure and allocate the handle:
257  * \code
258  * rv = xrif_set_size(handle, 64,64, 1,1024, XRIF_TYPECODE_INT16);
259  * rv = xrif_configure(handle, XRIF_DIFFERENCE_PREVIOUS, XRIF_REORDER_BYTEPACK, XRIF_COMPRESS_LZ4); //Note this is optional if defaults are ok.
260  * rv = xrif_allocate(handle);
261  * \endcode
262  * The above results in an xrif handle prepared to operate on 1024 signed 16-bit images of size 64x64. (Note that you should check the value of rv for errors!)
263  *
264  * Now to compress data:
265  * \code
266  * memcpy(xrif->raw_buffer, my_source, handle->width*handle->height*handle->depth*handle->frames*handle->data_size); //You are responsible for `my_source`.
267  * rv = xrif_encode(handle);
268  * printf("%f\%\n", handle->compression_ratio*100.0);
269  * \endcode
270  * After this `handle->raw_buffer` contains the compressed data. This is because `handle->compress_on_raw == 1` by default, causing the `raw_buffer` to be re-used.
271  * This also illustrates the built in performance monitoring, which is on by default but can be turned off.
272  *
273  * To decompress:
274  * \code
275  * rv = xrif_decode(handle);
276  * memcpy(my_dest, xrif->raw_buffer, xrif->width*xrif->height*xrif->depth*xrif->frames*xrif->data_size); //You are responsible for `my_dest`.
277  * \endcode
278  * after which `my_dest` will contain the original data.
279  *
280  * To start over, use:
281  * \code
282  * rv = xrif_reset(handle);
283  * \endcode
284  *
285  * And when you are done with the handle, it can be fully de-allocated with
286  * \code
287  * rv = xrif_delete(handle);
288  * \endcode
289  * after which the handle should not be used again, unless `xrif_new` is called on it.
290  * @{
291  */
292 
293 /// The xrif library configuration structure, organizing various parameters used by the functions.
294 /** This structure provides for setup and management of memory allocation, though externally allocated
295  * buffers can be used when desired.
296  *
297  * Options related to compression level and speed are also provided.
298  *
299  * It is intended that this structure be interacted with via the xrif_t typedef, which is a pointer
300  * to xrif_handle. Values of this structure should generally be changed by one of the xrif_set_*() functions,
301  * to allow for error checking and consistency. Unless you know what you're doing, of course.
302  *
303  * \todo need xrif_set_XXXX function unit tests
304  *
305  */
306 typedef struct
307 {
308  xrif_dimension_t width; ///< The width of a single image, in pixels
309  xrif_dimension_t height; ///< The height of a single image, in pixels
310  xrif_dimension_t depth; ///< The depth of a single image, in pixels
311  xrif_dimension_t frames; ///< The number of frames in the stream
312 
313  xrif_typecode_t type_code; ///< The code specifying the data type of the pixels
314 
315  size_t data_size; ///< The size of the pixels, bytes. This corresponds to `sizeof(type)`.
316 
317  size_t raw_size; ///< Size of the stream before compression. Set dynamically by xrif_set_size or from header.
318  size_t compressed_size; ///< Size of the stream after compression. Set dynamically by compression functions or from header.
319 
320  int difference_method; ///< The difference method to use.
321 
322  int reorder_method; ///< The method to use for bit reordering.
323 
324  int compress_method; ///< The compression method used.
325 
326  int lz4_acceleration; ///< LZ4 acceleration parameter, >=1, higher is faster with less comporession. Default is 1.
327 
328  int omp_parallel; /**< Flag controlling whether OMP parallelization is used to speed up. This has no effect if XRIF_NO_OMP is defined at compile time,
329  which completely removes OMP code. Default is 0.*/
330 
331  int omp_numthreads; /**< Number of threads to use if omp_parallel is 1. For this to be meaningful,
332  * XRIF_NO_OMP must NOT be defined at compile time, and XRIF_OMP_NUMTHREADS must be defined at compile time. Default is 1.*/
333 
334  unsigned char compress_on_raw; ///< Flag (true/false) indicating whether the raw buffer is used for compression. Default on initializeation is true.
335 
336  unsigned char own_raw; ///< Flag (true/false) indicating whether the raw_buffer pointer is managed by this handle
337  char * raw_buffer; ///< The raw buffer pointer, contains the image data, and if compress_on_raw == true the compressed data.
338  size_t raw_buffer_size; /**< The size of the raw_buffer pointer. If `compress_on_raw` is false, then this must be at least width*height*depth*frames*data_size. If
339  *` compress_on_raw` is true, this should be at least LZ4_compressBound(width*height*depth*frames*data_size) in size, but this is not a strict
340  * requirement in practice for most streams. If this library is used to allocate it, it will be the larger of the two possibilities.*/
341 
342  unsigned char own_reordered; ///< Flag (true/false) indicating whether the reordered_buffer pointer is managed by this handle.
343  char * reordered_buffer; ///< The reordered buffer pointer, contains the reordered data.
344  size_t reordered_buffer_size; ///< The size of the reordered_buffer pointer. It must be at least width*height*depth*frames*data_size.
345  ///\todo need reordered_buffer_minsize; ///< The minimum size of the reordered buffer for the image parameters.
346 
347 
348  unsigned char own_compressed; ///< Flag (true/false) indicating whether the compressed_buffer pointer is managed by this handle.
349  char * compressed_buffer; ///< The compressed buffer pointer, contains the compressed data.
350  size_t compressed_buffer_size; /**< The size of the compressed_buffer pointer. In principle should be at least LZ4_compressBound(width*height*depth*frames*data_size)
351  * in size, but this is not a strict requirement in practice for most streams. It must be at least width*height*depth*frames*data_size.
352  * If this library is used to allocate it, it will be the larger of the two.*/
353 
354 
355  /** \name Performance Measurements
356  * @{
357  */
358  unsigned char calc_performance; ///< Flag (true/false) controlling whether performance metrics are calculated. Default is true.
359 
360  double compression_ratio; ///< The compression ratio, calculated as output-size/input-size
361  double encode_time; ///< Time in seconds taken to encode the data
362  double encode_rate; ///< Rate at which the data was encoded in bytes per second
363  double difference_time; ///< Time in seconds taken to difference the data
364  double difference_rate; ///< Rate at which the data was differenced in bytes per second
365  double reorder_time; ///< Time in seconds taken to reorder the data
366  double reorder_rate; ///< Rate at which the data was reordered in bytes per second
367  double compress_time; ///< Time in seconds taken to compress the data
368  double compress_rate; ///< Rate at which the data was compressed in bytes per second
369 
370  struct timespec ts_difference_start; ///< Timespec used to mark the beginning of differencing, which is also the beginning of encoding
371  struct timespec ts_reorder_start; ///< Timespec used to mark the beginning of reordering, which is the end of differencing
372  struct timespec ts_compress_start; ///< Timespec used to mark the beginning of compression, which is the end of reordering
373  struct timespec ts_compress_done; ///< Timespec used to mark the end of compression and encoding
374 
375  struct timespec ts_decompress_start; ///< Timespec used to mark the beginning of decompression, which is also the beginning of decoding
376  struct timespec ts_unreorder_start; ///< Timespec used to mark the beginning of unreordering, which is the end of decompression
377  struct timespec ts_undifference_start; ///< Timespec used to mark the beginning of undifferencing, which is the end of unreordering
378  struct timespec ts_undifference_done; ///< Timespec used to mark the end of undifferencing and decoding
379 
380  ///@}
381 
382 } xrif_handle;
383 
384 /// The xrif handle pointer type. This provides the main interface to the xrif library.
386 
387 ///@}
388 
389 
390 /** \defgroup xrif_init Initialization, Setup, and Allocation
391  * \ingroup xrif_interface
392  * @{
393  */
394 
395 /// Allocate a handle and initialize it.
396 /** The argument is a pointer to \ref xrif_t, making it the address of an `xrif_handle` pointer.
397  *
398  * \returns \ref XRIF_ERROR_NULLPTR if a null pointer is passed
399  * \returns \ref XRIF_ERROR_MALLOC on an allocation error
400  * \returns \ref XRIF_NOERROR on success
401  *
402  * \see xrif_reset, xrif_delete
403  */
404 xrif_error_t xrif_new(xrif_t * handle_ptr /**< [out] a pointer to an xrif handle. */);
405 
406 /// Set the basic parameters of an xrif handle
407 /** After setting these parameters, a call to one of the allocate or set functions
408  * will succceed.
409  *
410  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
411  * \returns \ref XRIF_ERROR_INVALID_SIZE if any of `w`, `h`, `d`, or `f` are 0.
412  * \returns \ref XRIF_ERROR_INVALID_TYPE if `c` specifies an invalid type code
413  * \returns \ref XRIF_NOERROR on success
414  */
415 xrif_error_t xrif_set_size( xrif_t handle, ///< [in/out] the xrif handle to be set up
416  xrif_dimension_t w, ///< [in] the width of a single frame of data, in pixels
417  xrif_dimension_t h, ///< [in] the height of a single frame of data, in pixels
418  xrif_dimension_t d, ///< [in] the depth of a single frame of data, in pixels
419  xrif_dimension_t f, ///< [in] the number of frames of data, each frame having w X h x d pixels
420  xrif_typecode_t c ///< [in] the code specifying the data type
421  );
422 
423 /// Configure the difference, reorder, and compression methods.
424 /** Sets the difference_method, reorder_method, and compress_method members of handle.
425  *
426  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
427  * \returns \ref XRIF_ERROR_BADARG if `difference_method`, `reorder_method`, or `compress_method` is not a valid method. Will set that method its default.
428  * \returns \ref XRIF_NOERROR on success.
429  */
430 xrif_error_t xrif_configure( xrif_t handle, ///< [in/out] the xrif handle to be configured
431  int difference_method, ///< [in] the new reorder method
432  int reorder_method, ///< [in] the new reorder method
433  int compress_method ///< [in] the new compress method
434  );
435 
436 /// Allocate all memory buffers according to the configuration specified in the handle.
437 /** You must call xrif_set_size and xrif_configure prior to calling this function.
438  *
439  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a null pointer
440  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle has not been configured
441  * \returns \ref XRIF_ERROR_MALLOC on an error from `malloc`
442  * \returns \ref XRIF_NOERROR on success.
443  */
444 xrif_error_t xrif_allocate( xrif_t handle /**< [in/out] the xrif object to be allocated */);
445 
446 
447 /// Reset a handle, restoring it to the initialized state. De-allocates owned pointers and re-initializes.
448 /** Free()s the raw and reordered buffers (if owned by this handle) and
449  * calls xrif_initialize_handle(). All defaults will be set.
450  *
451  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a null pointer
452  * \returns \ref XRIF_NOERROR on success.
453  *
454  * \see xrif_new, xrif_delete
455  */
456 xrif_error_t xrif_reset( xrif_t handle /**< [in/out] the xrif handle */);
457 
458 /// Deallocate a handle, including any memory that it owns.
459 /**
460  * \returns \ref XRIF_ERROR_NULLPTR if a null pointer is passed
461  * \returns \ref XRIF_NOERROR on success
462  *
463  * \see xrif_new, xrif_reset
464  */
465 xrif_error_t xrif_delete(xrif_t handle /**< [in] an xrif handle which has been initialized with xrif_new */);
466 
467 /// @}
468 
469 /** \defgroup xrif_init_fine Fine-grained Initialization, Setup, and Allocation
470  * \ingroup xrif_init
471  * @{
472  */
473 
474 /// Initialize an xrif handle object.
475 /** Sets all values to defaults, and ensures that
476  * calls to allocate functions or xrif_reset_handle
477  * will safely succeed.
478  *
479  * In general this should not be called independently, rather you should use
480  * xrif_new. If you do, this function must only be called on an xrif handle which does
481  * not already have memory alocated -- otherwise memory leaks will occur!
482  *
483  * \returns \ref XRIF_ERROR_NULLPTR if handle is NULL.
484  * \returns \ref XRIF_NOERROR on success
485  *
486  * \test Verify handle initialization. \ref tests_initialize_handle_noerror "[test doc]"
487  * \test Verify xrif_initialize_handle returns error on NULL pointer. \ref tests_initialize_handle_nullptr "[test doc]"
488  */
489 xrif_error_t xrif_initialize_handle( xrif_t handle /**< [out] the xrif handle to initialize */);
490 
491 /// Set the difference method.
492 /** Sets the difference_method member of handle.
493  *
494  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
495  * \returns \ref XRIF_ERROR_BADARG if `difference_method` is not a valid difference method. Will set method to XRIF_DIFFERENCE_DEFAULT.
496  * \returns \ref XRIF_NOERROR on success.
497  */
498 xrif_error_t xrif_set_difference_method( xrif_t handle, ///< [in/out] the xrif handle to be configured
499  int difference_method ///< [in] the new reorder method
500  );
501 
502 /// Set the reorder method.
503 /** Sets the reorder_method member of handle.
504  *
505  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
506  * \returns \ref XRIF_ERROR_BADARG if `reorder_method` is not a valid reorder method. Will set method to XRIF_REORDER_DEFAULT.
507  * \returns \ref XRIF_NOERROR on success.
508  */
509 xrif_error_t xrif_set_reorder_method( xrif_t handle, ///< [in/out] the xrif handle to be configured
510  int reorder_method ///< [in] the new reorder method
511  );
512 
513 /// Set the compress method.
514 /** Sets the compress_method member of handle.
515  * Valid methods are XRIF_COMPRESS_NONE, XRIF_COMPRESS_DEFAULT, and XRIF_COMPRESS_LZ4. XRIF_COMPRESS_DEFAULT is equivalent to XRIF_COMPRESS_LZ4.
516  *
517  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
518  * \returns \ref XRIF_ERROR_BADARG if `compress_method` is not a valid compress method. Will set method to XRIF_COMPRESS_DEFAULT.
519  * \returns \ref XRIF_NOERROR on success.
520  */
521 xrif_error_t xrif_set_compress_method( xrif_t handle, ///< [in/out] the xrif handle to be configured
522  int compress_method ///< [in] the new compress method
523  );
524 
525 /// Set the LZ4 acceleration parameter
526 /** The LZ4 acceleration paraameter is a number greater than or equal to 1. Larger values speed up the compression
527  * process, but with less size reduction. The default and minimum value is 1 (XRIF_LZ4_ACCEL_MIN).
528  * The maximum value is 65537 (XRIF_LZ4_ACCEL_MAX). The LZ4 docs claim a +-3% improvement in speed for each incrment.
529  *
530  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
531  * \returns \ref XRIF_ERROR_BADARG if `lz4_acceleration` is out of range. Will set value to correspondling min or max limit.
532  * \returns \ref XRIF_NOERROR on success.
533  */
534 xrif_error_t xrif_set_lz4_acceleration( xrif_t handle, ///< [in/out] the xrif handle to be configured
535  int32_t lz4_accel ///< [in] LZ4 acceleration parameter
536  );
537 
538 /// Calculate the minimum size of the raw buffer.
539 /** Result is based on current connfiguration of the handle.
540  *
541  * \returns the minimum size of the raw buffer for a valid configuration.
542  * \returns 0 for an invalid configuration.
543  */
544 size_t xrif_min_raw_size(xrif_t handle /**< [in] the xrif handle */ );
545 
546 /// Calculate the minimum size of the reordered buffer.
547 /** Result is based on current connfiguration of the handle.
548  *
549  * \returns the minimum size of the reordered buffer for a valid configuration.
550  * \returns 0 for an invalid configuration.
551  */
552 size_t xrif_min_reordered_size(xrif_t handle /**< [in] the xrif handle */ );
553 
554 /// Calculate the minimum size of the compressed buffer.
555 /** Result is based on current connfiguration of the handle.
556  *
557  * \returns the minimum size of the compressed buffer for a valid configuration.
558  * \returns 0 for an invalid configuration.
559  */
560 size_t xrif_min_compressed_size(xrif_t handle /**< [in] the xrif handle */ );
561 
562 /// Set the raw data buffer to a pre-allocated pointer
563 /** Must only be called after \ref xrif_set_size and \ref xrif_configure have been called.
564  * You are responsible for allocating the buffer to be at least as large as the value returned by \ref xrif_min_raw_size.
565  * This will return an error if size is too small for the currently set values.
566  *
567  * This pointer will not be free()-ed on a call to \ref xrif_reset_handle.
568  *
569  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
570  * \returns \ref XRIF_ERROR_INVALID_SIZE if bad values are passed for raw or size
571  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if the size of the buffer is too small for the configured parameters
572  * \returns \ref XRIF_NOERROR on success
573  *
574  * \see xrif_allocate_raw
575  */
576 xrif_error_t xrif_set_raw( xrif_t handle, ///< [in/out] the xrif handle
577  void * raw, ///< [in] the pointer to a pre-allocated block
578  size_t size ///< [in] the size of the pre-allocated block
579  );
580 
581 /// Allocate the raw buffer based on the already set stream dimensions.
582 /** Must only be called after \ref xrif_set_size and \ref xrif_configure have been called.
583  *
584  * If xrif_handle::raw_buffer is currently allocated and owned, it is first free()-ed.
585  *
586  * The size will be set to the maximum of the pre-setup data size and (if xrif_handle::compress_on_raw == true)
587  * the LZ4_compressBound result. LZ4 typically (in all tested cases) requests
588  * a few hundred more bytes for compression.
589  *
590  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a null pointer
591  * \returns \ref XRIF_ERROR_NOT_SETUP if the width, heigh, depth, frames, and data_size parameters have not been set
592  * \returns \ref XRIF_ERROR_MALLOC if malloc returns a null pointer. In this case own_raw will be set to 0.
593  * \returns \ref XRIF_NOERROR on success
594  *
595  * \see xrif_set_raw
596  */
597 xrif_error_t xrif_allocate_raw( xrif_t handle /**< [in/out] the xrif object to modify */);
598 
599 
600 /// Set the rordered (working) data buffer to a pre-allocated pointer
601 /** Must only be called after xrif_set_size and xrif_configure have been called.
602  *
603  * You are responsible for allocating the buffer to be at least the value returned by xrif_min_reordered_size(xrif_t).
604  *
605  * This pointer will not be free()-ed on a call to xrif_reset_handle.
606  *
607  * \returns 0 on success
608  * \returns < 0 on error, with the appropriate XRIF_ERROR_* code.
609  *
610  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
611  * \returns \ref XRIF_ERROR_INVALID_SIZE if bad values are passed for raw or size
612  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if the size of the buffer is too small for the configured parameters
613  * \returns \ref XRIF_NOERROR on success\todo need to have a min size calculation function exposed
614  *
615  */
616 xrif_error_t xrif_set_reordered( xrif_t handle, ///< [in/out] the xrif object to modify
617  void * reordered, ///< [in] pointer to a pre-allocated block
618  size_t size ///< [in] the size of the pre-allocated block
619  );
620 
621 /// Allocate the reordered buffer based on the already set stream dimensions.
622 /** Must only be called after xrif_set_size and xrif_configure have been called.
623  *
624  * If the reordered_buffer is currently allocated and owned, it is first free()-ed.
625  *
626  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a null pointer
627  * \returns \ref XRIF_ERROR_NOT_SETUP if the width, heigh, depth, frames, and data_size parameters have not been set
628  * \returns \ref XRIF_ERROR_MALLOC if malloc returns a null pointer. In this case own_raw will be set to 0.
629  * \returns \ref XRIF_NOERROR on success
630  *
631  */
632 xrif_error_t xrif_allocate_reordered( xrif_t handle /**< [in/out] the xrif object to modify */);
633 
634 /// Set the compressed data buffer to a pre-allocated pointer
635 /** Must only be called after xrif_set_size and xrif_configure have been called.
636  *
637  * You are responsible for allocating the buffer to be at least as large as xrif_min_compressed_size(xrif_t).
638  *
639  *
640  * This pointer will not be free()-ed on a call to xrif_reset_handle.
641  *
642  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a NULL pointer
643  * \returns \ref XRIF_ERROR_INVALID_SIZE if bad values are passed for raw or size
644  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if the size of the buffer is too small for the configured parameters
645  * \returns \ref XRIF_NOERROR on success\todo need to have a min size calculation function exposed
646  *
647  */
648 xrif_error_t xrif_set_compressed( xrif_t handle, ///< [in/out] the xrif object to modify
649  void * reordered, ///< [in] pointer to a pre-allocated block
650  size_t size ///< [in] the size of the pre-allocated block
651  );
652 
653 /// Allocate the compressed buffer based on the already set stream dimensions.
654 /** Must only be called after xrif_set_size and xrif_configure have been called.
655  *
656  * If the compressed_buffer is currently allocated and owned, it is first free()-ed.
657  *
658  * \returns \ref XRIF_ERROR_NULLPTR if `handle` is a null pointer
659  * \returns \ref XRIF_ERROR_NOT_SETUP if the width, heigh, depth, frames, and data_size parameters have not been set
660  * \returns \ref XRIF_ERROR_MALLOC if malloc returns a null pointer. In this case own_raw will be set to 0.
661  * \returns \ref XRIF_NOERROR on success
662  */
663 xrif_error_t xrif_allocate_compressed( xrif_t handle /**< [in/out] the xrif handle */);
664 
665 /// @}
666 
667 /** \defgroup access Current Configuration
668  * \ingroup \xrif_interface
669  *
670  * Access to current configuration values.
671  *
672  *@{
673  */
674 
675 /// Get the current width of the configured handle.
676 /**
677  * \returns the width
678  */
679 xrif_dimension_t xrif_width( xrif_t handle /**< [in] the xrif handle*/);
680 
681 /// Get the current height of the configured handle.
682 /**
683  * \returns the height
684  */
685 xrif_dimension_t xrif_height( xrif_t handle /**< [in] the xrif handle*/);
686 
687 /// Get the current depth of the configured handle.
688 /**
689  * \returns the depth
690  */
691 xrif_dimension_t xrif_depth( xrif_t handle /**< [in] the xrif handle*/);
692 
693 /// Get the current number of frames of the configured handle.
694 /**
695  * \returns the frames
696  */
697 xrif_dimension_t xrif_frames( xrif_t handle /**< [in] the xrif handle*/);
698 
699 ///@}
700 
701 /** \defgroup header Header Processing
702  * \ingroup xrif_interface
703  *
704  * These functions populate or read the xrif header.
705  *
706  * @{
707  */
708 
709 /// Populate a header buffer with the xrif protocol details.
710 /**
711  * \returns \ref XRIF_ERROR_NULLPTR if either header or handle is NULL
712  * \returns \ref XRIF_NOERROR on success
713  */
714 xrif_error_t xrif_write_header( char * header, ///< [out] the buffer to hold the protocol header. Must be at least 48 bytes long.
715  xrif_t handle ///< [in] the xrif handle from which to populate the header. This must have been created with xrif_new.
716  );
717 
718 /// Configure an xrif handle by reading a xrif protocol header
719 /**
720  * \returns \ref XRIF_ERROR_NULLPTR if any of the arguments are NULL
721  * \returns \ref XRIF_ERROR_BADHEADER if the xrif magic number is not the first 4 bytes
722  * \returns \ref XRIF_ERROR_WRONGVERSION if the XRIF version in the header is too high for the compiled library
723  * \returns \ref XRIF_NOERROR on success
724  */
725 xrif_error_t xrif_read_header( xrif_t handle, ///< [out] the xrif header to configure. This must have been created with xrif_new.
726  uint32_t * header_size, ///< [out] the total size of the header, read from the buffer.
727  char * header ///< [in] the buffer containing the header
728  );
729 ///@}
730 
731 /** \defgroup xrif_encode Encoding & Decoding
732  * \ingroup xrif_interface
733  *
734  * These functions perform a complete cycle of encode and decode.
735  *
736  * @{
737  */
738 
739 /// Encode data using the xrif format
740 /** Calls \ref xrif_difference(), \ref xrif_reorder(), and \ref xrif_compress().
741  * If any of these returns an error, that error is returned.
742  * If all methods are NONE, this is a no-op and returns immediately.
743  *
744  * The timespecs are updated during this call.
745  *
746  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
747  * \returns \ref XRIF_ERROR_NOTIMPL if any of xrif_handle::difference_method, xrif_handle::reorder_method, or xrif_handle::compress_method as set in the handle are not valid
748  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either xrif_handle::raw_buffer or xrif_handle::reordered_buffer are not of sufficient size for the configured handle
749  * \returns \ref XRIF_NOERROR on success
750  *
751  * \see xrif_decode
752  */
753 xrif_error_t xrif_encode( xrif_t handle /**< [in/out] the xrif handle */);
754 
755 /// Decode data from the xrif format
756 /** Calls \ref xrif_decompress, \ref xrif_unreorder, and \ref xrif_undifference.
757  * If any of these returns an error, that error is returned.
758  *
759  * The timespecs are updated during this call.
760  *
761  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
762  * \returns \ref XRIF_ERROR_NOTIMPL if any of xrif_handle::difference_method, xrif_handle::reorder_method, or xrif_handle::compress_method as set in the handle are not valid
763  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either xrif_handle::raw_buffer or xrif_handle::reordered_buffer are not of sufficient size for the configured handle
764  * \returns \ref XRIF_NOERROR on success
765  *
766  * \see xrif_encode
767  */
768 xrif_error_t xrif_decode( xrif_t handle /**< [in/out] the xrif handle */);
769 
770 
771 /// @}
772 
773 /** \defgroup xrif_diff Differencing
774  * \ingroup xrif_encode
775  *
776  * @{
777  */
778 
779 /// Difference the image(s)
780 /** This function calls the method specific difference function for the method specified by
781  * handle->difference_method.
782  *
783  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
784  * \returns \ref XRIF_ERROR_NOTIMPL if xrif_handle::difference_method as set in the handle is not valid
785  * \returns other error codes from the differencing functions
786  * \returns \ref XRIF_NOERROR on success
787  */
788 xrif_error_t xrif_difference( xrif_t handle /**< [in/out] the xrif handle */ );
789 
790 /// Undifference the image(s)
791 /** This function calls the method specific undifference function for the method specified by
792  * handle->difference_method.
793  *
794  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
795  * \returns \ref XRIF_ERROR_NOTIMPL if xrif_handle::difference_method as set in the handle is not valid
796  * \returns other error codes from the differencing functions
797  * \returns \ref XRIF_NOERROR on success
798  */
799 xrif_error_t xrif_undifference( xrif_t handle /**< [in/out] the xrif handle */ );
800 
801 ///@}
802 
803 /** \defgroup xrif_diff_previous Previous Differencing
804  * \ingroup xrif_diff
805  *
806  * The previous differencing method uses the previous frame as the reference.
807  *
808  * @{
809  */
810 
811 /// Difference the images using the previous image as a reference.
812 /** This function calls the type specific difference function for the type specified by
813  * handle->type_code.
814  *
815  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
816  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
817  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
818  * \returns \ref XRIF_ERROR_NOTIMPL if differencing is not implemented for the type specified in xrif_handle::type_code
819  * \returns \ref XRIF_NOERROR on success
820  *
821  * \test Verify previous differencing for int16_t \ref diff_previous_int16_white "[test doc]"
822  * \test Verify previous differencing for uint16_t \ref diff_previous_uint16_white "[test doc]"
823  * \test Verify previous differencing for int32_t \ref diff_previous_int32_white "[test doc]"
824  * \test Verify previous differencing for uint32_t \ref diff_previous_uint32_white "[test doc]"
825  * \test Verify previous differencing for int64_t \ref diff_previous_int64_white "[test doc]"
826  * \test Verify previous differencing for uint64_t \ref diff_previous_uint64_white "[test doc]"
827  */
828 xrif_error_t xrif_difference_previous( xrif_t handle /**< [in/out] the xrif handle */ );
829 
830 ///@}
831 
832 /** \defgroup xrif_diff_first First Differencing
833  * \ingroup xrif_diff
834  *
835  * The first differencing method uses the first frame as the reference for all subsequent frames.
836  *
837  * @{
838  */
839 
840 /// Difference the images using the first image as a reference.
841 /** This function calls the type specific difference function for the type specified by
842  * handle->type_code.
843  *
844  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
845  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
846  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
847  * \returns \ref XRIF_ERROR_NOTIMPL if differencing is not implemented for the type specified in xrif_handle::type_code
848  * \returns \ref XRIF_NOERROR on success
849  *
850  * \test Verify first differencing for int16_t \ref diff_first_int16_white "[test doc]"
851  * \test Verify first differencing for uint16_t \ref diff_first_uint16_white "[test doc]"
852  * \test Verify first differencing for int32_t \ref diff_first_int32_white "[test doc]"
853  * \test Verify first differencing for uint32_t \ref diff_first_uint32_white "[test doc]"
854  * \test Verify first differencing for int64_t \ref diff_first_int64_white "[test doc]"
855  * \test Verify first differencing for uint64_t \ref diff_first_uint64_white "[test doc]"
856  */
857 xrif_error_t xrif_difference_first( xrif_t handle /**< [in/out] the xrif handle */ );
858 
859 ///@}
860 
861 /** \defgroup xrif_diff_pixel Pixel Differencing
862  * \ingroup xrif_diff
863  *
864  * The pixel differencing method uses the previous pixel as the reference.
865  *
866  * @{
867  */
868 
869 /// Difference the images using the previous pixel as a reference.
870 /** This function calls the type specific difference function for the type specified by
871  * handle->type_code.
872  *
873  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
874  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
875  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
876  * \returns \ref XRIF_ERROR_NOTIMPL if differencing is not implemented for the type specified in xrif_handle::type_code
877  * \returns \ref XRIF_NOERROR on success
878  *
879  * \test Verify pixel differencing for int16_t \ref diff_pixel_int16_white "[test doc]"
880  * \test Verify pixel differencing for uint16_t \ref diff_pixel_uint16_white "[test doc]"
881  * \test Verify pixel differencing for int32_t \ref diff_pixel_int32_white "[test doc]"
882  * \test Verify pixel differencing for uint32_t \ref diff_pixel_uint32_white "[test doc]"
883  * \test Verify pixel differencing for int64_t \ref diff_pixel_int64_white "[test doc]"
884  * \test Verify pixel differencing for uint64_t \ref diff_pixel_uint64_white "[test doc]"
885  *
886  */
887 xrif_error_t xrif_difference_pixel( xrif_t handle /**< [in/out] the xrif handle */ );
888 
889 
890 ///@}
891 
892 /// Undifference the images using the previous image as a reference.
893 /** This function calls the type specific undifference function for the type specified by
894  * handle->type_code.
895  *
896  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
897  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
898  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
899  * \returns \ref XRIF_ERROR_NOTIMPL if undifferencing is not implemented for the type specified in xrif_handle::type_code
900  * \returns \ref XRIF_NOERROR on success
901  *
902  * \test Verify previous differencing for int16_t \ref diff_previous_int16_white "[test doc]"
903  * \test Verify previous differencing for uint16_t \ref diff_previous_uint16_white "[test doc]"
904  * \test Verify previous differencing for int32_t \ref diff_previous_int32_white "[test doc]"
905  * \test Verify previous differencing for uint32_t \ref diff_previous_uint32_white "[test doc]"
906  * \test Verify previous differencing for int64_t \ref diff_previous_int64_white "[test doc]"
907  * \test Verify previous differencing for uint64_t \ref diff_previous_uint64_white "[test doc]"
908  *
909  * \ingroup xrif_diff_previous
910  */
911 xrif_error_t xrif_undifference_previous( xrif_t handle /**< [in/out] the xrif handle */ );
912 
913 /// Undifference the images using the first image as a reference.
914 /** This function calls the type specific undifference function for the type specified by
915  * handle->type_code.
916  *
917  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
918  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
919  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
920  * \returns \ref XRIF_ERROR_NOTIMPL if undifferencing is not implemented for the type specified in xrif_handle::type_code
921  * \returns \ref XRIF_NOERROR on success
922  *
923  * \test Verify first differencing for int16_t \ref diff_first_int16_white "[test doc]"
924  * \test Verify first differencing for uint16_t \ref diff_first_uint16_white "[test doc]"
925  * \test Verify first differencing for int32_t \ref diff_first_int32_white "[test doc]"
926  * \test Verify first differencing for uint32_t \ref diff_first_uint32_white "[test doc]"
927  * \test Verify first differencing for int64_t \ref diff_first_int64_white "[test doc]"
928  * \test Verify first differencing for uint64_t \ref diff_first_uint64_white "[test doc]"
929  *
930  * \ingroup xrif_diff_first
931  */
932 xrif_error_t xrif_undifference_first( xrif_t handle /**< [in/out] the xrif handle */ );
933 
934 /// Undifference the images using the previous pixel as a reference.
935 /** This function calls the type specific undifference function for the type specified by
936  * handle->type_code.
937  *
938  * \returns \ref XRIF_ERROR_NULLPTR if the handle is NULL
939  * \returns \ref XRIF_ERROR_NOT_SETUP if the handle is not configured
940  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if raw_buffer_size is not big enough given the configuration
941  * \returns \ref XRIF_ERROR_NOTIMPL if undifferencing is not implemented for the type specified in xrif_handle::type_code
942  * \returns \ref XRIF_NOERROR on success
943  *
944  * \test Verify pixel differencing for int16_t \ref diff_pixel_int16_white "[test doc]"
945  * \test Verify pixel differencing for uint16_t \ref diff_pixel_uint16_white "[test doc]"
946  * \test Verify pixel differencing for int32_t \ref diff_pixel_int32_white "[test doc]"
947  * \test Verify pixel differencing for uint32_t \ref diff_pixel_uint32_white "[test doc]"
948  * \test Verify pixel differencing for int64_t \ref diff_pixel_int64_white "[test doc]"
949  * \test Verify pixel differencing for uint64_t \ref diff_pixel_uint64_white "[test doc]"
950  *
951  * \ingroup xrif_diff_pixel
952  */
953 xrif_error_t xrif_undifference_pixel( xrif_t handle /**< [in/out] the xrif handle */ );
954 
955 
956 /** \defgroup xrif_reorder Reordering
957  * \ingroup xrif_encode
958  * @{
959  */
960 
961 /// Reorder the data using the method specified by `reorder_method`
962 /**
963  * \returns \ref XRIF_ERROR_NONE on success
964  * \returns an error code on an error.
965  */
966 xrif_error_t xrif_reorder( xrif_t handle /**< [in/out] the xrif handle */);
967 
968 /// Un-reorder the data using the method specified by `reorder_method`
969 /**
970  * \returns \ref XRIF_ERROR_NONE on success
971  * \returns an error code on an error.
972  */
973 xrif_error_t xrif_unreorder( xrif_t handle /**< [in/out] the xrif handle */);
974 
975 //xrif_reorder:
976 ///@}
977 
978 
979 /** \defgroup xrif_reorder_none No reordering
980  * \ingroup xrif_reorder
981  *
982  * Functions to perform the "none" reordering method
983  *
984  * @{
985  */
986 
987 /// Perform no re-ordering, simply copy raw to reordered.
988 /** Also zeroes any excess in xrif_handle::reordered_buffer.
989  *
990  * \returns \ref XRIF_NOERROR on success
991  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
992  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if allocated buffers aren't big enough
993  */
994 xrif_error_t xrif_reorder_none( xrif_t handle /**< [in/out] the xrif handle */ );
995 
996 //xrif_reorder_none:
997 ///@}
998 
999 /** \defgroup xrif_reorder_bytepack Bytepack reordering
1000  * \ingroup xrif_reorder
1001  *
1002  * Functions to perform the "bytepack" reordering method
1003  *
1004  * @{
1005  */
1006 
1007 /// Dispatch bytepack reodering based on type
1008 /** Calls the type appropriate xrif_reorder_bytepack_X function.
1009  *
1010  * \returns \ref XRIF_NOERROR on success
1011  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
1012  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either raw_buffer or reorderd_buffer aren't big enough
1013  */
1014 xrif_error_t xrif_reorder_bytepack( xrif_t handle /**< [in/out] the xrif handle */ );
1015 
1016 /// Perform bytepack reodering for signed 16 bit ints
1017 /**
1018  *
1019  * \returns \ref XRIF_NOERROR on success
1020  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
1021  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either raw_buffer or reorderd_buffer aren't big enough
1022  */
1023 xrif_error_t xrif_reorder_bytepack_sint16( xrif_t handle /**< [in/out] the xrif handle */ );
1024 
1025 //xrif_reorder_bytepack:
1026 ///@}
1027 
1028 xrif_error_t xrif_reorder_bytepack_renibble( xrif_t handle /**< [in/out] the xrif handle */ );
1029 
1030 xrif_error_t xrif_reorder_bytepack_renibble_sint16( xrif_t handle /**< [in/out] the xrif handle */ );
1031 
1032 xrif_error_t xrif_reorder_bitpack( xrif_t handle /**< [in/out] the xrif handle */ );
1033 
1034 xrif_error_t xrif_reorder_bitpack_sint16( xrif_t handle /**< [in/out] the xrif handle */ );
1035 
1036 /// Perform no un-re-ordering, simply copy reordered to raw.
1037 /** Also zeroes any excess in xrif_handle::raw_buffer.
1038  *
1039  * \returns \ref XRIF_NOERROR on success
1040  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
1041  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if allocated buffers aren't big enough
1042  *
1043  * \ingroup xrif_reorder_none
1044  */
1045 xrif_error_t xrif_unreorder_none( xrif_t handle /**< [in/out] the xrif handle */);
1046 
1047 /// Dispatch bytepack unreodering based on type
1048 /** Calls the type appropriate xrif_unreorder_bytepack_X function.
1049  *
1050  * \returns \ref XRIF_NOERROR on success
1051  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
1052  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either raw_buffer or reorderd_buffer aren't big enough
1053  *
1054  * \ingroup xrif_reorder_bytepack
1055  */
1056 xrif_error_t xrif_unreorder_bytepack( xrif_t handle /**< [in/out] the xrif handle */);
1057 
1058 /// Perform bytepack unreodering for signed 16 bit ints
1059 /**
1060  * \todo this does not actually perform any size checks, but should.
1061  *
1062  * \returns \ref XRIF_NOERROR on success
1063  * \returns \ref XRIF_ERROR_NULLPTR if handle is null.
1064  * \returns \ref XRIF_ERROR_INSUFFICIENT_SIZE if either raw_buffer or reorderd_buffer aren't big enough
1065  *
1066  * \ingroup xrif_reorder_bytepack
1067  */
1068 xrif_error_t xrif_unreorder_bytepack_sint16( xrif_t handle /**< [in/out] the xrif handle */);
1069 
1070 xrif_error_t xrif_unreorder_bytepack_renibble( xrif_t handle /**< [in/out] the xrif handle */);
1071 
1072 xrif_error_t xrif_unreorder_bitpack( xrif_t handle /**< [in/out] the xrif handle */);
1073 
1074 ///@}
1075 
1076 /** \defgroup xrif_compress Compression & De-compression
1077  * \ingroup xrif_encode
1078  *
1079  * @{
1080  */
1081 xrif_error_t xrif_compress( xrif_t handle /**< [in/out] the xrif handle */);
1082 
1083 xrif_error_t xrif_decompress(xrif_t handle /**< [in/out] the xrif handle */);
1084 
1085 xrif_error_t xrif_compress_none( xrif_t handle /**< [in/out] the xrif handle */);
1086 
1087 xrif_error_t xrif_decompress_none( xrif_t handle /**< [in/out] the xrif handle */);
1088 
1089 xrif_error_t xrif_compress_lz4( xrif_t handle /**< [in/out] the xrif handle */);
1090 
1091 xrif_error_t xrif_decompress_lz4( xrif_t handle /**< [in/out] the xrif handle */);
1092 
1093 ///@}
1094 
1095 
1096 /** \defgroup xrif_performance Performance Measurements
1097  * \ingroup xrif_interface
1098  *
1099  * @{
1100  */
1101 
1102 /// Calculate the compression ratio
1103 /**
1104  * \returns the ratio of compressed_size to raw_size.
1105  */
1106 double xrif_compression_ratio( xrif_t handle /**< [in/out] the xrif handle */);
1107 
1108 /// Calculate the time in seconds taken to encode the data
1109 /**
1110  * \returns the difference in the timespecs marking the beginning of differencing the end of compression
1111  */
1112 double xrif_encode_time ( xrif_t handle /**< [in/out] the xrif handle */);
1113 
1114 /// Calculate the encode rate in bytes/sec
1115 /**
1116  * \returns the ratio of raw_size to xrif_encode_time
1117  */
1118 double xrif_encode_rate( xrif_t handle /**< [in/out] the xrif handle */);
1119 
1120 /// Calculate the time in seconds taken to difference the data
1121 /**
1122  * \returns the difference in the timespecs marking the beginning of reordering and the beginning of differencing
1123  */
1124 double xrif_difference_time( xrif_t handle /**< [in/out] the xrif handle */);
1125 
1126 /// Calculate the differencing rate in bytes/sec
1127 /**
1128  * \returns the ratio of raw_size to xrif_difference_time
1129  */
1130 double xrif_difference_rate( xrif_t handle /**< [in/out] the xrif handle */);
1131 
1132 /// Calculate the time in seconds taken to reorder the data
1133 /**
1134  * \returns the difference in the timespecs marking the beginning of compression and the beginning of reordering
1135  */
1136 double xrif_reorder_time( xrif_t handle /**< [in/out] the xrif handle */);
1137 
1138 /// Calculate the reordering rate in bytes/sec
1139 /**
1140  * \returns the ratio of raw_size to xrif_reorder_time
1141  */
1142 double xrif_reorder_rate( xrif_t handle /**< [in/out] the xrif handle */);
1143 
1144 /// Calculate the time in seconds taken to compress the differenced and reordered data
1145 /**
1146  * \returns the difference in the timespecs marking the beginning of reordering and the end of compression
1147  */
1148 double xrif_compress_time( xrif_t handle /**< [in/out] the xrif handle */);
1149 
1150 /// Calculate the compression rate in bytes/sec
1151 /**
1152  * \returns the ratio of raw_size to xrif_compress_time
1153  */
1154 double xrif_compress_rate( xrif_t handle /**< [in/out] the xrif handle */);
1155 
1156 
1157 /// Calculate the time in seconds taken to decode the data
1158 /**
1159  * \returns the difference in the timespecs marking the beginning of decompression and the end of undifferencing
1160  */
1161 double xrif_decode_time ( xrif_t handle /**< [in/out] the xrif handle */);
1162 
1163 /// Calculate the decode rate in bytes/sec
1164 /**
1165  * \returns the ratio of raw_size to xrif_decode_time
1166  */
1167 double xrif_decode_rate( xrif_t handle /**< [in/out] the xrif handle */);
1168 
1169 /// Calculate the time in seconds taken to undifference the data
1170 /**
1171  * \returns the difference in the timespecs marking the end of undifferencing and the end of unreodering
1172  */
1173 double xrif_undifference_time( xrif_t handle /**< [in/out] the xrif handle */);
1174 
1175 /// Calculate the undifferencing rate in bytes/sec
1176 /**
1177  * \returns the ratio of raw_size to xrif_undifference_time
1178  */
1179 double xrif_undifference_rate( xrif_t handle /**< [in/out] the xrif handle */);
1180 
1181 /// Calculate the time in seconds taken to unreorder the data
1182 /**
1183  * \returns the difference in the timespecs marking the beginning of differencing and the end of decompression
1184  */
1185 double xrif_unreorder_time( xrif_t handle /**< [in/out] the xrif handle */);
1186 
1187 /// Calculate the unreordering rate in bytes/sec
1188 /**
1189  * \returns the ratio of raw_size to xrif_unreorder_time
1190  */
1191 double xrif_unreorder_rate( xrif_t handle /**< [in/out] the xrif handle */);
1192 
1193 /// Calculate the time in seconds taken to decompress the differenced and reordered data
1194 /**
1195  * \returns the difference in the timespecs marking the decompression time
1196  */
1197 double xrif_decompress_time( xrif_t handle /**< [in/out] the xrif handle */);
1198 
1199 /// Calculate the decompression rate in bytes/sec
1200 /**
1201  * \returns the ratio of raw_size to xrif_decompress_time
1202  */
1203 double xrif_decompress_rate( xrif_t handle /**< [in/out] the xrif handle */);
1204 
1205 
1206 ///@}
1207 
1208 
1209 /** \defgroup xrif_utils Utilities
1210  *
1211  * @{
1212  */
1213 
1214 /// Return the size of the type specified by the code.
1215 /**
1216  * \returns the equivalent to `sizeof(type)` for the specified type code.
1217  * \returns 0 if the `type_code` is invalid
1218  */
1219 size_t xrif_typesize( xrif_typecode_t type_code /**< [in] the type code*/);
1220 
1221 /// Calculate the difference between two timespecs.
1222 /** Calculates `ts1-ts0` in `double` precision.
1223  *
1224  * \returns the difference in seconds between the two timespecs
1225  */
1226 double xrif_ts_difference( struct timespec * ts1, ///< [in] the end time
1227  struct timespec * ts0 ///< [in] the start time
1228  );
1229 
1230 /// Get a string describing the difference method
1231 /** Returns a pointer to a string describing the difference method.
1232  *
1233  * \returns a pointer to the string if `diff_method` is valid
1234  * \returns NULL if `diff_method` is not valid
1235  */
1236 const char * xrif_difference_method_string( int diff_method /**< [in] the difference method */);
1237 
1238 /// Get a string describing the reordering method
1239 /** Returns a pointer to a string describing the reordering method.
1240  *
1241  * \returns a pointer to the string if `reorder_method` is valid
1242  * \returns NULL if `reorder_method` is not valid
1243  */
1244 const char * xrif_reorder_method_string( int reorder_method /**< [in] the reorder method*/);
1245 
1246 /// Get a string describing the compression method
1247 /** Returns a pointer to a string describing the compression method.
1248  *
1249  * \returns a pointer to the string if `compress_method` is valid
1250  * \returns NULL if `compress_method` is not valid
1251  */
1252 const char * xrif_compress_method_string( int compress_method /**< [in] the compression method*/);
1253 
1254 ///@}
1255 
1256 #ifdef __cplusplus
1257 //extern "C"
1258 }
1259 #endif
1260 
1261 #endif //xrif_xrif_h
xrif_frames
xrif_dimension_t xrif_frames(xrif_t handle)
Get the current number of frames of the configured handle.
Definition: xrif.c:834
xrif_encode_rate
double xrif_encode_rate(xrif_t handle)
Calculate the encode rate in bytes/sec.
Definition: xrif.c:2074
xrif_handle::compression_ratio
double compression_ratio
The compression ratio, calculated as output-size/input-size.
Definition: xrif.h:360
xrif_set_compressed
xrif_error_t xrif_set_compressed(xrif_t handle, void *reordered, size_t size)
Set the compressed data buffer to a pre-allocated pointer.
Definition: xrif.c:715
xrif_handle::compress_time
double compress_time
Time in seconds taken to compress the data.
Definition: xrif.h:367
xrif_handle::width
xrif_dimension_t width
The width of a single image, in pixels.
Definition: xrif.h:308
xrif_handle::reordered_buffer
char * reordered_buffer
The reordered buffer pointer, contains the reordered data.
Definition: xrif.h:343
xrif_handle::difference_method
int difference_method
The difference method to use.
Definition: xrif.h:320
xrif_read_header
xrif_error_t xrif_read_header(xrif_t handle, uint32_t *header_size, char *header)
Configure an xrif handle by reading a xrif protocol header.
Definition: xrif.c:901
xrif_undifference_first
xrif_error_t xrif_undifference_first(xrif_t handle)
Undifference the images using the first image as a reference.
Definition: xrif_difference_first.c:386
xrif_difference_previous
xrif_error_t xrif_difference_previous(xrif_t handle)
Difference the images using the previous image as a reference.
Definition: xrif_difference_previous.c:216
xrif_encode_time
double xrif_encode_time(xrif_t handle)
Calculate the time in seconds taken to encode the data.
Definition: xrif.c:2069
xrif_allocate_reordered
xrif_error_t xrif_allocate_reordered(xrif_t handle)
Allocate the reordered buffer based on the already set stream dimensions.
Definition: xrif.c:673
xrif_ts_difference
double xrif_ts_difference(struct timespec *ts1, struct timespec *ts0)
Calculate the difference between two timespecs.
Definition: xrif.c:2185
xrif_decompress_time
double xrif_decompress_time(xrif_t handle)
Calculate the time in seconds taken to decompress the differenced and reordered data.
Definition: xrif.c:2141
xrif_handle::compress_method
int compress_method
The compression method used.
Definition: xrif.h:324
xrif_handle::omp_numthreads
int omp_numthreads
Definition: xrif.h:331
xrif_min_raw_size
size_t xrif_min_raw_size(xrif_t handle)
Calculate the minimum size of the raw buffer.
Definition: xrif.c:462
xrif_difference_rate
double xrif_difference_rate(xrif_t handle)
Calculate the differencing rate in bytes/sec.
Definition: xrif.c:2084
xrif_typecode_t
uint8_t xrif_typecode_t
The type used for storing the ImageStreamIO data type code.
Definition: xrif.h:208
xrif_unreorder_time
double xrif_unreorder_time(xrif_t handle)
Calculate the time in seconds taken to unreorder the data.
Definition: xrif.c:2131
xrif_t
xrif_handle * xrif_t
The xrif handle pointer type. This provides the main interface to the xrif library.
Definition: xrif.h:385
xrif_handle::compressed_buffer
char * compressed_buffer
The compressed buffer pointer, contains the compressed data.
Definition: xrif.h:349
xrif_handle::reorder_method
int reorder_method
The method to use for bit reordering.
Definition: xrif.h:322
xrif_depth
xrif_dimension_t xrif_depth(xrif_t handle)
Get the current depth of the configured handle.
Definition: xrif.c:823
xrif_min_compressed_size
size_t xrif_min_compressed_size(xrif_t handle)
Calculate the minimum size of the compressed buffer.
Definition: xrif.c:521
xrif_handle::omp_parallel
int omp_parallel
Definition: xrif.h:328
xrif_reorder_bytepack_renibble
xrif_error_t xrif_reorder_bytepack_renibble(xrif_t handle)
Definition: xrif.c:1409
xrif_allocate_raw
xrif_error_t xrif_allocate_raw(xrif_t handle)
Allocate the raw buffer based on the already set stream dimensions.
Definition: xrif.c:584
xrif_handle::lz4_acceleration
int lz4_acceleration
LZ4 acceleration parameter, >=1, higher is faster with less comporession. Default is 1.
Definition: xrif.h:326
xrif_set_compress_method
xrif_error_t xrif_set_compress_method(xrif_t handle, int compress_method)
Set the compress method.
Definition: xrif.c:408
xrif_handle
The xrif library configuration structure, organizing various parameters used by the functions.
Definition: xrif.h:306
xrif_handle::frames
xrif_dimension_t frames
The number of frames in the stream.
Definition: xrif.h:311
xrif_difference_method_string
const char * xrif_difference_method_string(int diff_method)
Get a string describing the difference method.
Definition: xrif.c:2192
xrif_set_raw
xrif_error_t xrif_set_raw(xrif_t handle, void *raw, size_t size)
Set the raw data buffer to a pre-allocated pointer.
Definition: xrif.c:538
xrif_set_lz4_acceleration
xrif_error_t xrif_set_lz4_acceleration(xrif_t handle, int32_t lz4_accel)
Set the LZ4 acceleration parameter.
Definition: xrif.c:432
xrif_reorder_bytepack_sint16
xrif_error_t xrif_reorder_bytepack_sint16(xrif_t handle)
Perform bytepack reodering for signed 16 bit ints.
Definition: xrif.c:1336
xrif_undifference_pixel
xrif_error_t xrif_undifference_pixel(xrif_t handle)
Undifference the images using the previous pixel as a reference.
Definition: xrif_difference_pixel.c:413
xrif_handle::calc_performance
unsigned char calc_performance
Flag (true/false) controlling whether performance metrics are calculated. Default is true.
Definition: xrif.h:358
xrif_decompress_lz4
xrif_error_t xrif_decompress_lz4(xrif_t handle)
Definition: xrif.c:2027
xrif_reorder_method_string
const char * xrif_reorder_method_string(int reorder_method)
Get a string describing the reordering method.
Definition: xrif.c:2207
xrif_write_header
xrif_error_t xrif_write_header(char *header, xrif_t handle)
Populate a header buffer with the xrif protocol details.
Definition: xrif.c:846
xrif_handle::reordered_buffer_size
size_t reordered_buffer_size
Definition: xrif.h:344
xrif_reorder_time
double xrif_reorder_time(xrif_t handle)
Calculate the time in seconds taken to reorder the data.
Definition: xrif.c:2089
xrif_handle::reorder_time
double reorder_time
Time in seconds taken to reorder the data.
Definition: xrif.h:365
xrif_new
xrif_error_t xrif_new(xrif_t *handle_ptr)
Allocate a handle and initialize it.
Definition: xrif.c:107
xrif_decompress_rate
double xrif_decompress_rate(xrif_t handle)
Calculate the decompression rate in bytes/sec.
Definition: xrif.c:2146
xrif_compress_rate
double xrif_compress_rate(xrif_t handle)
Calculate the compression rate in bytes/sec.
Definition: xrif.c:2104
xrif_unreorder_none
xrif_error_t xrif_unreorder_none(xrif_t handle)
Perform no un-re-ordering, simply copy reordered to raw.
Definition: xrif.c:1616
xrif_handle::height
xrif_dimension_t height
The height of a single image, in pixels.
Definition: xrif.h:309
xrif_undifference_rate
double xrif_undifference_rate(xrif_t handle)
Calculate the undifferencing rate in bytes/sec.
Definition: xrif.c:2126
xrif_handle::own_reordered
unsigned char own_reordered
Flag (true/false) indicating whether the reordered_buffer pointer is managed by this handle.
Definition: xrif.h:342
xrif_undifference_time
double xrif_undifference_time(xrif_t handle)
Calculate the time in seconds taken to undifference the data.
Definition: xrif.c:2121
xrif_allocate_compressed
xrif_error_t xrif_allocate_compressed(xrif_t handle)
Allocate the compressed buffer based on the already set stream dimensions.
Definition: xrif.c:760
xrif_width
xrif_dimension_t xrif_width(xrif_t handle)
Get the current width of the configured handle.
Definition: xrif.c:801
xrif_unreorder_bytepack_renibble
xrif_error_t xrif_unreorder_bytepack_renibble(xrif_t handle)
Definition: xrif.c:1742
xrif_unreorder_rate
double xrif_unreorder_rate(xrif_t handle)
Calculate the unreordering rate in bytes/sec.
Definition: xrif.c:2136
xrif_set_reordered
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.
Definition: xrif.c:627
xrif_compress_none
xrif_error_t xrif_compress_none(xrif_t handle)
Definition: xrif.c:1926
xrif_decode_rate
double xrif_decode_rate(xrif_t handle)
Calculate the decode rate in bytes/sec.
Definition: xrif.c:2116
xrif_set_difference_method
xrif_error_t xrif_set_difference_method(xrif_t handle, int difference_method)
Set the difference method.
Definition: xrif.c:355
xrif_handle::compress_on_raw
unsigned char compress_on_raw
Flag (true/false) indicating whether the raw buffer is used for compression. Default on initializeati...
Definition: xrif.h:334
xrif_error_t
int xrif_error_t
The error reporting type.
Definition: xrif.h:157
xrif_difference
xrif_error_t xrif_difference(xrif_t handle)
Difference the image(s)
Definition: xrif.c:1102
xrif_compress_lz4
xrif_error_t xrif_compress_lz4(xrif_t handle)
Definition: xrif.c:1996
xrif_compress_time
double xrif_compress_time(xrif_t handle)
Calculate the time in seconds taken to compress the differenced and reordered data.
Definition: xrif.c:2099
xrif_set_size
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.
Definition: xrif.c:128
xrif_undifference
xrif_error_t xrif_undifference(xrif_t handle)
Undifference the image(s)
Definition: xrif.c:1129
xrif_compress_method_string
const char * xrif_compress_method_string(int compress_method)
Get a string describing the compression method.
Definition: xrif.c:2224
xrif_decompress_none
xrif_error_t xrif_decompress_none(xrif_t handle)
Definition: xrif.c:1962
xrif_reorder
xrif_error_t xrif_reorder(xrif_t handle)
Reorder the data using the method specified by reorder_method
Definition: xrif.c:1227
xrif_handle::encode_rate
double encode_rate
Rate at which the data was encoded in bytes per second.
Definition: xrif.h:362
xrif_reorder_bytepack
xrif_error_t xrif_reorder_bytepack(xrif_t handle)
Dispatch bytepack reodering based on type.
Definition: xrif.c:1305
xrif_reorder_rate
double xrif_reorder_rate(xrif_t handle)
Calculate the reordering rate in bytes/sec.
Definition: xrif.c:2094
xrif_initialize_handle
xrif_error_t xrif_initialize_handle(xrif_t handle)
Initialize an xrif handle object.
Definition: xrif.c:294
xrif_handle::raw_size
size_t raw_size
Size of the stream before compression. Set dynamically by xrif_set_size or from header.
Definition: xrif.h:317
xrif_difference_pixel
xrif_error_t xrif_difference_pixel(xrif_t handle)
Difference the images using the previous pixel as a reference.
Definition: xrif_difference_pixel.c:227
xrif_compression_ratio
double xrif_compression_ratio(xrif_t handle)
Calculate the compression ratio.
Definition: xrif.c:2064
xrif_handle::encode_time
double encode_time
Time in seconds taken to encode the data.
Definition: xrif.h:361
xrif_handle::raw_buffer
char * raw_buffer
The raw buffer pointer, contains the image data, and if compress_on_raw == true the compressed data.
Definition: xrif.h:337
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...
Definition: xrif.c:243
xrif_unreorder_bytepack_sint16
xrif_error_t xrif_unreorder_bytepack_sint16(xrif_t handle)
Perform bytepack unreodering for signed 16 bit ints.
Definition: xrif.c:1682
xrif_handle::reorder_rate
double reorder_rate
Rate at which the data was reordered in bytes per second.
Definition: xrif.h:366
xrif_handle::difference_time
double difference_time
Time in seconds taken to difference the data.
Definition: xrif.h:363
xrif_min_reordered_size
size_t xrif_min_reordered_size(xrif_t handle)
Calculate the minimum size of the reordered buffer.
Definition: xrif.c:485
xrif_handle::depth
xrif_dimension_t depth
The depth of a single image, in pixels.
Definition: xrif.h:310
xrif_delete
xrif_error_t xrif_delete(xrif_t handle)
Deallocate a handle, including any memory that it owns.
Definition: xrif.c:277
xrif_difference_first
xrif_error_t xrif_difference_first(xrif_t handle)
Difference the images using the first image as a reference.
Definition: xrif_difference_first.c:216
xrif_undifference_previous
xrif_error_t xrif_undifference_previous(xrif_t handle)
Undifference the images using the previous image as a reference.
Definition: xrif_difference_previous.c:384
xrif_decode
xrif_error_t xrif_decode(xrif_t handle)
Decode data from the xrif format.
Definition: xrif.c:1043
xrif_decode_time
double xrif_decode_time(xrif_t handle)
Calculate the time in seconds taken to decode the data.
Definition: xrif.c:2111
xrif_handle::compressed_size
size_t compressed_size
Size of the stream after compression. Set dynamically by compression functions or from header.
Definition: xrif.h:318
xrif_reorder_bitpack
xrif_error_t xrif_reorder_bitpack(xrif_t handle)
Definition: xrif.c:1517
xrif_allocate
xrif_error_t xrif_allocate(xrif_t handle)
Allocate all memory buffers according to the configuration specified in the handle.
Definition: xrif.c:199
xrif_unreorder
xrif_error_t xrif_unreorder(xrif_t handle)
Un-reorder the data using the method specified by reorder_method
Definition: xrif.c:1248
xrif_encode
xrif_error_t xrif_encode(xrif_t handle)
Encode data using the xrif format.
Definition: xrif.c:966
xrif_handle::raw_buffer_size
size_t raw_buffer_size
Definition: xrif.h:338
xrif_typesize
size_t xrif_typesize(xrif_typecode_t type_code)
Return the size of the type specified by the code.
Definition: xrif.c:2150
xrif_reorder_bitpack_sint16
xrif_error_t xrif_reorder_bitpack_sint16(xrif_t handle)
xrif_set_reorder_method
xrif_error_t xrif_set_reorder_method(xrif_t handle, int reorder_method)
Set the reorder method.
Definition: xrif.c:382
xrif_handle::compressed_buffer_size
size_t compressed_buffer_size
Definition: xrif.h:350
xrif_height
xrif_dimension_t xrif_height(xrif_t handle)
Get the current height of the configured handle.
Definition: xrif.c:812
xrif_handle::own_raw
unsigned char own_raw
Flag (true/false) indicating whether the raw_buffer pointer is managed by this handle.
Definition: xrif.h:336
xrif_handle::data_size
size_t data_size
The size of the pixels, bytes. This corresponds to sizeof(type).
Definition: xrif.h:315
xrif_decompress
xrif_error_t xrif_decompress(xrif_t handle)
Definition: xrif.c:1906
xrif_unreorder_bytepack
xrif_error_t xrif_unreorder_bytepack(xrif_t handle)
Dispatch bytepack unreodering based on type.
Definition: xrif.c:1651
xrif_handle::own_compressed
unsigned char own_compressed
Flag (true/false) indicating whether the compressed_buffer pointer is managed by this handle.
Definition: xrif.h:348
xrif_handle::compress_rate
double compress_rate
Rate at which the data was compressed in bytes per second.
Definition: xrif.h:368
xrif_unreorder_bitpack
xrif_error_t xrif_unreorder_bitpack(xrif_t handle)
Definition: xrif.c:1820
xrif_difference_time
double xrif_difference_time(xrif_t handle)
Calculate the time in seconds taken to difference the data.
Definition: xrif.c:2079
xrif_reorder_bytepack_renibble_sint16
xrif_error_t xrif_reorder_bytepack_renibble_sint16(xrif_t handle)
xrif_handle::type_code
xrif_typecode_t type_code
The code specifying the data type of the pixels.
Definition: xrif.h:313
xrif_dimension_t
uint32_t xrif_dimension_t
The type used for storing the width and height and depth dimensions of images.
Definition: xrif.h:145
xrif_reorder_none
xrif_error_t xrif_reorder_none(xrif_t handle)
Perform no re-ordering, simply copy raw to reordered.
Definition: xrif.c:1270
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.
Definition: xrif.c:172
xrif_handle::difference_rate
double difference_rate
Rate at which the data was differenced in bytes per second.
Definition: xrif.h:364
xrif_compress
xrif_error_t xrif_compress(xrif_t handle)
Definition: xrif.c:1888