ReactOS  0.4.15-dev-4863-gba0d16f
zstd_compress_internal.h File Reference
#include "zstd_internal.h"
#include "zstd_cwksp.h"
Include dependency graph for zstd_compress_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ZSTD_prefixDict_s
 
struct  ZSTD_localDict
 
struct  ZSTD_hufCTables_t
 
struct  ZSTD_fseCTables_t
 
struct  ZSTD_entropyCTables_t
 
struct  ZSTD_match_t
 
struct  ZSTD_optimal_t
 
struct  optState_t
 
struct  ZSTD_compressedBlockState_t
 
struct  ZSTD_window_t
 
struct  ZSTD_matchState_t
 
struct  ZSTD_blockState_t
 
struct  ldmEntry_t
 
struct  ldmState_t
 
struct  ldmParams_t
 
struct  rawSeq
 
struct  rawSeqStore_t
 
struct  SeqCollector
 
struct  ZSTD_CCtx_params_s
 
struct  ZSTD_CCtx_s
 
struct  repcodes_s
 

Macros

#define kSearchStrength   8
 
#define HASH_READ_SIZE   8
 
#define ZSTD_DUBT_UNSORTED_MARK
 
#define ZSTD_ROLL_HASH_CHAR_OFFSET   10
 
#define ZSTD_CURRENT_MAX   ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
 
#define ZSTD_CHUNKSIZE_MAX
 

Typedefs

typedef struct ZSTD_prefixDict_s ZSTD_prefixDict
 
typedef struct ZSTD_matchState_t ZSTD_matchState_t
 
typedef size_t(* ZSTD_blockCompressor) (ZSTD_matchState_t *bs, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
 
typedef struct repcodes_s repcodes_t
 

Enumerations

enum  ZSTD_compressionStage_e { ZSTDcs_created =0, ZSTDcs_init, ZSTDcs_ongoing, ZSTDcs_ending }
 
enum  ZSTD_cStreamStage { zcss_init =0, zcss_load, zcss_flush }
 
enum  ZSTD_OptPrice_e { zop_dynamic =0, zop_predef }
 
enum  ZSTD_dictTableLoadMethod_e { ZSTD_dtlm_fast, ZSTD_dtlm_full }
 
enum  ZSTD_dictMode_e { ZSTD_noDict = 0, ZSTD_extDict = 1, ZSTD_dictMatchState = 2 }
 

Functions

ZSTD_blockCompressor ZSTD_selectBlockCompressor (ZSTD_strategy strat, ZSTD_dictMode_e dictMode)
 
MEM_STATIC U32 ZSTD_LLcode (U32 litLength)
 
MEM_STATIC U32 ZSTD_MLcode (U32 mlBase)
 
MEM_STATIC repcodes_t ZSTD_updateRep (U32 const rep[3], U32 const offset, U32 const ll0)
 
MEM_STATIC int ZSTD_cParam_withinBounds (ZSTD_cParameter cParam, int value)
 
MEM_STATIC size_t ZSTD_noCompressBlock (void *dst, size_t dstCapacity, const void *src, size_t srcSize, U32 lastBlock)
 
MEM_STATIC size_t ZSTD_rleCompressBlock (void *dst, size_t dstCapacity, BYTE src, size_t srcSize, U32 lastBlock)
 
MEM_STATIC size_t ZSTD_minGain (size_t srcSize, ZSTD_strategy strat)
 
MEM_STATIC int ZSTD_disableLiteralsCompression (const ZSTD_CCtx_params *cctxParams)
 
static void ZSTD_safecopyLiterals (BYTE *op, BYTE const *ip, BYTE const *const iend, BYTE const *ilimit_w)
 
HINT_INLINE UNUSED_ATTR void ZSTD_storeSeq (seqStore_t *seqStorePtr, size_t litLength, const BYTE *literals, const BYTE *litLimit, U32 offCode, size_t mlBase)
 
static unsigned ZSTD_NbCommonBytes (size_t val)
 
MEM_STATIC size_t ZSTD_count (const BYTE *pIn, const BYTE *pMatch, const BYTE *const pInLimit)
 
MEM_STATIC size_t ZSTD_count_2segments (const BYTE *ip, const BYTE *match, const BYTE *iEnd, const BYTE *mEnd, const BYTE *iStart)
 
static U32 ZSTD_hash3 (U32 u, U32 h)
 
MEM_STATIC size_t ZSTD_hash3Ptr (const void *ptr, U32 h)
 
static U32 ZSTD_hash4 (U32 u, U32 h)
 
static size_t ZSTD_hash4Ptr (const void *ptr, U32 h)
 
static size_t ZSTD_hash5 (U64 u, U32 h)
 
static size_t ZSTD_hash5Ptr (const void *p, U32 h)
 
static size_t ZSTD_hash6 (U64 u, U32 h)
 
static size_t ZSTD_hash6Ptr (const void *p, U32 h)
 
static size_t ZSTD_hash7 (U64 u, U32 h)
 
static size_t ZSTD_hash7Ptr (const void *p, U32 h)
 
static size_t ZSTD_hash8 (U64 u, U32 h)
 
static size_t ZSTD_hash8Ptr (const void *p, U32 h)
 
MEM_STATIC size_t ZSTD_hashPtr (const void *p, U32 hBits, U32 mls)
 
static U64 ZSTD_ipow (U64 base, U64 exponent)
 
static U64 ZSTD_rollingHash_append (U64 hash, void const *buf, size_t size)
 
MEM_STATIC U64 ZSTD_rollingHash_compute (void const *buf, size_t size)
 
MEM_STATIC U64 ZSTD_rollingHash_primePower (U32 length)
 
MEM_STATIC U64 ZSTD_rollingHash_rotate (U64 hash, BYTE toRemove, BYTE toAdd, U64 primePower)
 
MEM_STATIC void ZSTD_window_clear (ZSTD_window_t *window)
 
MEM_STATIC U32 ZSTD_window_hasExtDict (ZSTD_window_t const window)
 
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode (const ZSTD_matchState_t *ms)
 
MEM_STATIC U32 ZSTD_window_needOverflowCorrection (ZSTD_window_t const window, void const *srcEnd)
 
MEM_STATIC U32 ZSTD_window_correctOverflow (ZSTD_window_t *window, U32 cycleLog, U32 maxDist, void const *src)
 
MEM_STATIC void ZSTD_window_enforceMaxDist (ZSTD_window_t *window, const void *blockEnd, U32 maxDist, U32 *loadedDictEndPtr, const ZSTD_matchState_t **dictMatchStatePtr)
 
MEM_STATIC void ZSTD_checkDictValidity (const ZSTD_window_t *window, const void *blockEnd, U32 maxDist, U32 *loadedDictEndPtr, const ZSTD_matchState_t **dictMatchStatePtr)
 
MEM_STATIC void ZSTD_window_init (ZSTD_window_t *window)
 
MEM_STATIC U32 ZSTD_window_update (ZSTD_window_t *window, void const *src, size_t srcSize)
 
MEM_STATIC U32 ZSTD_getLowestMatchIndex (const ZSTD_matchState_t *ms, U32 current, unsigned windowLog)
 
MEM_STATIC U32 ZSTD_getLowestPrefixIndex (const ZSTD_matchState_t *ms, U32 current, unsigned windowLog)
 
size_t ZSTD_loadCEntropy (ZSTD_compressedBlockState_t *bs, void *workspace, short *offcodeNCount, unsigned *offcodeMaxValue, const void *const dict, size_t dictSize)
 
void ZSTD_reset_compressedBlockState (ZSTD_compressedBlockState_t *bs)
 
ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams (const ZSTD_CCtx_params *CCtxParams, U64 srcSizeHint, size_t dictSize)
 
size_t ZSTD_initCStream_internal (ZSTD_CStream *zcs, const void *dict, size_t dictSize, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, unsigned long long pledgedSrcSize)
 
void ZSTD_resetSeqStore (seqStore_t *ssPtr)
 
ZSTD_compressionParameters ZSTD_getCParamsFromCDict (const ZSTD_CDict *cdict)
 
size_t ZSTD_compressBegin_advanced_internal (ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, ZSTD_dictTableLoadMethod_e dtlm, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, unsigned long long pledgedSrcSize)
 
size_t ZSTD_compress_advanced_internal (ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, const ZSTD_CCtx_params *params)
 
size_t ZSTD_writeLastEmptyBlock (void *dst, size_t dstCapacity)
 
size_t ZSTD_referenceExternalSequences (ZSTD_CCtx *cctx, rawSeq *seq, size_t nbSeq)
 
U32 ZSTD_cycleLog (U32 hashLog, ZSTD_strategy strat)
 

Variables

static const U32 prime3bytes = 506832829U
 
static const U32 prime4bytes = 2654435761U
 
static const U64 prime5bytes = 889523592379ULL
 
static const U64 prime6bytes = 227718039650203ULL
 
static const U64 prime7bytes = 58295818150454627ULL
 
static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL
 

Macro Definition Documentation

◆ HASH_READ_SIZE

#define HASH_READ_SIZE   8

Definition at line 36 of file zstd_compress_internal.h.

◆ kSearchStrength

#define kSearchStrength   8

Definition at line 35 of file zstd_compress_internal.h.

◆ ZSTD_CHUNKSIZE_MAX

#define ZSTD_CHUNKSIZE_MAX
Value:
( ((U32)-1) /* Maximum ending current index */ \
- ZSTD_CURRENT_MAX) /* Maximum beginning lowLimit */
#define ZSTD_CURRENT_MAX
unsigned int U32
Definition: xxhash.c:195

Definition at line 709 of file zstd_compress_internal.h.

◆ ZSTD_CURRENT_MAX

#define ZSTD_CURRENT_MAX   ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))

Definition at line 707 of file zstd_compress_internal.h.

◆ ZSTD_DUBT_UNSORTED_MARK

#define ZSTD_DUBT_UNSORTED_MARK
Value:
1 /* For btlazy2 strategy, index ZSTD_DUBT_UNSORTED_MARK==1 means "unsorted".
It could be confused for a real successor at index "1", if sorted as larger than its predecessor.
It's not a big deal though : candidate will just be sorted again.
Additionally, candidate position 1 will be lost.
But candidate 1 cannot hide a large tree of candidates, so it's a minimal loss.
The benefit is that ZSTD_DUBT_UNSORTED_MARK cannot be mishandled after table re-use with a different strategy.
This constant is required by ZSTD_compressBlock_btlazy2() and ZSTD_reduceTable_internal() */

Definition at line 37 of file zstd_compress_internal.h.

◆ ZSTD_ROLL_HASH_CHAR_OFFSET

#define ZSTD_ROLL_HASH_CHAR_OFFSET   10

Definition at line 656 of file zstd_compress_internal.h.

Typedef Documentation

◆ repcodes_t

◆ ZSTD_blockCompressor

typedef size_t(* ZSTD_blockCompressor) (ZSTD_matchState_t *bs, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)

Definition at line 292 of file zstd_compress_internal.h.

◆ ZSTD_matchState_t

◆ ZSTD_prefixDict

Enumeration Type Documentation

◆ ZSTD_compressionStage_e

◆ ZSTD_cStreamStage

Enumerator
zcss_init 
zcss_load 
zcss_flush 

Definition at line 50 of file zstd_compress_internal.h.

◆ ZSTD_dictMode_e

Enumerator
ZSTD_noDict 
ZSTD_extDict 
ZSTD_dictMatchState 

Definition at line 289 of file zstd_compress_internal.h.

◆ ZSTD_dictTableLoadMethod_e

◆ ZSTD_OptPrice_e

Enumerator
zop_dynamic 
zop_predef 

Definition at line 98 of file zstd_compress_internal.h.

Function Documentation

◆ ZSTD_checkDictValidity()

MEM_STATIC void ZSTD_checkDictValidity ( const ZSTD_window_t window,
const void blockEnd,
U32  maxDist,
U32 loadedDictEndPtr,
const ZSTD_matchState_t **  dictMatchStatePtr 
)

Definition at line 893 of file zstd_compress_internal.h.

898 {
899  assert(loadedDictEndPtr != NULL);
900  assert(dictMatchStatePtr != NULL);
901  { U32 const blockEndIdx = (U32)((BYTE const*)blockEnd - window->base);
902  U32 const loadedDictEnd = *loadedDictEndPtr;
903  DEBUGLOG(5, "ZSTD_checkDictValidity: blockEndIdx=%u, maxDist=%u, loadedDictEnd=%u",
904  (unsigned)blockEndIdx, (unsigned)maxDist, (unsigned)loadedDictEnd);
905  assert(blockEndIdx >= loadedDictEnd);
906 
907  if (blockEndIdx > loadedDictEnd + maxDist) {
908  /* On reaching window size, dictionaries are invalidated.
909  * For simplification, if window size is reached anywhere within next block,
910  * the dictionary is invalidated for the full block.
911  */
912  DEBUGLOG(6, "invalidating dictionary for current block (distance > windowSize)");
913  *loadedDictEndPtr = 0;
914  *dictMatchStatePtr = NULL;
915  } else {
916  if (*loadedDictEndPtr != 0) {
917  DEBUGLOG(6, "dictionary considered valid for current block");
918  } } }
919 }
#define assert(x)
Definition: debug.h:53
#define DEBUGLOG(l,...)
Definition: debug.h:106
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
#define NULL
Definition: types.h:112
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compress_frameChunk().

◆ ZSTD_compress_advanced_internal()

size_t ZSTD_compress_advanced_internal ( ZSTD_CCtx cctx,
void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
const void dict,
size_t  dictSize,
const ZSTD_CCtx_params *  params 
)

Definition at line 3270 of file zstd_compress.c.

3276 {
3277  DEBUGLOG(4, "ZSTD_compress_advanced_internal (srcSize:%u)", (unsigned)srcSize);
3279  dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL,
3280  params, srcSize, ZSTDb_not_buffered) , "");
3281  return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);
3282 }
static size_t ZSTD_compressBegin_internal(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, ZSTD_dictTableLoadMethod_e dtlm, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, U64 pledgedSrcSize, ZSTD_buffered_policy_e zbuff)
#define DEBUGLOG(l,...)
Definition: debug.h:106
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define NULL
Definition: types.h:112
#define FORWARD_IF_ERROR(err,...)
size_t ZSTD_compressEnd(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)

