Go to the documentation of this file.
45 #define DEBUG(...) fprintf(stderr, __VA_ARGS__)
53 #define LZ4_VERSION (LZ4_VERSION_MAJOR * 100 * 100 + LZ4_VERSION_MINOR * 100 + LZ4_VERSION_RELEASE)
54 #if LZ4_VERSION >= 10701
55 #define LZ4_COMPRESS_DEFAULT LZ4_compress_default
57 #define LZ4_COMPRESS_DEFAULT LZ4_compress_limitedOutput
72 return ((buffer[0] << 0) | (buffer[1] << 8) |
73 (buffer[2] << 16) | (buffer[3] << 24));
77 buffer[0] = val & 0xFF;
78 buffer[1] = (val >> 8) & 0xFF;
79 buffer[2] = (val >> 16) & 0xFF;
80 buffer[3] = (val >> 24) & 0xFF;
84 int min(
int a,
int b) {
129 char *dest = (
char*) dest_val;
131 memcpy(dest + *offset, str->
input_next, to_copy);
145 *(out+4) = ((
unsigned)version &
k2Bits) << 6;
156 DEBUG(
"writeHeader() Put 7 bytes in output\n");
188 DEBUG(
"bufferToOutput() Not enough space left in output\n");
192 DEBUG(
"bufferToOutput() Flushing %i bytes, %i left in output\n",
199 (
int) uncomp_size - 1);
202 DEBUG(
"bufferToOutput() Compressed to %i bytes\n", comp_size);
204 wrote = 4 + comp_size;
208 DEBUG(
"bufferToOutput() Can't compress, copying input\n");
212 wrote = 4 + uncomp_size;
219 DEBUG(
"bufferToOutput() Ate %i from buffer, wrote %i to output (%i)\n",
242 DEBUG(
"inputToBuffer() Wrote % 5i bytes to buffer (size=% 5i)\n",
263 if (state->
buffer != NULL) {
291 if (!(4 <= block_size_id && block_size_id <= 7)) {
299 if (state->
buffer == NULL) {
308 if (state->
buffer != NULL) {
320 return (1 << (8 + (2 * block_id)));
325 if (ret < 0) {
return ret; }
340 if (ret < 0) {
return ret; }
345 int read = 0, wrote = 0;
348 if (read < 0) {
return read; }
353 if (wrote < 0) {
return wrote; }
355 }
while (read > 0 || wrote > 0);
392 unsigned char *header = (
unsigned char*) state->
header;
398 int version = (header[4] >> 6) &
k2Bits;
399 int block_independence_flag = (header[4] >> 5) &
k1Bits;
400 int block_checksum_flag = (header[4] >> 4) &
k1Bits;
401 int stream_size_flag = (header[4] >> 3) &
k1Bits;
402 int stream_checksum_flag = (header[4] >> 2) &
k1Bits;
403 int reserved1 = (header[4] >> 1) &
k1Bits;
404 int preset_dictionary_flag = (header[4] >> 0) &
k1Bits;
406 int reserved2 = (header[5] >> 7) &
k1Bits;
407 int block_max_id = (header[5] >> 4) &
k3Bits;
408 int reserved3 = (header[5] >> 0) &
k4Bits;
414 if (reserved1 != 0 || reserved2 != 0 || reserved3 != 0) {
417 if (!(4 <= block_max_id && block_max_id <= 7)) {
422 if (stream_size_flag != 0) {
425 if (preset_dictionary_flag != 0) {
428 if (block_independence_flag != 1) {
431 if (block_checksum_flag != 0) {
434 if (stream_checksum_flag != 1) {
438 int header_checksum = (
XXH32(header + 4, 2, 0) >> 8) &
k8Bits;
439 int stored_header_checksum = (header[6] >> 0) &
k8Bits;
440 if (header_checksum != stored_header_checksum) {
461 DEBUG(
"readBlockSize() Block size = %i uncompressed = %i\n",
484 DEBUG(
"readBlock() Read %i bytes from input (block = %i/%i)\n",
513 if (decomp_size < 0) {
571 else if (ret < 0) {
return ret; }
574 if (ret < 0) {
return ret; }
586 char *output,
unsigned int *output_size,
620 char *output,
unsigned int *output_size) {
void * XXH32_init(U32 seed)
uint32_t readUInt32(unsigned char *buffer)
U32 XXH32_digest(void *state_in)
int roslz4_decompress(roslz4_stream *str)
void fillUInt32(roslz4_stream *str, uint32_t *dest_val, int *offset)
int roslz4_buffToBuffDecompress(char *input, unsigned int input_size, char *output, unsigned int *output_size)
int readBlockSize(roslz4_stream *str)
#define LZ4_COMPRESS_DEFAULT
void writeUInt32(unsigned char *buffer, uint32_t val)
int bufferToOutput(roslz4_stream *str)
const int ROSLZ4_MEMORY_ERROR
const int ROSLZ4_PARAM_ERROR
const uint32_t kMagicNumber
int readBlock(roslz4_stream *str)
int roslz4_decompressStart(roslz4_stream *str)
void advanceOutput(roslz4_stream *str, int nbytes)
const int ROSLZ4_OUTPUT_SMALL
const int ROSLZ4_DATA_ERROR
int streamResizeBuffer(roslz4_stream *str, int block_size_id)
XXH_errorcode XXH32_update(void *state_in, const void *input, int len)
int inputToBuffer(roslz4_stream *str)
const int ROSLZ4_STREAM_END
void roslz4_decompressEnd(roslz4_stream *str)
U32 XXH32(const void *input, int len, U32 seed)
int roslz4_compressStart(roslz4_stream *str, int block_size_id)
int roslz4_blockSizeFromIndex(int block_id)
void roslz4_compressEnd(roslz4_stream *str)
int roslz4_buffToBuffCompress(char *input, unsigned int input_size, char *output, unsigned int *output_size, int block_size_id)
int block_independence_flag
int streamStateAlloc(roslz4_stream *str)
int roslz4_compress(roslz4_stream *str, int action)
int processHeader(roslz4_stream *str)
int writeEOS(roslz4_stream *str)
void streamStateFree(roslz4_stream *str)
const uint32_t kEndOfStream
void advanceInput(roslz4_stream *str, int nbytes)
int readChecksum(roslz4_stream *str)
int decompressBlock(roslz4_stream *str)
int writeHeader(roslz4_stream *str)
roslz4
Author(s): Ben Charrow
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:30