15#if defined (__cplusplus)
19#ifndef HUF_H_298734234
20#define HUF_H_298734234
30#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
31# define HUF_PUBLIC_API __attribute__ ((visibility ("default")))
32#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1)
33# define HUF_PUBLIC_API __declspec(dllexport)
34#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
35# define HUF_PUBLIC_API __declspec(dllimport)
37# define HUF_PUBLIC_API
55 const void*
src,
size_t srcSize);
68 const void* cSrc,
size_t cSrcSize);
72#define HUF_BLOCKSIZE_MAX (128 * 1024)
87 const void*
src,
size_t srcSize,
88 unsigned maxSymbolValue,
unsigned tableLog);
93#define HUF_WORKSPACE_SIZE ((6 << 10) + 256)
94#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32))
96 const void*
src,
size_t srcSize,
97 unsigned maxSymbolValue,
unsigned tableLog,
98 void* workSpace,
size_t wkspSize);
109#if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY)
110#define HUF_H_HUF_STATIC_LINKING_ONLY
117#define HUF_TABLELOG_MAX 12
118#define HUF_TABLELOG_DEFAULT 11
119#define HUF_SYMBOLVALUE_MAX 255
121#define HUF_TABLELOG_ABSOLUTEMAX 15
122#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
123# error "HUF_TABLELOG_MAX is too large !"
131#define HUF_CTABLEBOUND 129
132#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8)
133#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size))
136#define HUF_CTABLE_SIZE_U32(maxSymbolValue) ((maxSymbolValue)+1)
137#define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_U32(maxSymbolValue) * sizeof(U32))
138#define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \
139 U32 name##hb[HUF_CTABLE_SIZE_U32(maxSymbolValue)]; \
140 void* name##hv = &(name##hb); \
141 HUF_CElt* name = (HUF_CElt*)(name##hv)
144typedef U32 HUF_DTable;
145#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog)))
146#define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \
147 HUF_DTable DTable[HUF_DTABLE_SIZE((maxTableLog)-1)] = { ((U32)((maxTableLog)-1) * 0x01000001) }
148#define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \
149 HUF_DTable DTable[HUF_DTABLE_SIZE(maxTableLog)] = { ((U32)(maxTableLog) * 0x01000001) }
156#ifndef HUF_FORCE_DECOMPRESS_X1
164size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx,
void*
dst,
size_t dstSize,
const void* cSrc,
size_t cSrcSize,
void* workSpace,
size_t wkspSize);
165#ifndef HUF_FORCE_DECOMPRESS_X1
167size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx,
void*
dst,
size_t dstSize,
const void* cSrc,
size_t cSrcSize,
void* workSpace,
size_t wkspSize);
186unsigned HUF_optimalTableLog(
unsigned maxTableLog,
size_t srcSize,
unsigned maxSymbolValue);
188size_t HUF_buildCTable (HUF_CElt* CTable,
const unsigned*
count,
unsigned maxSymbolValue,
unsigned maxNbBits);
189size_t HUF_writeCTable (
void*
dst,
size_t maxDstSize,
const HUF_CElt* CTable,
unsigned maxSymbolValue,
unsigned huffLog);
205 const void*
src,
size_t srcSize,
206 unsigned maxSymbolValue,
unsigned tableLog,
207 void* workSpace,
size_t wkspSize,
208 HUF_CElt* hufTable, HUF_repeat*
repeat,
int preferRepeat,
int bmi2);
214#define HUF_CTABLE_WORKSPACE_SIZE_U32 (2*HUF_SYMBOLVALUE_MAX +1 +1)
215#define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned))
217 const unsigned*
count,
U32 maxSymbolValue,
U32 maxNbBits,
218 void* workSpace,
size_t wkspSize);
226 U32* rankStats,
U32* nbSymbolsPtr,
U32* tableLogPtr,
227 const void*
src,
size_t srcSize);
231size_t HUF_readCTable (HUF_CElt* CTable,
unsigned* maxSymbolValuePtr,
const void*
src,
size_t srcSize,
unsigned *hasZeroWeights);
263#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10)
264#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
266#ifndef HUF_FORCE_DECOMPRESS_X2
268size_t HUF_readDTableX1_wksp (HUF_DTable* DTable,
const void*
src,
size_t srcSize,
void* workSpace,
size_t wkspSize);
270#ifndef HUF_FORCE_DECOMPRESS_X1
272size_t HUF_readDTableX2_wksp (HUF_DTable* DTable,
const void*
src,
size_t srcSize,
void* workSpace,
size_t wkspSize);
276#ifndef HUF_FORCE_DECOMPRESS_X2
279#ifndef HUF_FORCE_DECOMPRESS_X1
288size_t HUF_compress1X (
void*
dst,
size_t dstSize,
const void*
src,
size_t srcSize,
unsigned maxSymbolValue,
unsigned tableLog);
289size_t HUF_compress1X_wksp (
void*
dst,
size_t dstSize,
const void*
src,
size_t srcSize,
unsigned maxSymbolValue,
unsigned tableLog,
void* workSpace,
size_t wkspSize);
297 const void*
src,
size_t srcSize,
298 unsigned maxSymbolValue,
unsigned tableLog,
299 void* workSpace,
size_t wkspSize,
300 HUF_CElt* hufTable, HUF_repeat*
repeat,
int preferRepeat,
int bmi2);
303#ifndef HUF_FORCE_DECOMPRESS_X1
308size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx,
void*
dst,
size_t dstSize,
const void* cSrc,
size_t cSrcSize,
void* workSpace,
size_t wkspSize);
309#ifndef HUF_FORCE_DECOMPRESS_X2
311size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* dctx,
void*
dst,
size_t dstSize,
const void* cSrc,
size_t cSrcSize,
void* workSpace,
size_t wkspSize);
313#ifndef HUF_FORCE_DECOMPRESS_X1
315size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx,
void*
dst,
size_t dstSize,
const void* cSrc,
size_t cSrcSize,
void* workSpace,
size_t wkspSize);
319#ifndef HUF_FORCE_DECOMPRESS_X2
322#ifndef HUF_FORCE_DECOMPRESS_X1
330#ifndef HUF_FORCE_DECOMPRESS_X2
338#if defined (__cplusplus)
size_t HUF_readStats(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize)
GLuint GLuint GLsizei count
HUF_PUBLIC_API size_t HUF_compressBound(size_t size)
HUF_PUBLIC_API size_t HUF_decompress(void *dst, size_t originalSize, const void *cSrc, size_t cSrcSize)
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)
HUF_PUBLIC_API const char * HUF_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_compress(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
size_t HUF_compress1X(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog)
size_t HUF_compress4X_repeat(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, void *workSpace, size_t wkspSize, HUF_CElt *hufTable, HUF_repeat *repeat, int preferRepeat, int bmi2)
int HUF_validateCTable(const HUF_CElt *CTable, const unsigned *count, unsigned maxSymbolValue)
size_t HUF_compress4X_usingCTable(void *dst, size_t dstSize, const void *src, size_t srcSize, const HUF_CElt *CTable)
unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue)
size_t HUF_buildCTable(HUF_CElt *tree, const unsigned *count, unsigned maxSymbolValue, unsigned maxNbBits)
size_t HUF_writeCTable(void *dst, size_t maxDstSize, const HUF_CElt *CTable, unsigned maxSymbolValue, unsigned huffLog)
size_t HUF_compress1X_usingCTable(void *dst, size_t dstSize, const void *src, size_t srcSize, const HUF_CElt *CTable)
U32 HUF_getNbBits(const void *symbolTable, U32 symbolValue)
size_t HUF_estimateCompressedSize(const HUF_CElt *CTable, const unsigned *count, unsigned maxSymbolValue)
size_t HUF_compress1X_wksp(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, void *workSpace, size_t wkspSize)
size_t HUF_buildCTable_wksp(HUF_CElt *tree, const unsigned *count, U32 maxSymbolValue, U32 maxNbBits, void *workSpace, size_t wkspSize)
size_t HUF_readCTable(HUF_CElt *CTable, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize, unsigned *hasZeroWeights)
size_t HUF_compress1X_repeat(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, void *workSpace, size_t wkspSize, HUF_CElt *hufTable, HUF_repeat *repeat, int preferRepeat, int bmi2)
size_t HUF_decompress1X_usingDTable_bmi2(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable, int bmi2)
size_t HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
size_t HUF_readDTableX1_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
size_t HUF_readDTableX2(HUF_DTable *DTable, const void *src, size_t srcSize)
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)
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)
size_t HUF_decompress4X_DCtx(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X_DCtx(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize)
size_t HUF_decompress4X_usingDTable_bmi2(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable, int bmi2)
size_t HUF_decompress1X1(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X2_DCtx(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress4X2(void *dst, size_t dstSize, const void *cSrc, 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)
size_t HUF_decompress4X1(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
size_t HUF_decompress4X2_DCtx(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X1_DCtx(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X2(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress1X1_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
size_t HUF_decompress4X1_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int bmi2)
size_t HUF_decompress4X1_DCtx(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_decompress4X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize)
size_t HUF_decompress4X_hufOnly(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
size_t HUF_readDTableX1(HUF_DTable *DTable, const void *src, size_t srcSize)
size_t HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
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)
size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workSpace, size_t wkspSize, int bmi2)