Lines Matching refs:zc
1558 static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, in ZSTD_resetCCtx_internal() argument
1564 ZSTD_cwksp* const ws = &zc->workspace; in ZSTD_resetCCtx_internal()
1569 zc->isFirstBlock = 1; in ZSTD_resetCCtx_internal()
1590 int const indexTooClose = ZSTD_indexTooCloseToMax(zc->blockState.matchState.window); in ZSTD_resetCCtx_internal()
1592 (!indexTooClose && zc->initialized) ? ZSTDirp_continue : ZSTDirp_reset; in ZSTD_resetCCtx_internal()
1596 ¶ms.cParams, ¶ms.ldmParams, zc->staticSize != 0, in ZSTD_resetCCtx_internal()
1600 if (!zc->staticSize) ZSTD_cwksp_bump_oversized_duration(ws, 0); in ZSTD_resetCCtx_internal()
1615 RETURN_ERROR_IF(zc->staticSize, memory_allocation, "static cctx : no resize"); in ZSTD_resetCCtx_internal()
1619 ZSTD_cwksp_free(ws, zc->customMem); in ZSTD_resetCCtx_internal()
1620 FORWARD_IF_ERROR(ZSTD_cwksp_create(ws, neededSpace, zc->customMem), ""); in ZSTD_resetCCtx_internal()
1627 …zc->blockState.prevCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1628 …RETURN_ERROR_IF(zc->blockState.prevCBlock == NULL, memory_allocation, "couldn't allocate prevCBloc… in ZSTD_resetCCtx_internal()
1629 …zc->blockState.nextCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1630 …RETURN_ERROR_IF(zc->blockState.nextCBlock == NULL, memory_allocation, "couldn't allocate nextCBloc… in ZSTD_resetCCtx_internal()
1631 zc->entropyWorkspace = (U32*) ZSTD_cwksp_reserve_object(ws, ENTROPY_WORKSPACE_SIZE); in ZSTD_resetCCtx_internal()
1632 …RETURN_ERROR_IF(zc->blockState.nextCBlock == NULL, memory_allocation, "couldn't allocate entropyWo… in ZSTD_resetCCtx_internal()
1638 zc->appliedParams = params; in ZSTD_resetCCtx_internal()
1639 zc->blockState.matchState.cParams = params.cParams; in ZSTD_resetCCtx_internal()
1640 zc->pledgedSrcSizePlusOne = pledgedSrcSize+1; in ZSTD_resetCCtx_internal()
1641 zc->consumedSrcSize = 0; in ZSTD_resetCCtx_internal()
1642 zc->producedCSize = 0; in ZSTD_resetCCtx_internal()
1644 zc->appliedParams.fParams.contentSizeFlag = 0; in ZSTD_resetCCtx_internal()
1646 (unsigned)pledgedSrcSize, zc->appliedParams.fParams.contentSizeFlag); in ZSTD_resetCCtx_internal()
1647 zc->blockSize = blockSize; in ZSTD_resetCCtx_internal()
1649 xxh64_reset(&zc->xxhState, 0); in ZSTD_resetCCtx_internal()
1650 zc->stage = ZSTDcs_init; in ZSTD_resetCCtx_internal()
1651 zc->dictID = 0; in ZSTD_resetCCtx_internal()
1652 zc->dictContentSize = 0; in ZSTD_resetCCtx_internal()
1654 ZSTD_reset_compressedBlockState(zc->blockState.prevCBlock); in ZSTD_resetCCtx_internal()
1659 zc->seqStore.litStart = ZSTD_cwksp_reserve_buffer(ws, blockSize + WILDCOPY_OVERLENGTH); in ZSTD_resetCCtx_internal()
1660 zc->seqStore.maxNbLit = blockSize; in ZSTD_resetCCtx_internal()
1663 zc->bufferedPolicy = zbuff; in ZSTD_resetCCtx_internal()
1664 zc->inBuffSize = buffInSize; in ZSTD_resetCCtx_internal()
1665 zc->inBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffInSize); in ZSTD_resetCCtx_internal()
1666 zc->outBuffSize = buffOutSize; in ZSTD_resetCCtx_internal()
1667 zc->outBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffOutSize); in ZSTD_resetCCtx_internal()
1675 zc->ldmState.bucketOffsets = ZSTD_cwksp_reserve_buffer(ws, numBuckets); in ZSTD_resetCCtx_internal()
1676 ZSTD_memset(zc->ldmState.bucketOffsets, 0, numBuckets); in ZSTD_resetCCtx_internal()
1680 ZSTD_referenceExternalSequences(zc, NULL, 0); in ZSTD_resetCCtx_internal()
1681 zc->seqStore.maxNbSeq = maxNbSeq; in ZSTD_resetCCtx_internal()
1682 zc->seqStore.llCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1683 zc->seqStore.mlCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1684 zc->seqStore.ofCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1685 … zc->seqStore.sequencesStart = (seqDef*)ZSTD_cwksp_reserve_aligned(ws, maxNbSeq * sizeof(seqDef)); in ZSTD_resetCCtx_internal()
1688 &zc->blockState.matchState, in ZSTD_resetCCtx_internal()
1699 …zc->ldmState.hashTable = (ldmEntry_t*)ZSTD_cwksp_reserve_aligned(ws, ldmHSize * sizeof(ldmEntry_t)… in ZSTD_resetCCtx_internal()
1700 ZSTD_memset(zc->ldmState.hashTable, 0, ldmHSize * sizeof(ldmEntry_t)); in ZSTD_resetCCtx_internal()
1701 … zc->ldmSequences = (rawSeq*)ZSTD_cwksp_reserve_aligned(ws, maxNbLdmSeq * sizeof(rawSeq)); in ZSTD_resetCCtx_internal()
1702 zc->maxNbLdmSequences = maxNbLdmSeq; in ZSTD_resetCCtx_internal()
1704 ZSTD_window_init(&zc->ldmState.window); in ZSTD_resetCCtx_internal()
1705 ZSTD_window_clear(&zc->ldmState.window); in ZSTD_resetCCtx_internal()
1706 zc->ldmState.loadedDictEnd = 0; in ZSTD_resetCCtx_internal()
1716 zc->initialized = 1; in ZSTD_resetCCtx_internal()
2391 static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize) in ZSTD_buildSeqStore() argument
2393 ZSTD_matchState_t* const ms = &zc->blockState.matchState; in ZSTD_buildSeqStore()
2397 ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams); in ZSTD_buildSeqStore()
2399 if (zc->appliedParams.cParams.strategy >= ZSTD_btopt) { in ZSTD_buildSeqStore()
2400 ZSTD_ldm_skipRawSeqStoreBytes(&zc->externSeqStore, srcSize); in ZSTD_buildSeqStore()
2402 … ZSTD_ldm_skipSequences(&zc->externSeqStore, srcSize, zc->appliedParams.cParams.minMatch); in ZSTD_buildSeqStore()
2406 ZSTD_resetSeqStore(&(zc->seqStore)); in ZSTD_buildSeqStore()
2408 ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy; in ZSTD_buildSeqStore()
2410 ms->opt.literalCompressionMode = zc->appliedParams.literalCompressionMode; in ZSTD_buildSeqStore()
2430 zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i]; in ZSTD_buildSeqStore()
2432 if (zc->externSeqStore.pos < zc->externSeqStore.size) { in ZSTD_buildSeqStore()
2433 assert(!zc->appliedParams.ldmParams.enableLdm); in ZSTD_buildSeqStore()
2436 ZSTD_ldm_blockCompress(&zc->externSeqStore, in ZSTD_buildSeqStore()
2437 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2438 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2440 assert(zc->externSeqStore.pos <= zc->externSeqStore.size); in ZSTD_buildSeqStore()
2441 } else if (zc->appliedParams.ldmParams.enableLdm) { in ZSTD_buildSeqStore()
2444 ldmSeqStore.seq = zc->ldmSequences; in ZSTD_buildSeqStore()
2445 ldmSeqStore.capacity = zc->maxNbLdmSequences; in ZSTD_buildSeqStore()
2447 FORWARD_IF_ERROR(ZSTD_ldm_generateSequences(&zc->ldmState, &ldmSeqStore, in ZSTD_buildSeqStore()
2448 &zc->appliedParams.ldmParams, in ZSTD_buildSeqStore()
2453 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2454 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2458 …ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.… in ZSTD_buildSeqStore()
2460 … lastLLSize = blockCompressor(ms, &zc->seqStore, zc->blockState.nextCBlock->rep, src, srcSize); in ZSTD_buildSeqStore()
2463 ZSTD_storeLastLiterals(&zc->seqStore, lastLiterals, lastLLSize); in ZSTD_buildSeqStore()
2468 static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc) in ZSTD_copyBlockSequences() argument
2470 const seqStore_t* seqStore = ZSTD_getSeqStore(zc); in ZSTD_copyBlockSequences()
2477 ZSTD_Sequence* outSeqs = &zc->seqCollector.seqStart[zc->seqCollector.seqIndex]; in ZSTD_copyBlockSequences()
2481 assert(zc->seqCollector.seqIndex + 1 < zc->seqCollector.maxSequences); in ZSTD_copyBlockSequences()
2483 assert(zc->seqCollector.maxSequences >= seqStoreSeqSize + 1); in ZSTD_copyBlockSequences()
2484 ZSTD_memcpy(updatedRepcodes.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_copyBlockSequences()
2529 zc->seqCollector.seqIndex += seqStoreSeqSize; in ZSTD_copyBlockSequences()
2532 size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs, in ZSTD_generateSequences() argument
2545 zc->seqCollector = seqCollector; in ZSTD_generateSequences()
2547 ZSTD_compress2(zc, dst, dstCapacity, src, srcSize); in ZSTD_generateSequences()
2549 return zc->seqCollector.seqIndex; in ZSTD_generateSequences()
2605 static void ZSTD_confirmRepcodesAndEntropyTables(ZSTD_CCtx* zc) in ZSTD_confirmRepcodesAndEntropyTables() argument
2607 ZSTD_compressedBlockState_t* const tmp = zc->blockState.prevCBlock; in ZSTD_confirmRepcodesAndEntropyTables()
2608 zc->blockState.prevCBlock = zc->blockState.nextCBlock; in ZSTD_confirmRepcodesAndEntropyTables()
2609 zc->blockState.nextCBlock = tmp; in ZSTD_confirmRepcodesAndEntropyTables()
2612 static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, in ZSTD_compressBlock_internal() argument
2625 (unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, in ZSTD_compressBlock_internal()
2626 (unsigned)zc->blockState.matchState.nextToUpdate); in ZSTD_compressBlock_internal()
2628 { const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_internal()
2633 if (zc->seqCollector.collectSequences) { in ZSTD_compressBlock_internal()
2634 ZSTD_copyBlockSequences(zc); in ZSTD_compressBlock_internal()
2635 ZSTD_confirmRepcodesAndEntropyTables(zc); in ZSTD_compressBlock_internal()
2640 cSize = ZSTD_entropyCompressSequences(&zc->seqStore, in ZSTD_compressBlock_internal()
2641 &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy, in ZSTD_compressBlock_internal()
2642 &zc->appliedParams, in ZSTD_compressBlock_internal()
2645 zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressBlock_internal()
2646 zc->bmi2); in ZSTD_compressBlock_internal()
2648 if (zc->seqCollector.collectSequences) { in ZSTD_compressBlock_internal()
2649 ZSTD_copyBlockSequences(zc); in ZSTD_compressBlock_internal()
2659 !zc->isFirstBlock && in ZSTD_compressBlock_internal()
2669 ZSTD_confirmRepcodesAndEntropyTables(zc); in ZSTD_compressBlock_internal()
2675 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_internal()
2676 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_internal()
2681 static size_t ZSTD_compressBlock_targetCBlockSize_body(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize_body() argument
2692 !zc->isFirstBlock && in ZSTD_compressBlock_targetCBlockSize_body()
2693 ZSTD_maybeRLE(&zc->seqStore) && in ZSTD_compressBlock_targetCBlockSize_body()
2717 … size_t const cSize = ZSTD_compressSuperBlock(zc, dst, dstCapacity, src, srcSize, lastBlock); in ZSTD_compressBlock_targetCBlockSize_body()
2719 … size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, zc->appliedParams.cParams.strategy); in ZSTD_compressBlock_targetCBlockSize_body()
2722 ZSTD_confirmRepcodesAndEntropyTables(zc); in ZSTD_compressBlock_targetCBlockSize_body()
2736 static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize() argument
2742 const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_targetCBlockSize()
2744 …(unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, (unsigned)zc->blockSt… in ZSTD_compressBlock_targetCBlockSize()
2747 …cSize = ZSTD_compressBlock_targetCBlockSize_body(zc, dst, dstCapacity, src, srcSize, bss, lastBloc… in ZSTD_compressBlock_targetCBlockSize()
2750 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_targetCBlockSize()
2751 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_targetCBlockSize()