Lines Matching refs:cctx

97 static void ZSTD_initCCtx(ZSTD_CCtx* cctx, ZSTD_customMem memManager)  in ZSTD_initCCtx()  argument
99 assert(cctx != NULL); in ZSTD_initCCtx()
100 ZSTD_memset(cctx, 0, sizeof(*cctx)); in ZSTD_initCCtx()
101 cctx->customMem = memManager; in ZSTD_initCCtx()
102 cctx->bmi2 = ZSTD_cpuSupportsBmi2(); in ZSTD_initCCtx()
103 { size_t const err = ZSTD_CCtx_reset(cctx, ZSTD_reset_parameters); in ZSTD_initCCtx()
114 { ZSTD_CCtx* const cctx = (ZSTD_CCtx*)ZSTD_customMalloc(sizeof(ZSTD_CCtx), customMem); in ZSTD_createCCtx_advanced() local
115 if (!cctx) return NULL; in ZSTD_createCCtx_advanced()
116 ZSTD_initCCtx(cctx, customMem); in ZSTD_createCCtx_advanced()
117 return cctx; in ZSTD_createCCtx_advanced()
124 ZSTD_CCtx* cctx; in ZSTD_initStaticCCtx() local
129 cctx = (ZSTD_CCtx*)ZSTD_cwksp_reserve_object(&ws, sizeof(ZSTD_CCtx)); in ZSTD_initStaticCCtx()
130 if (cctx == NULL) return NULL; in ZSTD_initStaticCCtx()
132 ZSTD_memset(cctx, 0, sizeof(ZSTD_CCtx)); in ZSTD_initStaticCCtx()
133 ZSTD_cwksp_move(&cctx->workspace, &ws); in ZSTD_initStaticCCtx()
134 cctx->staticSize = workspaceSize; in ZSTD_initStaticCCtx()
137 …if (!ZSTD_cwksp_check_available(&cctx->workspace, ENTROPY_WORKSPACE_SIZE + 2 * sizeof(ZSTD_compres… in ZSTD_initStaticCCtx()
138cctx->blockState.prevCBlock = (ZSTD_compressedBlockState_t*)ZSTD_cwksp_reserve_object(&cctx->works… in ZSTD_initStaticCCtx()
139cctx->blockState.nextCBlock = (ZSTD_compressedBlockState_t*)ZSTD_cwksp_reserve_object(&cctx->works… in ZSTD_initStaticCCtx()
140cctx->entropyWorkspace = (U32*)ZSTD_cwksp_reserve_object(&cctx->workspace, ENTROPY_WORKSPACE_SIZE); in ZSTD_initStaticCCtx()
141 cctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid()); in ZSTD_initStaticCCtx()
142 return cctx; in ZSTD_initStaticCCtx()
148 static void ZSTD_clearAllDicts(ZSTD_CCtx* cctx) in ZSTD_clearAllDicts() argument
150 ZSTD_customFree(cctx->localDict.dictBuffer, cctx->customMem); in ZSTD_clearAllDicts()
151 ZSTD_freeCDict(cctx->localDict.cdict); in ZSTD_clearAllDicts()
152 ZSTD_memset(&cctx->localDict, 0, sizeof(cctx->localDict)); in ZSTD_clearAllDicts()
153 ZSTD_memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); in ZSTD_clearAllDicts()
154 cctx->cdict = NULL; in ZSTD_clearAllDicts()
164 static void ZSTD_freeCCtxContent(ZSTD_CCtx* cctx) in ZSTD_freeCCtxContent() argument
166 assert(cctx != NULL); in ZSTD_freeCCtxContent()
167 assert(cctx->staticSize == 0); in ZSTD_freeCCtxContent()
168 ZSTD_clearAllDicts(cctx); in ZSTD_freeCCtxContent()
170 ZSTDMT_freeCCtx(cctx->mtctx); cctx->mtctx = NULL; in ZSTD_freeCCtxContent()
172 ZSTD_cwksp_free(&cctx->workspace, cctx->customMem); in ZSTD_freeCCtxContent()
175 size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx) in ZSTD_freeCCtx() argument
177 if (cctx==NULL) return 0; /* support free on NULL */ in ZSTD_freeCCtx()
178 RETURN_ERROR_IF(cctx->staticSize, memory_allocation, in ZSTD_freeCCtx()
181 int cctxInWorkspace = ZSTD_cwksp_owns_buffer(&cctx->workspace, cctx); in ZSTD_freeCCtx()
182 ZSTD_freeCCtxContent(cctx); in ZSTD_freeCCtx()
184 ZSTD_customFree(cctx, cctx->customMem); in ZSTD_freeCCtx()
191 static size_t ZSTD_sizeof_mtctx(const ZSTD_CCtx* cctx) in ZSTD_sizeof_mtctx() argument
194 return ZSTDMT_sizeof_CCtx(cctx->mtctx); in ZSTD_sizeof_mtctx()
196 (void)cctx; in ZSTD_sizeof_mtctx()
202 size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx) in ZSTD_sizeof_CCtx() argument
204 if (cctx==NULL) return 0; /* support sizeof on NULL */ in ZSTD_sizeof_CCtx()
206 return (cctx->workspace.workspace == cctx ? 0 : sizeof(*cctx)) in ZSTD_sizeof_CCtx()
207 + ZSTD_cwksp_sizeof(&cctx->workspace) in ZSTD_sizeof_CCtx()
208 + ZSTD_sizeof_localDict(cctx->localDict) in ZSTD_sizeof_CCtx()
209 + ZSTD_sizeof_mtctx(cctx); in ZSTD_sizeof_CCtx()
644 size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value) in ZSTD_CCtx_setParameter() argument
647 if (cctx->streamStage != zcss_init) { in ZSTD_CCtx_setParameter()
649 cctx->cParamsChanged = 1; in ZSTD_CCtx_setParameter()
657 RETURN_ERROR_IF((value!=0) && cctx->staticSize, parameter_unsupported, in ZSTD_CCtx_setParameter()
698 return ZSTD_CCtxParams_setParameter(&cctx->requestedParams, param, value); in ZSTD_CCtx_setParameter()
924 size_t ZSTD_CCtx_getParameter(ZSTD_CCtx const* cctx, ZSTD_cParameter param, int* value) in ZSTD_CCtx_getParameter() argument
926 return ZSTD_CCtxParams_getParameter(&cctx->requestedParams, param, value); in ZSTD_CCtx_getParameter()
1065 ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params) in ZSTD_CCtx_setParametersUsingCCtxParams() argument
1068 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_setParametersUsingCCtxParams()
1070 RETURN_ERROR_IF(cctx->cdict, stage_wrong, in ZSTD_CCtx_setParametersUsingCCtxParams()
1074 cctx->requestedParams = *params; in ZSTD_CCtx_setParametersUsingCCtxParams()
1078 size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize) in ZSTD_CCtx_setPledgedSrcSize() argument
1081 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_setPledgedSrcSize()
1083 cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1; in ZSTD_CCtx_setPledgedSrcSize()
1100 static size_t ZSTD_initLocalDict(ZSTD_CCtx* cctx) in ZSTD_initLocalDict() argument
1102 ZSTD_localDict* const dl = &cctx->localDict; in ZSTD_initLocalDict()
1111 assert(cctx->cdict == dl->cdict); in ZSTD_initLocalDict()
1116 assert(cctx->cdict == NULL); in ZSTD_initLocalDict()
1117 assert(cctx->prefixDict.dict == NULL); in ZSTD_initLocalDict()
1124 &cctx->requestedParams, in ZSTD_initLocalDict()
1125 cctx->customMem); in ZSTD_initLocalDict()
1127 cctx->cdict = dl->cdict; in ZSTD_initLocalDict()
1132 ZSTD_CCtx* cctx, const void* dict, size_t dictSize, in ZSTD_CCtx_loadDictionary_advanced() argument
1135 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_loadDictionary_advanced()
1138 ZSTD_clearAllDicts(cctx); /* in case one already exists */ in ZSTD_CCtx_loadDictionary_advanced()
1142 cctx->localDict.dict = dict; in ZSTD_CCtx_loadDictionary_advanced()
1145 RETURN_ERROR_IF(cctx->staticSize, memory_allocation, in ZSTD_CCtx_loadDictionary_advanced()
1147 dictBuffer = ZSTD_customMalloc(dictSize, cctx->customMem); in ZSTD_CCtx_loadDictionary_advanced()
1150 cctx->localDict.dictBuffer = dictBuffer; in ZSTD_CCtx_loadDictionary_advanced()
1151 cctx->localDict.dict = dictBuffer; in ZSTD_CCtx_loadDictionary_advanced()
1153 cctx->localDict.dictSize = dictSize; in ZSTD_CCtx_loadDictionary_advanced()
1154 cctx->localDict.dictContentType = dictContentType; in ZSTD_CCtx_loadDictionary_advanced()
1159 ZSTD_CCtx* cctx, const void* dict, size_t dictSize) in ZSTD_CCtx_loadDictionary_byReference() argument
1162 cctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto); in ZSTD_CCtx_loadDictionary_byReference()
1165 size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize) in ZSTD_CCtx_loadDictionary() argument
1168 cctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto); in ZSTD_CCtx_loadDictionary()
1172 size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict) in ZSTD_CCtx_refCDict() argument
1174 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_refCDict()
1177 ZSTD_clearAllDicts(cctx); in ZSTD_CCtx_refCDict()
1178 cctx->cdict = cdict; in ZSTD_CCtx_refCDict()
1182 size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool) in ZSTD_CCtx_refThreadPool() argument
1184 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_refThreadPool()
1186 cctx->pool = pool; in ZSTD_CCtx_refThreadPool()
1190 size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize) in ZSTD_CCtx_refPrefix() argument
1192 return ZSTD_CCtx_refPrefix_advanced(cctx, prefix, prefixSize, ZSTD_dct_rawContent); in ZSTD_CCtx_refPrefix()
1196 … ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType) in ZSTD_CCtx_refPrefix_advanced() argument
1198 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_refPrefix_advanced()
1200 ZSTD_clearAllDicts(cctx); in ZSTD_CCtx_refPrefix_advanced()
1202 cctx->prefixDict.dict = prefix; in ZSTD_CCtx_refPrefix_advanced()
1203 cctx->prefixDict.dictSize = prefixSize; in ZSTD_CCtx_refPrefix_advanced()
1204 cctx->prefixDict.dictContentType = dictContentType; in ZSTD_CCtx_refPrefix_advanced()
1211 size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset) in ZSTD_CCtx_reset() argument
1215 cctx->streamStage = zcss_init; in ZSTD_CCtx_reset()
1216 cctx->pledgedSrcSizePlusOne = 0; in ZSTD_CCtx_reset()
1220 RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, in ZSTD_CCtx_reset()
1222 ZSTD_clearAllDicts(cctx); in ZSTD_CCtx_reset()
1223 return ZSTD_CCtxParams_reset(&cctx->requestedParams); in ZSTD_CCtx_reset()
1618 ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx) in ZSTD_getFrameProgression() argument
1621 if (cctx->appliedParams.nbWorkers > 0) { in ZSTD_getFrameProgression()
1622 return ZSTDMT_getFrameProgression(cctx->mtctx); in ZSTD_getFrameProgression()
1626 size_t const buffered = (cctx->inBuff == NULL) ? 0 : in ZSTD_getFrameProgression()
1627 cctx->inBuffPos - cctx->inToCompress; in ZSTD_getFrameProgression()
1628 if (buffered) assert(cctx->inBuffPos >= cctx->inToCompress); in ZSTD_getFrameProgression()
1630 fp.ingested = cctx->consumedSrcSize + buffered; in ZSTD_getFrameProgression()
1631 fp.consumed = cctx->consumedSrcSize; in ZSTD_getFrameProgression()
1632 fp.produced = cctx->producedCSize; in ZSTD_getFrameProgression()
1633 …fp.flushed = cctx->producedCSize; /* simplified; some data might still be left within streaming… in ZSTD_getFrameProgression()
1642 size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx) in ZSTD_toFlushNow() argument
1645 if (cctx->appliedParams.nbWorkers > 0) { in ZSTD_toFlushNow()
1646 return ZSTDMT_toFlushNow(cctx->mtctx); in ZSTD_toFlushNow()
1649 (void)cctx; in ZSTD_toFlushNow()
2002 void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) { in ZSTD_invalidateRepCodes() argument
2004 for (i=0; i<ZSTD_REP_NUM; i++) cctx->blockState.prevCBlock->rep[i] = 0; in ZSTD_invalidateRepCodes()
2005 assert(!ZSTD_window_hasExtDict(cctx->blockState.matchState.window)); in ZSTD_invalidateRepCodes()
2041 ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx, in ZSTD_resetCCtx_byAttachingCDict() argument
2065 FORWARD_IF_ERROR(ZSTD_resetCCtx_internal(cctx, &params, pledgedSrcSize, in ZSTD_resetCCtx_byAttachingCDict()
2068 assert(cctx->appliedParams.cParams.strategy == adjusted_cdict_cParams.strategy); in ZSTD_resetCCtx_byAttachingCDict()
2079 cctx->blockState.matchState.dictMatchState = &cdict->matchState; in ZSTD_resetCCtx_byAttachingCDict()
2083 if (cctx->blockState.matchState.window.dictLimit < cdictEnd) { in ZSTD_resetCCtx_byAttachingCDict()
2084 cctx->blockState.matchState.window.nextSrc = in ZSTD_resetCCtx_byAttachingCDict()
2085 cctx->blockState.matchState.window.base + cdictEnd; in ZSTD_resetCCtx_byAttachingCDict()
2086 ZSTD_window_clear(&cctx->blockState.matchState.window); in ZSTD_resetCCtx_byAttachingCDict()
2089cctx->blockState.matchState.loadedDictEnd = cctx->blockState.matchState.window.dictLimit; in ZSTD_resetCCtx_byAttachingCDict()
2092 cctx->dictID = cdict->dictID; in ZSTD_resetCCtx_byAttachingCDict()
2093 cctx->dictContentSize = cdict->dictContentSize; in ZSTD_resetCCtx_byAttachingCDict()
2096 ZSTD_memcpy(cctx->blockState.prevCBlock, &cdict->cBlockState, sizeof(cdict->cBlockState)); in ZSTD_resetCCtx_byAttachingCDict()
2101 static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx, in ZSTD_resetCCtx_byCopyingCDict() argument
2119 FORWARD_IF_ERROR(ZSTD_resetCCtx_internal(cctx, &params, pledgedSrcSize, in ZSTD_resetCCtx_byCopyingCDict()
2122 assert(cctx->appliedParams.cParams.strategy == cdict_cParams->strategy); in ZSTD_resetCCtx_byCopyingCDict()
2123 assert(cctx->appliedParams.cParams.hashLog == cdict_cParams->hashLog); in ZSTD_resetCCtx_byCopyingCDict()
2124 assert(cctx->appliedParams.cParams.chainLog == cdict_cParams->chainLog); in ZSTD_resetCCtx_byCopyingCDict()
2127 ZSTD_cwksp_mark_tables_dirty(&cctx->workspace); in ZSTD_resetCCtx_byCopyingCDict()
2136 ZSTD_memcpy(cctx->blockState.matchState.hashTable, in ZSTD_resetCCtx_byCopyingCDict()
2140 …if (ZSTD_allocateChainTable(cctx->appliedParams.cParams.strategy, cctx->appliedParams.useRowMatchF… in ZSTD_resetCCtx_byCopyingCDict()
2141 ZSTD_memcpy(cctx->blockState.matchState.chainTable, in ZSTD_resetCCtx_byCopyingCDict()
2148 ZSTD_memcpy(cctx->blockState.matchState.tagTable, in ZSTD_resetCCtx_byCopyingCDict()
2155 { int const h3log = cctx->blockState.matchState.hashLog3; in ZSTD_resetCCtx_byCopyingCDict()
2158 ZSTD_memset(cctx->blockState.matchState.hashTable3, 0, h3Size * sizeof(U32)); in ZSTD_resetCCtx_byCopyingCDict()
2161 ZSTD_cwksp_mark_tables_clean(&cctx->workspace); in ZSTD_resetCCtx_byCopyingCDict()
2165 ZSTD_matchState_t* dstMatchState = &cctx->blockState.matchState; in ZSTD_resetCCtx_byCopyingCDict()
2171 cctx->dictID = cdict->dictID; in ZSTD_resetCCtx_byCopyingCDict()
2172 cctx->dictContentSize = cdict->dictContentSize; in ZSTD_resetCCtx_byCopyingCDict()
2175 ZSTD_memcpy(cctx->blockState.prevCBlock, &cdict->cBlockState, sizeof(cdict->cBlockState)); in ZSTD_resetCCtx_byCopyingCDict()
2183 static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx, in ZSTD_resetCCtx_usingCDict() argument
2195 cctx, cdict, *params, pledgedSrcSize, zbuff); in ZSTD_resetCCtx_usingCDict()
2198 cctx, cdict, *params, pledgedSrcSize, zbuff); in ZSTD_resetCCtx_usingCDict()
3932 static size_t ZSTD_compress_frameChunk(ZSTD_CCtx* cctx, in ZSTD_compress_frameChunk() argument
3937 size_t blockSize = cctx->blockSize; in ZSTD_compress_frameChunk()
3942 U32 const maxDist = (U32)1 << cctx->appliedParams.cParams.windowLog; in ZSTD_compress_frameChunk()
3944 assert(cctx->appliedParams.cParams.windowLog <= ZSTD_WINDOWLOG_MAX); in ZSTD_compress_frameChunk()
3947 if (cctx->appliedParams.fParams.checksumFlag && srcSize) in ZSTD_compress_frameChunk()
3948 XXH64_update(&cctx->xxhState, src, srcSize); in ZSTD_compress_frameChunk()
3951 ZSTD_matchState_t* const ms = &cctx->blockState.matchState; in ZSTD_compress_frameChunk()
3960 ms, &cctx->workspace, &cctx->appliedParams, ip, ip + blockSize); in ZSTD_compress_frameChunk()
3968 if (ZSTD_useTargetCBlockSize(&cctx->appliedParams)) { in ZSTD_compress_frameChunk()
3969 … cSize = ZSTD_compressBlock_targetCBlockSize(cctx, op, dstCapacity, ip, blockSize, lastBlock); in ZSTD_compress_frameChunk()
3973 } else if (ZSTD_blockSplitterEnabled(&cctx->appliedParams)) { in ZSTD_compress_frameChunk()
3974 … cSize = ZSTD_compressBlock_splitBlock(cctx, op, dstCapacity, ip, blockSize, lastBlock); in ZSTD_compress_frameChunk()
3976 assert(cSize > 0 || cctx->seqCollector.collectSequences == 1); in ZSTD_compress_frameChunk()
3978 cSize = ZSTD_compressBlock_internal(cctx, in ZSTD_compress_frameChunk()
4002 cctx->isFirstBlock = 0; in ZSTD_compress_frameChunk()
4007 if (lastFrameChunk && (op>ostart)) cctx->stage = ZSTDcs_ending; in ZSTD_compress_frameChunk()
4095 size_t ZSTD_referenceExternalSequences(ZSTD_CCtx* cctx, rawSeq* seq, size_t nbSeq) in ZSTD_referenceExternalSequences() argument
4097 RETURN_ERROR_IF(cctx->stage != ZSTDcs_init, stage_wrong, in ZSTD_referenceExternalSequences()
4099 RETURN_ERROR_IF(cctx->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable, in ZSTD_referenceExternalSequences()
4102 cctx->externSeqStore.seq = seq; in ZSTD_referenceExternalSequences()
4103 cctx->externSeqStore.size = nbSeq; in ZSTD_referenceExternalSequences()
4104 cctx->externSeqStore.capacity = nbSeq; in ZSTD_referenceExternalSequences()
4105 cctx->externSeqStore.pos = 0; in ZSTD_referenceExternalSequences()
4106 cctx->externSeqStore.posInSequence = 0; in ZSTD_referenceExternalSequences()
4111 static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx, in ZSTD_compressContinue_internal() argument
4116 ZSTD_matchState_t* const ms = &cctx->blockState.matchState; in ZSTD_compressContinue_internal()
4120 cctx->stage, (unsigned)srcSize); in ZSTD_compressContinue_internal()
4121 RETURN_ERROR_IF(cctx->stage==ZSTDcs_created, stage_wrong, in ZSTD_compressContinue_internal()
4124 if (frame && (cctx->stage==ZSTDcs_init)) { in ZSTD_compressContinue_internal()
4125 fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, &cctx->appliedParams, in ZSTD_compressContinue_internal()
4126 cctx->pledgedSrcSizePlusOne-1, cctx->dictID); in ZSTD_compressContinue_internal()
4131 cctx->stage = ZSTDcs_ongoing; in ZSTD_compressContinue_internal()
4140 if (cctx->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable) { in ZSTD_compressContinue_internal()
4141 ZSTD_window_update(&cctx->ldmState.window, src, srcSize, /* forceNonContiguous */ 0); in ZSTD_compressContinue_internal()
4147 ms, &cctx->workspace, &cctx->appliedParams, in ZSTD_compressContinue_internal()
4151 DEBUGLOG(5, "ZSTD_compressContinue_internal (blockSize=%u)", (unsigned)cctx->blockSize); in ZSTD_compressContinue_internal()
4153 … ZSTD_compress_frameChunk (cctx, dst, dstCapacity, src, srcSize, lastFrameChunk) : in ZSTD_compressContinue_internal()
4154 … ZSTD_compressBlock_internal (cctx, dst, dstCapacity, src, srcSize, 0 /* frame */); in ZSTD_compressContinue_internal()
4156 cctx->consumedSrcSize += srcSize; in ZSTD_compressContinue_internal()
4157 cctx->producedCSize += (cSize + fhSize); in ZSTD_compressContinue_internal()
4158 assert(!(cctx->appliedParams.fParams.contentSizeFlag && cctx->pledgedSrcSizePlusOne == 0)); in ZSTD_compressContinue_internal()
4159 if (cctx->pledgedSrcSizePlusOne != 0) { /* control src size */ in ZSTD_compressContinue_internal()
4162 cctx->consumedSrcSize+1 > cctx->pledgedSrcSizePlusOne, in ZSTD_compressContinue_internal()
4165 (unsigned)cctx->pledgedSrcSizePlusOne-1, in ZSTD_compressContinue_internal()
4166 (unsigned)cctx->consumedSrcSize); in ZSTD_compressContinue_internal()
4172 size_t ZSTD_compressContinue (ZSTD_CCtx* cctx, in ZSTD_compressContinue() argument
4177 …return ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 1 /* frame mode */, 0 … in ZSTD_compressContinue()
4181 size_t ZSTD_getBlockSize(const ZSTD_CCtx* cctx) in ZSTD_getBlockSize() argument
4183 ZSTD_compressionParameters const cParams = cctx->appliedParams.cParams; in ZSTD_getBlockSize()
4188 size_t ZSTD_compressBlock(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t s… in ZSTD_compressBlock() argument
4191 { size_t const blockSizeMax = ZSTD_getBlockSize(cctx); in ZSTD_compressBlock()
4194 …return ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 0 /* frame mode */, 0 … in ZSTD_compressBlock()
4489 static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx, in ZSTD_compressBegin_internal() argument
4499 cctx->traceCtx = (ZSTD_trace_compress_begin != NULL) ? ZSTD_trace_compress_begin(cctx) : 0; in ZSTD_compressBegin_internal()
4512 return ZSTD_resetCCtx_usingCDict(cctx, cdict, params, pledgedSrcSize, zbuff); in ZSTD_compressBegin_internal()
4515 FORWARD_IF_ERROR( ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize, in ZSTD_compressBegin_internal()
4520 cctx->blockState.prevCBlock, &cctx->blockState.matchState, in ZSTD_compressBegin_internal()
4521 &cctx->ldmState, &cctx->workspace, &cctx->appliedParams, cdict->dictContent, in ZSTD_compressBegin_internal()
4523 cctx->entropyWorkspace) in ZSTD_compressBegin_internal()
4525 cctx->blockState.prevCBlock, &cctx->blockState.matchState, in ZSTD_compressBegin_internal()
4526 &cctx->ldmState, &cctx->workspace, &cctx->appliedParams, dict, dictSize, in ZSTD_compressBegin_internal()
4527 dictContentType, dtlm, cctx->entropyWorkspace); in ZSTD_compressBegin_internal()
4530 cctx->dictID = (U32)dictID; in ZSTD_compressBegin_internal()
4531 cctx->dictContentSize = dictContentSize; in ZSTD_compressBegin_internal()
4536 size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx, in ZSTD_compressBegin_advanced_internal() argument
4547 return ZSTD_compressBegin_internal(cctx, in ZSTD_compressBegin_advanced_internal()
4556 size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, in ZSTD_compressBegin_advanced() argument
4562 return ZSTD_compressBegin_advanced_internal(cctx, in ZSTD_compressBegin_advanced()
4568 size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compres… in ZSTD_compressBegin_usingDict() argument
4576 return ZSTD_compressBegin_internal(cctx, dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL, in ZSTD_compressBegin_usingDict()
4580 size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel) in ZSTD_compressBegin() argument
4582 return ZSTD_compressBegin_usingDict(cctx, NULL, 0, compressionLevel); in ZSTD_compressBegin()
4589 static size_t ZSTD_writeEpilogue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity) in ZSTD_writeEpilogue() argument
4596 RETURN_ERROR_IF(cctx->stage == ZSTDcs_created, stage_wrong, "init missing"); in ZSTD_writeEpilogue()
4599 if (cctx->stage == ZSTDcs_init) { in ZSTD_writeEpilogue()
4600 fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, &cctx->appliedParams, 0, 0); in ZSTD_writeEpilogue()
4604 cctx->stage = ZSTDcs_ongoing; in ZSTD_writeEpilogue()
4607 if (cctx->stage != ZSTDcs_ending) { in ZSTD_writeEpilogue()
4616 if (cctx->appliedParams.fParams.checksumFlag) { in ZSTD_writeEpilogue()
4617 U32 const checksum = (U32) XXH64_digest(&cctx->xxhState); in ZSTD_writeEpilogue()
4624 cctx->stage = ZSTDcs_created; /* return to "created but no init" status */ in ZSTD_writeEpilogue()
4628 void ZSTD_CCtx_trace(ZSTD_CCtx* cctx, size_t extraCSize) in ZSTD_CCtx_trace() argument
4631 if (cctx->traceCtx && ZSTD_trace_compress_end != NULL) { in ZSTD_CCtx_trace()
4632 …int const streaming = cctx->inBuffSize > 0 || cctx->outBuffSize > 0 || cctx->appliedParams.nbWorke… in ZSTD_CCtx_trace()
4637 trace.dictionaryID = cctx->dictID; in ZSTD_CCtx_trace()
4638 trace.dictionarySize = cctx->dictContentSize; in ZSTD_CCtx_trace()
4639 trace.uncompressedSize = cctx->consumedSrcSize; in ZSTD_CCtx_trace()
4640 trace.compressedSize = cctx->producedCSize + extraCSize; in ZSTD_CCtx_trace()
4641 trace.params = &cctx->appliedParams; in ZSTD_CCtx_trace()
4642 trace.cctx = cctx; in ZSTD_CCtx_trace()
4643 ZSTD_trace_compress_end(cctx->traceCtx, &trace); in ZSTD_CCtx_trace()
4645 cctx->traceCtx = 0; in ZSTD_CCtx_trace()
4647 (void)cctx; in ZSTD_CCtx_trace()
4652 size_t ZSTD_compressEnd (ZSTD_CCtx* cctx, in ZSTD_compressEnd() argument
4657 size_t const cSize = ZSTD_compressContinue_internal(cctx, in ZSTD_compressEnd()
4661 endResult = ZSTD_writeEpilogue(cctx, (char*)dst + cSize, dstCapacity-cSize); in ZSTD_compressEnd()
4663 assert(!(cctx->appliedParams.fParams.contentSizeFlag && cctx->pledgedSrcSizePlusOne == 0)); in ZSTD_compressEnd()
4664 if (cctx->pledgedSrcSizePlusOne != 0) { /* control src size */ in ZSTD_compressEnd()
4668 cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1, in ZSTD_compressEnd()
4671 (unsigned)cctx->pledgedSrcSizePlusOne-1, in ZSTD_compressEnd()
4672 (unsigned)cctx->consumedSrcSize); in ZSTD_compressEnd()
4674 ZSTD_CCtx_trace(cctx, endResult); in ZSTD_compressEnd()
4678 size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx, in ZSTD_compress_advanced() argument
4686 ZSTD_CCtxParams_init_internal(&cctx->simpleApiParams, &params, ZSTD_NO_CLEVEL); in ZSTD_compress_advanced()
4687 return ZSTD_compress_advanced_internal(cctx, in ZSTD_compress_advanced()
4691 &cctx->simpleApiParams); in ZSTD_compress_advanced()
4696 ZSTD_CCtx* cctx, in ZSTD_compress_advanced_internal() argument
4703 FORWARD_IF_ERROR( ZSTD_compressBegin_internal(cctx, in ZSTD_compress_advanced_internal()
4706 return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize); in ZSTD_compress_advanced_internal()
4709 size_t ZSTD_compress_usingDict(ZSTD_CCtx* cctx, in ZSTD_compress_usingDict() argument
4718 …ZSTD_CCtxParams_init_internal(&cctx->simpleApiParams, &params, (compressionLevel == 0) ? ZSTD_CLEV… in ZSTD_compress_usingDict()
4721 …return ZSTD_compress_advanced_internal(cctx, dst, dstCapacity, src, srcSize, dict, dictSize, &cctx in ZSTD_compress_usingDict()
4724 size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx, in ZSTD_compressCCtx() argument
4730 assert(cctx != NULL); in ZSTD_compressCCtx()
4731 return ZSTD_compress_usingDict(cctx, dst, dstCapacity, src, srcSize, NULL, 0, compressionLevel); in ZSTD_compressCCtx()
4740 ZSTD_CCtx* cctx = ZSTD_createCCtx(); in ZSTD_compress() local
4741 RETURN_ERROR_IF(!cctx, memory_allocation, "ZSTD_createCCtx failed"); in ZSTD_compress()
4742 result = ZSTD_compressCCtx(cctx, dst, dstCapacity, src, srcSize, compressionLevel); in ZSTD_compress()
4743 ZSTD_freeCCtx(cctx); in ZSTD_compress()
5058 ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, in ZSTD_compressBegin_usingCDict_internal() argument
5087 return ZSTD_compressBegin_internal(cctx, in ZSTD_compressBegin_usingCDict_internal()
5099 ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, in ZSTD_compressBegin_usingCDict_advanced() argument
5102 return ZSTD_compressBegin_usingCDict_internal(cctx, cdict, fParams, pledgedSrcSize); in ZSTD_compressBegin_usingCDict_advanced()
5107 size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict) in ZSTD_compressBegin_usingCDict() argument
5110 return ZSTD_compressBegin_usingCDict_internal(cctx, cdict, fParams, ZSTD_CONTENTSIZE_UNKNOWN); in ZSTD_compressBegin_usingCDict()
5116 static size_t ZSTD_compress_usingCDict_internal(ZSTD_CCtx* cctx, in ZSTD_compress_usingCDict_internal() argument
5121 …FORWARD_IF_ERROR(ZSTD_compressBegin_usingCDict_internal(cctx, cdict, fParams, srcSize), ""); /* wi… in ZSTD_compress_usingCDict_internal()
5122 return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize); in ZSTD_compress_usingCDict_internal()
5128 size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, in ZSTD_compress_usingCDict_advanced() argument
5133 return ZSTD_compress_usingCDict_internal(cctx, dst, dstCapacity, src, srcSize, cdict, fParams); in ZSTD_compress_usingCDict_advanced()
5141 size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, in ZSTD_compress_usingCDict() argument
5147 return ZSTD_compress_usingCDict_internal(cctx, dst, dstCapacity, src, srcSize, cdict, fParams); in ZSTD_compress_usingCDict()
5317 static size_t ZSTD_nextInputSizeHint(const ZSTD_CCtx* cctx) in ZSTD_nextInputSizeHint() argument
5319 size_t hintInSize = cctx->inBuffTarget - cctx->inBuffPos; in ZSTD_nextInputSizeHint()
5320 if (hintInSize==0) hintInSize = cctx->blockSize; in ZSTD_nextInputSizeHint()
5495 static size_t ZSTD_nextInputSizeHint_MTorST(const ZSTD_CCtx* cctx) in ZSTD_nextInputSizeHint_MTorST() argument
5498 if (cctx->appliedParams.nbWorkers >= 1) { in ZSTD_nextInputSizeHint_MTorST()
5499 assert(cctx->mtctx != NULL); in ZSTD_nextInputSizeHint_MTorST()
5500 return ZSTDMT_nextInputSizeHint(cctx->mtctx); in ZSTD_nextInputSizeHint_MTorST()
5503 return ZSTD_nextInputSizeHint(cctx); in ZSTD_nextInputSizeHint_MTorST()
5516 static void ZSTD_setBufferExpectations(ZSTD_CCtx* cctx, ZSTD_outBuffer const* output, ZSTD_inBuffer… in ZSTD_setBufferExpectations() argument
5518 if (cctx->appliedParams.inBufferMode == ZSTD_bm_stable) { in ZSTD_setBufferExpectations()
5519 cctx->expectedInBuffer = *input; in ZSTD_setBufferExpectations()
5521 if (cctx->appliedParams.outBufferMode == ZSTD_bm_stable) { in ZSTD_setBufferExpectations()
5522 cctx->expectedOutBufferSize = output->size - output->pos; in ZSTD_setBufferExpectations()
5529 static size_t ZSTD_checkBufferStability(ZSTD_CCtx const* cctx, in ZSTD_checkBufferStability() argument
5534 if (cctx->appliedParams.inBufferMode == ZSTD_bm_stable) { in ZSTD_checkBufferStability()
5535 ZSTD_inBuffer const expect = cctx->expectedInBuffer; in ZSTD_checkBufferStability()
5541 if (cctx->appliedParams.outBufferMode == ZSTD_bm_stable) { in ZSTD_checkBufferStability()
5543 if (cctx->expectedOutBufferSize != outBufferSize) in ZSTD_checkBufferStability()
5549 static size_t ZSTD_CCtx_init_compressStream2(ZSTD_CCtx* cctx, in ZSTD_CCtx_init_compressStream2() argument
5552 ZSTD_CCtx_params params = cctx->requestedParams; in ZSTD_CCtx_init_compressStream2()
5553 ZSTD_prefixDict const prefixDict = cctx->prefixDict; in ZSTD_CCtx_init_compressStream2()
5554 FORWARD_IF_ERROR( ZSTD_initLocalDict(cctx) , ""); /* Init the local dict if present. */ in ZSTD_CCtx_init_compressStream2()
5555 ZSTD_memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); /* single usage */ in ZSTD_CCtx_init_compressStream2()
5556 assert(prefixDict.dict==NULL || cctx->cdict==NULL); /* only one can be set */ in ZSTD_CCtx_init_compressStream2()
5557 if (cctx->cdict && !cctx->localDict.cdict) { in ZSTD_CCtx_init_compressStream2()
5562 params.compressionLevel = cctx->cdict->compressionLevel; in ZSTD_CCtx_init_compressStream2()
5565 … if (endOp == ZSTD_e_end) cctx->pledgedSrcSizePlusOne = inSize + 1; /* auto-fix pledgedSrcSize */ in ZSTD_CCtx_init_compressStream2()
5569 : (cctx->cdict ? cctx->cdict->dictContentSize : 0); in ZSTD_CCtx_init_compressStream2()
5570 …ZSTD_cParamMode_e const mode = ZSTD_getCParamMode(cctx->cdict, &params, cctx->pledgedSrcSizePlusOn… in ZSTD_CCtx_init_compressStream2()
5572 &params, cctx->pledgedSrcSizePlusOne-1, in ZSTD_CCtx_init_compressStream2()
5581 if ((cctx->pledgedSrcSizePlusOne-1) <= ZSTDMT_JOBSIZE_MIN) { in ZSTD_CCtx_init_compressStream2()
5586 cctx->traceCtx = (ZSTD_trace_compress_begin != NULL) ? ZSTD_trace_compress_begin(cctx) : 0; in ZSTD_CCtx_init_compressStream2()
5589 if (cctx->mtctx == NULL) { in ZSTD_CCtx_init_compressStream2()
5592cctx->mtctx = ZSTDMT_createCCtx_advanced((U32)params.nbWorkers, cctx->customMem, cctx->pool); in ZSTD_CCtx_init_compressStream2()
5593 RETURN_ERROR_IF(cctx->mtctx == NULL, memory_allocation, "NULL pointer!"); in ZSTD_CCtx_init_compressStream2()
5598 cctx->mtctx, in ZSTD_CCtx_init_compressStream2()
5600 cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) , ""); in ZSTD_CCtx_init_compressStream2()
5601 cctx->dictID = cctx->cdict ? cctx->cdict->dictID : 0; in ZSTD_CCtx_init_compressStream2()
5602 cctx->dictContentSize = cctx->cdict ? cctx->cdict->dictContentSize : prefixDict.dictSize; in ZSTD_CCtx_init_compressStream2()
5603 cctx->consumedSrcSize = 0; in ZSTD_CCtx_init_compressStream2()
5604 cctx->producedCSize = 0; in ZSTD_CCtx_init_compressStream2()
5605 cctx->streamStage = zcss_load; in ZSTD_CCtx_init_compressStream2()
5606 cctx->appliedParams = params; in ZSTD_CCtx_init_compressStream2()
5609 { U64 const pledgedSrcSize = cctx->pledgedSrcSizePlusOne - 1; in ZSTD_CCtx_init_compressStream2()
5611 FORWARD_IF_ERROR( ZSTD_compressBegin_internal(cctx, in ZSTD_CCtx_init_compressStream2()
5613 cctx->cdict, in ZSTD_CCtx_init_compressStream2()
5616 assert(cctx->appliedParams.nbWorkers == 0); in ZSTD_CCtx_init_compressStream2()
5617 cctx->inToCompress = 0; in ZSTD_CCtx_init_compressStream2()
5618 cctx->inBuffPos = 0; in ZSTD_CCtx_init_compressStream2()
5619 if (cctx->appliedParams.inBufferMode == ZSTD_bm_buffered) { in ZSTD_CCtx_init_compressStream2()
5623 cctx->inBuffTarget = cctx->blockSize + (cctx->blockSize == pledgedSrcSize); in ZSTD_CCtx_init_compressStream2()
5625 cctx->inBuffTarget = 0; in ZSTD_CCtx_init_compressStream2()
5627 cctx->outBuffContentSize = cctx->outBuffFlushedSize = 0; in ZSTD_CCtx_init_compressStream2()
5628 cctx->streamStage = zcss_load; in ZSTD_CCtx_init_compressStream2()
5629 cctx->frameEnded = 0; in ZSTD_CCtx_init_compressStream2()
5634 size_t ZSTD_compressStream2( ZSTD_CCtx* cctx, in ZSTD_compressStream2() argument
5644 assert(cctx != NULL); in ZSTD_compressStream2()
5647 if (cctx->streamStage == zcss_init) { in ZSTD_compressStream2()
5648 …FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, endOp, input->size), "CompressStream2 initia… in ZSTD_compressStream2()
5649 …ZSTD_setBufferExpectations(cctx, output, input); /* Set initial buffer expectations now that we… in ZSTD_compressStream2()
5653 FORWARD_IF_ERROR(ZSTD_checkBufferStability(cctx, output, input, endOp), "invalid buffers"); in ZSTD_compressStream2()
5656 if (cctx->appliedParams.nbWorkers > 0) { in ZSTD_compressStream2()
5658 if (cctx->cParamsChanged) { in ZSTD_compressStream2()
5659 ZSTDMT_updateCParams_whileCompressing(cctx->mtctx, &cctx->requestedParams); in ZSTD_compressStream2()
5660 cctx->cParamsChanged = 0; in ZSTD_compressStream2()
5665 flushMin = ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp); in ZSTD_compressStream2()
5666 cctx->consumedSrcSize += (U64)(input->pos - ipos); in ZSTD_compressStream2()
5667 cctx->producedCSize += (U64)(output->pos - opos); in ZSTD_compressStream2()
5671 ZSTD_CCtx_trace(cctx, 0); in ZSTD_compressStream2()
5672 ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only); in ZSTD_compressStream2()
5697 ZSTD_setBufferExpectations(cctx, output, input); in ZSTD_compressStream2()
5701 FORWARD_IF_ERROR( ZSTD_compressStream_generic(cctx, output, input, endOp) , ""); in ZSTD_compressStream2()
5703 ZSTD_setBufferExpectations(cctx, output, input); in ZSTD_compressStream2()
5704 return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */ in ZSTD_compressStream2()
5708 ZSTD_CCtx* cctx, in ZSTD_compressStream2_simpleArgs() argument
5716 size_t const cErr = ZSTD_compressStream2(cctx, &output, &input, endOp); in ZSTD_compressStream2_simpleArgs()
5722 size_t ZSTD_compress2(ZSTD_CCtx* cctx, in ZSTD_compress2() argument
5726 ZSTD_bufferMode_e const originalInBufferMode = cctx->requestedParams.inBufferMode; in ZSTD_compress2()
5727 ZSTD_bufferMode_e const originalOutBufferMode = cctx->requestedParams.outBufferMode; in ZSTD_compress2()
5729 ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only); in ZSTD_compress2()
5731 cctx->requestedParams.inBufferMode = ZSTD_bm_stable; in ZSTD_compress2()
5732 cctx->requestedParams.outBufferMode = ZSTD_bm_stable; in ZSTD_compress2()
5735 size_t const result = ZSTD_compressStream2_simpleArgs(cctx, in ZSTD_compress2()
5740 cctx->requestedParams.inBufferMode = originalInBufferMode; in ZSTD_compress2()
5741 cctx->requestedParams.outBufferMode = originalOutBufferMode; in ZSTD_compress2()
5799 ZSTD_copySequencesToSeqStoreExplicitBlockDelim(ZSTD_CCtx* cctx, in ZSTD_copySequencesToSeqStoreExplicitBlockDelim() argument
5810 if (cctx->cdict) { in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5811 dictSize = (U32)cctx->cdict->dictContentSize; in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5812 } else if (cctx->prefixDict.dict) { in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5813 dictSize = (U32)cctx->prefixDict.dictSize; in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5817 ZSTD_memcpy(updatedRepcodes.rep, cctx->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5826 if (cctx->appliedParams.validateSequences) { in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5829 cctx->appliedParams.cParams.windowLog, dictSize), in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5832 RETURN_ERROR_IF(idx - seqPos->idx > cctx->seqStore.maxNbSeq, memory_allocation, in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5834 ZSTD_storeSeq(&cctx->seqStore, litLength, ip, iend, offCode, matchLength); in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5837 ZSTD_memcpy(cctx->blockState.nextCBlock->rep, updatedRepcodes.rep, sizeof(repcodes_t)); in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5841 ZSTD_storeLastLiterals(&cctx->seqStore, ip, inSeqs[idx].litLength); in ZSTD_copySequencesToSeqStoreExplicitBlockDelim()
5862 ZSTD_copySequencesToSeqStoreNoBlockDelim(ZSTD_CCtx* cctx, ZSTD_sequencePosition* seqPos, in ZSTD_copySequencesToSeqStoreNoBlockDelim() argument
5876 if (cctx->cdict) { in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5877 dictSize = cctx->cdict->dictContentSize; in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5878 } else if (cctx->prefixDict.dict) { in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5879 dictSize = cctx->prefixDict.dictSize; in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5885 ZSTD_memcpy(updatedRepcodes.rep, cctx->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5915 … if (matchLength > blockSize && firstHalfMatchLength >= cctx->appliedParams.cParams.minMatch) { in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5918 if (secondHalfMatchLength < cctx->appliedParams.cParams.minMatch) { in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5920 … endPosInSequence -= cctx->appliedParams.cParams.minMatch - secondHalfMatchLength; in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5921 … bytesAdjustment = cctx->appliedParams.cParams.minMatch - secondHalfMatchLength; in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5949 if (cctx->appliedParams.validateSequences) { in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5952 cctx->appliedParams.cParams.windowLog, dictSize), in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5956 RETURN_ERROR_IF(idx - seqPos->idx > cctx->seqStore.maxNbSeq, memory_allocation, in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5958 ZSTD_storeSeq(&cctx->seqStore, litLength, ip, iend, offCode, matchLength); in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5965 ZSTD_memcpy(cctx->blockState.nextCBlock->rep, updatedRepcodes.rep, sizeof(repcodes_t)); in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5973 ZSTD_storeLastLiterals(&cctx->seqStore, ip, lastLLSize); in ZSTD_copySequencesToSeqStoreNoBlockDelim()
5980 typedef size_t (*ZSTD_sequenceCopier) (ZSTD_CCtx* cctx, ZSTD_sequencePosition* seqPos,
6002 ZSTD_compressSequences_internal(ZSTD_CCtx* cctx, in ZSTD_compressSequences_internal() argument
6016 …ZSTD_sequenceCopier const sequenceCopier = ZSTD_selectSequenceCopier(cctx->appliedParams.blockDeli… in ZSTD_compressSequences_internal()
6032 lastBlock = remaining <= cctx->blockSize; in ZSTD_compressSequences_internal()
6033 blockSize = lastBlock ? (U32)remaining : (U32)cctx->blockSize; in ZSTD_compressSequences_internal()
6034 ZSTD_resetSeqStore(&cctx->seqStore); in ZSTD_compressSequences_internal()
6037 additionalByteAdjustment = sequenceCopier(cctx, &seqPos, inSeqs, inSeqsSize, ip, blockSize); in ZSTD_compressSequences_internal()
6054 compressedSeqsSize = ZSTD_entropyCompressSeqStore(&cctx->seqStore, in ZSTD_compressSequences_internal()
6055 … &cctx->blockState.prevCBlock->entropy, &cctx->blockState.nextCBlock->entropy, in ZSTD_compressSequences_internal()
6056 &cctx->appliedParams, in ZSTD_compressSequences_internal()
6059cctx->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressSequences_internal()
6060 cctx->bmi2); in ZSTD_compressSequences_internal()
6064 if (!cctx->isFirstBlock && in ZSTD_compressSequences_internal()
6065 ZSTD_maybeRLE(&cctx->seqStore) && in ZSTD_compressSequences_internal()
6086 ZSTD_blockState_confirmRepcodesAndEntropyTables(&cctx->blockState); in ZSTD_compressSequences_internal()
6087 if (cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressSequences_internal()
6088 cctx->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressSequences_internal()
6107 cctx->isFirstBlock = 0; in ZSTD_compressSequences_internal()
6114 size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstCapacity, in ZSTD_compressSequences() argument
6125 assert(cctx != NULL); in ZSTD_compressSequences()
6126 …FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, ZSTD_e_end, srcSize), "CCtx initialization f… in ZSTD_compressSequences()
6128 …frameHeaderSize = ZSTD_writeFrameHeader(op, dstCapacity, &cctx->appliedParams, srcSize, cctx->dict… in ZSTD_compressSequences()
6132 if (cctx->appliedParams.fParams.checksumFlag && srcSize) { in ZSTD_compressSequences()
6133 XXH64_update(&cctx->xxhState, src, srcSize); in ZSTD_compressSequences()
6136 compressedBlocksSize = ZSTD_compressSequences_internal(cctx, in ZSTD_compressSequences()
6144 if (cctx->appliedParams.fParams.checksumFlag) { in ZSTD_compressSequences()
6145 U32 const checksum = (U32) XXH64_digest(&cctx->xxhState); in ZSTD_compressSequences()