Libpolycomp  1.0
A compression/decompression library that implements the polynomial compression and other simple compression schemes
libpolycomp.h File Reference

Header file for Libpolycomp. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for libpolycomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PCOMP_STAT_SUCCESS   0 /** \brief All ok */
 
#define PCOMP_STAT_INVALID_ENCODING
 
#define PCOMP_STAT_INVALID_BUFFER   2 /** \brief Output buffer too small */
 
#define PCOMP_STAT_INVALID_FIT   3 /** \brief Least-square fit error */
 

Typedefs

typedef struct __pcomp_quant_params_t pcomp_quant_params_t
 
typedef struct __pcomp_poly_fit_data_t pcomp_poly_fit_data_t
 
typedef struct __pcomp_chebyshev_t pcomp_chebyshev_t
 
typedef uint8_t pcomp_poly_size_t
 
typedef uint16_t pcomp_chunk_size_t
 
typedef struct __pcomp_polycomp_t pcomp_polycomp_t
 
typedef struct __pcomp_polycomp_chunk_t pcomp_polycomp_chunk_t
 

Enumerations

enum  pcomp_transform_direction_t { PCOMP_TD_DIRECT = 0, PCOMP_TD_INVERSE = 1 }
 Direction of a Chebyshev transform. More...
 
enum  pcomp_polycomp_algorithm_t { PCOMP_ALG_USE_CHEBYSHEV = 0, PCOMP_ALG_NO_CHEBYSHEV = 1 }
 Kind of algorithm used for the polynomial compression. More...
 

Functions

void pcomp_version (int *major, int *minor)
 
size_t pcomp_rle_bufsize (size_t input_size)
 Calculate an upper limit for the size of a buffer holding RLE-encoded streams. More...
 
int pcomp_compress_rle_int8 (int8_t *output_buf, size_t *output_size, const int8_t *input_buf, size_t input_size)
 Compress an array of int8_t values using the RLE compression. More...
 
int pcomp_compress_rle_int16 (int16_t *output_buf, size_t *output_size, const int16_t *input_buf, size_t input_size)
 Compress an array of int16_t values using the RLE compression. More...
 
int pcomp_compress_rle_int32 (int32_t *output_buf, size_t *output_size, const int32_t *input_buf, size_t input_size)
 Compress an array of int32_t values using the RLE compression. More...
 
int pcomp_compress_rle_int64 (int64_t *output_buf, size_t *output_size, const int64_t *input_buf, size_t input_size)
 Compress an array of int64_t values using the RLE compression. More...
 
int pcomp_compress_rle_uint8 (uint8_t *output_buf, size_t *output_size, const uint8_t *input_buf, size_t input_size)
 Compress an array of uint8_t values using the RLE compression. More...
 
int pcomp_compress_rle_uint16 (uint16_t *output_buf, size_t *output_size, const uint16_t *input_buf, size_t input_size)
 Compress an array of uint16_t values using the RLE compression. More...
 
int pcomp_compress_rle_uint32 (uint32_t *output_buf, size_t *output_size, const uint32_t *input_buf, size_t input_size)
 Compress an array of uint32_t values using the RLE compression. More...
 
int pcomp_compress_rle_uint64 (uint64_t *output_buf, size_t *output_size, const uint64_t *input_buf, size_t input_size)
 Compress an array of uint64_t values using the RLE compression. More...
 
