Unify external API signatures across all buffer transforms

Every exported buffer transform now has the same shape:

    int32_t AARU_xxx(const uint8_t *src_buffer, size_t src_size,
                     uint8_t *dst_buffer, size_t *dst_size, ...extras);

On entry *dst_size is the capacity of dst_buffer; on success it holds the
number of bytes written. The return value is 0 (AARU_ERROR_NONE) on success
and non-zero on error, either an AARU_ERROR_* constant or the underlying
library's own error code when it is propagated.

Changes by category:

- Parameter reorder only: all AARU_zip_*, AARU_stuffit*, AARU_dd_*,
  AARU_cpt_*, AARU_lzo_*, AARU_xz_*, AARU_lzma2_*, AARU_kencode_*,
  AARU_apple_lzh_* and ace_decompress_*.
- Byte count return replaced by an out-parameter plus a status code:
  AARU_adc_*, AARU_apple_rle_*, AARU_lz4_*, AARU_lzip_*, AARU_lzfse_*,
  AARU_lzvn_*, AARU_zstd_* and AARU_flac_*. Their algorithm bodies are kept
  as static internals behind a thin exported wrapper.
- Type normalisation: bzip2 uint32_t* -> size_t*, zstd void* -> uint8_t*,
  ZIP PPMd size_t -> size_t*, and int/unsigned char -> int32_t/uint8_t
  throughout the header.
- AARU_lzma_decode_buffer no longer takes src_size as an in/out pointer; the
  consumed length is tracked internally.
- Already conforming decompressors (arc_*, pak_*, ha_*, lha_*, larc_*,
  pmarc_*, arj*, rar*, lh5_decompress) only had their declarations
  normalised.

The streaming LZD context API and AARU_get_acn_version are left alone, as
they are not buffer transforms.

Tests updated to the new call convention; all 78 pass.
This commit is contained in:
2026-08-31 12:26:05 +01:00
parent bbae748612
commit adecbc7c7f
26 changed files with 859 additions and 515 deletions

View File