Referenced by ZSTD_compress_internal(), and ZSTD_compress_usingDict().

◆ ZSTD_compressBegin_advanced_internal()

size_t ZSTD_compressBegin_advanced_internal ( ZSTD_CCtx cctx,
const void dict,
size_t  dictSize,
ZSTD_dictContentType_e  dictContentType,
ZSTD_dictTableLoadMethod_e  dtlm,
const ZSTD_CDict cdict,
const ZSTD_CCtx_params *  params,
unsigned long long  pledgedSrcSize 
)

Definition at line 3122 of file zstd_compress.c.

3129 {
3130  DEBUGLOG(4, "ZSTD_compressBegin_advanced_internal: wlog=%u", params->cParams.windowLog);
3131  /* compression parameters verification and optimization */
3132  FORWARD_IF_ERROR( ZSTD_checkCParams(params->cParams) , "");
3133  return ZSTD_compressBegin_internal(cctx,
3134  dict, dictSize, dictContentType, dtlm,
3135  cdict,
3136  params, pledgedSrcSize,
3138 }
static size_t ZSTD_compressBegin_internal(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, ZSTD_dictTableLoadMethod_e dtlm, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, U64 pledgedSrcSize, ZSTD_buffered_policy_e zbuff)
#define DEBUGLOG(l,...)
Definition: debug.h:106
GLenum const GLfloat * params
Definition: glext.h:5645
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
#define FORWARD_IF_ERROR(err,...)

Referenced by ZSTD_compressBegin_advanced().

◆ ZSTD_count()

MEM_STATIC size_t ZSTD_count ( const BYTE pIn,
const BYTE pMatch,
const BYTE *const  pInLimit 
)

Definition at line 561 of file zstd_compress_internal.h.

562 {
563  const BYTE* const pStart = pIn;
564  const BYTE* const pInLoopLimit = pInLimit - (sizeof(size_t)-1);
565 
566  if (pIn < pInLoopLimit) {
567  { size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
568  if (diff) return ZSTD_NbCommonBytes(diff); }
569  pIn+=sizeof(size_t); pMatch+=sizeof(size_t);
570  while (pIn < pInLoopLimit) {
571  size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
572  if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
573  pIn += ZSTD_NbCommonBytes(diff);
574  return (size_t)(pIn - pStart);
575  } }
576  if (MEM_64bits() && (pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
577  if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
578  if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
579  return (size_t)(pIn - pStart);
580 }
MEM_STATIC size_t MEM_readST(const void *memPtr)
Definition: mem.h:252
MEM_STATIC unsigned MEM_64bits(void)
Definition: mem.h:184
static unsigned ZSTD_NbCommonBytes(size_t val)
__kernel_size_t size_t
Definition: linux.h:237
MEM_STATIC U32 MEM_read32(const void *memPtr)
Definition: mem.h:242
unsigned char BYTE
Definition: xxhash.c:193
MEM_STATIC U16 MEM_read16(const void *memPtr)
Definition: mem.h:237

Referenced by ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast_dictMatchState_generic(), ZSTD_compressBlock_fast_generic(), ZSTD_compressBlock_lazy_generic(), ZSTD_count_2segments(), ZSTD_DUBT_findBestMatch(), ZSTD_HcFindBestMatch_generic(), ZSTD_insertBt1(), ZSTD_insertBtAndGetAllMatches(), ZSTD_insertDUBT1(), and ZSTD_ldm_generateSequences_internal().

◆ ZSTD_count_2segments()

MEM_STATIC size_t ZSTD_count_2segments ( const BYTE ip,
const BYTE match,
const BYTE iEnd,
const BYTE mEnd,
const BYTE iStart 
)

ZSTD_count_2segments() : can count match length with ip & match in 2 different segments. convention : on reaching mEnd, match count continue starting from iStart

Definition at line 587 of file zstd_compress_internal.h.

589 {
590  const BYTE* const vEnd = MIN( ip + (mEnd - match), iEnd);
591  size_t const matchLength = ZSTD_count(ip, match, vEnd);
592  if (match + matchLength != mEnd) return matchLength;
593  DEBUGLOG(7, "ZSTD_count_2segments: found a 2-parts match (current length==%zu)", matchLength);
594  DEBUGLOG(7, "distance from match beginning to end dictionary = %zi", mEnd - match);
595  DEBUGLOG(7, "distance from current pos to end buffer = %zi", iEnd - ip);
596  DEBUGLOG(7, "next byte : ip==%02X, istart==%02X", ip[matchLength], *iStart);
597  DEBUGLOG(7, "final match length = %zu", matchLength + ZSTD_count(ip+matchLength, iStart, iEnd));
598  return matchLength + ZSTD_count(ip+matchLength, iStart, iEnd);
599 }
Definition: match.c:28
_In_ UINT iStart
Definition: wingdi.h:3620
T MIN(T a, T b)
Definition: polytest.cpp:79
#define DEBUGLOG(l,...)
Definition: debug.h:106
MEM_STATIC size_t ZSTD_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *const pInLimit)
Definition: dhcpd.h:61
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast_dictMatchState_generic(), ZSTD_compressBlock_fast_extDict_generic(), ZSTD_compressBlock_lazy_extDict_generic(), ZSTD_compressBlock_lazy_generic(), ZSTD_DUBT_findBestMatch(), ZSTD_DUBT_findBetterDictMatch(), ZSTD_HcFindBestMatch_generic(), ZSTD_insertBt1(), ZSTD_insertBtAndGetAllMatches(), ZSTD_insertDUBT1(), and ZSTD_ldm_generateSequences_internal().

◆ ZSTD_cParam_withinBounds()

MEM_STATIC int ZSTD_cParam_withinBounds ( ZSTD_cParameter  cParam,
int  value 
)

Definition at line 357 of file zstd_compress_internal.h.

358 {
359  ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam);
360  if (ZSTD_isError(bounds.error)) return 0;
361  if (value < bounds.lowerBound) return 0;
362  if (value > bounds.upperBound) return 0;
363  return 1;
364 }
Definition: pdh_main.c:93
ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam)
#define ZSTD_isError
Definition: zstd_internal.h:46
int upperBound
Definition: zstd.h:422
size_t error
Definition: zstd.h:420
int lowerBound
Definition: zstd.h:421

