General refactor and cleanup.

This commit is contained in:
2024-04-30 15:37:29 +01:00
parent 47e6c8e50f
commit 123879fc7c
27 changed files with 620 additions and 725 deletions

View File

@@ -4,11 +4,14 @@ This repository contains the Aaru.Compression.Native library for [Aaru](https://
The purpose of this library is to provide compression and de-compression algorithms for Aaru.
No archiver processing code should fall here, those go in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
No archiver processing code should fall here, those go
in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with Aaru.Compression.
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with
Aaru.Compression.
Currently implemented algorithms are:
- Apple Data Compression (RLE with sliding dictionary created for Apple Disk Copy's NDIF)
- Apple RLE (Run Length Encoding created for Apple DART)
- [BZIP2](https://gitlab.com/bzip2/bzip2.git)

28
adc.c
View File

@@ -19,10 +19,14 @@ FORCE_INLINE int GetChunkSize(uint8_t byt)
{
switch(GetChunkType(byt))
{
case ADC_PLAIN: return (byt & 0x7F) + 1;
case ADC_TWO_BYTE: return ((byt & 0x3F) >> 2) + 3;
case ADC_THREE_BYTE: return (byt & 0x3F) + 4;
default: return -1;
case ADC_PLAIN:
return (byt & 0x7F) + 1;
case ADC_TWO_BYTE:
return ((byt & 0x3F) >> 2) + 3;
case ADC_THREE_BYTE:
return (byt & 0x3F) + 4;
default:
return -1;
}
}
@@ -30,16 +34,18 @@ FORCE_INLINE int GetOffset(uint8_t chunk[])
{
switch(GetChunkType(chunk[0]))
{
case ADC_PLAIN: return 0;
case ADC_TWO_BYTE: return ((chunk[0] & 0x03) << 8) + chunk[1];
case ADC_THREE_BYTE: return (chunk[1] << 8) + chunk[2];
default: return -1;
case ADC_PLAIN:
return 0;
case ADC_TWO_BYTE:
return ((chunk[0] & 0x03) << 8) + chunk[1];
case ADC_THREE_BYTE:
return (chunk[1] << 8) + chunk[2];
default:
return -1;
}
}
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size)
{
int inputPosition = 0;

View File

@@ -24,10 +24,8 @@
#include "library.h"
#include "apple_rle.h"
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
int32_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
const uint8_t *src_buffer, int32_t src_size)
{
static int32_t count = 0;
static bool nextA = true; // true if A, false if B

104
flac.c
View File

@@ -12,23 +12,21 @@
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
#include "flac.h"
static FLAC__StreamDecoderReadStatus
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
const FLAC__Frame* frame,
const FLAC__int32* const buffer[],
void* client_data);
static void
error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
size_t *bytes, void *client_data);
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size)
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
const FLAC__int32 const *buffer[], void *client_data);
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status,
void *client_data);
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
const uint8_t *src_buffer, size_t src_size)
{
FLAC__StreamDecoder* decoder;
FLAC__StreamDecoder *decoder;
FLAC__StreamDecoderInitStatus init_status;
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
aaru_flac_ctx *ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
size_t ret_size;
memset(ctx, 0, sizeof(aaru_flac_ctx));
@@ -51,8 +49,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
FLAC__stream_decoder_set_md5_checking(decoder, false);
init_status = FLAC__stream_decoder_init_stream(
decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL, error_callback, ctx);
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL,
error_callback, ctx);
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
{
@@ -72,10 +70,10 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
return ret_size;
}
static FLAC__StreamDecoderReadStatus
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
size_t *bytes, void *client_data)
{
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
if(ctx->src_len - ctx->src_pos < *bytes) *bytes = ctx->src_len - ctx->src_pos;
@@ -87,14 +85,12 @@ static FLAC__StreamDecoderReadStatus
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
const FLAC__Frame* frame,
const FLAC__int32* const buffer[],
void* client_data)
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
const FLAC__int32 const *buffer[], void *client_data)
{
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
size_t i;
uint16_t* buffer16 = (uint16_t*)(ctx->dst_buffer + ctx->dst_pos);
uint16_t *buffer16 = (uint16_t *)(ctx->dst_buffer + ctx->dst_pos);
// Why FLAC does not interleave the channels as PCM do, oh the mistery, we could use memcpy instead of looping
for(i = 0; i < frame->header.blocksize && ctx->dst_pos < ctx->dst_len; i++)
@@ -119,47 +115,34 @@ static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder*
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
static void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
{
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
ctx->error = 1;
}
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
const FLAC__byte buffer[],
size_t bytes,
uint32_t samples,
uint32_t current_frame,
void* client_data);
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
uint32_t current_frame, void *client_data);
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
uint32_t blocksize,
int32_t do_mid_side_stereo,
int32_t loose_mid_side_stereo,
const char* apodization,
uint32_t max_lpc_order,
uint32_t qlp_coeff_precision,
int32_t do_qlp_coeff_prec_search,
int32_t do_exhaustive_model_search,
uint32_t min_residual_partition_order,
uint32_t max_residual_partition_order,
const char* application_id,
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
uint32_t application_id_len)
{
FLAC__StreamEncoder* encoder;
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
FLAC__StreamEncoder *encoder;
aaru_flac_ctx *ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
FLAC__StreamEncoderInitStatus init_status;
size_t ret_size;
FLAC__int32* pcm;
FLAC__int32 *pcm;
int i;
int16_t* buffer16 = (int16_t*)src_buffer;
FLAC__StreamMetadata* metadata[1];
int16_t *buffer16 = (int16_t *)src_buffer;
FLAC__StreamMetadata *metadata[1];
memset(ctx, 0, sizeof(aaru_flac_ctx));
@@ -213,8 +196,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
if(application_id_len > 0 && application_id != NULL)
if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
FLAC__metadata_object_application_set_data(
metadata[0], (unsigned char*)application_id, application_id_len, true);
FLAC__metadata_object_application_set_data(metadata[0], (unsigned char *)application_id, application_id_len,
true);
FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
@@ -245,14 +228,11 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
return ret_size;
}
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
const FLAC__byte buffer[],
size_t bytes,
uint32_t samples,
uint32_t current_frame,
void* client_data)
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
uint32_t current_frame, void *client_data)
{
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
if(bytes > ctx->dst_len - ctx->dst_pos) bytes = ctx->dst_len - ctx->dst_pos;

4
flac.h
View File

@@ -7,10 +7,10 @@
typedef struct
{
const uint8_t* src_buffer;
const uint8_t *src_buffer;
size_t src_len;
size_t src_pos;
uint8_t* dst_buffer;
uint8_t *dst_buffer;
size_t dst_len;
size_t dst_pos;
uint8_t error;

View File

@@ -25,86 +25,59 @@
#include "3rdparty/lzma/C/LzmaLib.h"
#include "3rdparty/zstd/lib/zstd.h"
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
uint32_t* dst_size,
const uint8_t* src_buffer,
uint32_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
const uint8_t *src_buffer, uint32_t src_size)
{
return BZ2_bzBuffToBuffDecompress((char*)dst_buffer, dst_size, (char*)src_buffer, src_size, 0, 0);
return BZ2_bzBuffToBuffDecompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, 0, 0);
}
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
uint32_t* dst_size,
const uint8_t* src_buffer,
uint32_t src_size,
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
const uint8_t *src_buffer, uint32_t src_size,
int32_t blockSize100k)
{
return BZ2_bzBuffToBuffCompress((char*)dst_buffer, dst_size, (char*)src_buffer, src_size, blockSize100k, 0, 0);
return BZ2_bzBuffToBuffCompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, blockSize100k, 0, 0);
}
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
void* scratch_buffer)
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, void *scratch_buffer)
{
return lzfse_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
}
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
void* scratch_buffer)
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, void *scratch_buffer)
{
return lzfse_encode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
}
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
size_t* dst_size,
const uint8_t* src_buffer,
size_t* srcLen,
const uint8_t* props,
size_t propsSize)
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t *srcLen, const uint8_t *props, size_t propsSize)
{
return LzmaUncompress(dst_buffer, dst_size, src_buffer, srcLen, props, propsSize);
}
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
size_t* dst_size,
const uint8_t* src_buffer,
size_t srcLen,
uint8_t* outProps,
size_t* outPropsSize,
int32_t level,
uint32_t dictSize,
int32_t lc,
int32_t lp,
int32_t pb,
int32_t fb,
int32_t numThreads)
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t srcLen, uint8_t *outProps, size_t *outPropsSize,
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
int32_t pb, int32_t fb, int32_t numThreads)
{
return LzmaCompress(
dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads);
return LzmaCompress(dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb,
fb, numThreads);
}
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
size_t dst_size,
const void* src_buffer,
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
size_t src_size)
{
return ZSTD_decompress(dst_buffer, dst_size, src_buffer, src_size);
}
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void* dst_buffer,
size_t dst_size,
const void* src_buffer,
size_t src_size,
int32_t compressionLevel)
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
size_t src_size, int32_t compressionLevel)
{
return ZSTD_compress(dst_buffer, dst_size, src_buffer, src_size, compressionLevel);
}
// This is required if BZ_NO_STDIO
void bz_internal_error ( int errcode ) { }
void bz_internal_error(int errcode) {}
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version() { return AARU_CHECKUMS_NATIVE_VERSION; }

