ReactOS 0.4.15-dev-8119-g4fb2fdb
huf.h File Reference
#include <stddef.h>
Include dependency graph for huf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define HUF_H_298734234
#define HUF_BLOCKSIZE_MAX   (128 * 1024)
#define HUF_WORKSPACE_SIZE   ((6 << 10) + 256)


HUF_PUBLIC_API size_t HUF_compress (void *dst, size_t dstCapacity, const void *src, size_t srcSize)
HUF_PUBLIC_API size_t HUF_decompress (void *dst, size_t originalSize, const void *cSrc, size_t cSrcSize)
HUF_PUBLIC_API size_t HUF_compressBound (size_t size)
HUF_PUBLIC_API unsigned HUF_isError (size_t code)
HUF_PUBLIC_API const charHUF_getErrorName (size_t code)
HUF_PUBLIC_API size_t HUF_compress2 (void *dst, size_t dstCapacity, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog)
HUF_PUBLIC_API size_t HUF_compress4X_wksp (void *dst, size_t dstCapacity, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize)

Macro Definition Documentation


#define HUF_BLOCKSIZE_MAX   (128 * 1024)

maximum input size for a single block compressed with HUF_compress

Definition at line 72 of file huf.h.

◆ HUF_H_298734234

#define HUF_H_298734234

Definition at line 20 of file huf.h.



Definition at line 37 of file huf.h.


#define HUF_WORKSPACE_SIZE   ((6 << 10) + 256)

HUF_compress4X_wksp() : Same as HUF_compress2(), but uses externally allocated workSpace. workspace must have minimum alignment of 4, and be at least as large as HUF_WORKSPACE_SIZE

Definition at line 93 of file huf.h.



Definition at line 94 of file huf.h.

Function Documentation

◆ HUF_compress()

HUF_PUBLIC_API size_t HUF_compress ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize 

HUF_compress() : Compress content from buffer 'src', of size 'srcSize', into buffer 'dst'. 'dst' buffer must be already allocated. Compression runs faster if dstCapacity >= HUF_compressBound(srcSize). srcSize must be <= HUF_BLOCKSIZE_MAX == 128 KB.

: size of compressed data (<= dstCapacity). Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!! if HUF_isError(return), compression failed (more details using HUF_getErrorName())

Definition at line 795 of file huf_compress.c.

797 return HUF_compress2(dst, maxDstSize, src, srcSize, 255, HUF_TABLELOG_DEFAULT);
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
size_t HUF_compress2(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog)
Definition: huf_compress.c:787

◆ HUF_compress2()

HUF_PUBLIC_API size_t HUF_compress2 ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
unsigned  maxSymbolValue,
unsigned  tableLog 

HUF_compress2() : Same as HUF_compress(), but offers control over maxSymbolValue and tableLog. maxSymbolValue must be <= HUF_SYMBOLVALUE_MAX . tableLog must be <= HUF_TABLELOG_MAX .

Definition at line 787 of file huf_compress.c.

791 unsigned workSpace[HUF_WORKSPACE_SIZE_U32];
792 return HUF_compress4X_wksp(dst, dstSize, src, srcSize, maxSymbolValue, huffLog, workSpace, sizeof(workSpace));
Definition: huf.h:94
size_t HUF_compress4X_wksp(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, void *workSpace, size_t wkspSize)
Definition: huf_compress.c:761

Referenced by HUF_compress().

◆ HUF_compress4X_wksp()

HUF_PUBLIC_API size_t HUF_compress4X_wksp ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
unsigned  maxSymbolValue,
unsigned  tableLog,
void workSpace,
size_t  wkspSize 

Definition at line 761 of file huf_compress.c.

766 return HUF_compress_internal(dst, dstSize, src, srcSize,
767 maxSymbolValue, huffLog, HUF_fourStreams,
768 workSpace, wkspSize,
769 NULL, NULL, 0, 0 /*bmi2*/);
#define NULL
Definition: types.h:112
@ HUF_fourStreams
Definition: huf_compress.c:610
static size_t HUF_compress_internal(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, HUF_nbStreams_e nbStreams, void *workSpace, size_t wkspSize, HUF_CElt *oldHufTable, HUF_repeat *repeat, int preferRepeat, const int bmi2)
Definition: huf_compress.c:638

Referenced by HUF_compress2().

◆ HUF_compressBound()

HUF_PUBLIC_API size_t HUF_compressBound ( size_t  size)

maximum compressed size (worst case)

Definition at line 441 of file huf_compress.c.

441{ return HUF_COMPRESSBOUND(size); }
GLsizeiptr size
Definition: glext.h:5919

◆ HUF_decompress()

HUF_PUBLIC_API size_t HUF_decompress ( void dst,
size_t  originalSize,
const void cSrc,
size_t  cSrcSize 

HUF_decompress() : Decompress HUF data from buffer 'cSrc', of size 'cSrcSize', into already allocated buffer 'dst', of minimum size 'dstSize'. originalSize : must be the exact size of original (uncompressed) data. Note : in contrast with FSE, HUF_decompress can regenerate RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data, because it knows size to regenerate (originalSize).

: size of regenerated data (== originalSize), or an error code, which can be tested using HUF_isError()

Definition at line 1056 of file huf_decompress.c.

1058#if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
1059 static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
1062 /* validation checks */
1063 if (dstSize == 0) return ERROR(dstSize_tooSmall);
1064 if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1065 if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1066 if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1068 { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1069#if defined(HUF_FORCE_DECOMPRESS_X1)
1070 (void)algoNb;
1071 assert(algoNb == 0);
1072 return HUF_decompress4X1(dst, dstSize, cSrc, cSrcSize);
1073#elif defined(HUF_FORCE_DECOMPRESS_X2)
1074 (void)algoNb;
1075 assert(algoNb == 1);
1076 return HUF_decompress4X2(dst, dstSize, cSrc, cSrcSize);
1078 return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
1080 }
#define assert(x)
Definition: debug.h:53
#define ERROR(name)
Definition: error_private.h:53
U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
size_t HUF_decompress4X2(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress4X1(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t(* decompressionAlgo)(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memset(x, y, z)
Definition: compat.h:39
unsigned char BYTE
Definition: xxhash.c:193
unsigned int U32
Definition: xxhash.c:195

◆ HUF_getErrorName()

HUF_PUBLIC_API const char * HUF_getErrorName ( size_t  code)

provides error code string (useful for debugging)

Definition at line 35 of file entropy_common.c.

35{ return ERR_getErrorName(code); }
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:71
Definition: inflate.c:139

◆ HUF_isError()

HUF_PUBLIC_API unsigned HUF_isError ( size_t  code)

tells if a return value is an error code

Definition at line 34 of file entropy_common.c.

34{ return ERR_isError(code); }
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:56