80 return 1 + 2 * input_size;
363 #define IMPLEMENT_DIFFRLE_COMPR_FN(name, rle_compr_fn, datatype_t) \
364 int name(datatype_t* output_buf, size_t* output_size, \
365 const datatype_t* input_buf, size_t input_size) \
367 size_t rle_output_size; \
368 datatype_t* diff_buf = NULL; \
369 int rle_compr_result; \
372 if (output_buf == NULL || output_size == NULL \
373 || input_buf == NULL) \
376 if (input_size == 0) { \
378 return PCOMP_STAT_SUCCESS; \
381 output_buf[0] = input_buf[0]; \
382 if (input_size == 1) { \
384 return PCOMP_STAT_SUCCESS; \
387 diff_buf = malloc((input_size - 1) * sizeof(datatype_t)); \
388 for (idx = 0; idx < input_size - 1; ++idx) { \
389 diff_buf[idx] = input_buf[idx + 1] - input_buf[idx]; \
392 rle_output_size = *output_size - 1; \
394 = rle_compr_fn(output_buf + 1, &rle_output_size, diff_buf, \
397 if (rle_compr_result != PCOMP_STAT_SUCCESS) \
398 return rle_compr_result; \
400 *output_size = rle_output_size + 1; \
401 return PCOMP_STAT_SUCCESS; \
426 #define IMPLEMENT_DIFFRLE_DECOMPR_FN(name, datatype_t) \
427 int name(datatype_t* output_buf, size_t output_size, \
428 const datatype_t* input_buf, size_t input_size) \
430 size_t input_idx = 0; \
431 size_t output_idx = 0; \
433 if (output_buf == NULL || input_buf == NULL) \
436 if (input_size == 0) { \
437 return PCOMP_STAT_SUCCESS; \
440 if (input_size % 2 != 1) { \
441 return PCOMP_STAT_INVALID_ENCODING; \
444 output_buf[output_idx++] = input_buf[input_idx++]; \
446 while (output_idx < output_size \
447 && input_idx < input_size - 1) { \
448 datatype_t count = input_buf[input_idx]; \
449 datatype_t incr = input_buf[input_idx + 1]; \
452 for (idx = 0; idx < count; ++idx) { \
453 output_buf[output_idx] = output_buf[output_idx - 1] \
461 return PCOMP_STAT_SUCCESS; \
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.
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.
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.
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.
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.
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.
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.
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.
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.
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...
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Header file for Libpolycomp.
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.