109
library.h
View File

@@ -54,104 +54,55 @@
#define FORCE_INLINE static inline __attribute__((always_inline))
#endif
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
int32_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
const uint8_t *src_buffer, int32_t src_size);
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size);
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
const uint8_t *src_buffer, size_t src_size);
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
uint32_t blocksize,
int32_t do_mid_side_stereo,
int32_t loose_mid_side_stereo,
const char* apodization,
uint32_t max_lpc_order,
uint32_t qlp_coeff_precision,
int32_t do_qlp_coeff_prec_search,
int32_t do_exhaustive_model_search,
uint32_t min_residual_partition_order,
uint32_t max_residual_partition_order,
const char* application_id,
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
uint32_t application_id_len);
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
int32_t src_size,
int32_t dictionary_size,
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size, int32_t dictionary_size,
int32_t match_len_limit);
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
uint32_t* dst_size,
const uint8_t* src_buffer,
uint32_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
const uint8_t *src_buffer, uint32_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
uint32_t* dst_size,
const uint8_t* src_buffer,
uint32_t src_size,
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
const uint8_t *src_buffer, uint32_t src_size,
int32_t blockSize100k);
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
void* scratch_buffer);
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, void *scratch_buffer);
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
size_t dst_size,
const uint8_t* src_buffer,
size_t src_size,
void* scratch_buffer);
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, void *scratch_buffer);
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
size_t* dst_size,
const uint8_t* src_buffer,
size_t* src_size,
const uint8_t* props,
size_t propsSize);
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t *src_size, const uint8_t *props, size_t propsSize);
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
size_t* dst_size,
const uint8_t* src_buffer,
size_t src_size,
uint8_t* outProps,
size_t* outPropsSize,
int32_t level,
uint32_t dictSize,
int32_t lc,
int32_t lp,
int32_t pb,
int32_t fb,
int32_t numThreads);
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, uint8_t *outProps, size_t *outPropsSize,
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
int32_t pb, int32_t fb, int32_t numThreads);
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
size_t dst_size,
const void* src_buffer,
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
size_t src_size);
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void* dst_buffer,
size_t dst_size,
const void* src_buffer,
size_t src_size,
int32_t compressionLevel);
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
size_t src_size, int32_t compressionLevel);
#define AARU_CHECKUMS_NATIVE_VERSION 0x06000089