Referenced by ZSTD_minGain(), and ZSTD_selectBlockCompressor().

◆ ZSTD_cycleLog()

U32 ZSTD_cycleLog ( U32  hashLog,
ZSTD_strategy  strat 
)

ZSTD_cycleLog() : condition for correct operation : hashLog > 1

Definition at line 1019 of file zstd_compress.c.

1020 {
1021  U32 const btScale = ((U32)strat >= (U32)ZSTD_btlazy2);
1022  return hashLog - btScale;
1023 }
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_adjustCParams_internal(), and ZSTD_overflowCorrectIfNeeded().

◆ ZSTD_disableLiteralsCompression()

MEM_STATIC int ZSTD_disableLiteralsCompression ( const ZSTD_CCtx_params *  cctxParams)

Definition at line 402 of file zstd_compress_internal.h.

403 {
404  switch (cctxParams->literalCompressionMode) {
405  case ZSTD_lcm_huffman:
406  return 0;
407  case ZSTD_lcm_uncompressed:
408  return 1;
409  default:
410  assert(0 /* impossible: pre-validated */);
411  /* fall-through */
412  case ZSTD_lcm_auto:
413  return (cctxParams->cParams.strategy == ZSTD_fast) && (cctxParams->cParams.targetLength > 0);
414  }
415 }
#define assert(x)
Definition: debug.h:53

Referenced by ZSTD_buildSuperBlockEntropy(), and ZSTD_compressSequences_internal().

◆ ZSTD_getCParamsFromCCtxParams()

ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams ( const ZSTD_CCtx_params *  CCtxParams,
U64  srcSizeHint,
size_t  dictSize 
)

Definition at line 1077 of file zstd_compress.c.

1079 {
1080  ZSTD_compressionParameters cParams;
1081  if (srcSizeHint == ZSTD_CONTENTSIZE_UNKNOWN && CCtxParams->srcSizeHint > 0) {
1082  srcSizeHint = CCtxParams->srcSizeHint;
1083  }
1084  cParams = ZSTD_getCParams_internal(CCtxParams->compressionLevel, srcSizeHint, dictSize);
1085  if (CCtxParams->ldmParams.enableLdm) cParams.windowLog = ZSTD_LDM_DEFAULT_WINDOW_LOG;
1086  if (CCtxParams->cParams.windowLog) cParams.windowLog = CCtxParams->cParams.windowLog;
1087  if (CCtxParams->cParams.hashLog) cParams.hashLog = CCtxParams->cParams.hashLog;
1088  if (CCtxParams->cParams.chainLog) cParams.chainLog = CCtxParams->cParams.chainLog;
1089  if (CCtxParams->cParams.searchLog) cParams.searchLog = CCtxParams->cParams.searchLog;
1090  if (CCtxParams->cParams.minMatch) cParams.minMatch = CCtxParams->cParams.minMatch;
1091  if (CCtxParams->cParams.targetLength) cParams.targetLength = CCtxParams->cParams.targetLength;
1092  if (CCtxParams->cParams.strategy) cParams.strategy = CCtxParams->cParams.strategy;
1093  assert(!ZSTD_checkCParams(cParams));
1094  /* srcSizeHint == 0 means 0 */
1095  return ZSTD_adjustCParams_internal(cParams, srcSizeHint, dictSize);
1096 }
#define ZSTD_CONTENTSIZE_UNKNOWN
Definition: zstd.h:152
#define assert(x)
Definition: debug.h:53
#define ZSTD_LDM_DEFAULT_WINDOW_LOG
Definition: zstd_ldm.h:25
static ZSTD_compressionParameters ZSTD_getCParams_internal(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
static ZSTD_compressionParameters ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)

Referenced by ZSTD_compressStream2(), ZSTD_estimateCCtxSize_usingCCtxParams(), ZSTD_estimateCStreamSize_usingCCtxParams(), ZSTD_initLocalDict(), and ZSTD_resetCStream_internal().

◆ ZSTD_getCParamsFromCDict()

ZSTD_compressionParameters ZSTD_getCParamsFromCDict ( const ZSTD_CDict cdict)

ZSTD_getCParamsFromCDict() : as the name implies

Definition at line 3530 of file zstd_compress.c.

3531 {
3532  assert(cdict != NULL);
3533  return cdict->matchState.cParams;
3534 }
ZSTD_matchState_t matchState
Definition: zstd_compress.c:57
#define assert(x)
Definition: debug.h:53
ZSTD_compressionParameters cParams
#define NULL
Definition: types.h:112

Referenced by ZSTD_compressBegin_usingCDict_advanced().

◆ ZSTD_getLowestMatchIndex()

MEM_STATIC U32 ZSTD_getLowestMatchIndex ( const ZSTD_matchState_t ms,
U32  current,
unsigned  windowLog 
)

Returns the lowest allowed match index. It may either be in the ext-dict or the prefix.

Definition at line 976 of file zstd_compress_internal.h.

977 {
978  U32 const maxDistance = 1U << windowLog;
979  U32 const lowestValid = ms->window.lowLimit;
980  U32 const withinWindow = (current - lowestValid > maxDistance) ? current - maxDistance : lowestValid;
981  U32 const isDictionary = (ms->loadedDictEnd != 0);
982  U32 const matchLowest = isDictionary ? lowestValid : withinWindow;
983  return matchLowest;
984 }
#define U(x)
Definition: wordpad.c:45
struct task_struct * current
Definition: linux.c:32
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_fast_extDict_generic(), ZSTD_compressBlock_lazy_extDict_generic(), ZSTD_DUBT_findBestMatch(), and ZSTD_insertBtAndGetAllMatches().

◆ ZSTD_getLowestPrefixIndex()

MEM_STATIC U32 ZSTD_getLowestPrefixIndex ( const ZSTD_matchState_t ms,
U32  current,
unsigned  windowLog 
)

Returns the lowest allowed match index in the prefix.

Definition at line 989 of file zstd_compress_internal.h.

990 {
991  U32 const maxDistance = 1U << windowLog;
992  U32 const lowestValid = ms->window.dictLimit;
993  U32 const withinWindow = (current - lowestValid > maxDistance) ? current - maxDistance : lowestValid;
994  U32 const isDictionary = (ms->loadedDictEnd != 0);
995  U32 const matchLowest = isDictionary ? lowestValid : withinWindow;
996  return matchLowest;
997 }
#define U(x)
Definition: wordpad.c:45
struct task_struct * current
Definition: linux.c:32
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast_generic(), and ZSTD_compressBlock_lazy_generic().

◆ ZSTD_hash3()

static U32 ZSTD_hash3 ( U32  u,
U32  h 
)
static

Definition at line 606 of file zstd_compress_internal.h.

606 { return ((u << (32-24)) * prime3bytes) >> (32-h) ; }
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 * u
Definition: glfuncs.h:240
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const U32 prime3bytes

Referenced by ZSTD_hash3Ptr().

◆ ZSTD_hash3Ptr()

MEM_STATIC size_t ZSTD_hash3Ptr ( const void ptr,
U32  h 
)

Definition at line 607 of file zstd_compress_internal.h.

607 { return ZSTD_hash3(MEM_readLE32(ptr), h); } /* only in zstd_opt.h */
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
Definition: mem.h:346
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static PVOID ptr
Definition: dispmode.c:27
static U32 ZSTD_hash3(U32 u, U32 h)

Referenced by ZSTD_insertAndFindFirstIndexHash3().

◆ ZSTD_hash4()

static U32 ZSTD_hash4 ( U32  u,
U32  h 
)
static

Definition at line 610 of file zstd_compress_internal.h.

610 { return (u * prime4bytes) >> (32-h) ; }
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 * u
Definition: glfuncs.h:240
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const U32 prime4bytes

Referenced by ZSTD_hash4Ptr().

◆ ZSTD_hash4Ptr()

static size_t ZSTD_hash4Ptr ( const void ptr,
U32  h 
)
static

Definition at line 611 of file zstd_compress_internal.h.

611 { return ZSTD_hash4(MEM_read32(ptr), h); }
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static PVOID ptr
Definition: dispmode.c:27
MEM_STATIC U32 MEM_read32(const void *memPtr)
Definition: mem.h:242
static U32 ZSTD_hash4(U32 u, U32 h)

Referenced by ZSTD_hashPtr().

◆ ZSTD_hash5()

static size_t ZSTD_hash5 ( U64  u,
U32  h 
)
static

Definition at line 614 of file zstd_compress_internal.h.

614 { return (size_t)(((u << (64-40)) * prime5bytes) >> (64-h)) ; }
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 * u
Definition: glfuncs.h:240
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const U64 prime5bytes

Referenced by ZSTD_hash5Ptr().

◆ ZSTD_hash5Ptr()

static size_t ZSTD_hash5Ptr ( const void p,
U32  h 
)
static

Definition at line 615 of file zstd_compress_internal.h.

615 { return ZSTD_hash5(MEM_readLE64(p), h); }
static size_t ZSTD_hash5(U64 u, U32 h)
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:362
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ZSTD_hashPtr().

◆ ZSTD_hash6()

static size_t ZSTD_hash6 ( U64  u,
U32  h 
)
static

Definition at line 618 of file zstd_compress_internal.h.

618 { return (size_t)(((u << (64-48)) * prime6bytes) >> (64-h)) ; }
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 * u
Definition: glfuncs.h:240
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const U64 prime6bytes

Referenced by ZSTD_hash6Ptr().

◆ ZSTD_hash6Ptr()

static size_t ZSTD_hash6Ptr ( const void p,
U32  h 
)
static

Definition at line 619 of file zstd_compress_internal.h.

619 { return ZSTD_hash6(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:362
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static size_t ZSTD_hash6(U64 u, U32 h)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ZSTD_hashPtr().

◆ ZSTD_hash7()

static size_t ZSTD_hash7 ( U64  u,
U32  h 
)
static

Definition at line 622 of file zstd_compress_internal.h.

622 { return (size_t)(((u << (64-56)) * prime7bytes) >> (64-h)) ; }
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 * u
Definition: glfuncs.h:240
static const U64 prime7bytes
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by ZSTD_hash7Ptr().

◆ ZSTD_hash7Ptr()

static size_t ZSTD_hash7Ptr ( const void p,
U32  h 
)
static

Definition at line 623 of file zstd_compress_internal.h.

623 { return ZSTD_hash7(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:362
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static size_t ZSTD_hash7(U64 u, U32 h)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ZSTD_hashPtr().

◆ ZSTD_hash8()

static size_t ZSTD_hash8 ( U64  u,
U32  h 
)
static

Definition at line 626 of file zstd_compress_internal.h.

626 { return (size_t)(((u) * prime8bytes) >> (64-h)) ; }
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 * u
Definition: glfuncs.h:240
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const U64 prime8bytes

Referenced by ZSTD_hash8Ptr().

◆ ZSTD_hash8Ptr()

static size_t ZSTD_hash8Ptr ( const void p,
U32  h 
)
static

Definition at line 627 of file zstd_compress_internal.h.

627 { return ZSTD_hash8(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:362
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static size_t ZSTD_hash8(U64 u, U32 h)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ZSTD_hashPtr().

◆ ZSTD_hashPtr()

MEM_STATIC size_t ZSTD_hashPtr ( const void p,
U32  hBits,
U32  mls 
)

Definition at line 629 of file zstd_compress_internal.h.

630 {
631  switch(mls)
632  {
633  default:
634  case 4: return ZSTD_hash4Ptr(p, hBits);
635  case 5: return ZSTD_hash5Ptr(p, hBits);
636  case 6: return ZSTD_hash6Ptr(p, hBits);
637  case 7: return ZSTD_hash7Ptr(p, hBits);
638  case 8: return ZSTD_hash8Ptr(p, hBits);
639  }
640 }
static size_t ZSTD_hash5Ptr(const void *p, U32 h)
void mls(int argc, const char *argv[])
Definition: cmds.c:1168
static size_t ZSTD_hash4Ptr(const void *ptr, U32 h)
static size_t ZSTD_hash8Ptr(const void *p, U32 h)
static size_t ZSTD_hash6Ptr(const void *p, U32 h)
static size_t ZSTD_hash7Ptr(const void *p, U32 h)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast_dictMatchState_generic(), ZSTD_compressBlock_fast_extDict_generic(), ZSTD_compressBlock_fast_generic(), ZSTD_DUBT_findBestMatch(), ZSTD_DUBT_findBetterDictMatch(), ZSTD_fillDoubleHashTable(), ZSTD_fillHashTable(), ZSTD_HcFindBestMatch_generic(), ZSTD_insertAndFindFirstIndex_internal(), ZSTD_insertBt1(), ZSTD_insertBtAndGetAllMatches(), and ZSTD_updateDUBT().

◆ ZSTD_initCStream_internal()

size_t ZSTD_initCStream_internal ( ZSTD_CStream zcs,
const void dict,
size_t  dictSize,
const ZSTD_CDict cdict,
const ZSTD_CCtx_params *  params,
unsigned long long  pledgedSrcSize 
)

ZSTD_initCStream_internal() : Private use only. Init streaming operation. expects params to be valid. must receive dict, or cdict, or none, but not both.

Returns
: 0, or an error code

ZSTD_initCStream_internal() : Note : for lib/compress only. Used by zstdmt_compress.c. Assumption 1 : params are valid Assumption 2 : either dict, or cdict, is defined, not both

Definition at line 3690 of file zstd_compress.c.

3694 {
3695  DEBUGLOG(4, "ZSTD_initCStream_internal");
3697  FORWARD_IF_ERROR( ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize) , "");
3699  zcs->requestedParams = *params;
3700  assert(!((dict) && (cdict))); /* either dict or cdict, not both */
3701  if (dict) {
3702  FORWARD_IF_ERROR( ZSTD_CCtx_loadDictionary(zcs, dict, dictSize) , "");
3703  } else {
3704  /* Dictionary is cleared if !cdict */
3705  FORWARD_IF_ERROR( ZSTD_CCtx_refCDict(zcs, cdict) , "");
3706  }
3707  return 0;
3708 }
#define assert(x)
Definition: debug.h:53
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx *cctx, unsigned long long pledgedSrcSize)
#define DEBUGLOG(l,...)
Definition: debug.h:106
#define ZSTD_isError
Definition: zstd_internal.h:46
GLenum const GLfloat * params
Definition: glext.h:5645
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx *cctx, const void *dict, size_t dictSize)
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
size_t ZSTD_CCtx_reset(ZSTD_CCtx *cctx, ZSTD_ResetDirective reset)
size_t ZSTD_CCtx_refCDict(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
#define FORWARD_IF_ERROR(err,...)
ZSTD_CCtx_params requestedParams

◆ ZSTD_ipow()

static U64 ZSTD_ipow ( U64  base,
U64  exponent 
)
static

ZSTD_ipow() : Return base^exponent.

Definition at line 645 of file zstd_compress_internal.h.

646 {
647  U64 power = 1;
648  while (exponent) {
649  if (exponent & 1) power *= base;
650  exponent >>= 1;
651  base *= base;
652  }
653  return power;
654 }
GLuint base
Definition: 3dtext.c:35
float power
Definition: d3drm.c:3372
unsigned long long U64
Definition: xxhash.c:197

Referenced by ZSTD_rollingHash_primePower().

◆ ZSTD_LLcode()

MEM_STATIC U32 ZSTD_LLcode ( U32  litLength)

Definition at line 298 of file zstd_compress_internal.h.

299 {
300  static const BYTE LL_Code[64] = { 0, 1, 2, 3, 4, 5, 6, 7,
301  8, 9, 10, 11, 12, 13, 14, 15,
302  16, 16, 17, 17, 18, 18, 19, 19,
303  20, 20, 20, 20, 21, 21, 21, 21,
304  22, 22, 22, 22, 22, 22, 22, 22,
305  23, 23, 23, 23, 23, 23, 23, 23,
306  24, 24, 24, 24, 24, 24, 24, 24,
307  24, 24, 24, 24, 24, 24, 24, 24 };
308  static const U32 LL_deltaCode = 19;
309  return (litLength > 63) ? ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
310 }
unsigned char BYTE
Definition: xxhash.c:193
MEM_STATIC U32 ZSTD_highbit32(U32 val)
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_litLengthPrice(), ZSTD_seqToCodes(), and ZSTD_updateStats().

◆ ZSTD_loadCEntropy()

size_t ZSTD_loadCEntropy ( ZSTD_compressedBlockState_t bs,
void workspace,
short offcodeNCount,
unsigned offcodeMaxValue,
const void *const  dict,
size_t  dictSize 
)

Definition at line 2902 of file zstd_compress.c.

2905 {
2906  const BYTE* dictPtr = (const BYTE*)dict; /* skip magic num and dict ID */
2907  const BYTE* const dictEnd = dictPtr + dictSize;
2908  dictPtr += 8;
2909  bs->entropy.huf.repeatMode = HUF_repeat_check;
2910 
2911  { unsigned maxSymbolValue = 255;
2912  unsigned hasZeroWeights = 1;
2913  size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)bs->entropy.huf.CTable, &maxSymbolValue, dictPtr,
2914  dictEnd-dictPtr, &hasZeroWeights);
2915 
2916  /* We only set the loaded table as valid if it contains all non-zero
2917  * weights. Otherwise, we set it to check */
2918  if (!hasZeroWeights)
2919  bs->entropy.huf.repeatMode = HUF_repeat_valid;
2920 
2921  RETURN_ERROR_IF(HUF_isError(hufHeaderSize), dictionary_corrupted, "");
2922  RETURN_ERROR_IF(maxSymbolValue < 255, dictionary_corrupted, "");
2923  dictPtr += hufHeaderSize;
2924  }
2925 
2926  { unsigned offcodeLog;
2927  size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
2928  RETURN_ERROR_IF(FSE_isError(offcodeHeaderSize), dictionary_corrupted, "");
2929  RETURN_ERROR_IF(offcodeLog > OffFSELog, dictionary_corrupted, "");
2930  /* Defer checking offcodeMaxValue because we need to know the size of the dictionary content */
2931  /* fill all offset symbols to avoid garbage at end of table */
2933  bs->entropy.fse.offcodeCTable,
2934  offcodeNCount, MaxOff, offcodeLog,
2935  workspace, HUF_WORKSPACE_SIZE)),
2936  dictionary_corrupted, "");
2937  dictPtr += offcodeHeaderSize;
2938  }
2939 
2940  { short matchlengthNCount[MaxML+1];
2941  unsigned matchlengthMaxValue = MaxML, matchlengthLog;
2942  size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
2943  RETURN_ERROR_IF(FSE_isError(matchlengthHeaderSize), dictionary_corrupted, "");
2944  RETURN_ERROR_IF(matchlengthLog > MLFSELog, dictionary_corrupted, "");
2945  /* Every match length code must have non-zero probability */
2946  FORWARD_IF_ERROR( ZSTD_checkDictNCount(matchlengthNCount, matchlengthMaxValue, MaxML), "");
2948  bs->entropy.fse.matchlengthCTable,
2949  matchlengthNCount, matchlengthMaxValue, matchlengthLog,
2950  workspace, HUF_WORKSPACE_SIZE)),
2951  dictionary_corrupted, "");
2952  dictPtr += matchlengthHeaderSize;
2953  }
2954 
2955  { short litlengthNCount[MaxLL+1];
2956  unsigned litlengthMaxValue = MaxLL, litlengthLog;
2957  size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
2958  RETURN_ERROR_IF(FSE_isError(litlengthHeaderSize), dictionary_corrupted, "");
2959  RETURN_ERROR_IF(litlengthLog > LLFSELog, dictionary_corrupted, "");
2960  /* Every literal length code must have non-zero probability */
2961  FORWARD_IF_ERROR( ZSTD_checkDictNCount(litlengthNCount, litlengthMaxValue, MaxLL), "");
2963  bs->entropy.fse.litlengthCTable,
2964  litlengthNCount, litlengthMaxValue, litlengthLog,
2965  workspace, HUF_WORKSPACE_SIZE)),
2966  dictionary_corrupted, "");
2967  dictPtr += litlengthHeaderSize;
2968  }
2969 
2970  RETURN_ERROR_IF(dictPtr+12 > dictEnd, dictionary_corrupted, "");
2971  bs->rep[0] = MEM_readLE32(dictPtr+0);
2972  bs->rep[1] = MEM_readLE32(dictPtr+4);
2973  bs->rep[2] = MEM_readLE32(dictPtr+8);
2974  dictPtr += 12;
2975 
2976  return dictPtr - (const BYTE*)dict;
2977 }
size_t FSE_buildCTable_wksp(FSE_CTable *ct, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize)
Definition: fse_compress.c:69
#define HUF_isError
Definition: huf_compress.c:41
size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSVPtr, unsigned *tableLogPtr, const void *headerBuffer, size_t hbSize)
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
Definition: mem.h:346
#define FSE_isError
Definition: fse_compress.c:35
size_t HUF_readCTable(HUF_CElt *CTable, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize, unsigned *hasZeroWeights)
Definition: huf_compress.c:150
#define MaxML
#define MLFSELog
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91
#define OffFSELog
unsigned char BYTE
Definition: xxhash.c:193
#define MaxOff
static size_t ZSTD_checkDictNCount(short *normalizedCounter, unsigned dictMaxSymbolValue, unsigned maxSymbolValue)
#define FORWARD_IF_ERROR(err,...)
#define MaxLL
#define HUF_WORKSPACE_SIZE
Definition: huf.h:93
#define LLFSELog
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539

Referenced by ZSTD_loadZstdDictionary().

◆ ZSTD_matchState_dictMode()

MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode ( const ZSTD_matchState_t ms)

ZSTD_matchState_dictMode(): Inspects the provided matchState and figures out what dictMode should be passed to the compressor.

Definition at line 740 of file zstd_compress_internal.h.

741 {
742  return ZSTD_window_hasExtDict(ms->window) ?
743  ZSTD_extDict :
744  ms->dictMatchState != NULL ?
746  ZSTD_noDict;
747 }
MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
const ZSTD_matchState_t * dictMatchState
#define NULL
Definition: types.h:112

Referenced by ZSTD_buildSeqStore(), and ZSTD_ldm_blockCompress().

◆ ZSTD_minGain()

MEM_STATIC size_t ZSTD_minGain ( size_t  srcSize,
ZSTD_strategy  strat 
)

Definition at line 394 of file zstd_compress_internal.h.

395 {
396  U32 const minlog = (strat>=ZSTD_btultra) ? (U32)(strat) - 1 : 6;
399  return (srcSize >> minlog) + 2;
400 }
MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
#define assert(x)
Definition: debug.h:53
#define ZSTD_STATIC_ASSERT(c)
Definition: zstd_internal.h:45
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_targetCBlockSize_body(), ZSTD_compressLiterals(), and ZSTD_compressSequences().

◆ ZSTD_MLcode()

MEM_STATIC U32 ZSTD_MLcode ( U32  mlBase)

Definition at line 315 of file zstd_compress_internal.h.

316 {
317  static const BYTE ML_Code[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
318  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
319  32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37,
320  38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39,
321  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
322  41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
323  42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
324  42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 };
325  static const U32 ML_deltaCode = 36;
326  return (mlBase > 127) ? ZSTD_highbit32(mlBase) + ML_deltaCode : ML_Code[mlBase];
327 }
unsigned char BYTE
Definition: xxhash.c:193
MEM_STATIC U32 ZSTD_highbit32(U32 val)
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_getMatchPrice(), ZSTD_seqToCodes(), and ZSTD_updateStats().

◆ ZSTD_NbCommonBytes()

static unsigned ZSTD_NbCommonBytes ( size_t  val)
static

Definition at line 496 of file zstd_compress_internal.h.

497 {
498  if (MEM_isLittleEndian()) {
499  if (MEM_64bits()) {
500 # if defined(_MSC_VER) && defined(_WIN64)
501  unsigned long r = 0;
502  return _BitScanForward64( &r, (U64)val ) ? (unsigned)(r >> 3) : 0;
503 # elif defined(__GNUC__) && (__GNUC__ >= 4)
504  return (__builtin_ctzll((U64)val) >> 3);
505 # else
506  static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
507  0, 3, 1, 3, 1, 4, 2, 7,
508  0, 2, 3, 6, 1, 5, 3, 5,
509  1, 3, 4, 4, 2, 5, 6, 7,
510  7, 0, 1, 2, 3, 3, 4, 6,
511  2, 6, 5, 5, 3, 4, 5, 6,
512  7, 1, 2, 4, 6, 4, 4, 5,
513  7, 2, 6, 5, 7, 6, 7, 7 };
514  return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
515 # endif
516  } else { /* 32 bits */
517 # if defined(_MSC_VER)
518  unsigned long r=0;
519  return _BitScanForward( &r, (U32)val ) ? (unsigned)(r >> 3) : 0;
520 # elif defined(__GNUC__) && (__GNUC__ >= 3)
521  return (__builtin_ctz((U32)val) >> 3);
522 # else
523  static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
524  3, 2, 2, 1, 3, 2, 0, 1,
525  3, 3, 1, 2, 2, 2, 2, 0,
526  3, 1, 2, 0, 1, 0, 1, 1 };
527  return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
528 # endif
529  }
530  } else { /* Big Endian CPU */
531  if (MEM_64bits()) {
532 # if defined(_MSC_VER) && defined(_WIN64)
533  unsigned long r = 0;
534  return _BitScanReverse64( &r, val ) ? (unsigned)(r >> 3) : 0;
535 # elif defined(__GNUC__) && (__GNUC__ >= 4)
536  return (__builtin_clzll(val) >> 3);
537 # else
538  unsigned r;
539  const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
540  if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
541  if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
542  r += (!val);
543  return r;
544 # endif
545  } else { /* 32 bits */
546 # if defined(_MSC_VER)
547  unsigned long r = 0;
548  return _BitScanReverse( &r, (unsigned long)val ) ? (unsigned)(r >> 3) : 0;
549 # elif defined(__GNUC__) && (__GNUC__ >= 3)
550  return (__builtin_clz((U32)val) >> 3);
551 # else
552  unsigned r;
553  if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
554  r += (!val);
555  return r;
556 # endif
557  } }
558 }
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:57
MEM_STATIC unsigned MEM_isLittleEndian(void)
Definition: mem.h:186
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
MEM_STATIC unsigned MEM_64bits(void)
Definition: mem.h:184
GLuint GLfloat * val
Definition: glext.h:7180
signed int S32
Definition: xxhash.c:196
__kernel_size_t size_t
Definition: linux.h:237
unsigned long long U64
Definition: xxhash.c:197
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:180
unsigned int U32
Definition: xxhash.c:195
static unsigned(__cdecl *hash_bstr)(bstr_t s)

Referenced by ZSTD_count().

◆ ZSTD_noCompressBlock()

MEM_STATIC size_t ZSTD_noCompressBlock ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
U32  lastBlock 
)

Definition at line 369 of file zstd_compress_internal.h.

370 {
371  U32 const cBlockHeader24 = lastBlock + (((U32)bt_raw)<<1) + (U32)(srcSize << 3);
372  RETURN_ERROR_IF(srcSize + ZSTD_blockHeaderSize > dstCapacity,
373  dstSize_tooSmall, "dst buf too small for uncompressed block");
374  MEM_writeLE24(dst, cBlockHeader24);
375  memcpy((BYTE*)dst + ZSTD_blockHeaderSize, src, srcSize);
376  return ZSTD_blockHeaderSize + srcSize;
377 }
static const size_t ZSTD_blockHeaderSize
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
GLenum GLenum dst
Definition: glext.h:6340
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
Definition: mem.h:340
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compress_frameChunk(), ZSTD_compressBlock_targetCBlockSize_body(), and ZSTD_compressSubBlock_multi().

◆ ZSTD_referenceExternalSequences()

size_t ZSTD_referenceExternalSequences ( ZSTD_CCtx cctx,
rawSeq seq,
size_t  nbSeq 
)

Definition at line 2717 of file zstd_compress.c.

2718 {
2719  RETURN_ERROR_IF(cctx->stage != ZSTDcs_init, stage_wrong,
2720  "wrong cctx stage");
2721  RETURN_ERROR_IF(cctx->appliedParams.ldmParams.enableLdm,
2722  parameter_unsupported,
2723  "incompatible with ldm");
2724  cctx->externSeqStore.seq = seq;
2725  cctx->externSeqStore.size = nbSeq;
2726  cctx->externSeqStore.capacity = nbSeq;
2727  cctx->externSeqStore.pos = 0;
2728  return 0;
2729 }
rawSeqStore_t externSeqStore
ZSTD_compressionStage_e stage
ZSTD_CCtx_params appliedParams
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91

Referenced by ZSTD_resetCCtx_internal().

◆ ZSTD_reset_compressedBlockState()

void ZSTD_reset_compressedBlockState ( ZSTD_compressedBlockState_t bs)

Definition at line 1282 of file zstd_compress.c.

1283 {
1284  int i;
1285  for (i = 0; i < ZSTD_REP_NUM; ++i)
1286  bs->rep[i] = repStartValue[i];
1287  bs->entropy.huf.repeatMode = HUF_repeat_none;
1288  bs->entropy.fse.offcode_repeatMode = FSE_repeat_none;
1289  bs->entropy.fse.matchlength_repeatMode = FSE_repeat_none;
1290  bs->entropy.fse.litlength_repeatMode = FSE_repeat_none;
1291 }
static const U32 repStartValue[ZSTD_REP_NUM]
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
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
#define ZSTD_REP_NUM

Referenced by ZSTD_compress_insertDictionary(), ZSTD_initCDict_internal(), and ZSTD_resetCCtx_internal().

◆ ZSTD_resetSeqStore()

void ZSTD_resetSeqStore ( seqStore_t ssPtr)

Definition at line 2233 of file zstd_compress.c.

2234 {
2235  ssPtr->lit = ssPtr->litStart;
2236  ssPtr->sequences = ssPtr->sequencesStart;
2237  ssPtr->longLengthID = 0;
2238 }
seqDef * sequencesStart
seqDef * sequences
BYTE * litStart

Referenced by ZSTD_buildSeqStore(), and ZSTD_initStats_ultra().

◆ ZSTD_rleCompressBlock()

MEM_STATIC size_t ZSTD_rleCompressBlock ( void dst,
size_t  dstCapacity,
BYTE  src,
size_t  srcSize,
U32  lastBlock 
)

Definition at line 379 of file zstd_compress_internal.h.

380 {
381  BYTE* const op = (BYTE*)dst;
382  U32 const cBlockHeader = lastBlock + (((U32)bt_rle)<<1) + (U32)(srcSize << 3);
383  RETURN_ERROR_IF(dstCapacity < 4, dstSize_tooSmall, "");
384  MEM_writeLE24(op, cBlockHeader);
385  op[3] = src;
386  return 4;
387 }
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91
UINT op
Definition: effect.c:236
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
GLenum GLenum dst
Definition: glext.h:6340
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
Definition: mem.h:340
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_targetCBlockSize_body().

◆ ZSTD_rollingHash_append()

static U64 ZSTD_rollingHash_append ( U64  hash,
void const buf,
size_t  size 
)
static

ZSTD_rollingHash_append() : Add the buffer to the hash value.

Definition at line 661 of file zstd_compress_internal.h.

