Project Alice
Loading...
Searching...
No Matches
huf_decompress.c File Reference
Include dependency graph for huf_decompress.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DTableDesc
 
struct  HUF_DecompressFastArgs
 
struct  HUF_DEltX1
 
struct  HUF_ReadDTableX1_Workspace
 
struct  HUF_DEltX2
 
struct  sortedSymbol_t
 
struct  HUF_ReadDTableX2_Workspace
 
struct  algo_time_t
 

Macros

#define HUF_DECODER_FAST_TABLELOG   11
 
#define HUF_ENABLE_FAST_DECODE   1
 
#define HUF_FAST_BMI2_ATTRS
 
#define HUF_EXTERN_C
 
#define HUF_ASM_DECL   HUF_EXTERN_C
 
#define HUF_NEED_BMI2_FUNCTION   0
 
#define HUF_isError   ERR_isError
 
#define HUF_ALIGN(x, a)   HUF_ALIGN_MASK((x), (a) - 1)
 
#define HUF_ALIGN_MASK(x, mask)   (((x) + (mask)) & ~(mask))
 
#define HUF_DGEN(fn)
 
#define HUF_4X_FOR_EACH_STREAM(X)
 
#define HUF_4X_FOR_EACH_STREAM_WITH_VAR(X, var)
 
#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)    do { *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog); } while (0)
 
#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr)
 
#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr)
 
#define HUF_4X1_DECODE_SYMBOL(_stream, _symbol)
 
#define HUF_4X1_RELOAD_STREAM(_stream)
 
#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr)    do { ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); } while (0)
 
#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr)
 
#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr)
 
#define HUF_4X2_DECODE_SYMBOL(_stream, _decode3)
 
#define HUF_4X2_RELOAD_STREAM(_stream)
 

Typedefs

typedef size_t(* HUF_DecompressUsingDTableFn) (void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
 
typedef void(* HUF_DecompressFastLoopFn) (HUF_DecompressFastArgs *)
 
typedef U32 rankValCol_t[HUF_TABLELOG_MAX+1]
 
typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX]
 

Functions

size_t HUF_readDTableX1_wksp (HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize, int flags)
 
FORCE_INLINE_TEMPLATE BYTE HUF_decodeSymbolX1 (BIT_DStream_t *Dstream, const HUF_DEltX1 *dt, const U32 dtLog)
 
HINT_INLINE size_t HUF_decodeStreamX1 (BYTE *p, BIT_DStream_t *const bitDPtr, BYTE *const pEnd, const HUF_DEltX1 *const dt, const U32 dtLog)
 
FORCE_INLINE_TEMPLATE size_t HUF_decompress1X1_usingDTable_internal_body (void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
 
FORCE_INLINE_TEMPLATE size_t HUF_decompress4X1_usingDTable_internal_body (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, int flags)
 
FORCE_INLINE_TEMPLATE U32 HUF_decodeSymbolX2 (void *op, BIT_DStream_t *DStream, const HUF_DEltX2 *dt, const U32 dtLog)
 
FORCE_INLINE_TEMPLATE U32 HUF_decodeLastSymbolX2 (void *op, BIT_DStream_t *DStream, const HUF_DEltX2 *dt, const U32 dtLog)
 
HINT_INLINE size_t HUF_decodeStreamX2 (BYTE *p, BIT_DStream_t *bitDPtr, BYTE *const pEnd, const HUF_DEltX2 *const dt, const U32 dtLog)
 
FORCE_INLINE_TEMPLATE size_t HUF_decompress1X2_usingDTable_internal_body (void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
 
FORCE_INLINE_TEMPLATE size_t HUF_decompress4X2_usingDTable_internal_body (void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)
 
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)
 
U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize)
 
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)
 
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_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_decompress4X_usingDTable (void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable, int flags)
 
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)
 

Macro Definition Documentation

◆ HUF_4X1_DECODE_SYMBOL

#define HUF_4X1_DECODE_SYMBOL (   _stream,
  _symbol 
)
Value:
do { \
int const index = (int)(bits[(_stream)] >> 53); \
int const entry = (int)dtable[index]; \
bits[(_stream)] <<= (entry & 0x3F); \
op[(_stream)][(_symbol)] = (BYTE)((entry >> 8) & 0xFF); \
} while (0)
unsigned char BYTE
Definition: mem.h:58

◆ HUF_4X1_RELOAD_STREAM

#define HUF_4X1_RELOAD_STREAM (   _stream)
Value:
do { \
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
int const nbBits = ctz & 7; \
int const nbBytes = ctz >> 3; \
op[(_stream)] += 5; \
ip[(_stream)] -= nbBytes; \
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
bits[(_stream)] <<= nbBits; \
} while (0)
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
Definition: bits.h:90
MEM_STATIC U64 MEM_read64(const void *memPtr)
Definition: mem.h:207

◆ HUF_4X2_DECODE_SYMBOL

