ReactOS 0.4.15-dev-7918-g2a2556c
zstd_decompress_internal.h File Reference
#include "mem.h"
#include "zstd_internal.h"
Include dependency graph for zstd_decompress_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ZSTD_seqSymbol_header
 
struct  ZSTD_seqSymbol
 
struct  ZSTD_entropyDTables_t
 
struct  ZSTD_DCtx_s
 

Macros

#define SEQSYMBOL_TABLE_SIZE(log)   (1 + (1 << (log)))
 

Enumerations

enum  ZSTD_dStage {
  ZSTDds_getFrameHeaderSize , ZSTDds_decodeFrameHeader , ZSTDds_decodeBlockHeader , ZSTDds_decompressBlock ,
  ZSTDds_decompressLastBlock , ZSTDds_checkChecksum , ZSTDds_decodeSkippableHeader , ZSTDds_skipFrame
}
 
enum  ZSTD_dStreamStage {
  zdss_init =0 , zdss_loadHeader , zdss_read , zdss_load ,
  zdss_flush
}
 
enum  ZSTD_dictUses_e { ZSTD_use_indefinitely = -1 , ZSTD_dont_use = 0 , ZSTD_use_once = 1 }
 
enum  ZSTD_outBufferMode_e { ZSTD_obm_buffered = 0 , ZSTD_obm_stable = 1 }
 

Functions

size_t ZSTD_loadDEntropy (ZSTD_entropyDTables_t *entropy, const void *const dict, size_t const dictSize)
 
void ZSTD_checkContinuity (ZSTD_DCtx *dctx, const void *dst)
 

Variables

static const U32 LL_base [MaxLL+1]
 
static const U32 OF_base [MaxOff+1]
 
static const U32 OF_bits [MaxOff+1]
 
static const U32 ML_base [MaxML+1]
 

Macro Definition Documentation

◆ SEQSYMBOL_TABLE_SIZE

#define SEQSYMBOL_TABLE_SIZE (   log)    (1 + (1 << (log)))

Definition at line 74 of file zstd_decompress_internal.h.

Enumeration Type Documentation

◆ ZSTD_dictUses_e

Enumerator
ZSTD_use_indefinitely 
ZSTD_dont_use 
ZSTD_use_once 

Definition at line 92 of file zstd_decompress_internal.h.

