Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
zstd_decompress.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "zstd_decompress.h"

Data Structures

struct  ostream_t
 
struct  istream_t
 
struct  HUF_dtable
 Structure containing all tables necessary for efficient Huffman decoding. More...
 
struct  FSE_dtable
 The tables needed to decode FSE encoded streams. More...
 
struct  frame_header_t
 
struct  frame_context_t
 The context needed to decode blocks in a frame. More...
 
struct  dictionary_s
 
struct  sequence_command_t
 
struct  sequence_states_t
 The combination of FSE states needed to decode sequences. More...
 

Macros

#define ZSTD_MAGIC_NUMBER   0xFD2FB528U
 
#define ZSTD_BLOCK_SIZE_MAX   ((size_t)128 * 1024)
 
#define MAX_LITERALS_SIZE   ZSTD_BLOCK_SIZE_MAX
 
#define MAX(a, b)
 
#define MIN(a, b)
 
#define MESSAGE(...)
 
#define ERROR(s)
 
#define INP_SIZE()
 
#define OUT_SIZE()
 
#define CORRUPTION()
 
#define BAD_ALLOC()
 
#define IMPOSSIBLE()
 
#define HUF_MAX_BITS   (16)
 
#define HUF_MAX_SYMBS   (256)
 
#define FSE_MAX_ACCURACY_LOG   (15)
 
#define FSE_MAX_SYMBS   (256)
 
#define DICT_SIZE_ERROR()
 
#define NULL_SRC()
 

Enumerations

enum  seq_part_t { seq_literal_length = 0 , seq_offset = 1 , seq_match_length = 2 }
 Different modes to signal to decode_seq_tables what to do. More...
 
enum  seq_mode_t { seq_predefined = 0 , seq_rle = 1 , seq_fse = 2 , seq_repeat = 3 }
 

Functions

size_t ZSTD_decompress (void *const dst, const size_t dst_len, const void *const src, const size_t src_len)
 
size_t ZSTD_decompress_with_dict (void *const dst, const size_t dst_len, const void *const src, const size_t src_len, dictionary_t *parsed_dict)
 
size_t ZSTD_get_decompressed_size (const void *src, const size_t src_len)
 
dictionary_tcreate_dictionary (void)
 
void free_dictionary (dictionary_t *const dict)
 Free an allocated dictionary.
 
void parse_dictionary (dictionary_t *const dict, const void *src, size_t src_len)
 

Macro Definition Documentation

◆ BAD_ALLOC

#define BAD_ALLOC ( )
Value:
ERROR("Memory allocation error")
#define ERROR(s)
Definition zstd_decompress.c:47

◆ CORRUPTION

#define CORRUPTION ( )
Value:
ERROR("Corruption detected while decompressing")

◆ DICT_SIZE_ERROR

#define DICT_SIZE_ERROR ( )
Value:
ERROR("Dictionary size cannot be less than 8 bytes")

◆ ERROR

#define ERROR ( s)
Value:
do { \
MESSAGE("Error: %s\n", s); \
exit(1); \
} while (0)

This decoder calls exit(1) when it encounters an error, however a production library should propagate error codes

◆ FSE_MAX_ACCURACY_LOG

#define FSE_MAX_ACCURACY_LOG   (15)

For more description of FSE see https://github.com/Cyan4973/FiniteStateEntropy/

◆ FSE_MAX_SYMBS

#define FSE_MAX_SYMBS   (256)

◆ HUF_MAX_BITS

#define HUF_MAX_BITS   (16)

◆ HUF_MAX_SYMBS

#define HUF_MAX_SYMBS   (256)

◆ IMPOSSIBLE

#define IMPOSSIBLE ( )
Value:
ERROR("An impossibility has occurred")

◆ INP_SIZE

#define INP_SIZE ( )
Value:
ERROR("Input buffer smaller than it should be or input is " \
"corrupted")

◆ MAX

#define MAX ( a,
b )
Value:
((a) > (b) ? (a) : (b))
#define b(i)
Definition sha256.c:42
#define a(i)
Definition sha256.c:41

◆ MAX_LITERALS_SIZE

#define MAX_LITERALS_SIZE   ZSTD_BLOCK_SIZE_MAX

◆ MESSAGE

#define MESSAGE ( ...)
Value:
fprintf(stderr, "" __VA_ARGS__)

◆ MIN

#define MIN ( a,
b )
Value:
((a) < (b) ? (a) : (b))

◆ NULL_SRC

#define NULL_SRC ( )
Value:
ERROR("Tried to create dictionary with pointer to null src");

◆ OUT_SIZE

#define OUT_SIZE ( )
Value:
ERROR("Output buffer too small for output")

◆ ZSTD_BLOCK_SIZE_MAX

#define ZSTD_BLOCK_SIZE_MAX   ((size_t)128 * 1024)

◆ ZSTD_MAGIC_NUMBER

#define ZSTD_MAGIC_NUMBER   0xFD2FB528U

Zstandard educational decoder implementation See https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md

Enumeration Type Documentation

◆ seq_mode_t

enum seq_mode_t
Enumerator
seq_predefined 
seq_rle 
seq_fse 
seq_repeat 

◆ seq_part_t

enum seq_part_t

Different modes to signal to decode_seq_tables what to do.

Enumerator
seq_literal_length 
seq_offset 
seq_match_length 

Function Documentation

◆ create_dictionary()

dictionary_t * create_dictionary ( void )

◆ free_dictionary()

void free_dictionary ( dictionary_t *const dict)

Free an allocated dictionary.

◆ parse_dictionary()

void parse_dictionary ( dictionary_t *const dict,
const void * src,
size_t src_len )

◆ ZSTD_decompress()

size_t ZSTD_decompress ( void *const dst,
const size_t dst_len,
const void *const src,
const size_t src_len )

Zstandard decompression functions. dst must point to a space at least as large as the reconstructed output.

For the case where the decompression library hasn't been included we add a dummy function to fake the process and stop the buffers being optimised out.

◆ ZSTD_decompress_with_dict()

size_t ZSTD_decompress_with_dict ( void *const dst,
const size_t dst_len,
const void *const src,
const size_t src_len,
dictionary_t * parsed_dict )

If dict != NULL and dict_len >= 8, does the same thing as ZSTD_decompress but uses the provided dict

◆ ZSTD_get_decompressed_size()

size_t ZSTD_get_decompressed_size ( const void * src,
const size_t src_len )

Get the decompressed size of an input stream so memory can be allocated in advance. This implementation assumes src points to a single ZSTD-compressed frame