15
lzip.c
View File

@@ -23,13 +23,11 @@
#include "library.h"
#include "3rdparty/lzlib/lzlib.h"
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size)
{
int max_in_size;
void* ctx;
void *ctx;
enum LZ_Errno lz_err;
int32_t in_pos = 0, out_pos = 0, in_size;
int rd;
@@ -83,15 +81,12 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
return out_pos;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
int32_t dst_size,
const uint8_t* src_buffer,
int32_t src_size,
int32_t dictionary_size,
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size, int32_t dictionary_size,
int32_t match_len_limit)
{
int max_in_size;
void* ctx;
void *ctx;
enum LZ_Errno lz_err;
int32_t in_pos = 0, out_pos = 0, in_size;
int rd;

View File

@@ -20,25 +20,25 @@
#include <cstdint>
#include <cstring>
#include "../adc.h"
#include "../library.h"
#include "../adc.h"
#include "crc32.h"
#include "gtest/gtest.h"
#define EXPECTED_CRC32 0x5a5a7388
static const uint8_t* buffer;
static const uint8_t *buffer;
class adcFixture : public ::testing::Test
{
public:
public:
adcFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -47,13 +47,13 @@ class adcFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/adc.bin", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(34367);
fread((void*)buffer, 1, 34367, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(34367);
fread((void *)buffer, 1, 34367, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~adcFixture()
{
@@ -65,7 +65,7 @@ class adcFixture : public ::testing::Test
TEST_F(adcFixture, adc)
{
auto* outBuf = (uint8_t*)malloc(327680);
auto *outBuf = (uint8_t *)malloc(327680);
auto decoded = AARU_adc_decode_buffer(outBuf, 327680, buffer, 34367);

View File

@@ -20,25 +20,25 @@
#include <cstdint>
#include <cstring>
#include "../apple_rle.h"
#include "../library.h"
#include "../apple_rle.h"
#include "crc32.h"
#include "gtest/gtest.h"
#define EXPECTED_CRC32 0x3525ef06
static const uint8_t* buffer;
static const uint8_t *buffer;
class apple_rleFixture : public ::testing::Test
{
public:
public:
apple_rleFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -47,13 +47,13 @@ class apple_rleFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/apple_rle.bin", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1102);
fread((void*)buffer, 1, 1102, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1102);
fread((void *)buffer, 1, 1102, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~apple_rleFixture()
{
@@ -65,7 +65,7 @@ class apple_rleFixture : public ::testing::Test
TEST_F(apple_rleFixture, apple_rle)
{
auto* outBuf = (uint8_t*)malloc(32768);
auto *outBuf = (uint8_t *)malloc(32768);
auto decoded = AARU_apple_rle_decode_buffer(outBuf, 32768, buffer, 1102);

View File

@@ -26,18 +26,18 @@
#define EXPECTED_CRC32 0xc64059c0
static const uint8_t* buffer;
static const uint8_t *buffer;
class bzip2Fixture : public ::testing::Test
{
public:
public:
bzip2Fixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -46,13 +46,13 @@ class bzip2Fixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/bzip2.bz2", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1053934);
fread((void*)buffer, 1, 1053934, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1053934);
fread((void *)buffer, 1, 1053934, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~bzip2Fixture()
{
@@ -65,7 +65,7 @@ class bzip2Fixture : public ::testing::Test
TEST_F(bzip2Fixture, bzip2)
{
uint real_size = 1048576;
auto* outBuf = (uint8_t*)malloc(1048576);
auto *outBuf = (uint8_t *)malloc(1048576);
auto bz_err = AARU_bzip2_decode_buffer(outBuf, &real_size, buffer, 1053934);
@@ -87,24 +87,24 @@ TEST_F(bzip2Fixture, bzip2Compress)
uint decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
int bz_err;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
@@ -125,7 +125,7 @@ TEST_F(bzip2Fixture, bzip2Compress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);

View File

@@ -19,13 +19,14 @@
extern "C"
{
#endif
#include <stdint.h>
#define CRC32_ISO_POLY 0xEDB88320
#define CRC32_ISO_SEED 0xFFFFFFFF
uint32_t crc32_data(const uint8_t *data, uint32_t len)
{
uint32_t crc32_data(const uint8_t *data, uint32_t len)
{
uint32_t localHashInt = CRC32_ISO_SEED;
uint32_t localTable[256];
int i, j;
@@ -43,13 +44,13 @@ uint32_t crc32_data(const uint8_t *data, uint32_t len)
localTable[i] = entry;
}
for(i = 0; i < len; i++)
localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
for(i = 0; i < len; i++) localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
localHashInt ^= CRC32_ISO_SEED;
return localHashInt;
}
}
#ifdef __cplusplus
}
#endif

View File

@@ -23,7 +23,8 @@ extern "C"
{
#endif
uint32_t crc32_data(const uint8_t* data, uint32_t len);
uint32_t crc32_data(const uint8_t *data, uint32_t len);
#ifdef __cplusplus
}
#endif

View File

@@ -20,25 +20,25 @@
#include <cstddef>
#include <cstdint>
#include "../flac.h"
#include "../library.h"
#include "../flac.h"
#include "crc32.h"
#include "gtest/gtest.h"
#define EXPECTED_CRC32 0xdfbc99bb
static const uint8_t* buffer;
static const uint8_t *buffer;
class flacFixture : public ::testing::Test
{
public:
public:
flacFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -47,13 +47,13 @@ class flacFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/flac.flac", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(6534197);
fread((void*)buffer, 1, 6534197, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(6534197);
fread((void *)buffer, 1, 6534197, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~flacFixture()
{
@@ -65,7 +65,7 @@ class flacFixture : public ::testing::Test
TEST_F(flacFixture, flac)
{
auto* outBuf = (uint8_t*)malloc(9633792);
auto *outBuf = (uint8_t *)malloc(9633792);
auto decoded = AARU_flac_decode_redbook_buffer(outBuf, 9633792, buffer, 6534197);
@@ -85,46 +85,33 @@ TEST_F(flacFixture, flacCompress)
uint decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
size_t newSize;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/audio.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer,
cmp_len,
original,
original_len,
4608,
1,
0,
"partial_tukey(0/1.0/1.0)",
12,
0,
1,
false,
0,
8,
"Aaru.Compression.Native.Tests",
strlen("Aaru.Compression.Native.Tests"));
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer, cmp_len, original, original_len, 4608, 1, 0,
"partial_tukey(0/1.0/1.0)", 12, 0, 1, false, 0, 8,
"Aaru.Compression.Native.Tests", strlen("Aaru.Compression.Native.Tests"));
cmp_len = newSize;
// Decompress
@@ -136,7 +123,7 @@ TEST_F(flacFixture, flacCompress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);

View File

@@ -26,18 +26,18 @@
#define EXPECTED_CRC32 0xc64059c0
static const uint8_t* buffer;
static const uint8_t *buffer;
class lzfseFixture : public ::testing::Test
{
public:
public:
lzfseFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -46,13 +46,13 @@ class lzfseFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/lzfse.bin", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1059299);
fread((void*)buffer, 1, 1059299, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1059299);
fread((void *)buffer, 1, 1059299, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~lzfseFixture()
{
@@ -64,7 +64,7 @@ class lzfseFixture : public ::testing::Test
TEST_F(lzfseFixture, lzfse)
{
auto* outBuf = (uint8_t*)malloc(1048576);
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_lzfse_decode_buffer(outBuf, 1048576, buffer, 1059299, nullptr);
@@ -84,24 +84,24 @@ TEST_F(lzfseFixture, lzfseCompress)
uint decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
size_t newSize;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
@@ -120,7 +120,7 @@ TEST_F(lzfseFixture, lzfseCompress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);

View File

@@ -26,18 +26,18 @@
#define EXPECTED_CRC32 0xc64059c0
static const uint8_t* buffer;
static const uint8_t *buffer;
class lzipFixture : public ::testing::Test
{
public:
public:
lzipFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -46,13 +46,13 @@ class lzipFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/lzip.lz", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1062874);
fread((void*)buffer, 1, 1062874, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1062874);
fread((void *)buffer, 1, 1062874, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~lzipFixture()
{
@@ -64,7 +64,7 @@ class lzipFixture : public ::testing::Test
TEST_F(lzipFixture, lzip)
{
auto* outBuf = (uint8_t*)malloc(1048576);
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_lzip_decode_buffer(outBuf, 1048576, buffer, 1062874);
@@ -84,24 +84,24 @@ TEST_F(lzipFixture, lzipCompress)
int32_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
int32_t newSize;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
@@ -120,7 +120,7 @@ TEST_F(lzipFixture, lzipCompress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);

View File

@@ -26,18 +26,18 @@
#define EXPECTED_CRC32 0x954bf76e
static const uint8_t* buffer;
static const uint8_t *buffer;
class lzmaFixture : public ::testing::Test
{
public:
public:
lzmaFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -46,13 +46,13 @@ class lzmaFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/lzma.bin", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1200275);
fread((void*)buffer, 1, 1200275, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1200275);
fread((void *)buffer, 1, 1200275, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~lzmaFixture()
{
@@ -67,7 +67,7 @@ TEST_F(lzmaFixture, lzma)
uint8_t params[] = {0x5D, 0x00, 0x00, 0x00, 0x02};
size_t destLen = 8388608;
size_t srcLen = 1200275;
auto* outBuf = (uint8_t*)malloc(8388608);
auto *outBuf = (uint8_t *)malloc(8388608);
auto err = AARU_lzma_decode_buffer(outBuf, &destLen, buffer, &srcLen, params, 5);
@@ -88,34 +88,34 @@ TEST_F(lzmaFixture, lzmaCompress)
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
int err;
uint8_t props[5];
size_t props_len = 5;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
original_crc = crc32_data(original, original_len);
// Compress
err = AARU_lzma_encode_buffer(
cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2, 273, 2);
err = AARU_lzma_encode_buffer(cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2,
273, 2);
EXPECT_EQ(err, 0);
// Decompress
@@ -127,7 +127,7 @@ TEST_F(lzmaFixture, lzmaCompress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);

View File

@@ -26,18 +26,18 @@
#define EXPECTED_CRC32 0xc64059c0
static const uint8_t* buffer;
static const uint8_t *buffer;
class zstdFixture : public ::testing::Test
{
public:
public:
zstdFixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -46,13 +46,13 @@ class zstdFixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/zstd.zst", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048613);
fread((void*)buffer, 1, 1048613, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1048613);
fread((void *)buffer, 1, 1048613, file);
fclose(file);
}
void TearDown() { free((void*)buffer); }
void TearDown() { free((void *)buffer); }
~zstdFixture()
{
@@ -64,7 +64,7 @@ class zstdFixture : public ::testing::Test
TEST_F(zstdFixture, zstd)
{
auto* outBuf = (uint8_t*)malloc(1048576);
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_zstd_decode_buffer(outBuf, 1048576, buffer, 1048613);
@@ -84,24 +84,24 @@ TEST_F(zstdFixture, zstdCompress)
uint decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE* file;
FILE *file;
uint32_t original_crc, decmp_crc;
const uint8_t* original;
uint8_t* cmp_buffer;
uint8_t* decmp_buffer;
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
size_t newSize;
// Allocate buffers
original = (const uint8_t*)malloc(original_len);
cmp_buffer = (uint8_t*)malloc(cmp_len);
decmp_buffer = (uint8_t*)malloc(decmp_len);
original = (const uint8_t *)malloc(original_len);
cmp_buffer = (uint8_t *)malloc(cmp_len);
decmp_buffer = (uint8_t *)malloc(decmp_len);
// Read the file
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
file = fopen(filename, "rb");
fread((void*)original, 1, original_len, file);
fread((void *)original, 1, original_len, file);
fclose(file);
// Calculate the CRC
@@ -120,7 +120,7 @@ TEST_F(zstdFixture, zstdCompress)
decmp_crc = crc32_data(decmp_buffer, decmp_len);
// Free buffers
free((void*)original);
free((void *)original);
free(cmp_buffer);
free(decmp_buffer);