92 {
93 ZSTD_use_indefinitely = -1, /* Use the dictionary indefinitely */
94 ZSTD_dont_use = 0, /* Do not use the dictionary (if one exists free it) */
95 ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */
@ ZSTD_use_indefinitely

◆ ZSTD_dStage

Enumerator
ZSTDds_getFrameHeaderSize 
ZSTDds_decodeFrameHeader 
ZSTDds_decodeBlockHeader 
ZSTDds_decompressBlock 
ZSTDds_decompressLastBlock 
ZSTDds_checkChecksum 
ZSTDds_decodeSkippableHeader 
ZSTDds_skipFrame 

Definition at line 84 of file zstd_decompress_internal.h.

◆ ZSTD_dStreamStage

Enumerator
zdss_init 
zdss_loadHeader 
zdss_read 
zdss_load 
zdss_flush 

Definition at line 89 of file zstd_decompress_internal.h.

◆ ZSTD_outBufferMode_e

Enumerator
ZSTD_obm_buffered 
ZSTD_obm_stable 

Definition at line 98 of file zstd_decompress_internal.h.

98 {
99 ZSTD_obm_buffered = 0, /* Buffer the output */
100 ZSTD_obm_stable = 1 /* ZSTD_outBuffer is stable */
@ ZSTD_obm_buffered

Function Documentation

◆ ZSTD_checkContinuity()

void ZSTD_checkContinuity ( ZSTD_DCtx dctx,
const void dst 
)

ZSTD_checkContinuity() : check if next dst follows previous position, where decompression ended. If yes, do nothing (continue on current segment). If not, classify previous segment as "external dictionary", and start a new segment. This function cannot fail.

Definition at line 1412 of file zstd_decompress_block.c.

1413{
1414 if (dst != dctx->previousDstEnd) { /* not contiguous */
1415 dctx->dictEnd = dctx->previousDstEnd;
1416 dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
1417 dctx->prefixStart = dst;
1418 dctx->previousDstEnd = dst;
1419 }
1420}
GLenum GLenum dst
Definition: glext.h:6340
const void * virtualStart
const void * prefixStart
const void * previousDstEnd

Referenced by ZSTD_decompressContinue(), ZSTD_decompressMultiFrame(), and ZSTD_insertBlock().

◆ ZSTD_loadDEntropy()

size_t ZSTD_loadDEntropy ( ZSTD_entropyDTables_t entropy,
const void *const  dict,
size_t const  dictSize 
)

ZSTD_loadDEntropy() : dict : must point at beginning of a valid zstd dictionary.

Returns
: size of dictionary header (size of magic number + dict ID + entropy tables)

ZSTD_loadDEntropy() : dict : must point at beginning of a valid zstd dictionary.

Returns
: size of entropy tables read

Definition at line 1056 of file zstd_decompress.c.

1058{
1059 const BYTE* dictPtr = (const BYTE*)dict;
1060 const BYTE* const dictEnd = dictPtr + dictSize;
1061
1062 RETURN_ERROR_IF(dictSize <= 8, dictionary_corrupted, "dict is too small");
1063 assert(MEM_readLE32(dict) == ZSTD_MAGIC_DICTIONARY); /* dict must be valid */
1064 dictPtr += 8; /* skip header = magic + dictID */
1065
1068 ZSTD_STATIC_ASSERT(sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable) >= HUF_DECOMPRESS_WORKSPACE_SIZE);
1069 { void* const workspace = &entropy->LLTable; /* use fse tables as temporary workspace; implies fse tables are grouped together */
1070 size_t const workspaceSize = sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable);
1071#ifdef HUF_FORCE_DECOMPRESS_X1
1072 /* in minimal huffman, we always use X1 variants */
1073 size_t const hSize = HUF_readDTableX1_wksp(entropy->hufTable,
1074 dictPtr, dictEnd - dictPtr,
1075 workspace, workspaceSize);
1076#else
1077 size_t const hSize = HUF_readDTableX2_wksp(entropy->hufTable,
1078 dictPtr, dictEnd - dictPtr,
1079 workspace, workspaceSize);
1080#endif
1081 RETURN_ERROR_IF(HUF_isError(hSize), dictionary_corrupted, "");
1082 dictPtr += hSize;
1083 }
1084
1085 { short offcodeNCount[MaxOff+1];
1086 unsigned offcodeMaxValue = MaxOff, offcodeLog;
1087 size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
1088 RETURN_ERROR_IF(FSE_isError(offcodeHeaderSize), dictionary_corrupted, "");
1089 RETURN_ERROR_IF(offcodeMaxValue > MaxOff, dictionary_corrupted, "");
1090 RETURN_ERROR_IF(offcodeLog > OffFSELog, dictionary_corrupted, "");
1091 ZSTD_buildFSETable( entropy->OFTable,
1092 offcodeNCount, offcodeMaxValue,
1094 offcodeLog);
1095 dictPtr += offcodeHeaderSize;
1096 }
1097
1098 { short matchlengthNCount[MaxML+1];
1099 unsigned matchlengthMaxValue = MaxML, matchlengthLog;
1100 size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
1101 RETURN_ERROR_IF(FSE_isError(matchlengthHeaderSize), dictionary_corrupted, "");
1102 RETURN_ERROR_IF(matchlengthMaxValue > MaxML, dictionary_corrupted, "");
1103 RETURN_ERROR_IF(matchlengthLog > MLFSELog, dictionary_corrupted, "");
1104 ZSTD_buildFSETable( entropy->MLTable,
1105 matchlengthNCount, matchlengthMaxValue,
1107 matchlengthLog);
1108 dictPtr += matchlengthHeaderSize;
1109 }
1110
1111 { short litlengthNCount[MaxLL+1];
1112 unsigned litlengthMaxValue = MaxLL, litlengthLog;
1113 size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
1114 RETURN_ERROR_IF(FSE_isError(litlengthHeaderSize), dictionary_corrupted, "");
1115 RETURN_ERROR_IF(litlengthMaxValue > MaxLL, dictionary_corrupted, "");
1116 RETURN_ERROR_IF(litlengthLog > LLFSELog, dictionary_corrupted, "");
1117 ZSTD_buildFSETable( entropy->LLTable,
1118 litlengthNCount, litlengthMaxValue,
1120 litlengthLog);
1121 dictPtr += litlengthHeaderSize;
1122 }
1123
1124 RETURN_ERROR_IF(dictPtr+12 > dictEnd, dictionary_corrupted, "");
1125 { int i;
1126 size_t const dictContentSize = (size_t)(dictEnd - (dictPtr+12));
1127 for (i=0; i<3; i++) {
1128 U32 const rep = MEM_readLE32(dictPtr); dictPtr += 4;
1129 RETURN_ERROR_IF(rep==0 || rep > dictContentSize,
1130 dictionary_corrupted, "");
1131 entropy->rep[i] = rep;
1132 } }
1133
1134 return dictPtr - (const BYTE*)dict;
1135}
#define assert(x)
Definition: debug.h:53
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
Definition: mem.h:346
__kernel_size_t size_t
Definition: linux.h:237
size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSVPtr, unsigned *tableLogPtr, const void *headerBuffer, size_t hbSize)
#define FSE_isError
Definition: fse_compress.c:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HUF_isError
Definition: huf_compress.c:41
size_t HUF_readDTableX1_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
#define offsetof(TYPE, MEMBER)
ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]
ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]
ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]
HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]
unsigned char BYTE
Definition: xxhash.c:193
unsigned int U32
Definition: xxhash.c:195
#define ZSTD_MAGIC_DICTIONARY
Definition: zstd.h:99
void ZSTD_buildFSETable(ZSTD_seqSymbol *dt, const short *normalizedCounter, unsigned maxSymbolValue, const U32 *baseValue, const U32 *nbAdditionalBits, unsigned tableLog)
static const U32 ML_base[MaxML+1]
static const U32 OF_base[MaxOff+1]
static const U32 OF_bits[MaxOff+1]
static const U32 LL_base[MaxLL+1]
#define MaxLL
#define MaxML
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91
static const U32 ML_bits[MaxML+1]
#define MLFSELog
static const U32 LL_bits[MaxLL+1]
#define MaxOff
#define LLFSELog
#define ZSTD_STATIC_ASSERT(c)
Definition: zstd_internal.h:45
#define OffFSELog

Referenced by ZSTD_decompress_insertDictionary(), and ZSTD_loadEntropy_intoDDict().

Variable Documentation

◆ LL_base

const U32 LL_base[MaxLL+1]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 18, 20, 22, 24, 28, 32, 40,
48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
0x2000, 0x4000, 0x8000, 0x10000 }

Definition at line 30 of file zstd_decompress_internal.h.

Referenced by ZSTD_loadDEntropy().

◆ ML_base

const U32 ML_base[MaxML+1]
static
Initial value:
= {
3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34,
35, 37, 39, 41, 43, 47, 51, 59,
67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803,
0x1003, 0x2003, 0x4003, 0x8003, 0x10003 }

Definition at line 49 of file zstd_decompress_internal.h.

Referenced by ZSTD_loadDEntropy().

◆ OF_base

const U32 OF_base[MaxOff+1]
static
Initial value:
= {
0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D,
0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD,
0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD,
0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD }

Definition at line 37 of file zstd_decompress_internal.h.

Referenced by ZSTD_loadDEntropy().

◆ OF_bits

const U32 OF_bits[MaxOff+1]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31 }

Definition at line 43 of file zstd_decompress_internal.h.

Referenced by ZSTD_loadDEntropy().