mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
General refactor and cleanup.
This commit is contained in:
@@ -4,11 +4,14 @@ This repository contains the Aaru.Compression.Native library for [Aaru](https://
|
|||||||
|
|
||||||
The purpose of this library is to provide compression and de-compression algorithms for Aaru.
|
The purpose of this library is to provide compression and de-compression algorithms for Aaru.
|
||||||
|
|
||||||
No archiver processing code should fall here, those go in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
|
No archiver processing code should fall here, those go
|
||||||
|
in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
|
||||||
|
|
||||||
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with Aaru.Compression.
|
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with
|
||||||
|
Aaru.Compression.
|
||||||
|
|
||||||
Currently implemented algorithms are:
|
Currently implemented algorithms are:
|
||||||
|
|
||||||
- Apple Data Compression (RLE with sliding dictionary created for Apple Disk Copy's NDIF)
|
- Apple Data Compression (RLE with sliding dictionary created for Apple Disk Copy's NDIF)
|
||||||
- Apple RLE (Run Length Encoding created for Apple DART)
|
- Apple RLE (Run Length Encoding created for Apple DART)
|
||||||
- [BZIP2](https://gitlab.com/bzip2/bzip2.git)
|
- [BZIP2](https://gitlab.com/bzip2/bzip2.git)
|
||||||
|
|||||||
28
adc.c
28
adc.c
@@ -19,10 +19,14 @@ FORCE_INLINE int GetChunkSize(uint8_t byt)
|
|||||||
{
|
{
|
||||||
switch(GetChunkType(byt))
|
switch(GetChunkType(byt))
|
||||||
{
|
{
|
||||||
case ADC_PLAIN: return (byt & 0x7F) + 1;
|
case ADC_PLAIN:
|
||||||
case ADC_TWO_BYTE: return ((byt & 0x3F) >> 2) + 3;
|
return (byt & 0x7F) + 1;
|
||||||
case ADC_THREE_BYTE: return (byt & 0x3F) + 4;
|
case ADC_TWO_BYTE:
|
||||||
default: return -1;
|
return ((byt & 0x3F) >> 2) + 3;
|
||||||
|
case ADC_THREE_BYTE:
|
||||||
|
return (byt & 0x3F) + 4;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,16 +34,18 @@ FORCE_INLINE int GetOffset(uint8_t chunk[])
|
|||||||
{
|
{
|
||||||
switch(GetChunkType(chunk[0]))
|
switch(GetChunkType(chunk[0]))
|
||||||
{
|
{
|
||||||
case ADC_PLAIN: return 0;
|
case ADC_PLAIN:
|
||||||
case ADC_TWO_BYTE: return ((chunk[0] & 0x03) << 8) + chunk[1];
|
return 0;
|
||||||
case ADC_THREE_BYTE: return (chunk[1] << 8) + chunk[2];
|
case ADC_TWO_BYTE:
|
||||||
default: return -1;
|
return ((chunk[0] & 0x03) << 8) + chunk[1];
|
||||||
|
case ADC_THREE_BYTE:
|
||||||
|
return (chunk[1] << 8) + chunk[2];
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
|
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 dst_size,
|
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size)
|
int32_t src_size)
|
||||||
{
|
{
|
||||||
int inputPosition = 0;
|
int inputPosition = 0;
|
||||||
|
|||||||
@@ -24,10 +24,8 @@
|
|||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "apple_rle.h"
|
#include "apple_rle.h"
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
|
||||||
int32_t dst_size,
|
const uint8_t *src_buffer, int32_t src_size)
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size)
|
|
||||||
{
|
{
|
||||||
static int32_t count = 0;
|
static int32_t count = 0;
|
||||||
static bool nextA = true; // true if A, false if B
|
static bool nextA = true; // true if A, false if B
|
||||||
|
|||||||
74
flac.c
74
flac.c
@@ -12,19 +12,17 @@
|
|||||||
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
|
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
|
||||||
#include "flac.h"
|
#include "flac.h"
|
||||||
|
|
||||||
static FLAC__StreamDecoderReadStatus
|
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
|
size_t *bytes, void *client_data);
|
||||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
|
||||||
const FLAC__Frame* frame,
|
|
||||||
const FLAC__int32* const buffer[],
|
|
||||||
void* client_data);
|
|
||||||
static void
|
|
||||||
error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
||||||
size_t dst_size,
|
const FLAC__int32 const *buffer[], void *client_data);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
size_t src_size)
|
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status,
|
||||||
|
void *client_data);
|
||||||
|
|
||||||
|
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
||||||
|
const uint8_t *src_buffer, size_t src_size)
|
||||||
{
|
{
|
||||||
FLAC__StreamDecoder *decoder;
|
FLAC__StreamDecoder *decoder;
|
||||||
FLAC__StreamDecoderInitStatus init_status;
|
FLAC__StreamDecoderInitStatus init_status;
|
||||||
@@ -51,8 +49,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
|
|||||||
|
|
||||||
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
||||||
|
|
||||||
init_status = FLAC__stream_decoder_init_stream(
|
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL,
|
||||||
decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL, error_callback, ctx);
|
error_callback, ctx);
|
||||||
|
|
||||||
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||||
{
|
{
|
||||||
@@ -72,8 +70,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
|
|||||||
return ret_size;
|
return ret_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamDecoderReadStatus
|
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
|
size_t *bytes, void *client_data)
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
|
|
||||||
@@ -87,10 +85,8 @@ static FLAC__StreamDecoderReadStatus
|
|||||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
||||||
const FLAC__Frame* frame,
|
const FLAC__int32 const *buffer[], void *client_data)
|
||||||
const FLAC__int32* const buffer[],
|
|
||||||
void* client_data)
|
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -129,27 +125,14 @@ static void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecod
|
|||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||||
const FLAC__byte buffer[],
|
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
||||||
size_t bytes,
|
uint32_t current_frame, void *client_data);
|
||||||
uint32_t samples,
|
|
||||||
uint32_t current_frame,
|
|
||||||
void* client_data);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
|
||||||
size_t dst_size,
|
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
||||||
const uint8_t* src_buffer,
|
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
||||||
size_t src_size,
|
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
||||||
uint32_t blocksize,
|
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
||||||
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)
|
uint32_t application_id_len)
|
||||||
{
|
{
|
||||||
FLAC__StreamEncoder *encoder;
|
FLAC__StreamEncoder *encoder;
|
||||||
@@ -213,8 +196,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
|
|||||||
|
|
||||||
if(application_id_len > 0 && application_id != NULL)
|
if(application_id_len > 0 && application_id != NULL)
|
||||||
if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
|
if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
|
||||||
FLAC__metadata_object_application_set_data(
|
FLAC__metadata_object_application_set_data(metadata[0], (unsigned char *)application_id, application_id_len,
|
||||||
metadata[0], (unsigned char*)application_id, application_id_len, true);
|
true);
|
||||||
|
|
||||||
FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
|
FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
|
||||||
|
|
||||||
@@ -246,11 +229,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
|
|||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||||
const FLAC__byte buffer[],
|
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
||||||
size_t bytes,
|
uint32_t current_frame, void *client_data)
|
||||||
uint32_t samples,
|
|
||||||
uint32_t current_frame,
|
|
||||||
void* client_data)
|
|
||||||
{
|
{
|
||||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||||
|
|
||||||
|
|||||||
67
library.c
67
library.c
@@ -25,81 +25,54 @@
|
|||||||
#include "3rdparty/lzma/C/LzmaLib.h"
|
#include "3rdparty/lzma/C/LzmaLib.h"
|
||||||
#include "3rdparty/zstd/lib/zstd.h"
|
#include "3rdparty/zstd/lib/zstd.h"
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||||
uint32_t* dst_size,
|
const uint8_t *src_buffer, uint32_t src_size)
|
||||||
const uint8_t* src_buffer,
|
|
||||||
uint32_t src_size)
|
|
||||||
{
|
{
|
||||||
return BZ2_bzBuffToBuffDecompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, 0, 0);
|
return BZ2_bzBuffToBuffDecompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||||
uint32_t* dst_size,
|
const uint8_t *src_buffer, uint32_t src_size,
|
||||||
const uint8_t* src_buffer,
|
|
||||||
uint32_t src_size,
|
|
||||||
int32_t blockSize100k)
|
int32_t blockSize100k)
|
||||||
{
|
{
|
||||||
return BZ2_bzBuffToBuffCompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, blockSize100k, 0, 0);
|
return BZ2_bzBuffToBuffCompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, blockSize100k, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
|
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 dst_size,
|
size_t src_size, void *scratch_buffer)
|
||||||
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);
|
return lzfse_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
|
||||||
}
|
}
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
|
|
||||||
size_t dst_size,
|
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||||
const uint8_t* src_buffer,
|
size_t src_size, void *scratch_buffer)
|
||||||
size_t src_size,
|
|
||||||
void* scratch_buffer)
|
|
||||||
{
|
{
|
||||||
return lzfse_encode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
|
return lzfse_encode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
|
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* dst_size,
|
size_t *srcLen, const uint8_t *props, size_t propsSize)
|
||||||
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);
|
return LzmaUncompress(dst_buffer, dst_size, src_buffer, srcLen, props, propsSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
|
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* dst_size,
|
size_t srcLen, uint8_t *outProps, size_t *outPropsSize,
|
||||||
const uint8_t* src_buffer,
|
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||||
size_t srcLen,
|
int32_t pb, int32_t fb, int32_t numThreads)
|
||||||
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(
|
return LzmaCompress(dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb,
|
||||||
dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads);
|
fb, numThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||||
size_t dst_size,
|
|
||||||
const void* src_buffer,
|
|
||||||
size_t src_size)
|
size_t src_size)
|
||||||
{
|
{
|
||||||
return ZSTD_decompress(dst_buffer, dst_size, src_buffer, 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,
|
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||||
size_t dst_size,
|
size_t src_size, int32_t compressionLevel)
|
||||||
const void* src_buffer,
|
|
||||||
size_t src_size,
|
|
||||||
int32_t compressionLevel)
|
|
||||||
{
|
{
|
||||||
return ZSTD_compress(dst_buffer, dst_size, src_buffer, src_size, compressionLevel);
|
return ZSTD_compress(dst_buffer, dst_size, src_buffer, src_size, compressionLevel);
|
||||||
}
|
}
|
||||||
|
|||||||
109
library.h
109
library.h
@@ -54,104 +54,55 @@
|
|||||||
#define FORCE_INLINE static inline __attribute__((always_inline))
|
#define FORCE_INLINE static inline __attribute__((always_inline))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||||
int32_t dst_size,
|
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size);
|
int32_t src_size);
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
|
||||||
int32_t dst_size,
|
const uint8_t *src_buffer, int32_t src_size);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
||||||
size_t dst_size,
|
const uint8_t *src_buffer, size_t src_size);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
size_t src_size);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
|
||||||
size_t dst_size,
|
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
||||||
const uint8_t* src_buffer,
|
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
||||||
size_t src_size,
|
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
||||||
uint32_t blocksize,
|
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
||||||
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);
|
uint32_t application_id_len);
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||||
int32_t dst_size,
|
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size);
|
int32_t src_size);
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
|
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 dst_size,
|
int32_t src_size, int32_t dictionary_size,
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size,
|
|
||||||
int32_t dictionary_size,
|
|
||||||
int32_t match_len_limit);
|
int32_t match_len_limit);
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||||
uint32_t* dst_size,
|
const uint8_t *src_buffer, uint32_t src_size);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
uint32_t src_size);
|
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||||
uint32_t* dst_size,
|
const uint8_t *src_buffer, uint32_t src_size,
|
||||||
const uint8_t* src_buffer,
|
|
||||||
uint32_t src_size,
|
|
||||||
int32_t blockSize100k);
|
int32_t blockSize100k);
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||||
size_t dst_size,
|
size_t src_size, void *scratch_buffer);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
size_t src_size,
|
|
||||||
void* scratch_buffer);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
|
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 dst_size,
|
size_t src_size, void *scratch_buffer);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
size_t src_size,
|
|
||||||
void* scratch_buffer);
|
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
|
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* dst_size,
|
size_t *src_size, const uint8_t *props, size_t propsSize);
|
||||||
const uint8_t* src_buffer,
|
|
||||||
size_t* src_size,
|
|
||||||
const uint8_t* props,
|
|
||||||
size_t propsSize);
|
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
|
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* dst_size,
|
size_t src_size, uint8_t *outProps, size_t *outPropsSize,
|
||||||
const uint8_t* src_buffer,
|
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||||
size_t src_size,
|
int32_t pb, int32_t fb, int32_t numThreads);
|
||||||
uint8_t* outProps,
|
|
||||||
size_t* outPropsSize,
|
|
||||||
int32_t level,
|
|
||||||
uint32_t dictSize,
|
|
||||||
int32_t lc,
|
|
||||||
int32_t lp,
|
|
||||||
int32_t pb,
|
|
||||||
int32_t fb,
|
|
||||||
int32_t numThreads);
|
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||||
size_t dst_size,
|
|
||||||
const void* src_buffer,
|
|
||||||
size_t src_size);
|
size_t src_size);
|
||||||
|
|
||||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void* dst_buffer,
|
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||||
size_t dst_size,
|
size_t src_size, int32_t compressionLevel);
|
||||||
const void* src_buffer,
|
|
||||||
size_t src_size,
|
|
||||||
int32_t compressionLevel);
|
|
||||||
|
|
||||||
#define AARU_CHECKUMS_NATIVE_VERSION 0x06000089
|
#define AARU_CHECKUMS_NATIVE_VERSION 0x06000089
|
||||||
|
|
||||||
|
|||||||
11
lzip.c
11
lzip.c
@@ -23,9 +23,7 @@
|
|||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "3rdparty/lzlib/lzlib.h"
|
#include "3rdparty/lzlib/lzlib.h"
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||||
int32_t dst_size,
|
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size)
|
int32_t src_size)
|
||||||
{
|
{
|
||||||
int max_in_size;
|
int max_in_size;
|
||||||
@@ -83,11 +81,8 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
|||||||
return out_pos;
|
return out_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
|
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 dst_size,
|
int32_t src_size, int32_t dictionary_size,
|
||||||
const uint8_t* src_buffer,
|
|
||||||
int32_t src_size,
|
|
||||||
int32_t dictionary_size,
|
|
||||||
int32_t match_len_limit)
|
int32_t match_len_limit)
|
||||||
{
|
{
|
||||||
int max_in_size;
|
int max_in_size;
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "../adc.h"
|
|
||||||
#include "../library.h"
|
#include "../library.h"
|
||||||
|
#include "../adc.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "../apple_rle.h"
|
|
||||||
#include "../library.h"
|
#include "../library.h"
|
||||||
|
#include "../apple_rle.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define CRC32_ISO_POLY 0xEDB88320
|
#define CRC32_ISO_POLY 0xEDB88320
|
||||||
@@ -43,13 +44,13 @@ uint32_t crc32_data(const uint8_t *data, uint32_t len)
|
|||||||
localTable[i] = entry;
|
localTable[i] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++) localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
||||||
localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
|
||||||
|
|
||||||
localHashInt ^= CRC32_ISO_SEED;
|
localHashInt ^= CRC32_ISO_SEED;
|
||||||
|
|
||||||
return localHashInt;
|
return localHashInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -24,6 +24,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t crc32_data(const uint8_t *data, uint32_t len);
|
uint32_t crc32_data(const uint8_t *data, uint32_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "../flac.h"
|
|
||||||
#include "../library.h"
|
#include "../library.h"
|
||||||
|
#include "../flac.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
@@ -109,22 +109,9 @@ TEST_F(flacFixture, flacCompress)
|
|||||||
original_crc = crc32_data(original, original_len);
|
original_crc = crc32_data(original, original_len);
|
||||||
|
|
||||||
// Compress
|
// Compress
|
||||||
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer,
|
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer, cmp_len, original, original_len, 4608, 1, 0,
|
||||||
cmp_len,
|
"partial_tukey(0/1.0/1.0)", 12, 0, 1, false, 0, 8,
|
||||||
original,
|
"Aaru.Compression.Native.Tests", strlen("Aaru.Compression.Native.Tests"));
|
||||||
original_len,
|
|
||||||
4608,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
"partial_tukey(0/1.0/1.0)",
|
|
||||||
12,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
8,
|
|
||||||
"Aaru.Compression.Native.Tests",
|
|
||||||
strlen("Aaru.Compression.Native.Tests"));
|
|
||||||
cmp_len = newSize;
|
cmp_len = newSize;
|
||||||
|
|
||||||
// Decompress
|
// Decompress
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ TEST_F(lzmaFixture, lzmaCompress)
|
|||||||
original_crc = crc32_data(original, original_len);
|
original_crc = crc32_data(original, original_len);
|
||||||
|
|
||||||
// Compress
|
// Compress
|
||||||
err = AARU_lzma_encode_buffer(
|
err = AARU_lzma_encode_buffer(cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2,
|
||||||
cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2, 273, 2);
|
273, 2);
|
||||||
EXPECT_EQ(err, 0);
|
EXPECT_EQ(err, 0);
|
||||||
|
|
||||||
// Decompress
|
// Decompress
|
||||||
|
|||||||
Reference in New Issue
Block a user