#define HUF_4X2_DECODE_SYMBOL (   _stream,
  _decode3 
)
Value:
do { \
if ((_decode3) || (_stream) != 3) { \
int const index = (int)(bits[(_stream)] >> 53); \
HUF_DEltX2 const entry = dtable[index]; \
MEM_write16(op[(_stream)], entry.sequence); \
bits[(_stream)] <<= (entry.nbBits) & 0x3F; \
op[(_stream)] += (entry.length); \
} \
} while (0)

◆ HUF_4X2_RELOAD_STREAM

#define HUF_4X2_RELOAD_STREAM (   _stream)
Value:
do { \
HUF_4X2_DECODE_SYMBOL(3, 1); \
{ \
int const ctz = ZSTD_countTrailingZeros64(bits[(_stream)]); \
int const nbBits = ctz & 7; \
int const nbBytes = ctz >> 3; \
ip[(_stream)] -= nbBytes; \
bits[(_stream)] = MEM_read64(ip[(_stream)]) | 1; \
bits[(_stream)] <<= nbBits; \
} \
} while (0)

◆ HUF_4X_FOR_EACH_STREAM

#define HUF_4X_FOR_EACH_STREAM (   X)
Value:
do { \
X(0); \
X(1); \
X(2); \
X(3); \
} while (0)

Definition at line 306 of file huf_decompress.c.

◆ HUF_4X_FOR_EACH_STREAM_WITH_VAR

#define HUF_4X_FOR_EACH_STREAM_WITH_VAR (   X,
  var 
)
Value:
do { \
X(0, (var)); \
X(1, (var)); \
X(2, (var)); \
X(3, (var)); \
} while (0)

Definition at line 315 of file huf_decompress.c.

◆ HUF_ALIGN

#define HUF_ALIGN (   x,
 
)    HUF_ALIGN_MASK((x), (a) - 1)

Definition at line 84 of file huf_decompress.c.

◆ HUF_ALIGN_MASK

#define HUF_ALIGN_MASK (   x,
  mask 
)    (((x) + (mask)) & ~(mask))

Definition at line 85 of file huf_decompress.c.

◆ HUF_ASM_DECL

#define HUF_ASM_DECL   HUF_EXTERN_C

Definition at line 67 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX1_0

#define HUF_DECODE_SYMBOLX1_0 (   ptr,
  DStreamPtr 
)     do { *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog); } while (0)

Definition at line 530 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX1_1

#define HUF_DECODE_SYMBOLX1_1 (   ptr,
  DStreamPtr 
)
Value:
do { \
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr); \
} while (0)
#define HUF_TABLELOG_MAX
Definition: huf.h:42
MEM_STATIC unsigned MEM_64bits(void)
Definition: mem.h:141

Definition at line 533 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX1_2

#define HUF_DECODE_SYMBOLX1_2 (   ptr,
  DStreamPtr 
)
Value:
do { \
if (MEM_64bits()) \
HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr); \
} while (0)

Definition at line 539 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX2_0

#define HUF_DECODE_SYMBOLX2_0 (   ptr,
  DStreamPtr 
)     do { ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); } while (0)

Definition at line 1292 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX2_1

#define HUF_DECODE_SYMBOLX2_1 (   ptr,
  DStreamPtr 
)
Value:
do { \
if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); \
} while (0)
FORCE_INLINE_TEMPLATE U32 HUF_decodeSymbolX2(void *op, BIT_DStream_t *DStream, const HUF_DEltX2 *dt, const U32 dtLog)

Definition at line 1295 of file huf_decompress.c.

◆ HUF_DECODE_SYMBOLX2_2

#define HUF_DECODE_SYMBOLX2_2 (   ptr,
  DStreamPtr 
)
Value:
do { \
if (MEM_64bits()) \
ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog); \
} while (0)

Definition at line 1301 of file huf_decompress.c.

◆ HUF_DECODER_FAST_TABLELOG

#define HUF_DECODER_FAST_TABLELOG   11

Definition at line 31 of file huf_decompress.c.

◆ HUF_DGEN

#define HUF_DGEN (   fn)
Value:
static size_t fn(void* dst, size_t dstSize, void const* cSrc, \
size_t cSrcSize, HUF_DTable const* DTable, int flags) \
{ \
(void)flags; \
return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
}
U32 HUF_DTable
Definition: huf.h:69

Definition at line 127 of file huf_decompress.c.

◆ HUF_ENABLE_FAST_DECODE

#define HUF_ENABLE_FAST_DECODE   1

Definition at line 40 of file huf_decompress.c.

◆ HUF_EXTERN_C

#define HUF_EXTERN_C

Definition at line 65 of file huf_decompress.c.

◆ HUF_FAST_BMI2_ATTRS

#define HUF_FAST_BMI2_ATTRS

Definition at line 59 of file huf_decompress.c.

◆ HUF_isError

#define HUF_isError   ERR_isError

Definition at line 78 of file huf_decompress.c.

◆ HUF_NEED_BMI2_FUNCTION

