Lines Matching refs:zc

1748 static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,  in ZSTD_resetCCtx_internal()  argument
1755 ZSTD_cwksp* const ws = &zc->workspace; in ZSTD_resetCCtx_internal()
1760 zc->isFirstBlock = 1; in ZSTD_resetCCtx_internal()
1765 zc->appliedParams = *params; in ZSTD_resetCCtx_internal()
1766 params = &zc->appliedParams; in ZSTD_resetCCtx_internal()
1773 ZSTD_ldm_adjustParameters(&zc->appliedParams.ldmParams, &params->cParams); in ZSTD_resetCCtx_internal()
1790 int const indexTooClose = ZSTD_indexTooCloseToMax(zc->blockState.matchState.window); in ZSTD_resetCCtx_internal()
1793 (indexTooClose || dictTooBig || !zc->initialized) ? ZSTDirp_reset : ZSTDirp_continue; in ZSTD_resetCCtx_internal()
1797 … &params->cParams, &params->ldmParams, zc->staticSize != 0, params->useRowMatchFinder, in ZSTD_resetCCtx_internal()
1803 if (!zc->staticSize) ZSTD_cwksp_bump_oversized_duration(ws, 0); in ZSTD_resetCCtx_internal()
1817 RETURN_ERROR_IF(zc->staticSize, memory_allocation, "static cctx : no resize"); in ZSTD_resetCCtx_internal()
1821 ZSTD_cwksp_free(ws, zc->customMem); in ZSTD_resetCCtx_internal()
1822 FORWARD_IF_ERROR(ZSTD_cwksp_create(ws, neededSpace, zc->customMem), ""); in ZSTD_resetCCtx_internal()
1829zc->blockState.prevCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1830 …RETURN_ERROR_IF(zc->blockState.prevCBlock == NULL, memory_allocation, "couldn't allocate prevCBloc… in ZSTD_resetCCtx_internal()
1831zc->blockState.nextCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1832 …RETURN_ERROR_IF(zc->blockState.nextCBlock == NULL, memory_allocation, "couldn't allocate nextCBloc… in ZSTD_resetCCtx_internal()
1833 zc->entropyWorkspace = (U32*) ZSTD_cwksp_reserve_object(ws, ENTROPY_WORKSPACE_SIZE); in ZSTD_resetCCtx_internal()
1834 …RETURN_ERROR_IF(zc->entropyWorkspace == NULL, memory_allocation, "couldn't allocate entropyWorkspa… in ZSTD_resetCCtx_internal()
1840 zc->blockState.matchState.cParams = params->cParams; in ZSTD_resetCCtx_internal()
1841 zc->pledgedSrcSizePlusOne = pledgedSrcSize+1; in ZSTD_resetCCtx_internal()
1842 zc->consumedSrcSize = 0; in ZSTD_resetCCtx_internal()
1843 zc->producedCSize = 0; in ZSTD_resetCCtx_internal()
1845 zc->appliedParams.fParams.contentSizeFlag = 0; in ZSTD_resetCCtx_internal()
1847 (unsigned)pledgedSrcSize, zc->appliedParams.fParams.contentSizeFlag); in ZSTD_resetCCtx_internal()
1848 zc->blockSize = blockSize; in ZSTD_resetCCtx_internal()
1850 xxh64_reset(&zc->xxhState, 0); in ZSTD_resetCCtx_internal()
1851 zc->stage = ZSTDcs_init; in ZSTD_resetCCtx_internal()
1852 zc->dictID = 0; in ZSTD_resetCCtx_internal()
1853 zc->dictContentSize = 0; in ZSTD_resetCCtx_internal()
1855 ZSTD_reset_compressedBlockState(zc->blockState.prevCBlock); in ZSTD_resetCCtx_internal()
1860 zc->seqStore.litStart = ZSTD_cwksp_reserve_buffer(ws, blockSize + WILDCOPY_OVERLENGTH); in ZSTD_resetCCtx_internal()
1861 zc->seqStore.maxNbLit = blockSize; in ZSTD_resetCCtx_internal()
1864 zc->bufferedPolicy = zbuff; in ZSTD_resetCCtx_internal()
1865 zc->inBuffSize = buffInSize; in ZSTD_resetCCtx_internal()
1866 zc->inBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffInSize); in ZSTD_resetCCtx_internal()
1867 zc->outBuffSize = buffOutSize; in ZSTD_resetCCtx_internal()
1868 zc->outBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffOutSize); in ZSTD_resetCCtx_internal()
1876 zc->ldmState.bucketOffsets = ZSTD_cwksp_reserve_buffer(ws, numBuckets); in ZSTD_resetCCtx_internal()
1877 ZSTD_memset(zc->ldmState.bucketOffsets, 0, numBuckets); in ZSTD_resetCCtx_internal()
1881 ZSTD_referenceExternalSequences(zc, NULL, 0); in ZSTD_resetCCtx_internal()
1882 zc->seqStore.maxNbSeq = maxNbSeq; in ZSTD_resetCCtx_internal()
1883 zc->seqStore.llCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1884 zc->seqStore.mlCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1885 zc->seqStore.ofCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1886zc->seqStore.sequencesStart = (seqDef*)ZSTD_cwksp_reserve_aligned(ws, maxNbSeq * sizeof(seqDef)); in ZSTD_resetCCtx_internal()
1889 &zc->blockState.matchState, in ZSTD_resetCCtx_internal()
1901zc->ldmState.hashTable = (ldmEntry_t*)ZSTD_cwksp_reserve_aligned(ws, ldmHSize * sizeof(ldmEntry_t)… in ZSTD_resetCCtx_internal()
1902 ZSTD_memset(zc->ldmState.hashTable, 0, ldmHSize * sizeof(ldmEntry_t)); in ZSTD_resetCCtx_internal()
1903zc->ldmSequences = (rawSeq*)ZSTD_cwksp_reserve_aligned(ws, maxNbLdmSeq * sizeof(rawSeq)); in ZSTD_resetCCtx_internal()
1904 zc->maxNbLdmSequences = maxNbLdmSeq; in ZSTD_resetCCtx_internal()
1906 ZSTD_window_init(&zc->ldmState.window); in ZSTD_resetCCtx_internal()
1907 zc->ldmState.loadedDictEnd = 0; in ZSTD_resetCCtx_internal()
1913 zc->initialized = 1; in ZSTD_resetCCtx_internal()
2723 static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize) in ZSTD_buildSeqStore() argument
2725 ZSTD_matchState_t* const ms = &zc->blockState.matchState; in ZSTD_buildSeqStore()
2729 ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams); in ZSTD_buildSeqStore()
2731 if (zc->appliedParams.cParams.strategy >= ZSTD_btopt) { in ZSTD_buildSeqStore()
2732 ZSTD_ldm_skipRawSeqStoreBytes(&zc->externSeqStore, srcSize); in ZSTD_buildSeqStore()
2734 … ZSTD_ldm_skipSequences(&zc->externSeqStore, srcSize, zc->appliedParams.cParams.minMatch); in ZSTD_buildSeqStore()
2738 ZSTD_resetSeqStore(&(zc->seqStore)); in ZSTD_buildSeqStore()
2740 ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy; in ZSTD_buildSeqStore()
2742 ms->opt.literalCompressionMode = zc->appliedParams.literalCompressionMode; in ZSTD_buildSeqStore()
2762 zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i]; in ZSTD_buildSeqStore()
2764 if (zc->externSeqStore.pos < zc->externSeqStore.size) { in ZSTD_buildSeqStore()
2765 assert(zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_disable); in ZSTD_buildSeqStore()
2768 ZSTD_ldm_blockCompress(&zc->externSeqStore, in ZSTD_buildSeqStore()
2769 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2770 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2771 zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2773 assert(zc->externSeqStore.pos <= zc->externSeqStore.size); in ZSTD_buildSeqStore()
2774 } else if (zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable) { in ZSTD_buildSeqStore()
2777 ldmSeqStore.seq = zc->ldmSequences; in ZSTD_buildSeqStore()
2778 ldmSeqStore.capacity = zc->maxNbLdmSequences; in ZSTD_buildSeqStore()
2780 FORWARD_IF_ERROR(ZSTD_ldm_generateSequences(&zc->ldmState, &ldmSeqStore, in ZSTD_buildSeqStore()
2781 &zc->appliedParams.ldmParams, in ZSTD_buildSeqStore()
2786 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2787 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2788 zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2792 …ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.… in ZSTD_buildSeqStore()
2793zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2796 … lastLLSize = blockCompressor(ms, &zc->seqStore, zc->blockState.nextCBlock->rep, src, srcSize); in ZSTD_buildSeqStore()
2799 ZSTD_storeLastLiterals(&zc->seqStore, lastLiterals, lastLLSize); in ZSTD_buildSeqStore()
2804 static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc) in ZSTD_copyBlockSequences() argument
2806 const seqStore_t* seqStore = ZSTD_getSeqStore(zc); in ZSTD_copyBlockSequences()
2813 ZSTD_Sequence* outSeqs = &zc->seqCollector.seqStart[zc->seqCollector.seqIndex]; in ZSTD_copyBlockSequences()
2817 assert(zc->seqCollector.seqIndex + 1 < zc->seqCollector.maxSequences); in ZSTD_copyBlockSequences()
2819 assert(zc->seqCollector.maxSequences >= seqStoreSeqSize + 1); in ZSTD_copyBlockSequences()
2820 ZSTD_memcpy(updatedRepcodes.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_copyBlockSequences()
2865 zc->seqCollector.seqIndex += seqStoreSeqSize; in ZSTD_copyBlockSequences()
2868 size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs, in ZSTD_generateSequences() argument
2881 zc->seqCollector = seqCollector; in ZSTD_generateSequences()
2883 ZSTD_compress2(zc, dst, dstCapacity, src, srcSize); in ZSTD_generateSequences()
2885 return zc->seqCollector.seqIndex; in ZSTD_generateSequences()
3259 …ic size_t ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(seqStore_t* seqStore, ZSTD_CCtx* zc) { in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize() argument
3260 ZSTD_entropyCTablesMetadata_t* entropyMetadata = &zc->blockSplitCtx.entropyMetadata; in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3263 &zc->blockState.prevCBlock->entropy, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3264 &zc->blockState.nextCBlock->entropy, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3265 &zc->appliedParams, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3267zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */), ""); in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3271 …&zc->blockState.nextCBlock->entropy, entropyMetadata, zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3407 ZSTD_compressSeqStore_singleBlock(ZSTD_CCtx* zc, seqStore_t* const seqStore, in ZSTD_compressSeqStore_singleBlock() argument
3427 &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy, in ZSTD_compressSeqStore_singleBlock()
3428 &zc->appliedParams, in ZSTD_compressSeqStore_singleBlock()
3431zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressSeqStore_singleBlock()
3432 zc->bmi2); in ZSTD_compressSeqStore_singleBlock()
3435 if (!zc->isFirstBlock && in ZSTD_compressSeqStore_singleBlock()
3445 if (zc->seqCollector.collectSequences) { in ZSTD_compressSeqStore_singleBlock()
3446 ZSTD_copyBlockSequences(zc); in ZSTD_compressSeqStore_singleBlock()
3447 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressSeqStore_singleBlock()
3462 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressSeqStore_singleBlock()
3468 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressSeqStore_singleBlock()
3469 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressSeqStore_singleBlock()
3496 ZSTD_CCtx* zc, const seqStore_t* origSeqStore) in ZSTD_deriveBlockSplitsHelper() argument
3498 seqStore_t* fullSeqStoreChunk = &zc->blockSplitCtx.fullSeqStoreChunk; in ZSTD_deriveBlockSplitsHelper()
3499 seqStore_t* firstHalfSeqStore = &zc->blockSplitCtx.firstHalfSeqStore; in ZSTD_deriveBlockSplitsHelper()
3500 seqStore_t* secondHalfSeqStore = &zc->blockSplitCtx.secondHalfSeqStore; in ZSTD_deriveBlockSplitsHelper()
3514 … estimatedOriginalSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(fullSeqStoreChunk, zc); in ZSTD_deriveBlockSplitsHelper()
3515 …estimatedFirstHalfSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(firstHalfSeqStore, zc); in ZSTD_deriveBlockSplitsHelper()
3516 …timatedSecondHalfSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(secondHalfSeqStore, zc); in ZSTD_deriveBlockSplitsHelper()
3523 ZSTD_deriveBlockSplitsHelper(splits, startIdx, midIdx, zc, origSeqStore); in ZSTD_deriveBlockSplitsHelper()
3526 ZSTD_deriveBlockSplitsHelper(splits, midIdx, endIdx, zc, origSeqStore); in ZSTD_deriveBlockSplitsHelper()
3534 static size_t ZSTD_deriveBlockSplits(ZSTD_CCtx* zc, U32 partitions[], U32 nbSeq) { in ZSTD_deriveBlockSplits() argument
3541 ZSTD_deriveBlockSplitsHelper(&splits, 0, nbSeq, zc, &zc->seqStore); in ZSTD_deriveBlockSplits()
3553 ZSTD_compressBlock_splitBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCapacity, in ZSTD_compressBlock_splitBlock_internal() argument
3561 U32* partitions = zc->blockSplitCtx.partitions; /* size == ZSTD_MAX_NB_BLOCK_SPLITS */ in ZSTD_compressBlock_splitBlock_internal()
3562 seqStore_t* nextSeqStore = &zc->blockSplitCtx.nextSeqStore; in ZSTD_compressBlock_splitBlock_internal()
3563 seqStore_t* currSeqStore = &zc->blockSplitCtx.currSeqStore; in ZSTD_compressBlock_splitBlock_internal()
3564 size_t numSplits = ZSTD_deriveBlockSplits(zc, partitions, nbSeq); in ZSTD_compressBlock_splitBlock_internal()
3582 ZSTD_memcpy(dRep.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3583 ZSTD_memcpy(cRep.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3587 (unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, in ZSTD_compressBlock_splitBlock_internal()
3588 (unsigned)zc->blockState.matchState.nextToUpdate); in ZSTD_compressBlock_splitBlock_internal()
3591 size_t cSizeSingleBlock = ZSTD_compressSeqStore_singleBlock(zc, &zc->seqStore, in ZSTD_compressBlock_splitBlock_internal()
3602 ZSTD_deriveSeqStoreChunk(currSeqStore, &zc->seqStore, 0, partitions[0]); in ZSTD_compressBlock_splitBlock_internal()
3616 ZSTD_deriveSeqStoreChunk(nextSeqStore, &zc->seqStore, partitions[i], partitions[i+1]); in ZSTD_compressBlock_splitBlock_internal()
3619 cSizeChunk = ZSTD_compressSeqStore_singleBlock(zc, currSeqStore, in ZSTD_compressBlock_splitBlock_internal()
3624 …tual size: %zu", ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(currSeqStore, zc), cSizeChunk); in ZSTD_compressBlock_splitBlock_internal()
3637 ZSTD_memcpy(zc->blockState.prevCBlock->rep, dRep.rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3642 ZSTD_compressBlock_splitBlock(ZSTD_CCtx* zc, in ZSTD_compressBlock_splitBlock() argument
3651 assert(zc->appliedParams.useBlockSplitter == ZSTD_ps_enable); in ZSTD_compressBlock_splitBlock()
3653 { const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_splitBlock()
3656 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_splitBlock()
3657 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_splitBlock()
3663 nbSeq = (U32)(zc->seqStore.sequences - zc->seqStore.sequencesStart); in ZSTD_compressBlock_splitBlock()
3666 …cSize = ZSTD_compressBlock_splitBlock_internal(zc, dst, dstCapacity, src, srcSize, lastBlock, nbSe… in ZSTD_compressBlock_splitBlock()
3672 ZSTD_compressBlock_internal(ZSTD_CCtx* zc, in ZSTD_compressBlock_internal() argument
3685 (unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, in ZSTD_compressBlock_internal()
3686 (unsigned)zc->blockState.matchState.nextToUpdate); in ZSTD_compressBlock_internal()
3688 { const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_internal()
3693 if (zc->seqCollector.collectSequences) { in ZSTD_compressBlock_internal()
3694 ZSTD_copyBlockSequences(zc); in ZSTD_compressBlock_internal()
3695 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_internal()
3700 cSize = ZSTD_entropyCompressSeqStore(&zc->seqStore, in ZSTD_compressBlock_internal()
3701 &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy, in ZSTD_compressBlock_internal()
3702 &zc->appliedParams, in ZSTD_compressBlock_internal()
3705 zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressBlock_internal()
3706 zc->bmi2); in ZSTD_compressBlock_internal()
3713 !zc->isFirstBlock && in ZSTD_compressBlock_internal()
3723 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_internal()
3729 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_internal()
3730 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_internal()
3735 static size_t ZSTD_compressBlock_targetCBlockSize_body(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize_body() argument
3746 !zc->isFirstBlock && in ZSTD_compressBlock_targetCBlockSize_body()
3747 ZSTD_maybeRLE(&zc->seqStore) && in ZSTD_compressBlock_targetCBlockSize_body()
3771 … size_t const cSize = ZSTD_compressSuperBlock(zc, dst, dstCapacity, src, srcSize, lastBlock); in ZSTD_compressBlock_targetCBlockSize_body()
3773 … size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, zc->appliedParams.cParams.strategy); in ZSTD_compressBlock_targetCBlockSize_body()
3776 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_targetCBlockSize_body()
3790 static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize() argument
3796 const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_targetCBlockSize()
3798 …(unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, (unsigned)zc->blockSt… in ZSTD_compressBlock_targetCBlockSize()
3801 …cSize = ZSTD_compressBlock_targetCBlockSize_body(zc, dst, dstCapacity, src, srcSize, bss, lastBloc… in ZSTD_compressBlock_targetCBlockSize()
3804 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_targetCBlockSize()
3805 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_targetCBlockSize()