ReactOS  0.4.15-dev-1184-g23e04ae
zstd_compress_internal.h File Reference
#include "zstd_internal.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_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  ZSTD_CCtx_params_s
 
struct  ZSTD_CCtx_s
 

Macros

#define kSearchStrength   8
 
#define HASH_READ_SIZE   8
 
#define ZSTD_DUBT_UNSORTED_MARK
 
#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)
 

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_dictAttachPref_e { ZSTD_dictDefaultAttach = 0, ZSTD_dictForceAttach = 1, ZSTD_dictForceCopy = -1 }
 
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 void ZSTD_storeSeq (seqStore_t *seqStorePtr, size_t litLength, const void *literals, U32 offsetCode, 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)
 
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, void const *srcEnd, U32 maxDist, U32 *loadedDictEndPtr, const ZSTD_matchState_t **dictMatchStatePtr)
 
MEM_STATIC U32 ZSTD_window_update (ZSTD_window_t *window, void const *src, size_t srcSize)
 
MEM_STATIC double ZSTD_fWeight (U32 rawStat)
 
MEM_STATIC void ZSTD_debugTable (const U32 *table, U32 max)
 
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, ZSTD_CCtx_params params, unsigned long long pledgedSrcSize)
 
void ZSTD_resetSeqStore (seqStore_t *ssPtr)
 
size_t ZSTD_compressStream_generic (ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input, ZSTD_EndDirective const flushMode)
 
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, 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, 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)
 

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 35 of file zstd_compress_internal.h.

◆ kSearchStrength

#define kSearchStrength   8

Definition at line 34 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 507 of file zstd_compress_internal.h.

◆ ZSTD_CURRENT_MAX

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

Definition at line 505 of file zstd_compress_internal.h.

◆ ZSTD_DUBT_UNSORTED_MARK

#define ZSTD_DUBT_UNSORTED_MARK
Value:
1 /* For btlazy2 strategy, index 1 now 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.
Additionnally, 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 misdhandled after table re-use with a different strategy
Constant required by ZSTD_compressBlock_btlazy2() and ZSTD_reduceTable_internal() */

Definition at line 36 of file zstd_compress_internal.h.

Typedef Documentation

◆ 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 266 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 49 of file zstd_compress_internal.h.

◆ ZSTD_dictAttachPref_e

Enumerator
ZSTD_dictDefaultAttach 
ZSTD_dictForceAttach 
ZSTD_dictForceCopy 

Definition at line 51 of file zstd_compress_internal.h.

◆ ZSTD_dictMode_e

Enumerator
ZSTD_noDict 
ZSTD_extDict 
ZSTD_dictMatchState 

Definition at line 263 of file zstd_compress_internal.h.

◆ ZSTD_dictTableLoadMethod_e

◆ ZSTD_OptPrice_e

Enumerator
zop_dynamic 
zop_predef 

Definition at line 95 of file zstd_compress_internal.h.

Function Documentation

◆ 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,
ZSTD_CCtx_params  params 
)

Definition at line 3135 of file zstd_compress.c.

3141 {
3142  DEBUGLOG(4, "ZSTD_compress_advanced_internal (srcSize:%u)", (U32)srcSize);
3144  dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL,
3145  params, srcSize, ZSTDb_not_buffered) );
3146  return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);
3147 }
#define DEBUGLOG(l,...)
Definition: debug.h:115
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
#define CHECK_F(f)
Definition: fse_compress.c:661
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
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, ZSTD_CCtx_params params, U64 pledgedSrcSize, ZSTD_buffered_policy_e zbuff)
size_t ZSTD_compressEnd(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
unsigned int U32
Definition: xxhash.c:195

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,
ZSTD_CCtx_params  params,
unsigned long long  pledgedSrcSize 
)

Definition at line 2989 of file zstd_compress.c.

2996 {
2997  DEBUGLOG(4, "ZSTD_compressBegin_advanced_internal: wlog=%u", params.cParams.windowLog);
2998  /* compression parameters verification and optimization */
2999  CHECK_F( ZSTD_checkCParams(params.cParams) );
3000  return ZSTD_compressBegin_internal(cctx,
3001  dict, dictSize, dictContentType, dtlm,
3002  cdict,
3003  params, pledgedSrcSize,
3005 }
#define DEBUGLOG(l,...)
Definition: debug.h:115
GLenum const GLfloat * params
Definition: glext.h:5645
#define CHECK_F(f)
Definition: fse_compress.c:661
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
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, ZSTD_CCtx_params params, U64 pledgedSrcSize, ZSTD_buffered_policy_e zbuff)

Referenced by ZSTD_compressBegin_advanced().

◆ ZSTD_compressStream_generic()

size_t ZSTD_compressStream_generic ( ZSTD_CStream zcs,
ZSTD_outBuffer output,
ZSTD_inBuffer input,
ZSTD_EndDirective const  flushMode 
)

ZSTD_compressStream_generic() : Private use only. To be called from zstdmt_compress.c in single-thread mode.

ZSTD_compressStream_generic(): internal function for all compressStream() variants and *compress_generic() non-static, because can be called from zstdmt_compress.c

Returns
: hint size for next input

Definition at line 3627 of file zstd_compress.c.