#define HUF_NEED_BMI2_FUNCTION   0

Definition at line 72 of file huf_decompress.c.

Typedef Documentation

◆ HUF_DecompressFastLoopFn

typedef void(* HUF_DecompressFastLoopFn) (HUF_DecompressFastArgs *)

Definition at line 183 of file huf_decompress.c.

◆ HUF_DecompressUsingDTableFn

typedef size_t(* HUF_DecompressUsingDTableFn) (void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable)

Definition at line 91 of file huf_decompress.c.

◆ rankVal_t

typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX]

Definition at line 956 of file huf_decompress.c.

◆ rankValCol_t

typedef U32 rankValCol_t[HUF_TABLELOG_MAX+1]

Definition at line 955 of file huf_decompress.c.

Function Documentation

◆ HUF_decodeLastSymbolX2()

FORCE_INLINE_TEMPLATE U32 HUF_decodeLastSymbolX2 ( void *  op,
BIT_DStream_t DStream,
const HUF_DEltX2 dt,
const U32  dtLog 
)

Definition at line 1275 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_decodeStreamX1()

HINT_INLINE size_t HUF_decodeStreamX1 ( BYTE p,
BIT_DStream_t *const  bitDPtr,
BYTE *const  pEnd,
const HUF_DEltX1 *const  dt,
const U32  dtLog 
)

Definition at line 546 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_decodeStreamX2()

HINT_INLINE size_t HUF_decodeStreamX2 ( BYTE p,
BIT_DStream_t bitDPtr,
BYTE *const  pEnd,
const HUF_DEltX2 *const  dt,
const U32  dtLog 
)

Definition at line 1308 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_decodeSymbolX1()

FORCE_INLINE_TEMPLATE BYTE HUF_decodeSymbolX1 ( BIT_DStream_t Dstream,
const HUF_DEltX1 dt,
const U32  dtLog 
)

Definition at line 522 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decodeSymbolX2()

FORCE_INLINE_TEMPLATE U32 HUF_decodeSymbolX2 ( void *  op,
BIT_DStream_t DStream,
const HUF_DEltX2 dt,
const U32  dtLog 
)

Definition at line 1266 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress1X1_DCtx_wksp()

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 
)

Definition at line 1894 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_decompress1X1_usingDTable_internal_body()

FORCE_INLINE_TEMPLATE size_t HUF_decompress1X1_usingDTable_internal_body ( void *  dst,
size_t  dstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable 
)

Definition at line 575 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress1X2_DCtx_wksp()

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 
)

double-symbols decoder

Definition at line 1754 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_decompress1X2_usingDTable_internal_body()

FORCE_INLINE_TEMPLATE size_t HUF_decompress1X2_usingDTable_internal_body ( void *  dst,
size_t  dstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable 
)

Definition at line 1353 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress1X_DCtx_wksp()

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 
)

Definition at line 1845 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress1X_usingDTable()

size_t HUF_decompress1X_usingDTable ( void *  dst,
size_t  maxDstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable,
int  flags 
)

Definition at line 1876 of file huf_decompress.c.

◆ HUF_decompress4X1_usingDTable_internal_body()

FORCE_INLINE_TEMPLATE size_t HUF_decompress4X1_usingDTable_internal_body ( void *  dst,
size_t  dstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable 
)

Definition at line 602 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress4X2_usingDTable_internal_body()

FORCE_INLINE_TEMPLATE size_t HUF_decompress4X2_usingDTable_internal_body ( void *  dst,
size_t  dstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable 
)

Definition at line 1384 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress4X_hufOnly_wksp()

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 
)

Definition at line 1924 of file huf_decompress.c.

Here is the call graph for this function:

◆ HUF_decompress4X_usingDTable()

size_t HUF_decompress4X_usingDTable ( void *  dst,
size_t  maxDstSize,
const void *  cSrc,
size_t  cSrcSize,
const HUF_DTable DTable,
int  flags 
)

Definition at line 1907 of file huf_decompress.c.

◆ HUF_readDTableX1_wksp()

size_t HUF_readDTableX1_wksp ( HUF_DTable DTable,
const void *  src,
size_t  srcSize,
void *  workSpace,
size_t  wkspSize,
int  flags 
)

Definition at line 385 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_readDTableX2_wksp()

size_t HUF_readDTableX2_wksp ( HUF_DTable DTable,
const void *  src,
size_t  srcSize,
void *  workSpace,
size_t  wkspSize,
int  flags 
)

Definition at line 1179 of file huf_decompress.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HUF_selectDecoder()

U32 HUF_selectDecoder ( size_t  dstSize,
size_t  cSrcSize 
)

HUF_selectDecoder() : Tells which decoder is likely to decode faster, based on a set of pre-computed metrics.

Returns
: 0==HUF_decompress4X1, 1==HUF_decompress4X2 . Assumption : 0 < dstSize <= 128 KB

Definition at line 1821 of file huf_decompress.c.

Here is the caller graph for this function: