15#if defined (__cplusplus)
19#ifndef HUF_H_298734234
20#define HUF_H_298734234
25#define FSE_STATIC_LINKING_ONLY
30#define HUF_BLOCKSIZE_MAX (128 * 1024)
38#define HUF_WORKSPACE_SIZE ((8 << 10) + 512 )
39#define HUF_WORKSPACE_SIZE_U64 (HUF_WORKSPACE_SIZE / sizeof(U64))
42#define HUF_TABLELOG_MAX 12
43#define HUF_TABLELOG_DEFAULT 11
44#define HUF_SYMBOLVALUE_MAX 255
46#define HUF_TABLELOG_ABSOLUTEMAX 12
47#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
48# error "HUF_TABLELOG_MAX is too large !"
56#define HUF_CTABLEBOUND 129
57#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8)
58#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size))
63#define HUF_CTABLE_SIZE_ST(maxSymbolValue) ((maxSymbolValue)+2)
64#define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_ST(maxSymbolValue) * sizeof(size_t))
65#define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \
66 HUF_CElt name[HUF_CTABLE_SIZE_ST(maxSymbolValue)]
70#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog)))
71#define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \
72 HUF_DTable DTable[HUF_DTABLE_SIZE((maxTableLog)-1)] = { ((U32)((maxTableLog)-1) * 0x01000001) }
73#define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \
74 HUF_DTable DTable[HUF_DTABLE_SIZE(maxTableLog)] = { ((U32)(maxTableLog) * 0x01000001) }
122#define HUF_OPTIMAL_DEPTH_THRESHOLD ZSTD_btultra
136unsigned HUF_cardinality(
const unsigned* count,
unsigned maxSymbolValue);
137unsigned HUF_optimalTableLog(
unsigned maxTableLog,
size_t srcSize,
unsigned maxSymbolValue,
void* workSpace,
138 size_t wkspSize,
HUF_CElt*
table,
const unsigned* count,
int flags);
139size_t HUF_writeCTable_wksp(
void* dst,
size_t maxDstSize,
const HUF_CElt* CTable,
unsigned maxSymbolValue,
unsigned huffLog,
void* workspace,
size_t workspaceSize);
157 const void* src,
size_t srcSize,
158 unsigned maxSymbolValue,
unsigned tableLog,
159 void* workSpace,
size_t wkspSize,
166#define HUF_CTABLE_WORKSPACE_SIZE_U32 ((4 * (HUF_SYMBOLVALUE_MAX + 1)) + 192)
167#define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned))
169 const unsigned* count,
U32 maxSymbolValue,
U32 maxNbBits,
170 void* workSpace,
size_t wkspSize);
178 U32* rankStats,
U32* nbSymbolsPtr,
U32* tableLogPtr,
179 const void* src,
size_t srcSize);
186#define HUF_READ_STATS_WORKSPACE_SIZE_U32 FSE_DECOMPRESS_WKSP_SIZE_U32(6, HUF_TABLELOG_MAX-1)
187#define HUF_READ_STATS_WORKSPACE_SIZE (HUF_READ_STATS_WORKSPACE_SIZE_U32 * sizeof(unsigned))
189 U32* rankStats,
U32* nbSymbolsPtr,
U32* tableLogPtr,
190 const void* src,
size_t srcSize,
191 void* workspace,
size_t wkspSize,
196size_t HUF_readCTable (
HUF_CElt* CTable,
unsigned* maxSymbolValuePtr,
const void* src,
size_t srcSize,
unsigned *hasZeroWeights);
208 BYTE unused[
sizeof(size_t) - 2];
240#define HUF_DECOMPRESS_WORKSPACE_SIZE ((2 << 10) + (1 << 9))
241#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
256 const void* src,
size_t srcSize,
257 unsigned maxSymbolValue,
unsigned tableLog,
258 void* workSpace,
size_t wkspSize,
262#ifndef HUF_FORCE_DECOMPRESS_X1
270#ifndef HUF_FORCE_DECOMPRESS_X2
275#ifndef HUF_FORCE_DECOMPRESS_X2
278#ifndef HUF_FORCE_DECOMPRESS_X1
284#if defined (__cplusplus)
size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize, int flags)
size_t HUF_compressBound(size_t size)
const char * HUF_getErrorName(size_t code)
int HUF_validateCTable(const HUF_CElt *CTable, const unsigned *count, unsigned maxSymbolValue)
U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int flags)
size_t HUF_writeCTable_wksp(void *dst, size_t maxDstSize, const HUF_CElt *CTable, unsigned maxSymbolValue, unsigned huffLog, void *workspace, size_t workspaceSize)
unsigned HUF_cardinality(const unsigned *count, unsigned maxSymbolValue)
@ HUF_flags_suspectUncompressible
U32 HUF_getNbBitsFromCTable(const HUF_CElt *symbolTable, U32 symbolValue)
size_t HUF_compress4X_usingCTable(void *dst, size_t dstSize, const void *src, size_t srcSize, const HUF_CElt *CTable, int flags)
size_t HUF_compress1X_repeat(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize, HUF_CElt *hufTable, HUF_repeat *repeat, int flags)
size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int flags)
size_t HUF_estimateCompressedSize(const HUF_CElt *CTable, const unsigned *count, unsigned maxSymbolValue)
size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int flags)
size_t HUF_readStats(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize)
HUF_CTableHeader HUF_readCTableHeader(HUF_CElt const *ctable)
size_t HUF_compress1X_usingCTable(void *dst, size_t dstSize, const void *src, size_t srcSize, const HUF_CElt *CTable, int flags)
size_t HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable, int flags)
size_t HUF_readStats_wksp(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize, void *workspace, size_t wkspSize, int flags)
size_t HUF_buildCTable_wksp(HUF_CElt *tree, const unsigned *count, U32 maxSymbolValue, U32 maxNbBits, void *workSpace, size_t wkspSize)
size_t HUF_compress4X_repeat(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize, HUF_CElt *hufTable, HUF_repeat *repeat, int flags)
size_t HUF_readDTableX1_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize, int flags)
size_t HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable, int flags)
size_t HUF_readCTable(HUF_CElt *CTable, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize, unsigned *hasZeroWeights)
unsigned HUF_minTableLog(unsigned symbolCardinality)
size_t HUF_decompress1X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int flags)
unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, void *workSpace, size_t wkspSize, HUF_CElt *table, const unsigned *count, int flags)