2017-06-09 01:43:56 +00:00
/* ******************************************************************
2020-09-18 19:38:36 +00:00
* huff0 huffman codec ,
* part of Finite State Entropy library
2021-11-19 11:54:45 +00:00
* Copyright ( c ) Yann Collet , Facebook , Inc .
2020-09-18 19:38:36 +00:00
*
* You can contact the author at :
* - Source repository : https : //github.com/Cyan4973/FiniteStateEntropy
*
* This source code is licensed under both the BSD - style license ( found in the
* LICENSE file in the root directory of this source tree ) and the GPLv2 ( found
* in the COPYING file in the root directory of this source tree ) .
* You may select , at your option , one of the above - listed licenses .
2017-06-09 01:43:56 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# if defined (__cplusplus)
extern " C " {
# endif
2017-08-27 10:05:17 +00:00
# ifndef HUF_H_298734234
# define HUF_H_298734234
2017-06-09 01:43:56 +00:00
/* *** Dependencies *** */
2021-01-08 10:21:43 +00:00
# include "zstd_deps.h" /* size_t */
2017-06-09 01:43:56 +00:00
/* *** library symbols visibility *** */
/* Note : when linking with -fvisibility=hidden on gcc, or by default on Visual,
* HUF symbols remain " private " ( internal symbols for library only ) .
* Set macro FSE_DLL_EXPORT to 1 if you want HUF symbols visible on DLL interface */
# if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
# define HUF_PUBLIC_API __attribute__ ((visibility ("default")))
# elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */
# define HUF_PUBLIC_API __declspec(dllexport)
# elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
# define HUF_PUBLIC_API __declspec(dllimport) /* not required, just to generate faster code (saves a function pointer load from IAT and an indirect jump) */
# else
# define HUF_PUBLIC_API
# endif
2018-05-15 17:45:22 +00:00
/* ========================== */
/* *** simple functions *** */
/* ========================== */
/** 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 .
* @ return : 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 ( ) )
*/
2017-06-09 01:43:56 +00:00
HUF_PUBLIC_API size_t HUF_compress ( void * dst , size_t dstCapacity ,
const void * src , size_t srcSize ) ;
2018-05-15 17:45:22 +00:00
/** 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 ) .
* @ return : size of regenerated data ( = = originalSize ) ,
* or an error code , which can be tested using HUF_isError ( )
*/
2017-06-09 01:43:56 +00:00
HUF_PUBLIC_API size_t HUF_decompress ( void * dst , size_t originalSize ,
const void * cSrc , size_t cSrcSize ) ;
/* *** Tool functions *** */
# define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
HUF_PUBLIC_API size_t HUF_compressBound ( size_t size ) ; /**< maximum compressed size (worst case) */
/* Error Management */
HUF_PUBLIC_API unsigned HUF_isError ( size_t code ) ; /**< tells if a return value is an error code */
HUF_PUBLIC_API const char * HUF_getErrorName ( size_t code ) ; /**< provides error code string (useful for debugging) */
/* *** Advanced function *** */
/** HUF_compress2() :
2018-05-15 17:45:22 +00:00
* Same as HUF_compress ( ) , but offers control over ` maxSymbolValue ` and ` tableLog ` .
* ` maxSymbolValue ` must be < = HUF_SYMBOLVALUE_MAX .
* ` tableLog ` must be ` < = HUF_TABLELOG_MAX ` . */
HUF_PUBLIC_API size_t HUF_compress2 ( void * dst , size_t dstCapacity ,
const void * src , size_t srcSize ,
unsigned maxSymbolValue , unsigned tableLog ) ;
2017-06-09 01:43:56 +00:00
/** HUF_compress4X_wksp() :
* Same as HUF_compress2 ( ) , but uses externally allocated ` workSpace ` .
2022-01-24 10:04:45 +00:00
* ` workspace ` must be at least as large as HUF_WORKSPACE_SIZE */
# define HUF_WORKSPACE_SIZE ((8 << 10) + 512 /* sorting scratch space */ )
# define HUF_WORKSPACE_SIZE_U64 (HUF_WORKSPACE_SIZE / sizeof(U64))
2018-05-15 17:45:22 +00:00
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 ) ;
2017-06-09 01:43:56 +00:00
2017-08-27 10:05:17 +00:00
# endif /* HUF_H_298734234 */
2017-06-09 01:43:56 +00:00
/* ******************************************************************
* WARNING ! !
* The following section contains advanced and experimental definitions
2018-05-15 17:45:22 +00:00
* which shall never be used in the context of a dynamic library ,
2017-06-09 01:43:56 +00:00
* because they are not guaranteed to remain stable in the future .
* Only consider them in association with static linking .
2018-05-15 17:45:22 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2017-08-27 10:05:17 +00:00
# if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY)
# define HUF_H_HUF_STATIC_LINKING_ONLY
2017-06-09 01:43:56 +00:00
/* *** Dependencies *** */
# include "mem.h" /* U32 */
2021-01-08 10:21:43 +00:00
# define FSE_STATIC_LINKING_ONLY
# include "fse.h"
2017-06-09 01:43:56 +00:00
/* *** Constants *** */
2022-01-24 10:04:45 +00:00
# define HUF_TABLELOG_MAX 12 /* max runtime value of tableLog (due to static allocation); can be modified up to HUF_TABLELOG_ABSOLUTEMAX */
2018-05-15 17:45:22 +00:00
# define HUF_TABLELOG_DEFAULT 11 /* default tableLog value when none specified */
2017-06-09 01:43:56 +00:00
# define HUF_SYMBOLVALUE_MAX 255
2022-01-24 10:04:45 +00:00
# define HUF_TABLELOG_ABSOLUTEMAX 12 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */
2017-06-09 01:43:56 +00:00
# if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
# error "HUF_TABLELOG_MAX is too large !"
# endif
/* ****************************************
* Static allocation
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* HUF buffer bounds */
# define HUF_CTABLEBOUND 129
# define HUF_BLOCKBOUND(size) (size + (size>>8) + 8) /* only true when incompressible is pre-filtered with fast heuristic */
# define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
/* static allocation of HUF's Compression Table */
2021-01-08 10:21:43 +00:00
/* this is a private definition, just exposed for allocation and strict aliasing purpose. never EVER access its members directly */
2022-01-24 10:04:45 +00:00
typedef size_t HUF_CElt ; /* consider it an incomplete type */
# define HUF_CTABLE_SIZE_ST(maxSymbolValue) ((maxSymbolValue)+2) /* Use tables of size_t, for proper alignment */
# define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_ST(maxSymbolValue) * sizeof(size_t))
2017-06-09 01:43:56 +00:00
# define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \
2022-01-24 10:04:45 +00:00
HUF_CElt name [ HUF_CTABLE_SIZE_ST ( maxSymbolValue ) ] /* no final ; */
2017-06-09 01:43:56 +00:00
/* static allocation of HUF's DTable */
typedef U32 HUF_DTable ;
# define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog)))
2019-01-04 00:30:03 +00:00
# define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \
2017-06-09 01:43:56 +00:00
HUF_DTable DTable [ HUF_DTABLE_SIZE ( ( maxTableLog ) - 1 ) ] = { ( ( U32 ) ( ( maxTableLog ) - 1 ) * 0x01000001 ) }
2019-01-04 00:30:03 +00:00
# define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \
2017-06-09 01:43:56 +00:00
HUF_DTable DTable [ HUF_DTABLE_SIZE ( maxTableLog ) ] = { ( ( U32 ) ( maxTableLog ) * 0x01000001 ) }
/* ****************************************
* Advanced decompression functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2019-01-04 00:30:03 +00:00
size_t HUF_decompress4X1 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< single-symbol decoder */
# ifndef HUF_FORCE_DECOMPRESS_X1
size_t HUF_decompress4X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< double-symbols decoder */
# endif
2017-06-09 01:43:56 +00:00
size_t HUF_decompress4X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< decodes RLE and uncompressed */
size_t HUF_decompress4X_hufOnly ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< considers RLE and uncompressed as errors */
2017-07-22 21:46:05 +00:00
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 ) ; /**< considers RLE and uncompressed as errors */
2019-01-04 00:30:03 +00:00
size_t HUF_decompress4X1_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< single-symbol decoder */
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 ) ; /**< single-symbol decoder */
# ifndef HUF_FORCE_DECOMPRESS_X1
size_t HUF_decompress4X2_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< double-symbols decoder */
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 ) ; /**< double-symbols decoder */
# endif
2017-06-09 01:43:56 +00:00
/* ****************************************
2018-05-15 17:45:22 +00:00
* HUF detailed API
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! HUF_compress() does the following:
* 1. count symbol occurrence f rom source [ ] into table count [ ] using FSE_count ( ) ( exposed within " fse.h " )
* 2. ( optional ) refine tableLog using HUF_optimalTableLog ( )
* 3. build Huffman table from count using HUF_buildCTable ( )
* 4. save Huffman table to memory buffer using HUF_writeCTable ( )
* 5. encode the data stream using HUF_compress4X_usingCTable ( )
*
* The following API allows targeting specific sub - functions for advanced tasks .
* For example , it ' s possible to compress several blocks using the same ' CTable ' ,
* or to save and regenerate ' CTable ' using external methods .
*/
2017-06-09 01:43:56 +00:00
unsigned HUF_optimalTableLog ( unsigned maxTableLog , size_t srcSize , unsigned maxSymbolValue ) ;
2018-05-15 17:45:22 +00:00
size_t HUF_buildCTable ( HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue , unsigned maxNbBits ) ; /* @return : maxNbBits; CTable and count can overlap. In which case, CTable will overwrite count content */
2017-06-09 01:43:56 +00:00
size_t HUF_writeCTable ( void * dst , size_t maxDstSize , const HUF_CElt * CTable , unsigned maxSymbolValue , unsigned huffLog ) ;
2021-11-19 11:54:45 +00:00
size_t HUF_writeCTable_wksp ( void * dst , size_t maxDstSize , const HUF_CElt * CTable , unsigned maxSymbolValue , unsigned huffLog , void * workspace , size_t workspaceSize ) ;
2017-06-09 01:43:56 +00:00
size_t HUF_compress4X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) ;
2022-01-24 10:04:45 +00:00
size_t HUF_compress4X_usingCTable_bmi2 ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable , int bmi2 ) ;
2020-09-18 19:38:36 +00:00
size_t HUF_estimateCompressedSize ( const HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue ) ;
int HUF_validateCTable ( const HUF_CElt * CTable , const unsigned * count , unsigned maxSymbolValue ) ;
2017-06-09 01:43:56 +00:00
typedef enum {
HUF_repeat_none , /**< Cannot use the previous table */
HUF_repeat_check , /**< Can use the previous table but it must be checked. Note : The previous table must have been constructed by HUF_compress{1, 4}X_repeat */
2019-01-04 00:30:03 +00:00
HUF_repeat_valid /**< Can use the previous table and it is assumed to be valid */
2017-06-09 01:43:56 +00:00
} HUF_repeat ;
/** HUF_compress4X_repeat() :
2018-05-15 17:45:22 +00:00
* Same as HUF_compress4X_wksp ( ) , but considers using hufTable if * repeat ! = HUF_repeat_none .
* If it uses hufTable it does not modify hufTable or repeat .
* If it doesn ' t , it sets * repeat = HUF_repeat_none , and it sets hufTable to the table used .
2022-01-24 10:04:45 +00:00
* If preferRepeat then the old table will always be used if valid .
* If suspectUncompressible then some sampling checks will be run to potentially skip huffman coding */
2018-05-15 17:45:22 +00:00
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 , /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
2022-01-24 10:04:45 +00:00
HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat , int bmi2 , unsigned suspectUncompressible ) ;
2017-06-09 01:43:56 +00:00
/** HUF_buildCTable_wksp() :
* Same as HUF_buildCTable ( ) , but using externally allocated scratch buffer .
2018-05-15 17:45:22 +00:00
* ` workSpace ` must be aligned on 4 - bytes boundaries , and its size must be > = HUF_CTABLE_WORKSPACE_SIZE .
2017-06-09 01:43:56 +00:00
*/
2018-05-15 17:45:22 +00:00
# define HUF_CTABLE_WORKSPACE_SIZE_U32 (2*HUF_SYMBOLVALUE_MAX +1 +1)
# define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned))
2019-01-04 00:30:03 +00:00
size_t HUF_buildCTable_wksp ( HUF_CElt * tree ,
const unsigned * count , U32 maxSymbolValue , U32 maxNbBits ,
void * workSpace , size_t wkspSize ) ;
2017-06-09 01:43:56 +00:00
/*! HUF_readStats() :
2018-05-15 17:45:22 +00:00
* Read compact Huffman tree , saved by HUF_writeCTable ( ) .
* ` huffWeight ` is destination buffer .
* @ return : size read from ` src ` , or an error Code .
* Note : Needed by HUF_readCTable ( ) and HUF_readDTableXn ( ) . */
size_t HUF_readStats ( BYTE * huffWeight , size_t hwSize ,
U32 * rankStats , U32 * nbSymbolsPtr , U32 * tableLogPtr ,
2017-06-09 01:43:56 +00:00
const void * src , size_t srcSize ) ;
2021-01-08 10:21:43 +00:00
/*! HUF_readStats_wksp() :
* Same as HUF_readStats ( ) but takes an external workspace which must be
* 4 - byte aligned and its size must be > = HUF_READ_STATS_WORKSPACE_SIZE .
* If the CPU has BMI2 support , pass bmi2 = 1 , otherwise pass bmi2 = 0.
*/
# define HUF_READ_STATS_WORKSPACE_SIZE_U32 FSE_DECOMPRESS_WKSP_SIZE_U32(6, HUF_TABLELOG_MAX-1)
# define HUF_READ_STATS_WORKSPACE_SIZE (HUF_READ_STATS_WORKSPACE_SIZE_U32 * sizeof(unsigned))
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 bmi2 ) ;
2017-06-09 01:43:56 +00:00
/** HUF_readCTable() :
2018-05-15 17:45:22 +00:00
* Loading a CTable saved with HUF_writeCTable ( ) */
2020-09-18 19:38:36 +00:00
size_t HUF_readCTable ( HUF_CElt * CTable , unsigned * maxSymbolValuePtr , const void * src , size_t srcSize , unsigned * hasZeroWeights ) ;
2017-06-09 01:43:56 +00:00
2022-01-24 10:04:45 +00:00
/** HUF_getNbBitsFromCTable() :
2019-01-04 00:30:03 +00:00
* Read nbBits from CTable symbolTable , for symbol ` symbolValue ` presumed < = HUF_SYMBOLVALUE_MAX
2022-01-24 10:04:45 +00:00
* Note 1 : is not inlined , as HUF_CElt definition is private */
U32 HUF_getNbBitsFromCTable ( const HUF_CElt * symbolTable , U32 symbolValue ) ;
2017-06-09 01:43:56 +00:00
/*
2018-05-15 17:45:22 +00:00
* HUF_decompress ( ) does the following :
2019-01-04 00:30:03 +00:00
* 1. select the decompression algorithm ( X1 , X2 ) based on pre - computed heuristics
2018-05-15 17:45:22 +00:00
* 2. build Huffman table from save , using HUF_readDTableX ? ( )
* 3. decode 1 or 4 segments in parallel using HUF_decompress ? X ? _usingDTable ( )
*/
2017-06-09 01:43:56 +00:00
/** HUF_selectDecoder() :
2018-05-15 17:45:22 +00:00
* Tells which decoder is likely to decode faster ,
* based on a set of pre - computed metrics .
2019-01-04 00:30:03 +00:00
* @ return : 0 = = HUF_decompress4X1 , 1 = = HUF_decompress4X2 .
2018-05-15 17:45:22 +00:00
* Assumption : 0 < dstSize < = 128 KB */
2017-06-09 01:43:56 +00:00
U32 HUF_selectDecoder ( size_t dstSize , size_t cSrcSize ) ;
2018-05-15 17:45:22 +00:00
/**
* The minimum workspace size for the ` workSpace ` used in
2019-01-04 00:30:03 +00:00
* HUF_readDTableX1_wksp ( ) and HUF_readDTableX2_wksp ( ) .
2018-05-15 17:45:22 +00:00
*
* The space used depends on HUF_TABLELOG_MAX , ranging from ~ 1500 bytes when
* HUF_TABLE_LOG_MAX = 12 to ~ 1850 bytes when HUF_TABLE_LOG_MAX = 15.
* Buffer overflow errors may potentially occur if code modifications result in
* a required workspace size greater than that specified in the following
* macro .
*/
2021-11-19 11:54:45 +00:00
# define HUF_DECOMPRESS_WORKSPACE_SIZE ((2 << 10) + (1 << 9))
2018-05-15 17:45:22 +00:00
# define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
2019-01-04 00:30:03 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
size_t HUF_readDTableX1 ( HUF_DTable * DTable , const void * src , size_t srcSize ) ;
size_t HUF_readDTableX1_wksp ( HUF_DTable * DTable , const void * src , size_t srcSize , void * workSpace , size_t wkspSize ) ;
# endif
# ifndef HUF_FORCE_DECOMPRESS_X1
2017-06-09 01:43:56 +00:00
size_t HUF_readDTableX2 ( HUF_DTable * DTable , const void * src , size_t srcSize ) ;
2017-07-22 21:46:05 +00:00
size_t HUF_readDTableX2_wksp ( HUF_DTable * DTable , const void * src , size_t srcSize , void * workSpace , size_t wkspSize ) ;
2019-01-04 00:30:03 +00:00
# endif
2017-06-09 01:43:56 +00:00
size_t HUF_decompress4X_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ;
2019-01-04 00:30:03 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
size_t HUF_decompress4X1_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ;
# endif
# ifndef HUF_FORCE_DECOMPRESS_X1
2017-06-09 01:43:56 +00:00
size_t HUF_decompress4X2_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ;
2019-01-04 00:30:03 +00:00
# endif
2017-06-09 01:43:56 +00:00
2018-05-15 17:45:22 +00:00
/* ====================== */
2017-06-09 01:43:56 +00:00
/* single stream variants */
2018-05-15 17:45:22 +00:00
/* ====================== */
2017-06-09 01:43:56 +00:00
size_t HUF_compress1X ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog ) ;
2022-01-24 10:04:45 +00:00
size_t HUF_compress1X_wksp ( void * dst , size_t dstSize , const void * src , size_t srcSize , unsigned maxSymbolValue , unsigned tableLog , void * workSpace , size_t wkspSize ) ; /**< `workSpace` must be a table of at least HUF_WORKSPACE_SIZE_U64 U64 */
2017-06-09 01:43:56 +00:00
size_t HUF_compress1X_usingCTable ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable ) ;
2022-01-24 10:04:45 +00:00
size_t HUF_compress1X_usingCTable_bmi2 ( void * dst , size_t dstSize , const void * src , size_t srcSize , const HUF_CElt * CTable , int bmi2 ) ;
2017-06-09 01:43:56 +00:00
/** HUF_compress1X_repeat() :
2018-05-15 17:45:22 +00:00
* Same as HUF_compress1X_wksp ( ) , but considers using hufTable if * repeat ! = HUF_repeat_none .
* If it uses hufTable it does not modify hufTable or repeat .
* If it doesn ' t , it sets * repeat = HUF_repeat_none , and it sets hufTable to the table used .
2022-01-24 10:04:45 +00:00
* If preferRepeat then the old table will always be used if valid .
* If suspectUncompressible then some sampling checks will be run to potentially skip huffman coding */
2018-05-15 17:45:22 +00:00
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 , /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
2022-01-24 10:04:45 +00:00
HUF_CElt * hufTable , HUF_repeat * repeat , int preferRepeat , int bmi2 , unsigned suspectUncompressible ) ;
2017-06-09 01:43:56 +00:00
2019-01-04 00:30:03 +00:00
size_t HUF_decompress1X1 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /* single-symbol decoder */
# ifndef HUF_FORCE_DECOMPRESS_X1
size_t HUF_decompress1X2 ( void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /* double-symbol decoder */
# endif
2017-06-09 01:43:56 +00:00
size_t HUF_decompress1X_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ;
2017-07-22 21:46:05 +00:00
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 ) ;
2019-01-04 00:30:03 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
size_t HUF_decompress1X1_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< single-symbol decoder */
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 ) ; /**< single-symbol decoder */
# endif
# ifndef HUF_FORCE_DECOMPRESS_X1
size_t HUF_decompress1X2_DCtx ( HUF_DTable * dctx , void * dst , size_t dstSize , const void * cSrc , size_t cSrcSize ) ; /**< double-symbols decoder */
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 ) ; /**< double-symbols decoder */
# endif
2017-06-09 01:43:56 +00:00
s ize_t HUF_decompress1X_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ; /**< automatic selection of sing or double symbol decoder, based on DTable */
2019-01-04 00:30:03 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
size_t HUF_decompress1X1_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ;
# endif
# ifndef HUF_FORCE_DECOMPRESS_X1
2017-06-09 01:43:56 +00:00
size_t HUF_decompress1X2_usingDTable ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable ) ;
2019-01-04 00:30:03 +00:00
# endif
2017-06-09 01:43:56 +00:00
2018-05-15 17:45:22 +00:00
/* BMI2 variants.
* If the CPU has BMI2 support , pass bmi2 = 1 , otherwise pass bmi2 = 0.
*/
size_t HUF_decompress1X_usingDTable_bmi2 ( void * dst , size_t maxDstSize , const void * cSrc , size_t cSrcSize , const HUF_DTable * DTable , int bmi2 ) ;
2019-01-04 00:30:03 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
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 ) ;
# endif
2018-05-15 17:45:22 +00:00
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_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 ) ;
2021-01-08 10:21:43 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X2
size_t HUF_readDTableX1_wksp_bmi2 ( HUF_DTable * DTable , const void * src , size_t srcSize , void * workSpace , size_t wkspSize , int bmi2 ) ;
# endif
2022-01-24 10:04:45 +00:00
# ifndef HUF_FORCE_DECOMPRESS_X1
size_t HUF_readDTableX2_wksp_bmi2 ( HUF_DTable * DTable , const void * src , size_t srcSize , void * workSpace , size_t wkspSize , int bmi2 ) ;
# endif
2018-05-15 17:45:22 +00:00
2017-06-09 01:43:56 +00:00
# endif /* HUF_STATIC_LINKING_ONLY */
# if defined (__cplusplus)
}
# endif