@@ -81,8 +81,20 @@ AARU_EXPORT return_type AARU_CALL function_name(parameters);
```
### Function Patterns
- Decode functions: `AARU_<algorithm>_decode_buffer(dst_buffer, dst_size, src_buffer, src_size)`
- Encode functions: `AARU_<algorithm>_encode_buffer(dst_buffer, dst_size, src_buffer, src_size, ...options)`
Every exported buffer transform has the same shape:
```c
int32_t AARU_<algorithm>_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, ...options);
int32_t AARU_<algorithm>_encode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, ...options);
```
- On entry `*dst_size` is the capacity of `dst_buffer`; on success it holds the number of bytes written.
- The return value is `0` (`AARU_ERROR_NONE`) on success, non-zero on error — either an `AARU_ERROR_*`
constant from `library.h` or the underlying library's own error code when it is propagated.
- The only exceptions are the streaming LZD context API (`CreateLZDContext`, `LZD_FeedNative`,
`LZD_DrainNative`, `DestroyLZDContext`) and `AARU_get_acn_version`.
## Adding New Compression Algorithms

20
adc.c
View File

@@ -45,8 +45,7 @@ FORCE_INLINE int GetOffset(uint8_t chunk[])
}
}
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)
static int32_t adc_decode(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer, int32_t src_size)
{
int inputPosition = 0;
int chunkSize;
@@ -128,4 +127,19 @@ AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_
finished:
return outPosition;
}
}
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
int32_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = adc_decode(dst_buffer, (int32_t)*dst_size, src_buffer, (int32_t)src_size);
if(written < 0) return AARU_ERROR_FAILURE;
*dst_size = (size_t)written;
return AARU_ERROR_NONE;
}

View File

@@ -200,8 +200,8 @@ static void apple_lzh_update(apple_lzh_tree *tree, apple_lzh_node *node)
}
}
AARU_EXPORT int AARU_CALL AARU_apple_lzh_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_apple_lzh_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{
lha_bitio bitio;
lha_lzss lzss;

View File

@@ -23,7 +23,7 @@
#include <stdint.h>
#include "library.h"
AARU_EXPORT int AARU_CALL AARU_apple_lzh_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_apple_lzh_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
#endif /* AARU_COMPRESSION_NATIVE__APPLE_LZH_H_ */

View File

@@ -24,8 +24,7 @@
#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)
static int32_t apple_rle_decode(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
@@ -92,4 +91,19 @@ AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer,
}
return out_pos;
}
}
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{
int32_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = apple_rle_decode(dst_buffer, (int32_t)*dst_size, src_buffer, (int32_t)src_size);
if(written < 0) return AARU_ERROR_FAILURE;
*dst_size = (size_t)written;
return AARU_ERROR_NONE;
}

46
flac.c
View File

@@ -26,10 +26,7 @@ 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)
static size_t flac_decode_redbook(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size)
{
FLAC__StreamDecoder * decoder;
FLAC__StreamDecoderInitStatus init_status;
@@ -150,7 +147,7 @@ static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamE
uint32_t current_frame,
void * client_data);
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t * dst_buffer,
static size_t flac_encode_redbook(uint8_t * dst_buffer,
size_t dst_size,
const uint8_t *src_buffer,
size_t src_size,
@@ -276,4 +273,41 @@ static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamE
ctx->dst_pos += bytes;
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
}
AARU_EXPORT int32_t AARU_CALL AARU_flac_decode_redbook_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{
size_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = flac_decode_redbook(dst_buffer, *dst_size, src_buffer, src_size);
if(written == (size_t)-1) return AARU_ERROR_FAILURE;
*dst_size = written;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_flac_encode_redbook_buffer(
const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer, size_t *dst_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)
{
size_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = flac_encode_redbook(dst_buffer, *dst_size, src_buffer, src_size, blocksize, do_mid_side_stereo,
loose_mid_side_stereo, apodization, max_lpc_order, qlp_coeff_precision,
do_qlp_coeff_prec_search, do_exhaustive_model_search, min_residual_partition_order,
max_residual_partition_order, application_id, application_id_len);
if(written == (size_t)-1) return AARU_ERROR_FAILURE;
*dst_size = written;
return AARU_ERROR_NONE;
}

View File

@@ -273,8 +273,8 @@ static int offset_dispatch(kc_bs *bs, int out_pos, int hash_size)
// Main decompressor — PEF 0x01AC
// ============================================================================
AARU_EXPORT int32_t AARU_CALL AARU_kencode_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_kencode_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{
if(!dst_buffer || !dst_size || !src_buffer || src_size == 0) return -1;

466
library.c
View File

@@ -52,35 +52,110 @@
#include "dd/dd.h"
#include "zip/zip.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)
{ return BZ2_bzBuffToBuffDecompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, 0, 0); }
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
unsigned int out_len;
int res;
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); }
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
AARU_EXPORT int32_t AARU_CALL AARU_lz4_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size)
{ return LZ4_decompress_safe((const char *)src_buffer, (char *)dst_buffer, src_size, dst_size); }
out_len = (unsigned int)*dst_size;
AARU_EXPORT int32_t AARU_CALL AARU_lz4_encode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
int32_t src_size)
{ return LZ4_compress_default((const char *)src_buffer, (char *)dst_buffer, src_size, dst_size); }
res = BZ2_bzBuffToBuffDecompress((char *)dst_buffer, &out_len, (char *)src_buffer, (unsigned int)src_size, 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)
{ return lzfse_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer); }
if(res != BZ_OK) return res;
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); }
*dst_size = out_len;
return AARU_ERROR_NONE;
}
AARU_EXPORT size_t AARU_CALL AARU_lzvn_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t blockSize100k)
{
unsigned int out_len;
int res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
out_len = (unsigned int)*dst_size;
res = BZ2_bzBuffToBuffCompress((char *)dst_buffer, &out_len, (char *)src_buffer, (unsigned int)src_size,
blockSize100k, 0, 0);
if(res != BZ_OK) return res;
*dst_size = out_len;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lz4_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
int res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
res = LZ4_decompress_safe((const char *)src_buffer, (char *)dst_buffer, (int)src_size, (int)*dst_size);
if(res < 0) return AARU_ERROR_FAILURE;
*dst_size = (size_t)res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lz4_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
int res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
res = LZ4_compress_default((const char *)src_buffer, (char *)dst_buffer, (int)src_size, (int)*dst_size);
if(res <= 0) return AARU_ERROR_BUFFER_TOO_SMALL;
*dst_size = (size_t)res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzfse_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, void *scratch_buffer)
{
size_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = lzfse_decode_buffer(dst_buffer, *dst_size, src_buffer, src_size, scratch_buffer);
if(written == 0 && src_size > 0) return AARU_ERROR_FAILURE;
*dst_size = written;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzfse_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, void *scratch_buffer)
{
size_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = lzfse_encode_buffer(dst_buffer, *dst_size, src_buffer, src_size, scratch_buffer);
if(written == 0 && src_size > 0) return AARU_ERROR_BUFFER_TOO_SMALL;
*dst_size = written;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzvn_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
lzvn_decoder_state state;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
memset(&state, 0, sizeof(state));
state.src = src_buffer;
@@ -88,17 +163,21 @@ AARU_EXPORT size_t AARU_CALL AARU_lzvn_decode_buffer(uint8_t *dst_buffer, size_t
state.dst = dst_buffer;
state.dst_begin = dst_buffer;
state.dst_end = dst_buffer + dst_size;
state.dst_end = dst_buffer + *dst_size;
lzvn_decode(&state);
return (size_t)(state.dst - dst_buffer);
*dst_size = (size_t)(state.dst - dst_buffer);
return AARU_ERROR_NONE;
}
AARU_EXPORT size_t AARU_CALL AARU_lzvn_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_lzvn_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, void *scratch_buffer)
{
lzvn_encoder_state state;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
memset(&state, 0, sizeof(state));
state.src = src_buffer;
@@ -110,26 +189,48 @@ AARU_EXPORT size_t AARU_CALL AARU_lzvn_encode_buffer(uint8_t *dst_buffer, size_t
state.dst = dst_buffer;
state.dst_begin = dst_buffer;
state.dst_end = dst_buffer + dst_size;
state.dst_end = dst_buffer + *dst_size;
state.table = (lzvn_encode_entry_type *)scratch_buffer;
lzvn_encode(&state);
return (size_t)(state.dst - dst_buffer);
*dst_size = (size_t)(state.dst - dst_buffer);
return AARU_ERROR_NONE;
}
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_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, const uint8_t *props, size_t propsSize)
{
size_t consumed;
int res;
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,
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
consumed = src_size;
res = LzmaUncompress(dst_buffer, dst_size, src_buffer, &consumed, props, propsSize);
if(res != SZ_OK) return res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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)
{
return LzmaCompress(dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb,
fb, numThreads);
int res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
res = LzmaCompress(dst_buffer, dst_size, src_buffer, src_size, outProps, outPropsSize, level, dictSize, lc, lp, pb,
fb, numThreads);
if(res != SZ_OK) return res;
return AARU_ERROR_NONE;
}
// XZ buffer stream structures
@@ -180,15 +281,20 @@ static void xz_init_crc_tables(void)
}
}
AARU_EXPORT int32_t AARU_CALL AARU_xz_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_xz_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
CXzUnpacker state;
SizeT destLen = (SizeT)*dst_size;
SizeT destLen;
SizeT srcLen = (SizeT)src_size;
ECoderStatus status;
SRes res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
destLen = (SizeT)*dst_size;
srcLen = (SizeT)src_size;
xz_init_crc_tables();
XzUnpacker_Construct(&state, &g_Alloc);
@@ -196,21 +302,25 @@ AARU_EXPORT int32_t AARU_CALL AARU_xz_decode_buffer(uint8_t *dst_buffer, size_t
res = XzUnpacker_CodeFull(&state, dst_buffer, &destLen, src_buffer, &srcLen, CODER_FINISH_END, &status);
*dst_size = destLen;
XzUnpacker_Free(&state);
return res;
if(res != SZ_OK) return res;
*dst_size = destLen;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_xz_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, uint32_t preset, uint32_t checkType)
AARU_EXPORT int32_t AARU_CALL AARU_xz_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint32_t preset, uint32_t checkType)
{
CXzProps props;
CBufferInStream inStream;
CBufferOutStream outStream;
SRes res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
xz_init_crc_tables();
XzProps_Init(&props);
@@ -229,23 +339,51 @@ AARU_EXPORT int32_t AARU_CALL AARU_xz_encode_buffer(uint8_t *dst_buffer, size_t
res = Xz_Encode(&outStream.vt, &inStream.vt, &props, NULL);
if(res != SZ_OK) return res;
*dst_size = outStream.pos;
return res;
return AARU_ERROR_NONE;
}
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)
{ return ZSTD_compress(dst_buffer, dst_size, src_buffer, src_size, compressionLevel); }
AARU_EXPORT int32_t AARU_CALL AARU_lzo_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int32_t algorithm)
AARU_EXPORT int32_t AARU_CALL AARU_zstd_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
lzo_uint out_len = *dst_size;
size_t res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
res = ZSTD_decompress(dst_buffer, *dst_size, src_buffer, src_size);
if(ZSTD_isError(res)) return AARU_ERROR_FAILURE;
*dst_size = res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_zstd_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t compressionLevel)
{
size_t res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
res = ZSTD_compress(dst_buffer, *dst_size, src_buffer, src_size, compressionLevel);
if(ZSTD_isError(res)) return AARU_ERROR_FAILURE;
*dst_size = res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzo_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t algorithm)
{
lzo_uint out_len;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
out_len = *dst_size;
int result = lzo_init();
if(result != LZO_E_OK) return result; // Initialization failed
@@ -287,13 +425,17 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzo_decode_buffer(uint8_t *dst_buffer, size_t
return result;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzo_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int32_t algorithm, int32_t compression_level)
AARU_EXPORT int32_t AARU_CALL AARU_lzo_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t algorithm, int32_t compression_level)
{
lzo_uint out_len = *dst_size;
lzo_uint out_len;
void *wrkmem = NULL;
size_t wrkmem_size = 0;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
out_len = *dst_size;
// Determine work memory size based on algorithm and compression level
switch(algorithm)
{
@@ -447,29 +589,33 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzo_encode_buffer(uint8_t *dst_buffer, size_t
// This is required if BZ_NO_STDIO
void bz_internal_error(int errcode) {}
AARU_EXPORT int AARU_CALL ace_decompress_lz77(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len,
int dic_bits)
AARU_EXPORT int32_t AARU_CALL ace_decompress_lz77(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t dic_bits)
{
ace_decompress_ctx_t ctx;
int ret;
if(ace_decompress_init(&ctx, dic_bits) != 0) return -1;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
ret = ace_decompress_v1(&ctx, in_buf, in_len, out_buf, out_len);
if(ace_decompress_init(&ctx, dic_bits) != 0) return AARU_ERROR_FAILURE;
ret = ace_decompress_v1(&ctx, src_buffer, src_size, dst_buffer, dst_size);
ace_decompress_free(&ctx);
return ret;
}
AARU_EXPORT int AARU_CALL ace_decompress_blocked(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len, int dic_bits)
AARU_EXPORT int32_t AARU_CALL ace_decompress_blocked(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t dic_bits)
{
ace_decompress_ctx_t ctx;
int ret;
if(ace_decompress_init(&ctx, dic_bits) != 0) return -1;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
ret = ace_decompress_v2(&ctx, in_buf, in_len, out_buf, out_len);
if(ace_decompress_init(&ctx, dic_bits) != 0) return AARU_ERROR_FAILURE;
ret = ace_decompress_v2(&ctx, src_buffer, src_size, dst_buffer, dst_size);
ace_decompress_free(&ctx);
return ret;
@@ -477,16 +623,29 @@ AARU_EXPORT int AARU_CALL ace_decompress_blocked(const uint8_t *in_buf, size_t i
/* ============== LZMA2 ============== */
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t *src_size, uint8_t prop)
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint8_t prop)
{
ELzmaStatus status;
return Lzma2Decode(dst_buffer, (SizeT *)dst_size, src_buffer, (SizeT *)src_size, prop, LZMA_FINISH_END, &status,
&g_Alloc);
SizeT destLen;
SizeT srcLen;
SRes res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
destLen = (SizeT)*dst_size;
srcLen = (SizeT)src_size;
res = Lzma2Decode(dst_buffer, &destLen, src_buffer, &srcLen, prop, LZMA_FINISH_END, &status, &g_Alloc);
if(res != SZ_OK) return res;
*dst_size = destLen;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, uint8_t *outProp, int32_t level,
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint8_t *outProp, int32_t level,
uint32_t dictSize, int32_t lc, int32_t lp, int32_t pb,
int32_t fb, int32_t numThreads)
{
@@ -494,6 +653,8 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(uint8_t *dst_buffer, size
CLzma2EncProps props;
SRes res;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
enc = Lzma2Enc_Create(&g_Alloc, &g_Alloc);
if(!enc) return SZ_ERROR_MEM;
@@ -518,160 +679,175 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(uint8_t *dst_buffer, size
res = Lzma2Enc_Encode2(enc, NULL, dst_buffer, dst_size, NULL, src_buffer, src_size, NULL);
Lzma2Enc_Destroy(enc);
return res;
if(res != SZ_OK) return res;
return AARU_ERROR_NONE;
}
/* ============== ZIP Wrappers ============== */
AARU_EXPORT int AARU_CALL AARU_zip_blast_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_zip_blast_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return zip_blast_decompress(src_buffer, src_size, dst_buffer, dst_size); }
AARU_EXPORT int AARU_CALL AARU_zip_shrink_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_zip_shrink_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return zip_shrink_decompress(src_buffer, src_size, dst_buffer, dst_size); }
AARU_EXPORT int AARU_CALL AARU_zip_reduce_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size, int comp_factor)
AARU_EXPORT int32_t AARU_CALL AARU_zip_reduce_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t comp_factor)
{ return zip_reduce_decompress(src_buffer, src_size, dst_buffer, dst_size, comp_factor); }
AARU_EXPORT int AARU_CALL AARU_zip_implode_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int large_dictionary, int has_literals)
AARU_EXPORT int32_t AARU_CALL AARU_zip_implode_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t large_dictionary, int32_t has_literals)
{ return zip_implode_decompress(src_buffer, src_size, dst_buffer, dst_size, large_dictionary, has_literals); }
AARU_EXPORT int AARU_CALL AARU_zip_deflate64_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_zip_deflate64_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return zip_deflate64_decompress(src_buffer, src_size, dst_buffer, dst_size); }
AARU_EXPORT int AARU_CALL AARU_zip_ppmd_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, int max_order, int sub_alloc_size,
int restoration)
{ return zip_ppmd_decompress(dst_buffer, dst_size, src_buffer, src_size, max_order, sub_alloc_size, restoration); }
AARU_EXPORT int32_t AARU_CALL AARU_zip_ppmd_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t max_order,
int32_t sub_alloc_size, int32_t restoration)
{
int res;
AARU_EXPORT int AARU_CALL AARU_zip_wavpack_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
uint32_t num_samples, int bits_per_sample, int num_channels)
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
// PPMd produces exactly the requested amount of output, there is no short read to report.
res = zip_ppmd_decompress(dst_buffer, *dst_size, src_buffer, src_size, max_order, sub_alloc_size, restoration);
if(res != 0) return res;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_zip_wavpack_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
uint32_t num_samples, int32_t bits_per_sample,
int32_t num_channels)
{
return zip_wavpack_decompress(dst_buffer, dst_size, src_buffer, src_size, num_samples, bits_per_sample,
num_channels);
}
AARU_EXPORT int AARU_CALL AARU_zip_winzipjpeg_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_zip_winzipjpeg_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return zip_winzipjpeg_decompress(dst_buffer, dst_size, src_buffer, src_size); }
/* ============== Compact Pro Wrappers ============== */
AARU_EXPORT int AARU_CALL AARU_cpt_rle_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_cpt_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return cpt_rle_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_cpt_lzh_rle_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_cpt_lzh_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return cpt_lzh_rle_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
/* ============== DiskDoubler Wrappers ============== */
AARU_EXPORT int AARU_CALL AARU_dd_adn_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_dd_adn_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return dd_adn_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_dd_ddn_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_dd_ddn_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return dd_ddn_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_dd_method2_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size, int num_trees)
AARU_EXPORT int32_t AARU_CALL AARU_dd_method2_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t num_trees)
{ return dd_method2_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, num_trees); }
AARU_EXPORT int AARU_CALL AARU_dd_stac_lzs_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_dd_stac_lzs_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return dd_stac_lzs_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_dd_cpt_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_dd_cpt_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return dd_cpt_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_dd_lzw_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int flags)
AARU_EXPORT int32_t AARU_CALL AARU_dd_lzw_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t flags)
{ return dd_lzw_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, flags); }
/* ============== StuffIt Wrappers ============== */
#include "stuffit/stuffit.h"
AARU_EXPORT int AARU_CALL AARU_stuffit_rle90_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_rle90_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_rle90_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_compress_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_compress_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_compress_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_huffman_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_huffman_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_huffman_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_lzah_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_lzah_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_lzah_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_mw_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_mw_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_mw_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_method13_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_method13_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_method13_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_method14_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_method14_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_method14_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_arsenic_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_arsenic_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_arsenic_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffit_shrinkwrap_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_shrinkwrap_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffit_shrinkwrap_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_brimstone_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int max_order, int sub_alloc_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_brimstone_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t max_order, int32_t sub_alloc_size)
{
return stuffitx_brimstone_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, max_order, sub_alloc_size,
NULL);
}
AARU_EXPORT int AARU_CALL AARU_stuffitx_cyanide_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_cyanide_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_cyanide_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, NULL); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_darkhorse_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int window_bits)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_darkhorse_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t window_bits)
{ return stuffitx_darkhorse_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, window_bits, NULL); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_deflate_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_deflate_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_deflate_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_blend_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_blend_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_blend_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_iron_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_iron_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_iron_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_english_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_english_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_english_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT int AARU_CALL AARU_stuffitx_x86_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size)
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_x86_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size)
{ return stuffitx_x86_decode_buffer(dst_buffer, dst_size, src_buffer, src_size); }
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version() { return AARU_CHECKUMS_NATIVE_VERSION; }
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version() { return AARU_CHECKUMS_NATIVE_VERSION; }

554
library.h
View File

@@ -54,81 +54,104 @@
#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,
int32_t src_size);
// KenCode decompression (NDIF chunk type 0x80)
AARU_EXPORT int32_t AARU_CALL AARU_kencode_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/*
* Uniform external API convention
* ===============================
*
* Every buffer transform exported by this library has the shape:
*
* int32_t AARU_xxx(const uint8_t *src_buffer, size_t src_size,
* uint8_t *dst_buffer, size_t *dst_size, ...extra parameters);
*
* On entry *dst_size holds the capacity of dst_buffer; on successful return it
* holds the number of bytes actually written. The return value is 0 on success
* and non-zero on error (see AARU_ERROR_* below, or the underlying library's
* own error code when it is propagated).
*/
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);
#define AARU_ERROR_NONE 0
#define AARU_ERROR_INVALID_ARGUMENT (-1)
#define AARU_ERROR_BUFFER_TOO_SMALL (-2)
#define AARU_ERROR_FAILURE (-3)
#define AARU_ERROR_NO_MEMORY (-4)
// Apple LZH decompression (DART "best" mode: LH1 variant with zero-filled window tail)
AARU_EXPORT int AARU_CALL AARU_apple_lzh_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* Apple ADC (Apple Data Compression) */
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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);
/* KenCode decompression (NDIF chunk type 0x80) */
AARU_EXPORT int32_t AARU_CALL AARU_kencode_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_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,
/* Apple RLE (DART) */
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
/* Apple LZH decompression (DART "best" mode: LH1 variant with zero-filled window tail) */
AARU_EXPORT int32_t AARU_CALL AARU_apple_lzh_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
AARU_EXPORT int32_t AARU_CALL AARU_flac_decode_redbook_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
AARU_EXPORT int32_t AARU_CALL AARU_flac_encode_redbook_buffer(
const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer, size_t *dst_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_lz4_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_lz4_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
AARU_EXPORT int32_t AARU_CALL AARU_lz4_encode_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_lz4_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
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_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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 int32_t AARU_CALL AARU_bzip2_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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 int32_t AARU_CALL AARU_lzfse_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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_lzfse_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, void *scratch_buffer);
AARU_EXPORT size_t AARU_CALL AARU_lzvn_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_lzvn_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
AARU_EXPORT size_t AARU_CALL AARU_lzvn_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_lzvn_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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,
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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_xz_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
AARU_EXPORT int32_t AARU_CALL AARU_xz_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
AARU_EXPORT int32_t AARU_CALL AARU_xz_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, uint32_t preset, uint32_t checkType);
AARU_EXPORT int32_t AARU_CALL AARU_xz_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint32_t preset, uint32_t checkType);
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 int32_t AARU_CALL AARU_zstd_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_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 int32_t AARU_CALL AARU_zstd_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t compressionLevel);
/**
* LZO Algorithm Types
@@ -146,57 +169,60 @@ typedef enum
AARU_LZO_ALGORITHM_LZO2A = 8 /* LZO2A algorithm (only 999 compression level) */
} aaru_lzo_algorithm_t;
AARU_EXPORT int32_t AARU_CALL AARU_lzo_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int32_t algorithm);
AARU_EXPORT int32_t AARU_CALL AARU_lzo_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t algorithm);
AARU_EXPORT int32_t AARU_CALL AARU_lzo_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int32_t algorithm, int32_t compression_level);
AARU_EXPORT int32_t AARU_CALL AARU_lzo_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t algorithm, int32_t compression_level);
/* Streaming LZD (Zoo) context API — not a buffer transform, keeps its own shape. */
AARU_EXPORT void AARU_CALL *CreateLZDContext(void);
AARU_EXPORT void AARU_CALL DestroyLZDContext(void *ctx);
AARU_EXPORT int AARU_CALL LZD_FeedNative(void *ctx, const unsigned char *data, size_t length);
AARU_EXPORT int32_t AARU_CALL LZD_FeedNative(void *ctx, const uint8_t *data, size_t length);
AARU_EXPORT int AARU_CALL LZD_DrainNative(void *ctx, unsigned char *outBuf, size_t outBufLen, size_t *produced);
AARU_EXPORT int32_t AARU_CALL LZD_DrainNative(void *ctx, uint8_t *outBuf, size_t outBufLen, size_t *produced);
AARU_EXPORT int AARU_CALL lh5_decompress(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* Zoo -lh5- */
AARU_EXPORT int32_t AARU_CALL lh5_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
#define AARU_CHECKUMS_NATIVE_VERSION 0x06000089
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version();
// ARC method 3: Stored with non-repeat packing
AARU_EXPORT int AARU_CALL arc_decompress_pack(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
// ARC method 4: Huffman squeezing
AARU_EXPORT int AARU_CALL arc_decompress_squeeze(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
// ARC Method 5: LZW (crunching)
AARU_EXPORT int AARU_CALL arc_decompress_crunch(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
// ARC Method 6: LZW with non-repeat packing (crunching)
AARU_EXPORT int AARU_CALL arc_decompress_crunch_nrpack(const unsigned char *in_buf, size_t in_len,
unsigned char *out_buf, size_t *out_len);
// ARC Method 7: LZW with non-repeat packing and new hash (Crunching)
AARU_EXPORT int AARU_CALL arc_decompress_crunch_nrpack_new(const unsigned char *in_buf, size_t in_len,
unsigned char *out_buf, size_t *out_len);
/* ARC method 3: Stored with non-repeat packing */
AARU_EXPORT int32_t AARU_CALL arc_decompress_pack(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
/* ARC method 4: Huffman squeezing */
AARU_EXPORT int32_t AARU_CALL arc_decompress_squeeze(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
/* ARC Method 5: LZW (crunching) */
AARU_EXPORT int32_t AARU_CALL arc_decompress_crunch(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
/* ARC Method 6: LZW with non-repeat packing (crunching) */
AARU_EXPORT int32_t AARU_CALL arc_decompress_crunch_nrpack(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
/* ARC Method 7: LZW with non-repeat packing and new hash (Crunching) */
AARU_EXPORT int32_t AARU_CALL arc_decompress_crunch_nrpack_new(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ARC Method 8: Dynamic LZW (crunching)
AARU_EXPORT int AARU_CALL arc_decompress_crunch_dynamic(const unsigned char *in_buf, size_t in_len,
unsigned char *out_buf, size_t *out_len);
/* ARC Method 8: Dynamic LZW (crunching) */
AARU_EXPORT int32_t AARU_CALL arc_decompress_crunch_dynamic(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ARC Method 9: Dynamic LZW with 13 bits (squashing)
AARU_EXPORT int AARU_CALL arc_decompress_squash(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
/* ARC Method 9: Dynamic LZW with 13 bits (squashing) */
AARU_EXPORT int32_t AARU_CALL arc_decompress_squash(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARC/PAK Method 10: LZW (crush) (unsure why it's different of the others but even XADMaster uses different codepaths)
AARU_EXPORT int AARU_CALL pak_decompress_crush(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
/* ARC/PAK Method 10: LZW (crush) */
AARU_EXPORT int32_t AARU_CALL pak_decompress_crush(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARC/PAK Method 11: LZSS (distill)
AARU_EXPORT int AARU_CALL pak_decompress_distill(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
/* ARC/PAK Method 11: LZSS (distill) */
AARU_EXPORT int32_t AARU_CALL pak_decompress_distill(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
/**
* HA Algorithm Types
@@ -207,243 +233,259 @@ typedef enum
HA_ALGORITHM_HSC = 1 /* HSC algorithm */
} ha_algorithm_t;
AARU_EXPORT int AARU_CALL ha_asc_decompress(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
AARU_EXPORT int32_t AARU_CALL ha_asc_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
AARU_EXPORT int AARU_CALL ha_hsc_decompress(const unsigned char *in_buf, size_t in_len, unsigned char *out_buf,
size_t *out_len);
AARU_EXPORT int32_t AARU_CALL ha_hsc_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh1- (Dynamic Huffman, 4KB window)
AARU_EXPORT int AARU_CALL lha_decompress_lh1(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh1- (Dynamic Huffman, 4KB window) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh1(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh2- (Dynamic Huffman, legacy)
AARU_EXPORT int AARU_CALL lha_decompress_lh2(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh2- (Dynamic Huffman, legacy) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh2(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh3- (Static Huffman, legacy)
AARU_EXPORT int AARU_CALL lha_decompress_lh3(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh3- (Static Huffman, legacy) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh3(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh4- (Block Huffman, 4KB window)
AARU_EXPORT int AARU_CALL lha_decompress_lh4(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh4- (Block Huffman, 4KB window) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh4(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh5- (Block Huffman, 8KB window)
AARU_EXPORT int AARU_CALL lha_decompress_lh5(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh5- (Block Huffman, 8KB window) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh5(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh6- (Block Huffman, 32KB window)
AARU_EXPORT int AARU_CALL lha_decompress_lh6(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh6- (Block Huffman, 32KB window) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh6(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LHA -lh7- (Block Huffman, 64KB window)
AARU_EXPORT int AARU_CALL lha_decompress_lh7(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LHA -lh7- (Block Huffman, 64KB window) */
AARU_EXPORT int32_t AARU_CALL lha_decompress_lh7(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LArc -lzs- (LZSS, 2KB window)
AARU_EXPORT int AARU_CALL larc_decompress_lzs(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LArc -lzs- (LZSS, 2KB window) */
AARU_EXPORT int32_t AARU_CALL larc_decompress_lzs(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// LArc -lz5- (Flag-byte LZSS, 4KB window)
AARU_EXPORT int AARU_CALL larc_decompress_lz5(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* LArc -lz5- (Flag-byte LZSS, 4KB window) */
AARU_EXPORT int32_t AARU_CALL larc_decompress_lz5(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// PMarc -pm1- (Adaptive history + Huffman)
AARU_EXPORT int AARU_CALL pmarc_decompress_pm1(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* PMarc -pm1- (Adaptive history + Huffman) */
AARU_EXPORT int32_t AARU_CALL pmarc_decompress_pm1(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// PMarc -pm2- (Dynamic trees + history, legacy)
AARU_EXPORT int AARU_CALL pmarc_decompress_pm2(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* PMarc -pm2- (Dynamic trees + history, legacy) */
AARU_EXPORT int32_t AARU_CALL pmarc_decompress_pm2(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ACE v1 (LZ77) decompression
AARU_EXPORT int AARU_CALL ace_decompress_lz77(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len,
int dic_bits);
/* ACE v1 (LZ77) decompression */
AARU_EXPORT int32_t AARU_CALL ace_decompress_lz77(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t dic_bits);
// ACE v2 (Blocked) decompression
AARU_EXPORT int AARU_CALL ace_decompress_blocked(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len, int dic_bits);
/* ACE v2 (Blocked) decompression */
AARU_EXPORT int32_t AARU_CALL ace_decompress_blocked(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t dic_bits);
// ARJ Method 1 (LZH, most compression)
AARU_EXPORT int AARU_CALL arj_decompress_method1(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJ Method 1 (LZH, most compression) */
AARU_EXPORT int32_t AARU_CALL arj_decompress_method1(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJ Method 2 (LZH, medium compression)
AARU_EXPORT int AARU_CALL arj_decompress_method2(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJ Method 2 (LZH, medium compression) */
AARU_EXPORT int32_t AARU_CALL arj_decompress_method2(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJ Method 3 (LZH, fast compression)
AARU_EXPORT int AARU_CALL arj_decompress_method3(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJ Method 3 (LZH, fast compression) */
AARU_EXPORT int32_t AARU_CALL arj_decompress_method3(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJ Method 4 (Fastest, variable-width LZSS)
AARU_EXPORT int AARU_CALL arj_decompress_fastest(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJ Method 4 (Fastest, variable-width LZSS) */
AARU_EXPORT int32_t AARU_CALL arj_decompress_fastest(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJZ Method 1 (LZH, 64KB window)
AARU_EXPORT int AARU_CALL arjz_decompress_method1(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJZ Method 1 (LZH, 64KB window) */
AARU_EXPORT int32_t AARU_CALL arjz_decompress_method1(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJZ Method 2 (LZH, 64KB window)
AARU_EXPORT int AARU_CALL arjz_decompress_method2(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJZ Method 2 (LZH, 64KB window) */
AARU_EXPORT int32_t AARU_CALL arjz_decompress_method2(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJZ Method 3 (LZH, 64KB window)
AARU_EXPORT int AARU_CALL arjz_decompress_method3(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len);
/* ARJZ Method 3 (LZH, 64KB window) */
AARU_EXPORT int32_t AARU_CALL arjz_decompress_method3(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// ARJZ custom extended DEFLATE decompression
AARU_EXPORT int AARU_CALL arjz_decompress_buffer(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf,
size_t *out_len, size_t orig_size);
/* ARJZ custom extended DEFLATE decompression */
AARU_EXPORT int32_t AARU_CALL arjz_decompress_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, size_t orig_size);
// LZMA2 decode (single prop byte instead of 5-byte props blob)
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t *src_size, uint8_t prop);
/* LZMA2 decode (single prop byte instead of 5-byte props blob) */
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint8_t prop);
// LZMA2 encode
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, uint8_t *outProp, int32_t level,
/* LZMA2 encode */
AARU_EXPORT int32_t AARU_CALL AARU_lzma2_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, uint8_t *outProp, int32_t level,
uint32_t dictSize, int32_t lc, int32_t lp, int32_t pb,
int32_t fb, int32_t numThreads);
// ZIP DCL Implode (PKWare Compression Library)
AARU_EXPORT int AARU_CALL AARU_zip_blast_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* ZIP DCL Implode (PKWare Compression Library) */
AARU_EXPORT int32_t AARU_CALL AARU_zip_blast_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ZIP method 1: Shrink (LZW, 9-13 bit codes)
AARU_EXPORT int AARU_CALL AARU_zip_shrink_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* ZIP method 1: Shrink (LZW, 9-13 bit codes) */
AARU_EXPORT int32_t AARU_CALL AARU_zip_shrink_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ZIP methods 2-5: Reduce (follower sets + LZ77, compression factor 1-4)
AARU_EXPORT int AARU_CALL AARU_zip_reduce_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size, int comp_factor);
/* ZIP methods 2-5: Reduce (follower sets + LZ77, compression factor 1-4) */
AARU_EXPORT int32_t AARU_CALL AARU_zip_reduce_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t comp_factor);
// ZIP method 6: Implode (Shannon-Fano + LZSS)
AARU_EXPORT int AARU_CALL AARU_zip_implode_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int large_dictionary, int has_literals);
/* ZIP method 6: Implode (Shannon-Fano + LZSS) */
AARU_EXPORT int32_t AARU_CALL AARU_zip_implode_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t large_dictionary, int32_t has_literals);
// ZIP method 9: Deflate64
AARU_EXPORT int AARU_CALL AARU_zip_deflate64_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* ZIP method 9: Deflate64 */
AARU_EXPORT int32_t AARU_CALL AARU_zip_deflate64_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ZIP method 98: PPMd variant I
AARU_EXPORT int AARU_CALL AARU_zip_ppmd_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
size_t src_size, int max_order, int sub_alloc_size,
int restoration);
/* ZIP method 98: PPMd variant I */
AARU_EXPORT int32_t AARU_CALL AARU_zip_ppmd_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t max_order,
int32_t sub_alloc_size, int32_t restoration);
// ZIP method 97: WinZip WavPack
AARU_EXPORT int AARU_CALL AARU_zip_wavpack_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
uint32_t num_samples, int bits_per_sample, int num_channels);
/* ZIP method 97: WinZip WavPack */
AARU_EXPORT int32_t AARU_CALL AARU_zip_wavpack_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
uint32_t num_samples, int32_t bits_per_sample,
int32_t num_channels);
// ZIP method 96: WinZip JPEG
AARU_EXPORT int AARU_CALL AARU_zip_winzipjpeg_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* ZIP method 96: WinZip JPEG */
AARU_EXPORT int32_t AARU_CALL AARU_zip_winzipjpeg_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// RAR 1.5 (UNP_VER=15): Custom LZ77 with fixed Huffman tables, 64KB window
AARU_EXPORT int AARU_CALL rar15_decompress(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* RAR 1.5 (UNP_VER=15): Custom LZ77 with fixed Huffman tables, 64KB window */
AARU_EXPORT int32_t AARU_CALL rar15_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// RAR 2.0 (UNP_VER=20): Block Huffman LZ77 with optional audio, 1MB window
AARU_EXPORT int AARU_CALL rar20_decompress(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* RAR 2.0 (UNP_VER=20): Block Huffman LZ77 with optional audio, 1MB window */
AARU_EXPORT int32_t AARU_CALL rar20_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// RAR 3.0 (UNP_VER=29): Huffman LZ77 / PPMd Variant H + VM filters, 4MB window
AARU_EXPORT int AARU_CALL rar30_decompress(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len);
/* RAR 3.0 (UNP_VER=29): Huffman LZ77 / PPMd Variant H + VM filters, 4MB window */
AARU_EXPORT int32_t AARU_CALL rar30_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size);
// RAR 5.0: Huffman LZ77 + native filters, variable window
AARU_EXPORT int AARU_CALL rar50_decompress(const uint8_t *in_buf, size_t in_len, uint8_t *out_buf, size_t *out_len,
size_t window_size);
/* RAR 5.0: Huffman LZ77 + native filters, variable window */
AARU_EXPORT int32_t AARU_CALL rar50_decompress(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, size_t window_size);
// Compact Pro: RLE decompression (always applied)
AARU_EXPORT int AARU_CALL AARU_cpt_rle_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* Compact Pro: RLE decompression (always applied) */
AARU_EXPORT int32_t AARU_CALL AARU_cpt_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// Compact Pro: LZH + RLE decompression (block Huffman LZSS + RLE)
AARU_EXPORT int AARU_CALL AARU_cpt_lzh_rle_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* Compact Pro: LZH + RLE decompression (block Huffman LZSS + RLE) */
AARU_EXPORT int32_t AARU_CALL AARU_cpt_lzh_rle_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// DiskDoubler: ADn block LZSS decompression (methods 6 and 9)
AARU_EXPORT int AARU_CALL AARU_dd_adn_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* DiskDoubler: ADn block LZSS decompression (methods 6 and 9) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_adn_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// DiskDoubler: DDn block Huffman LZ77 decompression (method 10)
AARU_EXPORT int AARU_CALL AARU_dd_ddn_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* DiskDoubler: DDn block Huffman LZ77 decompression (method 10) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_ddn_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// DiskDoubler: Method 2 adaptive Huffman decompression (methods 2 and 5)
AARU_EXPORT int AARU_CALL AARU_dd_method2_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size, int num_trees);
/* DiskDoubler: Method 2 adaptive Huffman decompression (methods 2 and 5) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_method2_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t num_trees);
// DiskDoubler: Stac LZS decompression (method 7)
AARU_EXPORT int AARU_CALL AARU_dd_stac_lzs_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* DiskDoubler: Stac LZS decompression (method 7) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_stac_lzs_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// DiskDoubler: Compact Pro decompression (method 8)
AARU_EXPORT int AARU_CALL AARU_dd_cpt_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size);
/* DiskDoubler: Compact Pro decompression (method 8) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_cpt_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// DiskDoubler: LZW decompression (method 1, Unix compress variant)
AARU_EXPORT int AARU_CALL AARU_dd_lzw_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
size_t src_size, int flags);
/* DiskDoubler: LZW decompression (method 1, Unix compress variant) */
AARU_EXPORT int32_t AARU_CALL AARU_dd_lzw_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size, int32_t flags);
// StuffIt classic method 1: RLE with 0x90 escape
AARU_EXPORT int AARU_CALL AARU_stuffit_rle90_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 1: RLE with 0x90 escape */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_rle90_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 2: UNIX compress (LZW)
AARU_EXPORT int AARU_CALL AARU_stuffit_compress_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 2: UNIX compress (LZW) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_compress_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 3: Static Huffman tree
AARU_EXPORT int AARU_CALL AARU_stuffit_huffman_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 3: Static Huffman tree */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_huffman_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 5: LZAH (LZH with adaptive Huffman, 4KB window)
AARU_EXPORT int AARU_CALL AARU_stuffit_lzah_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 5: LZAH (LZH with adaptive Huffman, 4KB window) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_lzah_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 8: MW (LZW variant)
AARU_EXPORT int AARU_CALL AARU_stuffit_mw_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 8: MW (LZW variant) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_mw_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 13: Dynamic/Static Huffman LZSS (64KB window)
AARU_EXPORT int AARU_CALL AARU_stuffit_method13_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 13: Dynamic/Static Huffman LZSS (64KB window) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_method13_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 14: Block Huffman LZSS (256KB window)
AARU_EXPORT int AARU_CALL AARU_stuffit_method14_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 14: Block Huffman LZSS (256KB window) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_method14_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt classic method 15: Arsenic (BWT + arithmetic coding)
AARU_EXPORT int AARU_CALL AARU_stuffit_arsenic_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt classic method 15: Arsenic (BWT + arithmetic coding) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_arsenic_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// ShrinkWrap 3 SIT2 compression (NDIF chunk type 0xF0)
AARU_EXPORT int AARU_CALL AARU_stuffit_shrinkwrap_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* ShrinkWrap 3 SIT2 compression (NDIF chunk type 0xF0) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffit_shrinkwrap_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X method 0: Brimstone (PPMd Variant G)
AARU_EXPORT int AARU_CALL AARU_stuffitx_brimstone_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int max_order, int sub_alloc_size);
/* StuffIt X method 0: Brimstone (PPMd Variant G) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_brimstone_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t max_order, int32_t sub_alloc_size);
// StuffIt X method 1: Cyanide (BWT + ternary range coding)
AARU_EXPORT int AARU_CALL AARU_stuffitx_cyanide_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X method 1: Cyanide (BWT + ternary range coding) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_cyanide_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X method 2: Darkhorse (context-weighted LZSS + range coder)
AARU_EXPORT int AARU_CALL AARU_stuffitx_darkhorse_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size,
int window_bits);
/* StuffIt X method 2: Darkhorse (context-weighted LZSS + range coder) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_darkhorse_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size,
int32_t window_bits);
// StuffIt X method 3: Modified Deflate
AARU_EXPORT int AARU_CALL AARU_stuffitx_deflate_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X method 3: Modified Deflate */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_deflate_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X method 4: Blend (Darkhorse/Cyanide/Brimstone multiplexer)
AARU_EXPORT int AARU_CALL AARU_stuffitx_blend_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X method 4: Blend (Darkhorse/Cyanide/Brimstone multiplexer) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_blend_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X method 6: Iron (advanced BWT/ST4 + range coder)
AARU_EXPORT int AARU_CALL AARU_stuffitx_iron_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X method 6: Iron (advanced BWT/ST4 + range coder) */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_iron_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X preprocessor 0: English dictionary word substitution
AARU_EXPORT int AARU_CALL AARU_stuffitx_english_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X preprocessor 0: English dictionary word substitution */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_english_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
// StuffIt X preprocessor 2: x86 executable address transformation
AARU_EXPORT int AARU_CALL AARU_stuffitx_x86_decode_buffer(uint8_t *dst_buffer, size_t *dst_size,
const uint8_t *src_buffer, size_t src_size);
/* StuffIt X preprocessor 2: x86 executable address transformation */
AARU_EXPORT int32_t AARU_CALL AARU_stuffitx_x86_decode_buffer(const uint8_t *src_buffer, size_t src_size,
uint8_t *dst_buffer, size_t *dst_size);
#endif // AARU_COMPRESSION_NATIVE_LIBRARY_H

42
lzip.c
View File

@@ -23,8 +23,7 @@
#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,
int32_t src_size)
static int32_t lzip_decode(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer, int32_t src_size)
{
int max_in_size;
void *ctx;
@@ -81,9 +80,8 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32
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,
int32_t match_len_limit)
static int32_t lzip_encode(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;
@@ -139,4 +137,36 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t *dst_buffer, int32
LZ_compress_close(ctx);
return out_pos;
}
}
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size)
{
int32_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = lzip_decode(dst_buffer, (int32_t)*dst_size, src_buffer, (int32_t)src_size);
if(written <= 0) return AARU_ERROR_FAILURE;
*dst_size = (size_t)written;
return AARU_ERROR_NONE;
}
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(const uint8_t *src_buffer, size_t src_size, uint8_t *dst_buffer,
size_t *dst_size, int32_t dictionary_size,
int32_t match_len_limit)
{
int32_t written;
if(!src_buffer || !dst_buffer || !dst_size) return AARU_ERROR_INVALID_ARGUMENT;
written = lzip_encode(dst_buffer, (int32_t)*dst_size, src_buffer, (int32_t)src_size, dictionary_size,
match_len_limit);
if(written <= 0) return AARU_ERROR_FAILURE;
*dst_size = (size_t)written;
return AARU_ERROR_NONE;
}

View File

@@ -67,8 +67,9 @@ TEST_F(adcFixture, adc)
{
auto *outBuf = (uint8_t *)malloc(327680);
auto decoded = AARU_adc_decode_buffer(outBuf, 327680, buffer, 34367);
size_t decoded = 327680;
EXPECT_EQ(AARU_adc_decode_buffer(buffer, 34367, outBuf, &decoded), 0);
EXPECT_EQ(decoded, 262144);
auto crc = crc32_data(outBuf, 262144);

View File

@@ -67,7 +67,9 @@ TEST_F(apple_rleFixture, apple_rle)
{
auto *outBuf = (uint8_t *)malloc(32768);
auto decoded = AARU_apple_rle_decode_buffer(outBuf, 32768, buffer, 1102);
size_t decoded = 32768;
EXPECT_EQ(AARU_apple_rle_decode_buffer(buffer, 1102, outBuf, &decoded), 0);
EXPECT_EQ(decoded, 20960);

View File

@@ -64,10 +64,10 @@ protected:
TEST_F(bzip2Fixture, bzip2)
{
uint real_size = 1048576;
auto *outBuf = (uint8_t *)malloc(1048576);
size_t real_size = 1048576;
auto *outBuf = (uint8_t *)malloc(1048576);
auto bz_err = AARU_bzip2_decode_buffer(outBuf, &real_size, buffer, 1053934);
auto bz_err = AARU_bzip2_decode_buffer(buffer, 1053934, outBuf, &real_size);
EXPECT_EQ(bz_err, 0);
@@ -83,8 +83,8 @@ TEST_F(bzip2Fixture, bzip2)
TEST_F(bzip2Fixture, bzip2Compress)
{
size_t original_len = 8388608;
uint cmp_len = original_len;
uint decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -111,12 +111,12 @@ TEST_F(bzip2Fixture, bzip2Compress)
original_crc = crc32_data(original, original_len);
// Compress
bz_err = AARU_bzip2_encode_buffer(cmp_buffer, &cmp_len, original, original_len, 9);
bz_err = AARU_bzip2_encode_buffer(original, original_len, cmp_buffer, &cmp_len, 9);
EXPECT_EQ(bz_err, 0);
// Decompress
bz_err = AARU_bzip2_decode_buffer(decmp_buffer, &decmp_len, cmp_buffer, cmp_len);
bz_err = AARU_bzip2_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &decmp_len);
EXPECT_EQ(bz_err, 0);

View File

@@ -59,7 +59,7 @@ TEST_F(CptRleFixture, cpt_rle)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_cpt_rle_decode_buffer(outBuf, &destLen, rle_buffer, RLE_COMPRESSED_SIZE);
auto err = AARU_cpt_rle_decode_buffer(rle_buffer, RLE_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -98,7 +98,7 @@ TEST_F(CptLzhRleFixture, cpt_lzh_rle)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_cpt_lzh_rle_decode_buffer(outBuf, &destLen, lzh_rle_buffer, LZH_RLE_COMPRESSED_SIZE);
auto err = AARU_cpt_lzh_rle_decode_buffer(lzh_rle_buffer, LZH_RLE_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);

View File

@@ -78,12 +78,13 @@ static size_t lzip_decompress_file(const char *path, uint8_t **out)
size_t try_sizes[] = {512 * 1024, 1024 * 1024, 2 * 1024 * 1024};
for(int i = 0; i < 3; i++)
{
*out = (uint8_t *)malloc(try_sizes[i]);
int32_t result = AARU_lzip_decode_buffer(*out, (int32_t)try_sizes[i], lz_buf, (int32_t)lz_size);
if(result > 0)
*out = (uint8_t *)malloc(try_sizes[i]);
size_t out_len = try_sizes[i];
int32_t result = AARU_lzip_decode_buffer(lz_buf, lz_size, *out, &out_len);
if(result == 0 && out_len > 0)
{
free(lz_buf);
return (size_t)result;
return out_len;
}
free(*out);
*out = NULL;
@@ -135,8 +136,8 @@ static bool load_dart_image(const char *path, dart_image_t *img)
size_t comp_size = (size_t)img->block_lengths[i] * 2;
if(in_pos + comp_size <= img->raw_size)
{
AARU_apple_rle_decode_buffer(img->data + out_pos, DART_BUFFER_SIZE, img->raw + in_pos,
(int32_t)comp_size);
size_t rle_out_len = DART_BUFFER_SIZE;
AARU_apple_rle_decode_buffer(img->raw + in_pos, comp_size, img->data + out_pos, &rle_out_len);
}
in_pos += comp_size;
}
@@ -217,7 +218,7 @@ static bool verify_dart_pair(const char *fast_name, const char *best_name)
memset(out, 0, DART_BUFFER_SIZE);
int ret = AARU_apple_lzh_decode_buffer(out, &out_len, best_img.raw + in_pos, comp_size);
int ret = AARU_apple_lzh_decode_buffer(best_img.raw + in_pos, comp_size, out, &out_len);
if(ret == 0 && out_len == DART_BUFFER_SIZE && memcmp(out, reference, DART_BUFFER_SIZE) == 0)
blocks_ok++;
else

View File

@@ -59,7 +59,7 @@ TEST_F(DdAdnFixture, dd_adn)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_dd_adn_decode_buffer(outBuf, &destLen, adn_buffer, ADN_COMPRESSED_SIZE);
auto err = AARU_dd_adn_decode_buffer(adn_buffer, ADN_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -98,7 +98,7 @@ TEST_F(DdAdn2Fixture, dd_adn2)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_dd_adn_decode_buffer(outBuf, &destLen, adn2_buffer, ADN2_COMPRESSED_SIZE);
auto err = AARU_dd_adn_decode_buffer(adn2_buffer, ADN2_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -137,7 +137,7 @@ TEST_F(DdDdn1Fixture, dd_ddn1)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_dd_ddn_decode_buffer(outBuf, &destLen, ddn1_buffer, DDN1_COMPRESSED_SIZE);
auto err = AARU_dd_ddn_decode_buffer(ddn1_buffer, DDN1_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -176,7 +176,7 @@ TEST_F(DdDdn2Fixture, dd_ddn2)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_dd_ddn_decode_buffer(outBuf, &destLen, ddn2_buffer, DDN2_COMPRESSED_SIZE);
auto err = AARU_dd_ddn_decode_buffer(ddn2_buffer, DDN2_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -215,7 +215,7 @@ TEST_F(DdDdn3Fixture, dd_ddn3)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_dd_ddn_decode_buffer(outBuf, &destLen, ddn3_buffer, DDN3_COMPRESSED_SIZE);
auto err = AARU_dd_ddn_decode_buffer(ddn3_buffer, DDN3_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);

View File

@@ -67,7 +67,9 @@ TEST_F(flacFixture, flac)
{
auto *outBuf = (uint8_t *)malloc(9633792);
auto decoded = AARU_flac_decode_redbook_buffer(outBuf, 9633792, buffer, 6534197);
size_t decoded = 9633792;
EXPECT_EQ(AARU_flac_decode_redbook_buffer(buffer, 6534197, outBuf, &decoded), 0);
EXPECT_EQ(decoded, 9633792);
@@ -81,8 +83,8 @@ TEST_F(flacFixture, flac)
TEST_F(flacFixture, flacCompress)
{
size_t original_len = 9633792;
uint cmp_len = original_len;
uint decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -109,13 +111,17 @@ TEST_F(flacFixture, flacCompress)
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer, cmp_len, original, original_len, 4608, 1, 0,
newSize = cmp_len;
EXPECT_EQ(AARU_flac_encode_redbook_buffer(original, original_len, cmp_buffer, &newSize, 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"));
"Aaru.Compression.Native.Tests",
strlen("Aaru.Compression.Native.Tests")),
0);
cmp_len = newSize;
// Decompress
newSize = AARU_flac_decode_redbook_buffer(decmp_buffer, decmp_len, cmp_buffer, cmp_len);
newSize = decmp_len;
EXPECT_EQ(AARU_flac_decode_redbook_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize), 0);
decmp_len = newSize;
EXPECT_EQ(decmp_len, original_len);

View File

@@ -87,7 +87,7 @@ TEST_F(KencodeBootFixture, kencode_boot)
auto *outBuf = (uint8_t *)malloc(KC_BOOT_DECOMP_SIZE);
size_t destLen = KC_BOOT_DECOMP_SIZE;
auto err = AARU_kencode_decode_buffer(outBuf, &destLen, kc_boot_buffer, KC_BOOT_COMP_SIZE);
auto err = AARU_kencode_decode_buffer(kc_boot_buffer, KC_BOOT_COMP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)KC_BOOT_DECOMP_SIZE);
@@ -115,7 +115,7 @@ TEST_F(KencodeZerosFixture, kencode_zeros)
auto *outBuf = (uint8_t *)malloc(KC_ZEROS_DECOMP_SIZE);
size_t destLen = KC_ZEROS_DECOMP_SIZE;
auto err = AARU_kencode_decode_buffer(outBuf, &destLen, kc_zeros_buffer, KC_ZEROS_COMP_SIZE);
auto err = AARU_kencode_decode_buffer(kc_zeros_buffer, KC_ZEROS_COMP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)KC_ZEROS_DECOMP_SIZE);
@@ -143,7 +143,7 @@ TEST_F(KencodeHfsFixture, kencode_hfs)
auto *outBuf = (uint8_t *)malloc(KC_HFS_DECOMP_SIZE);
size_t destLen = KC_HFS_DECOMP_SIZE;
auto err = AARU_kencode_decode_buffer(outBuf, &destLen, kc_hfs_buffer, KC_HFS_COMP_SIZE);
auto err = AARU_kencode_decode_buffer(kc_hfs_buffer, KC_HFS_COMP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)KC_HFS_DECOMP_SIZE);
@@ -171,7 +171,7 @@ TEST_F(KencodeLastFixture, kencode_last)
auto *outBuf = (uint8_t *)malloc(KC_LAST_DECOMP_SIZE);
size_t destLen = KC_LAST_DECOMP_SIZE;
auto err = AARU_kencode_decode_buffer(outBuf, &destLen, kc_last_buffer, KC_LAST_COMP_SIZE);
auto err = AARU_kencode_decode_buffer(kc_last_buffer, KC_LAST_COMP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)KC_LAST_DECOMP_SIZE);
@@ -199,7 +199,7 @@ TEST_F(KencodeLargeFixture, kencode_large)
auto *outBuf = (uint8_t *)malloc(KC_LARGE_DECOMP_SIZE);
size_t destLen = KC_LARGE_DECOMP_SIZE;
auto err = AARU_kencode_decode_buffer(outBuf, &destLen, kc_large_buffer, KC_LARGE_COMP_SIZE);
auto err = AARU_kencode_decode_buffer(kc_large_buffer, KC_LARGE_COMP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)KC_LARGE_DECOMP_SIZE);

View File

@@ -73,10 +73,10 @@ TEST_F(lz4Fixture, lz4)
int32_t original_len = 8388608; // 8MB
auto *outBuf = (uint8_t *)malloc(original_len);
auto decoded = AARU_lz4_decode_buffer(outBuf, original_len, buffer, buffer_size);
size_t decoded = original_len;
EXPECT_GT(decoded, 0);
EXPECT_EQ(decoded, original_len);
EXPECT_EQ(AARU_lz4_decode_buffer(buffer, buffer_size, outBuf, &decoded), 0);
EXPECT_EQ(decoded, (size_t)original_len);
auto crc = crc32_data(outBuf, original_len);
@@ -88,8 +88,8 @@ TEST_F(lz4Fixture, lz4)
TEST_F(lz4Fixture, lz4Compress)
{
int32_t original_len = 8388608;
int32_t cmp_len = original_len;
int32_t decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -97,7 +97,7 @@ TEST_F(lz4Fixture, lz4Compress)
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
int32_t newSize;
size_t newSize;
// Allocate buffers
original = (const uint8_t *)malloc(original_len);
@@ -116,13 +116,13 @@ TEST_F(lz4Fixture, lz4Compress)
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_lz4_encode_buffer(cmp_buffer, cmp_len, original, original_len);
EXPECT_GT(newSize, 0);
newSize = cmp_len;
EXPECT_EQ(AARU_lz4_encode_buffer(original, original_len, cmp_buffer, &newSize), 0);
cmp_len = newSize;
// Decompress
newSize = AARU_lz4_decode_buffer(decmp_buffer, decmp_len, cmp_buffer, cmp_len);
EXPECT_GT(newSize, 0);
newSize = decmp_len;
EXPECT_EQ(AARU_lz4_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize), 0);
decmp_len = newSize;
EXPECT_EQ(decmp_len, original_len);

View File

@@ -66,7 +66,9 @@ TEST_F(lzfseFixture, lzfse)
{
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_lzfse_decode_buffer(outBuf, 1048576, buffer, 1059299, nullptr);
size_t decoded = 1048576;
EXPECT_EQ(AARU_lzfse_decode_buffer(buffer, 1059299, outBuf, &decoded, nullptr), 0);
EXPECT_EQ(decoded, 1048576);
@@ -80,8 +82,8 @@ TEST_F(lzfseFixture, lzfse)
TEST_F(lzfseFixture, lzfseCompress)
{
size_t original_len = 8388608;
uint cmp_len = original_len;
uint decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -108,11 +110,13 @@ TEST_F(lzfseFixture, lzfseCompress)
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_lzfse_encode_buffer(cmp_buffer, cmp_len, original, original_len, nullptr);
newSize = cmp_len;
EXPECT_EQ(AARU_lzfse_encode_buffer(original, original_len, cmp_buffer, &newSize, nullptr), 0);
cmp_len = newSize;
// Decompress
newSize = AARU_lzfse_decode_buffer(decmp_buffer, decmp_len, cmp_buffer, cmp_len, nullptr);
newSize = decmp_len;
EXPECT_EQ(AARU_lzfse_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize, nullptr), 0);
decmp_len = newSize;
EXPECT_EQ(decmp_len, original_len);

View File

@@ -66,7 +66,9 @@ TEST_F(lzipFixture, lzip)
{
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_lzip_decode_buffer(outBuf, 1048576, buffer, 1062874);
size_t decoded = 1048576;
EXPECT_EQ(AARU_lzip_decode_buffer(buffer, 1062874, outBuf, &decoded), 0);
EXPECT_EQ(decoded, 1048576);
@@ -80,8 +82,8 @@ TEST_F(lzipFixture, lzip)
TEST_F(lzipFixture, lzipCompress)
{
int32_t original_len = 8388608;
int32_t cmp_len = original_len;
int32_t decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -89,7 +91,7 @@ TEST_F(lzipFixture, lzipCompress)
const uint8_t *original;
uint8_t *cmp_buffer;
uint8_t *decmp_buffer;
int32_t newSize;
size_t newSize;
// Allocate buffers
original = (const uint8_t *)malloc(original_len);
@@ -108,11 +110,13 @@ TEST_F(lzipFixture, lzipCompress)
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_lzip_encode_buffer(cmp_buffer, cmp_len, original, original_len, 1048576, 273);
newSize = cmp_len;
EXPECT_EQ(AARU_lzip_encode_buffer(original, original_len, cmp_buffer, &newSize, 1048576, 273), 0);
cmp_len = newSize;
// Decompress
newSize = AARU_lzip_decode_buffer(decmp_buffer, decmp_len, cmp_buffer, cmp_len);
newSize = decmp_len;
EXPECT_EQ(AARU_lzip_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize), 0);
decmp_len = newSize;
EXPECT_EQ(decmp_len, original_len);

View File

@@ -69,7 +69,7 @@ TEST_F(lzmaFixture, lzma)
size_t srcLen = 1200275;
auto *outBuf = (uint8_t *)malloc(8388608);
auto err = AARU_lzma_decode_buffer(outBuf, &destLen, buffer, &srcLen, params, 5);
auto err = AARU_lzma_decode_buffer(buffer, srcLen, outBuf, &destLen, params, 5);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, 8388608);
@@ -114,12 +114,12 @@ TEST_F(lzmaFixture, lzmaCompress)
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,
err = AARU_lzma_encode_buffer(original, original_len, cmp_buffer, &cmp_len, props, &props_len, 9, 1048576, 3, 0, 2,
273, 2);
EXPECT_EQ(err, 0);
// Decompress
err = AARU_lzma_decode_buffer(decmp_buffer, &decmp_len, cmp_buffer, &cmp_len, props, props_len);
err = AARU_lzma_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &decmp_len, props, props_len);
EXPECT_EQ(err, 0);
EXPECT_EQ(decmp_len, original_len);

View File

@@ -59,7 +59,7 @@ TEST_F(StuffitCompressFixture, stuffit_compress)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_compress_decode_buffer(outBuf, &destLen, compress_buffer, COMPRESS_SIZE);
auto err = AARU_stuffit_compress_decode_buffer(compress_buffer, COMPRESS_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -97,7 +97,7 @@ TEST_F(StuffitMethod13Fixture, stuffit_method13)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_method13_decode_buffer(outBuf, &destLen, method13_buffer, METHOD13_SIZE);
auto err = AARU_stuffit_method13_decode_buffer(method13_buffer, METHOD13_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -135,7 +135,7 @@ TEST_F(StuffitMethod13V5Fixture, stuffit_method13_v5)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_method13_decode_buffer(outBuf, &destLen, method13_v5_buffer, METHOD13_V5_SIZE);
auto err = AARU_stuffit_method13_decode_buffer(method13_v5_buffer, METHOD13_V5_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -173,7 +173,7 @@ TEST_F(StuffitArsenicFixture, stuffit_arsenic)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_arsenic_decode_buffer(outBuf, &destLen, arsenic_buffer, ARSENIC_SIZE);
auto err = AARU_stuffit_arsenic_decode_buffer(arsenic_buffer, ARSENIC_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -224,7 +224,7 @@ TEST_F(StuffitxBrimstoneFixture, stuffitx_brimstone)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_brimstone_decode_buffer(midBuf, &midLen, buf + 2, BRIMSTONE_SIZE - 2, order, allocsize);
auto err = AARU_stuffitx_brimstone_decode_buffer(buf + 2, BRIMSTONE_SIZE - 2, midBuf, &midLen, order, allocsize);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
@@ -232,7 +232,7 @@ TEST_F(StuffitxBrimstoneFixture, stuffitx_brimstone)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -262,14 +262,14 @@ TEST_F(StuffitxCyanideFixture, stuffitx_cyanide)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_cyanide_decode_buffer(midBuf, &midLen, buf, CYANIDE_SIZE);
auto err = AARU_stuffitx_cyanide_decode_buffer(buf, CYANIDE_SIZE, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -301,14 +301,14 @@ TEST_F(StuffitxDarkhorseFixture, stuffitx_darkhorse)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_darkhorse_decode_buffer(midBuf, &midLen, buf + 1, DARKHORSE_SIZE - 1, window_bits);
auto err = AARU_stuffitx_darkhorse_decode_buffer(buf + 1, DARKHORSE_SIZE - 1, midBuf, &midLen, window_bits);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -338,14 +338,14 @@ TEST_F(StuffitxDeflateFixture, stuffitx_deflate)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_deflate_decode_buffer(midBuf, &midLen, buf + 1, SITX_DEFLATE_SIZE - 1);
auto err = AARU_stuffitx_deflate_decode_buffer(buf + 1, SITX_DEFLATE_SIZE - 1, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -375,14 +375,14 @@ TEST_F(StuffitxBlendFixture, stuffitx_blend)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_blend_decode_buffer(midBuf, &midLen, buf, BLEND_SIZE);
auto err = AARU_stuffitx_blend_decode_buffer(buf, BLEND_SIZE, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -415,7 +415,7 @@ TEST_F(StuffitShrinkwrapFixture, stuffit_shrinkwrap)
size_t destLen = SHRINKWRAP_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(SHRINKWRAP_ORIGSIZE);
auto err = AARU_stuffit_shrinkwrap_decode_buffer(outBuf, &destLen, buf, SHRINKWRAP_SIZE);
auto err = AARU_stuffit_shrinkwrap_decode_buffer(buf, SHRINKWRAP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)SHRINKWRAP_ORIGSIZE);

View File

@@ -67,7 +67,7 @@ TEST_F(xzFixture, xz)
auto *outBuf = (uint8_t *)malloc(1048576);
size_t decoded = 1048576;
auto res = AARU_xz_decode_buffer(outBuf, &decoded, buffer, 1048696);
auto res = AARU_xz_decode_buffer(buffer, 1048696, outBuf, &decoded);
EXPECT_EQ(res, 0);
EXPECT_EQ(decoded, 1048576);
@@ -82,8 +82,8 @@ TEST_F(xzFixture, xz)
TEST_F(xzFixture, xzCompress)
{
size_t original_len = 8388608;
uint cmp_len = original_len;
uint decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -111,14 +111,14 @@ TEST_F(xzFixture, xzCompress)
// Compress
newSize = cmp_len;
int32_t res = AARU_xz_encode_buffer(cmp_buffer, &newSize, original, original_len, 9, 10);
int32_t res = AARU_xz_encode_buffer(original, original_len, cmp_buffer, &newSize, 9, 10);
cmp_len = newSize;
EXPECT_EQ(res, 0);
// Decompress
newSize = decmp_len;
res = AARU_xz_decode_buffer(decmp_buffer, &newSize, cmp_buffer, cmp_len);
res = AARU_xz_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize);
decmp_len = newSize;
EXPECT_EQ(res, 0);

View File

@@ -59,7 +59,7 @@ TEST_F(ZipShrinkFixture, ZipShrink)
size_t destLen = EXPECTED_OUTPUT_SIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_OUTPUT_SIZE);
auto err = AARU_zip_shrink_decode_buffer(outBuf, &destLen, shrink_buffer, SHRINK_COMPRESSED_SIZE);
auto err = AARU_zip_shrink_decode_buffer(shrink_buffer, SHRINK_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, EXPECTED_OUTPUT_SIZE);
@@ -100,7 +100,7 @@ TEST_F(ZipImplodeFixture, ZipImplode)
auto *outBuf = (uint8_t *)malloc(EXPECTED_OUTPUT_SIZE);
/* large_dictionary=1 (8K), has_literals=1 (3 trees) from flags 0x0006 */
auto err = AARU_zip_implode_decode_buffer(outBuf, &destLen, implode_buffer, IMPLODE_COMPRESSED_SIZE, 1, 1);
auto err = AARU_zip_implode_decode_buffer(implode_buffer, IMPLODE_COMPRESSED_SIZE, outBuf, &destLen, 1, 1);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, EXPECTED_OUTPUT_SIZE);
@@ -140,7 +140,7 @@ TEST_F(ZipDeflate64Fixture, ZipDeflate64)
size_t destLen = EXPECTED_OUTPUT_SIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_OUTPUT_SIZE);
auto err = AARU_zip_deflate64_decode_buffer(outBuf, &destLen, deflate64_buffer, DEFLATE64_COMPRESSED_SIZE);
auto err = AARU_zip_deflate64_decode_buffer(deflate64_buffer, DEFLATE64_COMPRESSED_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, EXPECTED_OUTPUT_SIZE);
@@ -181,8 +181,9 @@ TEST_F(ZipPPMdFixture, ZipPPMd)
auto *outBuf = (uint8_t *)malloc(EXPECTED_OUTPUT_SIZE);
/* maxorder=8, suballocsize=4194304 (4MB), restoration=0 (restart) */
auto err = AARU_zip_ppmd_decode_buffer(outBuf, EXPECTED_OUTPUT_SIZE, ppmd_buffer, PPMD_COMPRESSED_SIZE, 8,
4194304, 0);
size_t destLen = EXPECTED_OUTPUT_SIZE;
auto err = AARU_zip_ppmd_decode_buffer(ppmd_buffer, PPMD_COMPRESSED_SIZE, outBuf, &destLen, 8, 4194304, 0);
EXPECT_EQ(err, 0);

View File

@@ -66,8 +66,9 @@ TEST_F(zstdFixture, zstd)
{
auto *outBuf = (uint8_t *)malloc(1048576);
auto decoded = AARU_zstd_decode_buffer(outBuf, 1048576, buffer, 1048613);
size_t decoded = 1048576;
EXPECT_EQ(AARU_zstd_decode_buffer(buffer, 1048613, outBuf, &decoded), 0);
EXPECT_EQ(decoded, 1048576);
auto crc = crc32_data(outBuf, 1048576);
@@ -80,8 +81,8 @@ TEST_F(zstdFixture, zstd)
TEST_F(zstdFixture, zstdCompress)
{
size_t original_len = 8388608;
uint cmp_len = original_len;
uint decmp_len = original_len;
size_t cmp_len = original_len;
size_t decmp_len = original_len;
char path[PATH_MAX];
char filename[PATH_MAX * 2];
FILE *file;
@@ -108,11 +109,13 @@ TEST_F(zstdFixture, zstdCompress)
original_crc = crc32_data(original, original_len);
// Compress
newSize = AARU_zstd_encode_buffer(cmp_buffer, cmp_len, original, original_len, 22);
newSize = cmp_len;
EXPECT_EQ(AARU_zstd_encode_buffer(original, original_len, cmp_buffer, &newSize, 22), 0);
cmp_len = newSize;
// Decompress
newSize = AARU_zstd_decode_buffer(decmp_buffer, decmp_len, cmp_buffer, cmp_len);
newSize = decmp_len;
EXPECT_EQ(AARU_zstd_decode_buffer(cmp_buffer, cmp_len, decmp_buffer, &newSize), 0);
decmp_len = newSize;
EXPECT_EQ(decmp_len, original_len);