3631 {
3632  const char* const istart = (const char*)input->src;
3633  const char* const iend = istart + input->size;
3634  const char* ip = istart + input->pos;
3635  char* const ostart = (char*)output->dst;
3636  char* const oend = ostart + output->size;
3637  char* op = ostart + output->pos;
3638  U32 someMoreWork = 1;
3639 
3640  /* check expectations */
3641  DEBUGLOG(5, "ZSTD_compressStream_generic, flush=%u", (U32)flushMode);
3642  assert(zcs->inBuff != NULL);
3643  assert(zcs->inBuffSize > 0);
3644  assert(zcs->outBuff != NULL);
3645  assert(zcs->outBuffSize > 0);
3646  assert(output->pos <= output->size);
3647  assert(input->pos <= input->size);
3648 
3649  while (someMoreWork) {
3650  switch(zcs->streamStage)
3651  {
3652  case zcss_init:
3653  /* call ZSTD_initCStream() first ! */
3654  return ERROR(init_missing);
3655 
3656  case zcss_load:
3657  if ( (flushMode == ZSTD_e_end)
3658  && ((size_t)(oend-op) >= ZSTD_compressBound(iend-ip)) /* enough dstCapacity */
3659  && (zcs->inBuffPos == 0) ) {
3660  /* shortcut to compression pass directly into output buffer */
3661  size_t const cSize = ZSTD_compressEnd(zcs,
3662  op, oend-op, ip, iend-ip);
3663  DEBUGLOG(4, "ZSTD_compressEnd : %u", (U32)cSize);
3664  if (ZSTD_isError(cSize)) return cSize;
3665  ip = iend;
3666  op += cSize;
3667  zcs->frameEnded = 1;
3668  ZSTD_CCtx_reset(zcs);
3669  someMoreWork = 0; break;
3670  }
3671  /* complete loading into inBuffer */
3672  { size_t const toLoad = zcs->inBuffTarget - zcs->inBuffPos;
3673  size_t const loaded = ZSTD_limitCopy(
3674  zcs->inBuff + zcs->inBuffPos, toLoad,
3675  ip, iend-ip);
3676  zcs->inBuffPos += loaded;
3677  ip += loaded;
3678  if ( (flushMode == ZSTD_e_continue)
3679  && (zcs->inBuffPos < zcs->inBuffTarget) ) {
3680  /* not enough input to fill full block : stop here */
3681  someMoreWork = 0; break;
3682  }
3683  if ( (flushMode == ZSTD_e_flush)
3684  && (zcs->inBuffPos == zcs->inToCompress) ) {
3685  /* empty */
3686  someMoreWork = 0; break;
3687  }
3688  }
3689  /* compress current block (note : this stage cannot be stopped in the middle) */
3690  DEBUGLOG(5, "stream compression stage (flushMode==%u)", flushMode);
3691  { void* cDst;
3692  size_t cSize;
3693  size_t const iSize = zcs->inBuffPos - zcs->inToCompress;
3694  size_t oSize = oend-op;
3695  unsigned const lastBlock = (flushMode == ZSTD_e_end) && (ip==iend);
3696  if (oSize >= ZSTD_compressBound(iSize))
3697  cDst = op; /* compress into output buffer, to skip flush stage */
3698  else
3699  cDst = zcs->outBuff, oSize = zcs->outBuffSize;
3700  cSize = lastBlock ?
3701  ZSTD_compressEnd(zcs, cDst, oSize,
3702  zcs->inBuff + zcs->inToCompress, iSize) :
3703  ZSTD_compressContinue(zcs, cDst, oSize,
3704  zcs->inBuff + zcs->inToCompress, iSize);
3705  if (ZSTD_isError(cSize)) return cSize;
3706  zcs->frameEnded = lastBlock;
3707  /* prepare next block */
3708  zcs->inBuffTarget = zcs->inBuffPos + zcs->blockSize;
3709  if (zcs->inBuffTarget > zcs->inBuffSize)
3710  zcs->inBuffPos = 0, zcs->inBuffTarget = zcs->blockSize;
3711  DEBUGLOG(5, "inBuffTarget:%u / inBuffSize:%u",
3712  (U32)zcs->inBuffTarget, (U32)zcs->inBuffSize);
3713  if (!lastBlock)
3714  assert(zcs->inBuffTarget <= zcs->inBuffSize);
3715  zcs->inToCompress = zcs->inBuffPos;
3716  if (cDst == op) { /* no need to flush */
3717  op += cSize;
3718  if (zcs->frameEnded) {
3719  DEBUGLOG(5, "Frame completed directly in outBuffer");
3720  someMoreWork = 0;
3721  ZSTD_CCtx_reset(zcs);
3722  }
3723  break;
3724  }
3725  zcs->outBuffContentSize = cSize;
3726  zcs->outBuffFlushedSize = 0;
3727  zcs->streamStage = zcss_flush; /* pass-through to flush stage */
3728  }
3729  /* fall-through */
3730  case zcss_flush:
3731  DEBUGLOG(5, "flush stage");
3732  { size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
3733  size_t const flushed = ZSTD_limitCopy(op, oend-op,
3734  zcs->outBuff + zcs->outBuffFlushedSize, toFlush);
3735  DEBUGLOG(5, "toFlush: %u into %u ==> flushed: %u",
3736  (U32)toFlush, (U32)(oend-op), (U32)flushed);
3737  op += flushed;
3738  zcs->outBuffFlushedSize += flushed;
3739  if (toFlush!=flushed) {
3740  /* flush not fully completed, presumably because dst is too small */
3741  assert(op==oend);
3742  someMoreWork = 0;
3743  break;
3744  }
3745  zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0;
3746  if (zcs->frameEnded) {
3747  DEBUGLOG(5, "Frame completed on flush");
3748  someMoreWork = 0;
3749  ZSTD_CCtx_reset(zcs);
3750  break;
3751  }
3752  zcs->streamStage = zcss_load;
3753  break;
3754  }
3755 
3756  default: /* impossible */
3757  assert(0);
3758  }
3759  }
3760 
3761  input->pos = ip - istart;
3762  output->pos = op - ostart;
3763  if (zcs->frameEnded) return 0;
3764  { size_t hintInSize = zcs->inBuffTarget - zcs->inBuffPos;
3765  if (hintInSize==0) hintInSize = zcs->blockSize;
3766  return hintInSize;
3767  }
3768 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
#define ERROR(name)
Definition: error_private.h:53
size_t ZSTD_compressContinue(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
#define assert(x)
Definition: debug.h:53
MEM_STATIC size_t ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
#define DEBUGLOG(l,...)
Definition: debug.h:115
smooth NULL
Definition: ftsmooth.c:416
Definition: dhcpd.h:61
UINT op
Definition: effect.c:224
BOOL loaded
Definition: xmlview.c:54
void ZSTD_CCtx_reset(ZSTD_CCtx *cctx)
#define ZSTD_isError
GLenum GLenum GLenum input
Definition: glext.h:9031
ZSTD_cStreamStage streamStage
size_t ZSTD_compressEnd(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
unsigned int U32
Definition: xxhash.c:195
size_t ZSTD_compressBound(size_t srcSize)
Definition: zstd_compress.c:33

Referenced by ZSTD_compress_generic(), ZSTD_compressStream(), ZSTD_endStream(), and ZSTD_flushStream().

◆ ZSTD_count()

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

Definition at line 420 of file zstd_compress_internal.h.

421 {
422  const BYTE* const pStart = pIn;
423  const BYTE* const pInLoopLimit = pInLimit - (sizeof(size_t)-1);
424 
425  if (pIn < pInLoopLimit) {
426  { size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
427  if (diff) return ZSTD_NbCommonBytes(diff); }
428  pIn+=sizeof(size_t); pMatch+=sizeof(size_t);
429  while (pIn < pInLoopLimit) {
430  size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
431  if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
432  pIn += ZSTD_NbCommonBytes(diff);
433  return (size_t)(pIn - pStart);
434  } }
435  if (MEM_64bits() && (pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
436  if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
437  if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
438  return (size_t)(pIn - pStart);
439 }
MEM_STATIC size_t MEM_readST(const void *memPtr)
Definition: mem.h:179
MEM_STATIC unsigned MEM_64bits(void)
Definition: mem.h:111
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:169
unsigned char BYTE
Definition: xxhash.c:193
MEM_STATIC U16 MEM_read16(const void *memPtr)
Definition: mem.h:164

Referenced by ZSTD_compressBlock_doubleFast_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 446 of file zstd_compress_internal.h.

448 {
449  const BYTE* const vEnd = MIN( ip + (mEnd - match), iEnd);
450  size_t const matchLength = ZSTD_count(ip, match, vEnd);
451  if (match + matchLength != mEnd) return matchLength;
452  DEBUGLOG(7, "ZSTD_count_2segments: found a 2-parts match (current length==%zu)", matchLength);
453  DEBUGLOG(7, "distance from match beginning to end dictionary = %zi", mEnd - match);
454  DEBUGLOG(7, "distance from current pos to end buffer = %zi", iEnd - ip);
455  DEBUGLOG(7, "next byte : ip==%02X, istart==%02X", ip[matchLength], *iStart);
456  DEBUGLOG(7, "final match length = %zu", matchLength + ZSTD_count(ip+matchLength, iStart, iEnd));
457  return matchLength + ZSTD_count(ip+matchLength, iStart, iEnd);
458 }
Definition: match.c:28
_In_ UINT iStart
Definition: wingdi.h:3619
T MIN(T a, T b)
Definition: polytest.cpp:79
#define DEBUGLOG(l,...)
Definition: debug.h:115
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_extDict_generic(), ZSTD_compressBlock_fast_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_debugTable()

MEM_STATIC void ZSTD_debugTable ( const U32 table,
U32  max 
)

Definition at line 707 of file zstd_compress_internal.h.

708 {
709  unsigned u, sum;
710  for (u=0, sum=0; u<=max; u++) sum += table[u];
711  DEBUGLOG(2, "total nb elts: %u", sum);
712  for (u=0; u<=max; u++) {
713  DEBUGLOG(2, "%2u: %5u (%.2f)",
715  }
716 }
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
#define max(a, b)
Definition: svc.c:63
#define DEBUGLOG(l,...)
Definition: debug.h:115
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
MEM_STATIC double ZSTD_fWeight(U32 rawStat)

◆ ZSTD_fWeight()

MEM_STATIC double ZSTD_fWeight ( U32  rawStat)

Definition at line 694 of file zstd_compress_internal.h.

695 {
696  U32 const fp_accuracy = 8;
697  U32 const fp_multiplier = (1 << fp_accuracy);
698  U32 const stat = rawStat + 1;
699  U32 const hb = ZSTD_highbit32(stat);
700  U32 const BWeight = hb * fp_multiplier;
701  U32 const FWeight = (stat << fp_accuracy) >> hb;
702  U32 const weight = BWeight + FWeight;
703  assert(hb + fp_accuracy < 31);
704  return (double)weight / fp_multiplier;
705 }
#define assert(x)
Definition: debug.h:53
Definition: stat.h:55
weight
Definition: sortkey.c:156
MEM_STATIC U32 ZSTD_highbit32(U32 val)
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_debugTable().

◆ ZSTD_getCParamsFromCCtxParams()

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

Definition at line 768 of file zstd_compress.c.

770 {
771  ZSTD_compressionParameters cParams = ZSTD_getCParams(CCtxParams->compressionLevel, srcSizeHint, dictSize);
772  if (CCtxParams->ldmParams.enableLdm) cParams.windowLog = ZSTD_LDM_DEFAULT_WINDOW_LOG;
773  if (CCtxParams->cParams.windowLog) cParams.windowLog = CCtxParams->cParams.windowLog;
774  if (CCtxParams->cParams.hashLog) cParams.hashLog = CCtxParams->cParams.hashLog;
775  if (CCtxParams->cParams.chainLog) cParams.chainLog = CCtxParams->cParams.chainLog;
776  if (CCtxParams->cParams.searchLog) cParams.searchLog = CCtxParams->cParams.searchLog;
777  if (CCtxParams->cParams.searchLength) cParams.searchLength = CCtxParams->cParams.searchLength;
778  if (CCtxParams->cParams.targetLength) cParams.targetLength = CCtxParams->cParams.targetLength;
779  if (CCtxParams->cParams.strategy) cParams.strategy = CCtxParams->cParams.strategy;
780  assert(!ZSTD_checkCParams(cParams));
781  return ZSTD_adjustCParams_internal(cParams, srcSizeHint, dictSize);
782 }
#define assert(x)
Definition: debug.h:53
#define ZSTD_LDM_DEFAULT_WINDOW_LOG
Definition: zstd_ldm.h:24
static ZSTD_compressionParameters ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)

Referenced by ZSTD_CCtx_loadDictionary_advanced(), ZSTD_compress_generic(), ZSTD_estimateCCtxSize_usingCCtxParams(), ZSTD_initCStream_internal(), and ZSTD_resetCStream_internal().

◆ ZSTD_getCParamsFromCDict()

ZSTD_compressionParameters ZSTD_getCParamsFromCDict ( const ZSTD_CDict cdict)

ZSTD_getCParamsFromCDict() : as the name implies

Definition at line 3370 of file zstd_compress.c.

3371 {
3372  assert(cdict != NULL);
3373  return cdict->matchState.cParams;
3374 }
ZSTD_matchState_t matchState
Definition: zstd_compress.c:47
#define assert(x)
Definition: debug.h:53
ZSTD_compressionParameters cParams
smooth NULL
Definition: ftsmooth.c:416

Referenced by ZSTD_compressBegin_usingCDict_advanced(), ZSTD_initCStream_internal(), and ZSTD_initCStream_usingCDict_advanced().

◆ ZSTD_hash3()

static U32 ZSTD_hash3 ( U32  u,
U32  h 
)
static

Definition at line 465 of file zstd_compress_internal.h.

465 { 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 466 of file zstd_compress_internal.h.

466 { return ZSTD_hash3(MEM_readLE32(ptr), h); } /* only in zstd_opt.h */
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
Definition: mem.h:273
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 469 of file zstd_compress_internal.h.

469 { 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 470 of file zstd_compress_internal.h.

470 { 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:169
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 473 of file zstd_compress_internal.h.

473 { 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 474 of file zstd_compress_internal.h.

474 { 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:289
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 477 of file zstd_compress_internal.h.

477 { 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 478 of file zstd_compress_internal.h.

478 { return ZSTD_hash6(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:289
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 481 of file zstd_compress_internal.h.

481 { 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 482 of file zstd_compress_internal.h.

482 { return ZSTD_hash7(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:289
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 485 of file zstd_compress_internal.h.

485 { 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 486 of file zstd_compress_internal.h.

486 { return ZSTD_hash8(MEM_readLE64(p), h); }
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
Definition: mem.h:289
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 488 of file zstd_compress_internal.h.

489 {
490  switch(mls)
491  {
492  default:
493  case 4: return ZSTD_hash4Ptr(p, hBits);
494  case 5: return ZSTD_hash5Ptr(p, hBits);
495  case 6: return ZSTD_hash6Ptr(p, hBits);
496  case 7: return ZSTD_hash7Ptr(p, hBits);
497  case 8: return ZSTD_hash8Ptr(p, hBits);
498  }
499 }
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_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,
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 3518 of file zstd_compress.c.

3521 {
3522  DEBUGLOG(4, "ZSTD_initCStream_internal");
3523  params.cParams = ZSTD_getCParamsFromCCtxParams(&params, pledgedSrcSize, dictSize);
3525  assert(!((dict) && (cdict))); /* either dict or cdict, not both */
3526 
3527  if (dict && dictSize >= 8) {
3528  DEBUGLOG(4, "loading dictionary of size %u", (U32)dictSize);
3529  if (zcs->staticSize) { /* static CCtx : never uses malloc */
3530  /* incompatible with internal cdict creation */
3531  return ERROR(memory_allocation);
3532  }
3533  ZSTD_freeCDict(zcs->cdictLocal);
3534  zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
3535  ZSTD_dlm_byCopy, ZSTD_dct_auto,
3536  params.cParams, zcs->customMem);
3537  zcs->cdict = zcs->cdictLocal;
3538  if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
3539  } else {
3540  if (cdict) {
3541  params.cParams = ZSTD_getCParamsFromCDict(cdict); /* cParams are enforced from cdict; it includes windowLog */
3542  }
3543  ZSTD_freeCDict(zcs->cdictLocal);
3544  zcs->cdictLocal = NULL;
3545  zcs->cdict = cdict;
3546  }
3547 
3548  return ZSTD_resetCStream_internal(zcs, NULL, 0, ZSTD_dct_auto, zcs->cdict, params, pledgedSrcSize);
3549 }
#define ERROR(name)
Definition: error_private.h:53
#define assert(x)
Definition: debug.h:53
ZSTD_CDict * cdictLocal
#define DEBUGLOG(l,...)
Definition: debug.h:115
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
ZSTD_CDict * ZSTD_createCDict_advanced(const void *dictBuffer, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_compressionParameters cParams, ZSTD_customMem customMem)
ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict *cdict)
#define ZSTD_isError
ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(const ZSTD_CCtx_params *CCtxParams, U64 srcSizeHint, size_t dictSize)
const ZSTD_CDict * cdict
ZSTD_customMem customMem
unsigned int U32
Definition: xxhash.c:195
static size_t ZSTD_resetCStream_internal(ZSTD_CStream *cctx, const void *const dict, size_t const dictSize, ZSTD_dictContentType_e const dictContentType, const ZSTD_CDict *const cdict, ZSTD_CCtx_params params, unsigned long long const pledgedSrcSize)
size_t ZSTD_freeCDict(ZSTD_CDict *cdict)

Referenced by ZSTD_initCStream_advanced(), ZSTD_initCStream_srcSize(), ZSTD_initCStream_usingCDict_advanced(), and ZSTD_initCStream_usingDict().

◆ ZSTD_LLcode()

MEM_STATIC U32 ZSTD_LLcode ( U32  litLength)

Definition at line 272 of file zstd_compress_internal.h.

273 {
274  static const BYTE LL_Code[64] = { 0, 1, 2, 3, 4, 5, 6, 7,
275  8, 9, 10, 11, 12, 13, 14, 15,
276  16, 16, 17, 17, 18, 18, 19, 19,
277  20, 20, 20, 20, 21, 21, 21, 21,
278  22, 22, 22, 22, 22, 22, 22, 22,
279  23, 23, 23, 23, 23, 23, 23, 23,
280  24, 24, 24, 24, 24, 24, 24, 24,
281  24, 24, 24, 24, 24, 24, 24, 24 };
282  static const U32 LL_deltaCode = 19;
283  return (litLength > 63) ? ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
284 }
unsigned char BYTE
Definition: xxhash.c:193
MEM_STATIC U32 ZSTD_highbit32(U32 val)
unsigned int U32
Definition: xxhash.c:195

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

◆ 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 538 of file zstd_compress_internal.h.

539 {
540  return ZSTD_window_hasExtDict(ms->window) ?
541  ZSTD_extDict :
542  ms->dictMatchState != NULL ?
544  ZSTD_noDict;
545 }
MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
smooth NULL
Definition: ftsmooth.c:416
const ZSTD_matchState_t * dictMatchState

Referenced by ZSTD_compressBlock_internal(), and ZSTD_ldm_blockCompress().

◆ ZSTD_MLcode()

MEM_STATIC U32 ZSTD_MLcode ( U32  mlBase)

Definition at line 289 of file zstd_compress_internal.h.

290 {
291  static const BYTE ML_Code[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
292  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
293  32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37,
294  38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39,
295  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
296  41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
297  42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
298  42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 };
299  static const U32 ML_deltaCode = 36;
300  return (mlBase > 127) ? ZSTD_highbit32(mlBase) + ML_deltaCode : ML_Code[mlBase];
301 }
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 351 of file zstd_compress_internal.h.

352 {
353  if (MEM_isLittleEndian()) {
354  if (MEM_64bits()) {
355 # if defined(_MSC_VER) && defined(_WIN64)
356  unsigned long r = 0;
357  _BitScanForward64( &r, (U64)val );
358  return (unsigned)(r>>3);
359 # elif defined(__GNUC__) && (__GNUC__ >= 4)
360  return (__builtin_ctzll((U64)val) >> 3);
361 # else
362  static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
363  0, 3, 1, 3, 1, 4, 2, 7,
364  0, 2, 3, 6, 1, 5, 3, 5,
365  1, 3, 4, 4, 2, 5, 6, 7,
366  7, 0, 1, 2, 3, 3, 4, 6,
367  2, 6, 5, 5, 3, 4, 5, 6,
368  7, 1, 2, 4, 6, 4, 4, 5,
369  7, 2, 6, 5, 7, 6, 7, 7 };
370  return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
371 # endif
372  } else { /* 32 bits */
373 # if defined(_MSC_VER)
374  unsigned long r=0;
375  _BitScanForward( &r, (U32)val );
376  return (unsigned)(r>>3);
377 # elif defined(__GNUC__) && (__GNUC__ >= 3)
378  return (__builtin_ctz((U32)val) >> 3);
379 # else
380  static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
381  3, 2, 2, 1, 3, 2, 0, 1,
382  3, 3, 1, 2, 2, 2, 2, 0,
383  3, 1, 2, 0, 1, 0, 1, 1 };
384  return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
385 # endif
386  }
387  } else { /* Big Endian CPU */
388  if (MEM_64bits()) {
389 # if defined(_MSC_VER) && defined(_WIN64)
390  unsigned long r = 0;
391  _BitScanReverse64( &r, val );
392  return (unsigned)(r>>3);
393 # elif defined(__GNUC__) && (__GNUC__ >= 4)
394  return (__builtin_clzll(val) >> 3);
395 # else
396  unsigned r;
397  const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
398  if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
399  if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
400  r += (!val);
401  return r;
402 # endif
403  } else { /* 32 bits */
404 # if defined(_MSC_VER)
405  unsigned long r = 0;
406  _BitScanReverse( &r, (unsigned long)val );
407  return (unsigned)(r>>3);
408 # elif defined(__GNUC__) && (__GNUC__ >= 3)
409  return (__builtin_clz((U32)val) >> 3);
410 # else
411  unsigned r;
412  if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
413  r += (!val);
414  return r;
415 # endif
416  } }
417 }
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:57
MEM_STATIC unsigned MEM_isLittleEndian(void)
Definition: mem.h:113
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
MEM_STATIC unsigned MEM_64bits(void)
Definition: mem.h:111
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

Referenced by ZSTD_count().

◆ ZSTD_referenceExternalSequences()

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

Definition at line 2652 of file zstd_compress.c.

2653 {
2654  if (cctx->stage != ZSTDcs_init)
2655  return ERROR(stage_wrong);
2656  if (cctx->appliedParams.ldmParams.enableLdm)
2657  return ERROR(parameter_unsupported);
2658  cctx->externSeqStore.seq = seq;
2659  cctx->externSeqStore.size = nbSeq;
2660  cctx->externSeqStore.capacity = nbSeq;
2661  cctx->externSeqStore.pos = 0;
2662  return 0;
2663 }
rawSeqStore_t externSeqStore
#define ERROR(name)
Definition: error_private.h:53
ZSTD_compressionStage_e stage
ZSTD_CCtx_params appliedParams

Referenced by ZSTD_continueCCtx(), and ZSTD_resetCCtx_internal().

◆ ZSTD_resetSeqStore()

void ZSTD_resetSeqStore ( seqStore_t ssPtr)

Definition at line 2411 of file zstd_compress.c.

2412 {
2413  ssPtr->lit = ssPtr->litStart;
2414  ssPtr->sequences = ssPtr->sequencesStart;
2415  ssPtr->longLengthID = 0;
2416 }
seqDef * sequencesStart
seqDef * sequences
BYTE * litStart

Referenced by ZSTD_compressBlock_btultra(), and ZSTD_compressBlock_internal().

◆ ZSTD_selectBlockCompressor()

ZSTD_blockCompressor ZSTD_selectBlockCompressor ( ZSTD_strategy  strat,
ZSTD_dictMode_e  dictMode 
)

Definition at line 2363 of file zstd_compress.c.

2364 {
2365  static const ZSTD_blockCompressor blockCompressor[3][(unsigned)ZSTD_btultra+1] = {
2366  { ZSTD_compressBlock_fast /* default for 0 */,
2375  { ZSTD_compressBlock_fast_extDict /* default for 0 */,
2384  { ZSTD_compressBlock_fast_dictMatchState /* default for 0 */,
2393  };
2394  ZSTD_blockCompressor selectedCompressor;
2395  ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
2396 
2397  assert((U32)strat >= (U32)ZSTD_fast);
2398  assert((U32)strat <= (U32)ZSTD_btultra);
2399  selectedCompressor = blockCompressor[(int)dictMode][(U32)strat];
2400  assert(selectedCompressor != NULL);
2401  return selectedCompressor;
2402 }
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:886
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:1071
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:254
#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:879
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:1113
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:1120
#define ZSTD_STATIC_ASSERT(c)
Definition: zstd_internal.h:43
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:1040
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:1093
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:858
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:851
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:233
smooth NULL
Definition: ftsmooth.c:416
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:872
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:1127
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:865
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:1106
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:893
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:844
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:373
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:1070
unsigned int U32
Definition: xxhash.c:195
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:1077
static unsigned(__cdecl *hash_bstr)(bstr_t s)
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:1085

Referenced by ZSTD_compressBlock_internal(), and ZSTD_ldm_blockCompress().

◆ ZSTD_storeSeq()

MEM_STATIC void ZSTD_storeSeq ( seqStore_t seqStorePtr,
size_t  litLength,
const void literals,
U32  offsetCode,
size_t  mlBase 
)

ZSTD_storeSeq() : Store a sequence (literal length, literals, offset code and match length code) into seqStore_t. offsetCode : distance to match + 3 (values 1-3 are repCodes). mlBase : matchLength - MINMATCH

Definition at line 308 of file zstd_compress_internal.h.

309 {
310 #if defined(DEBUGLEVEL) && (DEBUGLEVEL >= 6)
311  static const BYTE* g_start = NULL;
312  if (g_start==NULL) g_start = (const BYTE*)literals; /* note : index only works for compression within a single segment */
313  { U32 const pos = (U32)((const BYTE*)literals - g_start);
314  DEBUGLOG(6, "Cpos%7u :%3u literals, match%4u bytes at offCode%7u",
315  pos, (U32)litLength, (U32)mlBase+MINMATCH, (U32)offsetCode);
316  }
317 #endif
318  assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
319  /* copy Literals */
320  assert(seqStorePtr->maxNbLit <= 128 KB);
321  assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
322  ZSTD_wildcopy(seqStorePtr->lit, literals, litLength);
323  seqStorePtr->lit += litLength;
324 
325  /* literal Length */
326  if (litLength>0xFFFF) {
327  assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
328  seqStorePtr->longLengthID = 1;
329  seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
330  }
331  seqStorePtr->sequences[0].litLength = (U16)litLength;
332 
333  /* match offset */
334  seqStorePtr->sequences[0].offset = offsetCode + 1;
335 
336  /* match Length */
337  if (mlBase>0xFFFF) {
338  assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
339  seqStorePtr->longLengthID = 2;
340  seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
341  }
342  seqStorePtr->sequences[0].matchLength = (U16)mlBase;
343 
344  seqStorePtr->sequences++;
345 }
U16 matchLength
#define assert(x)
Definition: debug.h:53
seqDef * sequencesStart
#define DEBUGLOG(l,...)
Definition: debug.h:115
seqDef * sequences
smooth NULL
Definition: ftsmooth.c:416
MEM_STATIC void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length)
size_t maxNbSeq
unsigned char BYTE
Definition: xxhash.c:193
unsigned short U16
Definition: xxhash.c:194
#define MINMATCH
Definition: zstd_internal.h:96
size_t maxNbLit
#define KB
Definition: setuplib.h:54
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_doubleFast_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_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 515 of file zstd_compress_internal.h.

516 {
517  size_t const endT = (size_t)(window->nextSrc - window->base);
518  U32 const end = (U32)endT;
519 
520  window->lowLimit = end;
521  window->dictLimit = end;
522 }
GLuint GLuint end
Definition: gl.h:1545
__kernel_size_t size_t
Definition: linux.h:237
static IHTMLWindow2 * window
Definition: events.c:77
unsigned int U32
Definition: xxhash.c:195

Referenced by ZSTD_continueCCtx(), 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 569 of file zstd_compress_internal.h.

571 {
572  /* preemptive overflow correction:
573  * 1. correction is large enough:
574  * lowLimit > (3<<29) ==> current > 3<<29 + 1<<windowLog
575  * 1<<windowLog <= newCurrent < 1<<chainLog + 1<<windowLog
576  *
577  * current - newCurrent
578  * > (3<<29 + 1<<windowLog) - (1<<windowLog + 1<<chainLog)
579  * > (3<<29) - (1<<chainLog)
580  * > (3<<29) - (1<<30) (NOTE: chainLog <= 30)
581  * > 1<<29
582  *
583  * 2. (ip+ZSTD_CHUNKSIZE_MAX - cctx->base) doesn't overflow:
584  * After correction, current is less than (1<<chainLog + 1<<windowLog).
585  * In 64-bit mode we are safe, because we have 64-bit ptrdiff_t.
586  * In 32-bit mode we are safe, because (chainLog <= 29), so
587  * ip+ZSTD_CHUNKSIZE_MAX - cctx->base < 1<<32.
588  * 3. (cctx->lowLimit + 1<<windowLog) < 1<<32:
589  * windowLog <= 31 ==> 3<<29 + 1<<windowLog < 7<<29 < 1<<32.
590  */
591  U32 const cycleMask = (1U << cycleLog) - 1;
592  U32 const current = (U32)((BYTE const*)src - window->base);
593  U32 const newCurrent = (current & cycleMask) + maxDist;
594  U32 const correction = current - newCurrent;
595  assert((maxDist & cycleMask) == 0);
596  assert(current > newCurrent);
597  /* Loose bound, should be around 1<<29 (see above) */
598  assert(correction > 1<<28);
599 
600  window->base += correction;
601  window->dictBase += correction;
602  window->lowLimit -= correction;
603  window->dictLimit -= correction;
604 
605  DEBUGLOG(4, "Correction of 0x%x bytes to lowLimit=0x%x", correction,
606  window->lowLimit);
607  return correction;
608 }
#define U(x)
Definition: wordpad.c:45
#define assert(x)
Definition: debug.h:53
#define DEBUGLOG(l,...)
Definition: debug.h:115
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
struct task_struct * current
Definition: linux.c:32

Referenced by ZSTD_compress_frameChunk(), ZSTD_compressContinue_internal(), and ZSTD_ldm_generateSequences().

◆ ZSTD_window_enforceMaxDist()

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

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

This allows a simple check that index >= lowLimit to see if index is valid. This must be called before a block compression call, with srcEnd as the block source end.

If loadedDictEndPtr is not NULL, we set it to zero once we update lowLimit. This is because dictionaries are allowed to be referenced as long as the last byte of the dictionary is in the window, but once they are out of range, they cannot be referenced. If loadedDictEndPtr is NULL, we use loadedDictEnd == 0.

In normal dict mode, the dict is 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 629 of file zstd_compress_internal.h.

633 {
634  U32 const current = (U32)((BYTE const*)srcEnd - window->base);
635  U32 loadedDictEnd = loadedDictEndPtr != NULL ? *loadedDictEndPtr : 0;
636  DEBUGLOG(5, "ZSTD_window_enforceMaxDist: current=%u, maxDist=%u", current, maxDist);
637  if (current > maxDist + loadedDictEnd) {
638  U32 const newLowLimit = current - maxDist;
639  if (window->lowLimit < newLowLimit) window->lowLimit = newLowLimit;
640  if (window->dictLimit < window->lowLimit) {
641  DEBUGLOG(5, "Update dictLimit to match lowLimit, from %u to %u",
642  window->dictLimit, window->lowLimit);
643  window->dictLimit = window->lowLimit;
644  }
645  if (loadedDictEndPtr)
646  *loadedDictEndPtr = 0;
647  if (dictMatchStatePtr)
648  *dictMatchStatePtr = NULL;
649  }
650 }
#define DEBUGLOG(l,...)
Definition: debug.h:115
smooth NULL
Definition: ftsmooth.c:416
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
unsigned int U32
Definition: xxhash.c:195
struct task_struct * current
Definition: linux.c:32

Referenced by ZSTD_compress_frameChunk(), and 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 528 of file zstd_compress_internal.h.

529 {
530  return window.lowLimit < window.dictLimit;
531 }
static IHTMLWindow2 * window
Definition: events.c:77

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

◆ 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 552 of file zstd_compress_internal.h.

554 {
555  U32 const current = (U32)((BYTE const*)srcEnd - window.base);
556  return current > ZSTD_CURRENT_MAX;
557 }
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
struct task_struct * current
Definition: linux.c:32

Referenced by ZSTD_compress_frameChunk(), ZSTD_compressContinue_internal(), and ZSTD_ldm_generateSequences().

◆ 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 659 of file zstd_compress_internal.h.

661 {
662  BYTE const* const ip = (BYTE const*)src;
663  U32 contiguous = 1;
664  DEBUGLOG(5, "ZSTD_window_update");
665  /* Check if blocks follow each other */
666  if (src != window->nextSrc) {
667  /* not contiguous */
668  size_t const distanceFromBase = (size_t)(window->nextSrc - window->base);
669  DEBUGLOG(5, "Non contiguous blocks, new segment starts at %u", window->dictLimit);
670  window->lowLimit = window->dictLimit;
671  assert(distanceFromBase == (size_t)(U32)distanceFromBase); /* should never overflow */
672  window->dictLimit = (U32)distanceFromBase;
673  window->dictBase = window->base;
674  window->base = ip - distanceFromBase;
675  // ms->nextToUpdate = window->dictLimit;
676  if (window->dictLimit - window->lowLimit < HASH_READ_SIZE) window->lowLimit = window->dictLimit; /* too small extDict */
677  contiguous = 0;
678  }
679  window->nextSrc = ip + srcSize;
680  /* if input and dictionary overlap : reduce dictionary (area presumed modified by input) */
681  if ( (ip+srcSize > window->dictBase + window->lowLimit)
682  & (ip < window->dictBase + window->dictLimit)) {
683  ptrdiff_t const highInputIdx = (ip + srcSize) - window->dictBase;
684  U32 const lowLimitMax = (highInputIdx > (ptrdiff_t)window->dictLimit) ? window->dictLimit : (U32)highInputIdx;
685  window->lowLimit = lowLimitMax;
686  DEBUGLOG(5, "Overlapping extDict and input : new lowLimit = %u", window->lowLimit);
687  }
688  return contiguous;
689 }
#define assert(x)
Definition: debug.h:53
#define DEBUGLOG(l,...)
Definition: debug.h:115
__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
__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 2643 of file zstd_compress.c.

2644 {
2645  if (dstCapacity < ZSTD_blockHeaderSize) return ERROR(dstSize_tooSmall);
2646  { U32 const cBlockHeader24 = 1 /*lastBlock*/ + (((U32)bt_raw)<<1); /* 0 size */
2647  MEM_writeLE24(dst, cBlockHeader24);
2648  return ZSTD_blockHeaderSize;
2649  }
2650 }
#define ERROR(name)
Definition: error_private.h:53
static const size_t ZSTD_blockHeaderSize
Definition: zstd_internal.h:85
GLenum GLenum dst
Definition: glext.h:6340
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
Definition: mem.h:267
unsigned int U32
Definition: xxhash.c:195

Variable Documentation

◆ prime3bytes

const U32 prime3bytes = 506832829U
static

Definition at line 464 of file zstd_compress_internal.h.

Referenced by ZSTD_hash3().

◆ prime4bytes

const U32 prime4bytes = 2654435761U
static

Definition at line 468 of file zstd_compress_internal.h.

Referenced by ZSTD_hash4().

◆ prime5bytes

const U64 prime5bytes = 889523592379ULL
static

Definition at line 472 of file zstd_compress_internal.h.

Referenced by ZSTD_hash5().

◆ prime6bytes

const U64 prime6bytes = 227718039650203ULL
static

Definition at line 476 of file zstd_compress_internal.h.

Referenced by ZSTD_hash6().

◆ prime7bytes

const U64 prime7bytes = 58295818150454627ULL
static

Definition at line 480 of file zstd_compress_internal.h.

Referenced by ZSTD_hash7().

◆ prime8bytes

const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL
static