int pcomp_decompress_rle_int8 (int8_t *output_buf, size_t output_size, const int8_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_int16 (int16_t *output_buf, size_t output_size, const int16_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_int32 (int32_t *output_buf, size_t output_size, const int32_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_int64 (int64_t *output_buf, size_t output_size, const int64_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_uint8 (uint8_t *output_buf, size_t output_size, const uint8_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_uint16 (uint16_t *output_buf, size_t output_size, const uint16_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_uint32 (uint32_t *output_buf, size_t output_size, const uint32_t *input_buf, size_t input_size)
 
int pcomp_decompress_rle_uint64 (uint64_t *output_buf, size_t output_size, const uint64_t *input_buf, size_t input_size)
 
size_t pcomp_diffrle_bufsize (size_t input_size)
 Calculate an upper limit for the size of a buffer holding streams encoded using differenced RLE. More...
 
int pcomp_compress_diffrle_int8 (int8_t *output_buf, size_t *output_size, const int8_t *input_buf, size_t input_size)
 Compress an array of int8_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_int16 (int16_t *output_buf, size_t *output_size, const int16_t *input_buf, size_t input_size)
 Compress an array of int16_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_int32 (int32_t *output_buf, size_t *output_size, const int32_t *input_buf, size_t input_size)
 Compress an array of int32_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_int64 (int64_t *output_buf, size_t *output_size, const int64_t *input_buf, size_t input_size)
 Compress an array of int64_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_uint8 (uint8_t *output_buf, size_t *output_size, const uint8_t *input_buf, size_t input_size)
 Compress an array of uint8_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_uint16 (uint16_t *output_buf, size_t *output_size, const uint16_t *input_buf, size_t input_size)
 Compress an array of uint16_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_uint32 (uint32_t *output_buf, size_t *output_size, const uint32_t *input_buf, size_t input_size)
 Compress an array of uint32_t values using the diffRLE compression. More...
 
int pcomp_compress_diffrle_uint64 (uint64_t *output_buf, size_t *output_size, const uint64_t *input_buf, size_t input_size)
 Compress an array of uint64_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_int8 (int8_t *output_buf, size_t output_size, const int8_t *input_buf, size_t input_size)
 Decompress an array of int8_t values encoded using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_int16 (int16_t *output_buf, size_t output_size, const int16_t *input_buf, size_t input_size)
 Compress an array of int16_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_int32 (int32_t *output_buf, size_t output_size, const int32_t *input_buf, size_t input_size)
 Compress an array of int32_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_int64 (int64_t *output_buf, size_t output_size, const int64_t *input_buf, size_t input_size)
 Compress an array of int64_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_uint8 (uint8_t *output_buf, size_t output_size, const uint8_t *input_buf, size_t input_size)
 Compress an array of uint8_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_uint16 (uint16_t *output_buf, size_t output_size, const uint16_t *input_buf, size_t input_size)
 Compress an array of uint16_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_uint32 (uint32_t *output_buf, size_t output_size, const uint32_t *input_buf, size_t input_size)
 Compress an array of uint32_t values using the diffRLE compression. More...
 
int pcomp_decompress_diffrle_uint64 (uint64_t *output_buf, size_t output_size, const uint64_t *input_buf, size_t input_size)
 Compress an array of uint64_t values using the diffRLE compression. More...
 
pcomp_quant_params_tpcomp_init_quant_params (size_t element_size, size_t bits_per_sample)
 Initialize a pcomp_quant_params_t structure. More...
 
void pcomp_free_quant_params (pcomp_quant_params_t *params)
 Free a pcomp_quant_params_t structure. More...
 
size_t pcomp_quant_element_size (const pcomp_quant_params_t *params)
 Return the size (in bytes) of the elements to be quantized. More...
 
size_t pcomp_quant_bits_per_sample (const pcomp_quant_params_t *params)
 Return the number of bits that must be used for each quantized sample.
 
double pcomp_quant_normalization (const pcomp_quant_params_t *params)
 Return the normalization constant used for converting floating-point numbers into quantized integers. More...
 
double pcomp_quant_offset (const pcomp_quant_params_t *params)
 Return the additive constant used for converting floating-point numbers into quantized integers. More...
 
void pcomp_quant_set_normalization (pcomp_quant_params_t *params, double normalization, double offset)
 Set the normalization constants (multiplicative and additive) used to quantize floating-point numbers. More...
 
size_t pcomp_quant_bufsize (size_t input_size, const pcomp_quant_params_t *params)
 Return the size (in bytes) of the buffer that will contain a quantized stream of input_size floating point values. More...
 
int pcomp_compress_quant_float (void *output_buf, size_t *output_size, const float *input_buf, size_t input_size, pcomp_quant_params_t *params)
 Quantize a stream of 32-bit floating point numbers. More...
 
int pcomp_compress_quant_double (void *output_buf, size_t *output_size, const double *input_buf, size_t input_size, pcomp_quant_params_t *params)
 Quantize a stream of 64-bit floating point numbers. More...
 
int pcomp_decompress_quant_float (float *output_buf, size_t output_size, const void *input_buf, size_t input_size, const pcomp_quant_params_t *params)
 
int pcomp_decompress_quant_double (double *output_buf, size_t output_size, const void *input_buf, size_t input_size, const pcomp_quant_params_t *params)
 
pcomp_poly_fit_data_tpcomp_init_poly_fit (size_t num_of_samples, size_t num_of_coeffs)
 Allocate a new instance of the pcomp_poly_fit_data_t structure on the heap. More...
 
void pcomp_free_poly_fit (pcomp_poly_fit_data_t *poly_fit)
 Free an instance of the pcomp_poly_fit_data_t that has been allocated via a call to pcomp_init_poly_fit. More...
 
size_t pcomp_poly_fit_num_of_samples (const pcomp_poly_fit_data_t *poly_fit)
 Return the number of samples to be used in a polynomial fit. More...
 
size_t pcomp_poly_fit_num_of_coeffs (const pcomp_poly_fit_data_t *poly_fit)
 Return the number of coefficients of the least-squares fitting polynomial. More...
 
int pcomp_run_poly_fit (pcomp_poly_fit_data_t *poly_fit, double *coeffs, const double *points)
 Calculates a polynomial least-squares fit. More...
 
pcomp_chebyshev_tpcomp_init_chebyshev (size_t num_of_samples, pcomp_transform_direction_t dir)
 Allocate a new instance of the pcomp_chebyshev_t structure on the heap. More...
 
void pcomp_free_chebyshev (pcomp_chebyshev_t *plan)
 Free the memory allocated by a previous call to pcomp_init_chebyshev. More...
 
size_t pcomp_chebyshev_num_of_samples (const pcomp_chebyshev_t *plan)
 Return the number of samples in a Chebyshev transform. More...
 
pcomp_transform_direction_t pcomp_chebyshev_direction (const pcomp_chebyshev_t *plan)
 Return the direction of a Chebyshev transform. More...
 
int pcomp_run_chebyshev (pcomp_chebyshev_t *plan, pcomp_transform_direction_t dir, double *output, const double *input)
 Compute a forward/backward Chebyshev discrete transform. More...
 
const double * pcomp_chebyshev_input (const pcomp_chebyshev_t *plan)
 Return the input data used in the last call to pcomp_run_chebyshev. More...
 
const double * pcomp_chebyshev_output (const pcomp_chebyshev_t *plan)
 Return the output (Chebyshev transform) of the last call to pcomp_run_chebyshev. More...
 
pcomp_polycomp_chunk_tpcomp_init_chunk (pcomp_chunk_size_t num_of_samples)
 Allocate memory for a pcomp_polycomp_chunk_t object. More...
 
pcomp_polycomp_chunk_tpcomp_init_uncompressed_chunk (pcomp_chunk_size_t num_of_samples, const double *samples)
 Allocate memory for a pcomp_polycomp_chunk_t object and fill it with data in uncompressed form. More...
 
pcomp_polycomp_chunk_tpcomp_init_compressed_chunk (pcomp_chunk_size_t num_of_samples, pcomp_poly_size_t num_of_poly_coeffs, const double *poly_coeffs, pcomp_chunk_size_t num_of_cheby_coeffs, const uint8_t *chebyshev_mask, const double *cheby_coeffs)
 Allocate memory for a pcomp_polycomp_chunk_t object and fill it with data compressed using the polynomial compression algorithm. More...
 
void pcomp_free_chunk (pcomp_polycomp_chunk_t *chunk)
 Free memory associated with a pcomp_poly_chunk_t. More...
 
pcomp_chunk_size_t pcomp_chunk_num_of_samples (const pcomp_polycomp_chunk_t *chunk)
 Return the number of samples in a chunk. More...
 
size_t pcomp_chunk_num_of_bytes (const pcomp_polycomp_chunk_t *chunk)
 Return the number of bytes necessary to encode a chunk. More...
 
int pcomp_chunk_is_compressed (const pcomp_polycomp_chunk_t *chunk)
 Return nonzero if the chunk holds data in uncompressed form.
 
const double * pcomp_chunk_uncompressed_data (const pcomp_polycomp_chunk_t *chunk)
 If the chunks contain uncompressed data, returns a pointer to the first element. Otherwise, return NULL.
 
pcomp_poly_size_t pcomp_chunk_num_of_poly_coeffs (const pcomp_polycomp_chunk_t *chunk)
 If the chunks contain compressed data, returns the number of polynomial coefficients used in the compression. Otherwise, return zero.
 
const double * pcomp_chunk_poly_coeffs (const pcomp_polycomp_chunk_t *chunk)
 If the chunks contain compressed data, returns a pointer to the first element of the array of coefficients of the interpolating polynomial. Otherwise, return NULL.
 
pcomp_chunk_size_t pcomp_chunk_num_of_cheby_coeffs (const pcomp_polycomp_chunk_t *chunk)
 If the chunks contain compressed data, returns the number of nonzero Chebyshev coefficients held in the chunk. Otherwise, return zero.
 
const double * pcomp_chunk_cheby_coeffs (const pcomp_polycomp_chunk_t *chunk)
 If the chunks contain compressed data, returns a pointer to the first element of the Chebyshev transform of the fit residuals. Otherwise, return NULL.
 
size_t pcomp_chunk_cheby_mask_size (pcomp_chunk_size_t chunk_size)
 Return the number of bytes required for the bitmask of nonzero Chebyshev coefficients. More...
 
const uint8_t * pcomp_chunk_cheby_mask (const pcomp_polycomp_chunk_t *chunk)
 Return a pointer to the bitmask of nonzero Chebyshev coefficients for a chunk. More...
 
void pcomp_straighten (double *output, const double *input, size_t num_of_samples, double period)
 Remove sudden jumps from input. More...
 
pcomp_polycomp_tpcomp_init_polycomp (pcomp_chunk_size_t samples_per_chunk, pcomp_poly_size_t num_of_coeffs, double max_allowable_error, pcomp_polycomp_algorithm_t algorithm)
 Allocate space for a pcomp_polycomp_t structure. More...
 
void pcomp_free_polycomp (pcomp_polycomp_t *params)
 Free the memory allocated by pcomp_init_polycomp for a pcomp_polycomp_t structure. More...
 
int pcomp_run_polycomp_on_chunk (pcomp_polycomp_t *params, const double *input, pcomp_chunk_size_t num_of_samples, pcomp_polycomp_chunk_t *chunk, double *max_error)
 Compress the first num_of_samples elements in input and store them in chunk. More...
 
int pcomp_decompress_polycomp_chunk (double *output, const pcomp_polycomp_chunk_t *chunk, pcomp_chebyshev_t *inv_chebyshev)
 Decompress the data in a chunk. More...
 
pcomp_chunk_size_t pcomp_polycomp_samples_per_chunk (const pcomp_polycomp_t *params)
 Return the number of samples per chunk. More...
 
pcomp_poly_size_t pcomp_polycomp_num_of_poly_coeffs (const pcomp_polycomp_t *params)
 Return the number of coefficients for the fitting polynomial used in the polynomial compression. More...
 
double pcomp_polycomp_max_error (const pcomp_polycomp_t *params)
 Return the upper bound on the error of the polynomial compression. More...
 
pcomp_polycomp_algorithm_t pcomp_polycomp_algorithm (const pcomp_polycomp_t *params)
 Return the kind of algorithm used for a polynomial compression. More...
 
pcomp_chebyshev_tpcomp_polycomp_forward_cheby (const pcomp_polycomp_t *params)
 Return a pointer to a pcomp_chebyshev_t structure representing the forward Chebyshev transform. More...
 
pcomp_chebyshev_tpcomp_polycomp_backward_cheby (const pcomp_polycomp_t *params)
 Return a pointer to a pcomp_chebyshev_t structure representing the forward Chebyshev transform. More...
 
double pcomp_polycomp_period (const pcomp_polycomp_t *params)
 Return the period of the input data, or a number less than or equal to 0 if the data have no periodicity. More...
 
void pcomp_polycomp_set_period (pcomp_polycomp_t *params, double period)
 Set the periodicity of the data to be compressed. More...
 
int pcomp_polyfit_and_chebyshev (pcomp_polycomp_t *params, double *coeffs, double *cheby_residuals, const double *input, double *max_residual)
 Compute a polynomial fit of the data in input and a Chebyshev transform of the residuals. More...
 
int pcomp_mask_get_bit (const uint8_t *mask, size_t pos)
 Return the value of the bit at the position pos in the bitmask mask. More...
 
void pcomp_mask_set_bit (uint8_t *mask, size_t pos, int value)
 Set the value of the bit at position pos in the bitmask . More...
 
size_t pcomp_find_chebyshev_mask (pcomp_chebyshev_t *chebyshev, pcomp_chebyshev_t *inv_chebyshev, double max_allowable_error, uint8_t *mask, double *max_error)
 Find the smallest subset of Chebyshev coefficients that can approximate a Chebyshev transform with an error less than max_allowable_error. More...
 
int pcomp_compress_polycomp (pcomp_polycomp_chunk_t **chunk_array[], size_t *num_of_chunks, const double *input_buf, size_t input_size, const pcomp_polycomp_t *params)
 Compress the array input_buf using polynomial compression. More...
 
size_t pcomp_total_num_of_samples (pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
 Compute the sum of the number of samples encoded in chunk_array. More...
 
int pcomp_decompress_polycomp (double *output_buf, pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
 Decompress a sequence of chunks. More...
 
void pcomp_free_chunks (pcomp_polycomp_chunk_t *chunk_array[], size_t num_of_chunks)
 Free an array of chunks. More...
 
size_t pcomp_chunks_num_of_bytes (pcomp_polycomp_chunk_t *const chunks[], size_t num_of_chunks)
 Number of bytes required by pcomp_encode_chunks. More...
 
int pcomp_encode_chunks (void *buf, size_t *buf_size, pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
 Encode a list of chunks into a sequence of raw bytes. More...
 
int pcomp_decode_chunks (pcomp_polycomp_chunk_t **chunk_array[], size_t *num_of_chunks, const void *buf)
 Decode a byte sequence created by pcomp_encode_chunks into an array of chunks. More...
 

Detailed Description

Header file for Libpolycomp.

This file is the only header the user has to include in order to use all the facilities offered by the library. Just use

#include <libpolycomp.h>

at the beginning of your source files to have the functions and the types implemented by Libpolycomp available.

There are several groups of compression functions available; currently, they are:

  • Run-Length Encoding (RLE);
  • Differenced Run-Length Encoding (diffRLE);
  • Quantization;
  • Polynomial compression.

Definition in file libpolycomp.h.

Macro Definition Documentation

#define PCOMP_STAT_INVALID_ENCODING
Value:
1

Definition at line 56 of file libpolycomp.h.