662 {
663  BYTE const* istart = (BYTE const*)buf;
664  size_t pos;
665  for (pos = 0; pos < size; ++pos) {
666  hash *= prime8bytes;
667  hash += istart[pos] + ZSTD_ROLL_HASH_CHAR_OFFSET;
668  }
669  return hash;
670 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int hash
Definition: main.c:58
GLsizeiptr size
Definition: glext.h:5919
static const U64 prime8bytes
unsigned char BYTE
Definition: xxhash.c:193
Definition: _hash_fun.h:40
#define ZSTD_ROLL_HASH_CHAR_OFFSET

Referenced by ZSTD_rollingHash_compute().

◆ ZSTD_rollingHash_compute()

MEM_STATIC U64 ZSTD_rollingHash_compute ( void const buf,
size_t  size 
)

ZSTD_rollingHash_compute() : Compute the rolling hash value of the buffer.

Definition at line 675 of file zstd_compress_internal.h.

676 {
677  return ZSTD_rollingHash_append(0, buf, size);
678 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
static U64 ZSTD_rollingHash_append(U64 hash, void const *buf, size_t size)

Referenced by ZSTD_ldm_fillHashTable(), and ZSTD_ldm_generateSequences_internal().

◆ ZSTD_rollingHash_primePower()

MEM_STATIC U64 ZSTD_rollingHash_primePower ( U32  length)

ZSTD_rollingHash_primePower() : Compute the primePower to be passed to ZSTD_rollingHash_rotate() for a hash over a window of length bytes.

Definition at line 684 of file zstd_compress_internal.h.

685 {
686  return ZSTD_ipow(prime8bytes, length - 1);
687 }
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const U64 prime8bytes
static U64 ZSTD_ipow(U64 base, U64 exponent)

Referenced by ZSTD_resetCCtx_internal().

◆ ZSTD_rollingHash_rotate()

MEM_STATIC U64 ZSTD_rollingHash_rotate ( U64  hash,
BYTE  toRemove,
BYTE  toAdd,
U64  primePower 
)

ZSTD_rollingHash_rotate() : Rotate the rolling hash by one byte.

Definition at line 692 of file zstd_compress_internal.h.

693 {
694  hash -= (toRemove + ZSTD_ROLL_HASH_CHAR_OFFSET) * primePower;
695  hash *= prime8bytes;
696  hash += toAdd + ZSTD_ROLL_HASH_CHAR_OFFSET;
697  return hash;
698 }
int hash
Definition: main.c:58
static const U64 prime8bytes
Definition: _hash_fun.h:40
#define ZSTD_ROLL_HASH_CHAR_OFFSET

Referenced by ZSTD_ldm_fillLdmHashTable(), and ZSTD_ldm_generateSequences_internal().

◆ ZSTD_safecopyLiterals()

static void ZSTD_safecopyLiterals ( BYTE op,
BYTE const ip,
BYTE const *const  iend,
BYTE const ilimit_w 
)
static

ZSTD_safecopyLiterals() : memcpy() function that won't read beyond more than WILDCOPY_OVERLENGTH bytes past ilimit_w. Only called when the sequence ends past ilimit_w, so it only needs to be optimized for single large copies.

Definition at line 422 of file zstd_compress_internal.h.

422  {
423  assert(iend > ilimit_w);
424  if (ip <= ilimit_w) {
425  ZSTD_wildcopy(op, ip, ilimit_w - ip, ZSTD_no_overlap);
426  op += ilimit_w - ip;
427  ip = ilimit_w;
428  }
429  while (ip < iend) *op++ = *ip++;
430 }
#define assert(x)
Definition: debug.h:53
int ip[4]
Definition: rtl.c:1176
Definition: dhcpd.h:61
MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
UINT op
Definition: effect.c:236

Referenced by ZSTD_storeSeq().

◆ ZSTD_selectBlockCompressor()

ZSTD_blockCompressor ZSTD_selectBlockCompressor ( ZSTD_strategy  strat,
ZSTD_dictMode_e  dictMode 
)

Definition at line 2183 of file zstd_compress.c.

2184 {
2185  static const ZSTD_blockCompressor blockCompressor[3][ZSTD_STRATEGY_MAX+1] = {
2186  { ZSTD_compressBlock_fast /* default for 0 */,
2196  { ZSTD_compressBlock_fast_extDict /* default for 0 */,
2206  { ZSTD_compressBlock_fast_dictMatchState /* default for 0 */,
2216  };
2217  ZSTD_blockCompressor selectedCompressor;
2218  ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
2219 
2221  selectedCompressor = blockCompressor[(int)dictMode][(int)strat];
2222  assert(selectedCompressor != NULL);
2223  return selectedCompressor;
2224 }
size_t ZSTD_compressBlock_lazy_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:913
MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
size_t ZSTD_compressBlock_btultra(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1134
size_t ZSTD_compressBlock_fast_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_fast.c:354
#define assert(x)
Definition: debug.h:53
size_t ZSTD_compressBlock_lazy2_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:906
size_t ZSTD_compressBlock_doubleFast_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
size_t ZSTD_compressBlock_btultra_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1177
size_t ZSTD_compressBlock_btopt_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1184
#define ZSTD_STATIC_ASSERT(c)
Definition: zstd_internal.h:45
size_t ZSTD_compressBlock_btopt(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1069
size_t ZSTD_compressBlock_btlazy2_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:1132
size_t ZSTD_compressBlock_lazy(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:885
size_t ZSTD_compressBlock_lazy2(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:878
size_t ZSTD_compressBlock_fast(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_fast.c:186
size_t ZSTD_compressBlock_btlazy2_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:899
size_t ZSTD_compressBlock_doubleFast_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
size_t(* ZSTD_blockCompressor)(ZSTD_matchState_t *bs, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
size_t ZSTD_compressBlock_btultra_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1191
size_t ZSTD_compressBlock_greedy(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:892
size_t ZSTD_compressBlock_btopt_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1170
size_t ZSTD_compressBlock_greedy_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:920
size_t ZSTD_compressBlock_btlazy2(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:871
#define NULL
Definition: types.h:112
size_t ZSTD_compressBlock_fast_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_fast.c:479
size_t ZSTD_compressBlock_doubleFast(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
size_t ZSTD_compressBlock_greedy_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:1109
size_t ZSTD_compressBlock_lazy_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:1116
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
size_t ZSTD_compressBlock_lazy2_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
Definition: zstd_lazy.c:1124
size_t ZSTD_compressBlock_btultra2(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], const void *src, size_t srcSize)
Definition: zstd_opt.c:1142

Referenced by ZSTD_buildSeqStore(), and ZSTD_ldm_blockCompress().

◆ ZSTD_storeSeq()

HINT_INLINE UNUSED_ATTR void ZSTD_storeSeq ( seqStore_t seqStorePtr,
size_t  litLength,
const BYTE literals,
const BYTE litLimit,
U32  offCode,
size_t  mlBase 
)

ZSTD_storeSeq() : Store a sequence (litlen, litPtr, offCode and mlBase) into seqStore_t. offCode : distance to match + ZSTD_REP_MOVE (values <= ZSTD_REP_MOVE are repCodes). mlBase : matchLength - MINMATCH Allowed to overread literals up to litLimit.

Definition at line 439 of file zstd_compress_internal.h.

440 {
441  BYTE const* const litLimit_w = litLimit - WILDCOPY_OVERLENGTH;
442  BYTE const* const litEnd = literals + litLength;
443 #if defined(DEBUGLEVEL) && (DEBUGLEVEL >= 6)
444  static const BYTE* g_start = NULL;
445  if (g_start==NULL) g_start = (const BYTE*)literals; /* note : index only works for compression within a single segment */
446  { U32 const pos = (U32)((const BYTE*)literals - g_start);
447  DEBUGLOG(6, "Cpos%7u :%3u literals, match%4u bytes at offCode%7u",
448  pos, (U32)litLength, (U32)mlBase+MINMATCH, (U32)offCode);
449  }
450 #endif
451  assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
452  /* copy Literals */
453  assert(seqStorePtr->maxNbLit <= 128 KB);
454  assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
455  assert(literals + litLength <= litLimit);
456  if (litEnd <= litLimit_w) {
457  /* Common case we can use wildcopy.
458  * First copy 16 bytes, because literals are likely short.
459  */
461  ZSTD_copy16(seqStorePtr->lit, literals);
462  if (litLength > 16) {
463  ZSTD_wildcopy(seqStorePtr->lit+16, literals+16, (ptrdiff_t)litLength-16, ZSTD_no_overlap);
464  }
465  } else {
466  ZSTD_safecopyLiterals(seqStorePtr->lit, literals, litEnd, litLimit_w);
467  }
468  seqStorePtr->lit += litLength;
469 
470  /* literal Length */
471  if (litLength>0xFFFF) {
472  assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
473  seqStorePtr->longLengthID = 1;
474  seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
475  }
476  seqStorePtr->sequences[0].litLength = (U16)litLength;
477 
478  /* match offset */
479  seqStorePtr->sequences[0].offset = offCode + 1;
480 
481  /* match Length */
482  if (mlBase>0xFFFF) {
483  assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
484  seqStorePtr->longLengthID = 2;
485  seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
486  }
487  seqStorePtr->sequences[0].matchLength = (U16)mlBase;
488 
489  seqStorePtr->sequences++;
490 }
#define WILDCOPY_OVERLENGTH
U16 matchLength
#define assert(x)
Definition: debug.h:53
seqDef * sequencesStart
#define DEBUGLOG(l,...)
Definition: debug.h:106
seqDef * sequences
static void ZSTD_safecopyLiterals(BYTE *op, BYTE const *ip, BYTE const *const iend, BYTE const *ilimit_w)
MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
static void ZSTD_copy16(void *dst, const void *src)
size_t maxNbSeq
unsigned char BYTE
Definition: xxhash.c:193
unsigned short U16
Definition: xxhash.c:194
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define MINMATCH
size_t maxNbLit
#define KB
Definition: setuplib.h:55
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast_dictMatchState_generic(), ZSTD_compressBlock_fast_extDict_generic(), ZSTD_compressBlock_fast_generic(), ZSTD_compressBlock_lazy_extDict_generic(), ZSTD_compressBlock_lazy_generic(), ZSTD_compressBlock_opt_generic(), and ZSTD_ldm_blockCompress().

◆ ZSTD_updateRep()

MEM_STATIC repcodes_t ZSTD_updateRep ( U32 const  rep[3],
U32 const  offset,
U32 const  ll0 
)

Definition at line 333 of file zstd_compress_internal.h.

334 {
335  repcodes_t newReps;
336  if (offset >= ZSTD_REP_NUM) { /* full offset */
337  newReps.rep[2] = rep[1];
338  newReps.rep[1] = rep[0];
339  newReps.rep[0] = offset - ZSTD_REP_MOVE;
340  } else { /* repcode */
341  U32 const repCode = offset + ll0;
342  if (repCode > 0) { /* note : if repCode==0, no change */
343  U32 const currentOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
344  newReps.rep[2] = (repCode >= 2) ? rep[1] : rep[2];
345  newReps.rep[1] = rep[0];
346  newReps.rep[0] = currentOffset;
347  } else { /* repCode == 0 */
348  memcpy(&newReps, rep, sizeof(newReps));
349  }
350  }
351  return newReps;
352 }
#define ZSTD_REP_MOVE
GLintptr offset
Definition: glext.h:5920
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int U32
Definition: xxhash.c:195
#define ZSTD_REP_NUM

Referenced by ZSTD_compressBlock_opt_generic(), and ZSTD_compressSubBlock_multi().

◆ ZSTD_window_clear()

MEM_STATIC void ZSTD_window_clear ( ZSTD_window_t window)

ZSTD_window_clear(): Clears the window containing the history by simply setting it to empty.

Definition at line 717 of file zstd_compress_internal.h.

718 {
719  size_t const endT = (size_t)(window->nextSrc - window->base);
720  U32 const end = (U32)endT;
721 
722  window->lowLimit = end;
723  window->dictLimit = end;
724 }
__kernel_size_t size_t
Definition: linux.h:237
GLuint GLuint end
Definition: gl.h:1545
static IHTMLWindow2 * window
Definition: events.c:77
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_invalidateMatchState(), ZSTD_resetCCtx_byAttachingCDict(), and ZSTD_resetCCtx_internal().

◆ ZSTD_window_correctOverflow()

MEM_STATIC U32 ZSTD_window_correctOverflow ( ZSTD_window_t window,
U32  cycleLog,
U32  maxDist,
void const src 
)

ZSTD_window_correctOverflow(): Reduces the indices to protect from index overflow. Returns the correction made to the indices, which must be applied to every stored index.

The least significant cycleLog bits of the indices must remain the same, which may be 0. Every index up to maxDist in the past must be valid. NOTE: (maxDist & cycleMask) must be zero.

Definition at line 771 of file zstd_compress_internal.h.

773 {
774  /* preemptive overflow correction:
775  * 1. correction is large enough:
776  * lowLimit > (3<<29) ==> current > 3<<29 + 1<<windowLog
777  * 1<<windowLog <= newCurrent < 1<<chainLog + 1<<windowLog
778  *
779  * current - newCurrent
780  * > (3<<29 + 1<<windowLog) - (1<<windowLog + 1<<chainLog)
781  * > (3<<29) - (1<<chainLog)
782  * > (3<<29) - (1<<30) (NOTE: chainLog <= 30)
783  * > 1<<29
784  *
785  * 2. (ip+ZSTD_CHUNKSIZE_MAX - cctx->base) doesn't overflow:
786  * After correction, current is less than (1<<chainLog + 1<<windowLog).
787  * In 64-bit mode we are safe, because we have 64-bit ptrdiff_t.
788  * In 32-bit mode we are safe, because (chainLog <= 29), so
789  * ip+ZSTD_CHUNKSIZE_MAX - cctx->base < 1<<32.
790  * 3. (cctx->lowLimit + 1<<windowLog) < 1<<32:
791  * windowLog <= 31 ==> 3<<29 + 1<<windowLog < 7<<29 < 1<<32.
792  */
793  U32 const cycleMask = (1U << cycleLog) - 1;
794  U32 const current = (U32)((BYTE const*)src - window->base);
795  U32 const currentCycle0 = current & cycleMask;
796  /* Exclude zero so that newCurrent - maxDist >= 1. */
797  U32 const currentCycle1 = currentCycle0 == 0 ? (1U << cycleLog) : currentCycle0;
798  U32 const newCurrent = currentCycle1 + maxDist;
799  U32 const correction = current - newCurrent;
800  assert((maxDist & cycleMask) == 0);
801  assert(current > newCurrent);
802  /* Loose bound, should be around 1<<29 (see above) */
803  assert(correction > 1<<28);
804 
805  window->base += correction;
806  window->dictBase += correction;
807  if (window->lowLimit <= correction) window->lowLimit = 1;
808  else window->lowLimit -= correction;
809  if (window->dictLimit <= correction) window->dictLimit = 1;
810  else window->dictLimit -= correction;
811 
812  /* Ensure we can still reference the full window. */
813  assert(newCurrent >= maxDist);
814  assert(newCurrent - maxDist >= 1);
815  /* Ensure that lowLimit and dictLimit didn't underflow. */
816  assert(window->lowLimit <= newCurrent);
817  assert(window->dictLimit <= newCurrent);
818 
819  DEBUGLOG(4, "Correction of 0x%x bytes to lowLimit=0x%x", correction,
820  window->lowLimit);
821  return correction;
822 }
#define U(x)
Definition: wordpad.c:45
#define assert(x)
Definition: debug.h:53
#define DEBUGLOG(l,...)
Definition: debug.h:106
struct task_struct * current
Definition: linux.c:32
GLenum src
Definition: glext.h:6340
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_ldm_generateSequences(), and ZSTD_overflowCorrectIfNeeded().

◆ ZSTD_window_enforceMaxDist()

MEM_STATIC void ZSTD_window_enforceMaxDist ( ZSTD_window_t window,
const void blockEnd,
U32  maxDist,
U32 loadedDictEndPtr,
const ZSTD_matchState_t **  dictMatchStatePtr 
)

ZSTD_window_enforceMaxDist(): Updates lowLimit so that: (srcEnd - base) - lowLimit == maxDist + loadedDictEnd

It ensures index is valid as long as index >= lowLimit. This must be called before a block compression call.

loadedDictEnd is only defined if a dictionary is in use for current compression. As the name implies, loadedDictEnd represents the index at end of dictionary. The value lies within context's referential, it can be directly compared to blockEndIdx.

If loadedDictEndPtr is NULL, no dictionary is in use, and we use loadedDictEnd == 0. If loadedDictEndPtr is not NULL, we set it to zero after updating lowLimit. This is because dictionaries are allowed to be referenced fully as long as the last byte of the dictionary is in the window. Once input has progressed beyond window size, dictionary cannot be referenced anymore.

In normal dict mode, the dictionary lies between lowLimit and dictLimit. In dictMatchState mode, lowLimit and dictLimit are the same, and the dictionary is below them. forceWindow and dictMatchState are therefore incompatible.

Definition at line 848 of file zstd_compress_internal.h.

853 {
854  U32 const blockEndIdx = (U32)((BYTE const*)blockEnd - window->base);
855  U32 const loadedDictEnd = (loadedDictEndPtr != NULL) ? *loadedDictEndPtr : 0;
856  DEBUGLOG(5, "ZSTD_window_enforceMaxDist: blockEndIdx=%u, maxDist=%u, loadedDictEnd=%u",
857  (unsigned)blockEndIdx, (unsigned)maxDist, (unsigned)loadedDictEnd);
858 
859  /* - When there is no dictionary : loadedDictEnd == 0.
860  In which case, the test (blockEndIdx > maxDist) is merely to avoid
861  overflowing next operation `newLowLimit = blockEndIdx - maxDist`.
862  - When there is a standard dictionary :
863  Index referential is copied from the dictionary,
864  which means it starts from 0.
865  In which case, loadedDictEnd == dictSize,
866  and it makes sense to compare `blockEndIdx > maxDist + dictSize`
867  since `blockEndIdx` also starts from zero.
868  - When there is an attached dictionary :
869  loadedDictEnd is expressed within the referential of the context,
870  so it can be directly compared against blockEndIdx.
871  */
872  if (blockEndIdx > maxDist + loadedDictEnd) {
873  U32 const newLowLimit = blockEndIdx - maxDist;
874  if (window->lowLimit < newLowLimit) window->lowLimit = newLowLimit;
875  if (window->dictLimit < window->lowLimit) {
876  DEBUGLOG(5, "Update dictLimit to match lowLimit, from %u to %u",
877  (unsigned)window->dictLimit, (unsigned)window->lowLimit);
878  window->dictLimit = window->lowLimit;
879  }
880  /* On reaching window size, dictionaries are invalidated */
881  if (loadedDictEndPtr) *loadedDictEndPtr = 0;
882  if (dictMatchStatePtr) *dictMatchStatePtr = NULL;
883  }
884 }
#define DEBUGLOG(l,...)
Definition: debug.h:106
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
#define NULL
Definition: types.h:112
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_ldm_generateSequences().

◆ ZSTD_window_hasExtDict()

MEM_STATIC U32 ZSTD_window_hasExtDict ( ZSTD_window_t const  window)

ZSTD_window_hasExtDict(): Returns non-zero if the window has a non-empty extDict.

Definition at line 730 of file zstd_compress_internal.h.

731 {
732  return window.lowLimit < window.dictLimit;
733 }
static IHTMLWindow2 * window
Definition: events.c:77

Referenced by ZSTD_invalidateRepCodes(), ZSTD_ldm_generateSequences_internal(), and ZSTD_matchState_dictMode().

◆ ZSTD_window_init()

MEM_STATIC void ZSTD_window_init ( ZSTD_window_t window)

Definition at line 921 of file zstd_compress_internal.h.

921  {
922  memset(window, 0, sizeof(*window));
923  window->base = (BYTE const*)"";
924  window->dictBase = (BYTE const*)"";
925  window->dictLimit = 1; /* start from 1, so that 1st position is valid */
926  window->lowLimit = 1; /* it ensures first and later CCtx usages compress the same */
927  window->nextSrc = window->base + 1; /* see issue #1241 */
928 }
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ZSTD_reset_matchState(), and ZSTD_resetCCtx_internal().

◆ ZSTD_window_needOverflowCorrection()

MEM_STATIC U32 ZSTD_window_needOverflowCorrection ( ZSTD_window_t const  window,
void const srcEnd 
)

ZSTD_window_needOverflowCorrection(): Returns non-zero if the indices are getting too large and need overflow protection.

Definition at line 754 of file zstd_compress_internal.h.

756 {
757  U32 const current = (U32)((BYTE const*)srcEnd - window.base);
758  return current > ZSTD_CURRENT_MAX;
759 }
struct task_struct * current
Definition: linux.c:32
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
#define ZSTD_CURRENT_MAX
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_ldm_generateSequences(), and ZSTD_overflowCorrectIfNeeded().

◆ ZSTD_window_update()

MEM_STATIC U32 ZSTD_window_update ( ZSTD_window_t window,
void const src,
size_t  srcSize 
)

ZSTD_window_update(): Updates the window by appending [src, src + srcSize) to the window. If it is not contiguous, the current prefix becomes the extDict, and we forget about the extDict. Handles overlap of the prefix and extDict. Returns non-zero if the segment is contiguous.

Definition at line 937 of file zstd_compress_internal.h.

939 {
940  BYTE const* const ip = (BYTE const*)src;
941  U32 contiguous = 1;
942  DEBUGLOG(5, "ZSTD_window_update");
943  if (srcSize == 0)
944  return contiguous;
945  assert(window->base != NULL);
946  assert(window->dictBase != NULL);
947  /* Check if blocks follow each other */
948  if (src != window->nextSrc) {
949  /* not contiguous */
950  size_t const distanceFromBase = (size_t)(window->nextSrc - window->base);
951  DEBUGLOG(5, "Non contiguous blocks, new segment starts at %u", window->dictLimit);
952  window->lowLimit = window->dictLimit;
953  assert(distanceFromBase == (size_t)(U32)distanceFromBase); /* should never overflow */
954  window->dictLimit = (U32)distanceFromBase;
955  window->dictBase = window->base;
956  window->base = ip - distanceFromBase;
957  /* ms->nextToUpdate = window->dictLimit; */
958  if (window->dictLimit - window->lowLimit < HASH_READ_SIZE) window->lowLimit = window->dictLimit; /* too small extDict */
959  contiguous = 0;
960  }
961  window->nextSrc = ip + srcSize;
962  /* if input and dictionary overlap : reduce dictionary (area presumed modified by input) */
963  if ( (ip+srcSize > window->dictBase + window->lowLimit)
964  & (ip < window->dictBase + window->dictLimit)) {
965  ptrdiff_t const highInputIdx = (ip + srcSize) - window->dictBase;
966  U32 const lowLimitMax = (highInputIdx > (ptrdiff_t)window->dictLimit) ? window->dictLimit : (U32)highInputIdx;
967  window->lowLimit = lowLimitMax;
968  DEBUGLOG(5, "Overlapping extDict and input : new lowLimit = %u", window->lowLimit);
969  }
970  return contiguous;
971 }
#define assert(x)
Definition: debug.h:53
#define DEBUGLOG(l,...)
Definition: debug.h:106
__kernel_size_t size_t
Definition: linux.h:237
Definition: dhcpd.h:61
#define HASH_READ_SIZE
GLenum src
Definition: glext.h:6340
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressContinue_internal(), and ZSTD_loadDictionaryContent().

◆ ZSTD_writeLastEmptyBlock()

size_t ZSTD_writeLastEmptyBlock ( void dst,
size_t  dstCapacity 
)

Definition at line 2707 of file zstd_compress.c.

2708 {
2709  RETURN_ERROR_IF(dstCapacity < ZSTD_blockHeaderSize, dstSize_tooSmall,
2710  "dst buf is too small to write frame trailer empty block.");
2711  { U32 const cBlockHeader24 = 1 /*lastBlock*/ + (((U32)bt_raw)<<1); /* 0 size */
2712  MEM_writeLE24(dst, cBlockHeader24);
2713  return ZSTD_blockHeaderSize;
2714  }
2715 }
static const size_t ZSTD_blockHeaderSize
#define RETURN_ERROR_IF(cond, err,...)
Definition: zstd_internal.h:91
GLenum GLenum dst
Definition: glext.h:6340
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
Definition: mem.h:340
unsigned int U32
Definition: xxhash.c:195

Variable Documentation

◆ prime3bytes

const U32 prime3bytes = 506832829U
static

Definition at line 605 of file zstd_compress_internal.h.

Referenced by ZSTD_hash3().

◆ prime4bytes

const U32 prime4bytes = 2654435761U
static

Definition at line 609 of file zstd_compress_internal.h.

Referenced by ZSTD_hash4().

◆ prime5bytes

const U64 prime5bytes = 889523592379ULL
static

Definition at line 613 of file zstd_compress_internal.h.

Referenced by ZSTD_hash5().

◆ prime6bytes

const U64 prime6bytes = 227718039650203ULL
static

Definition at line 617 of file zstd_compress_internal.h.

Referenced by ZSTD_hash6().

◆ prime7bytes

const U64 prime7bytes = 58295818150454627ULL
static

Definition at line 621 of file zstd_compress_internal.h.

Referenced by ZSTD_hash7().

◆ prime8bytes

const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL
static