Lines Matching refs:zc

1827 static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,  in ZSTD_resetCCtx_internal()  argument
1834 ZSTD_cwksp* const ws = &zc->workspace; in ZSTD_resetCCtx_internal()
1839 zc->isFirstBlock = 1; in ZSTD_resetCCtx_internal()
1844 zc->appliedParams = *params; in ZSTD_resetCCtx_internal()
1845 params = &zc->appliedParams; in ZSTD_resetCCtx_internal()
1852 ZSTD_ldm_adjustParameters(&zc->appliedParams.ldmParams, &params->cParams); in ZSTD_resetCCtx_internal()
1869 int const indexTooClose = ZSTD_indexTooCloseToMax(zc->blockState.matchState.window); in ZSTD_resetCCtx_internal()
1872 (indexTooClose || dictTooBig || !zc->initialized) ? ZSTDirp_reset : ZSTDirp_continue; in ZSTD_resetCCtx_internal()
1876 … &params->cParams, &params->ldmParams, zc->staticSize != 0, params->useRowMatchFinder, in ZSTD_resetCCtx_internal()
1882 if (!zc->staticSize) ZSTD_cwksp_bump_oversized_duration(ws, 0); in ZSTD_resetCCtx_internal()
1896 RETURN_ERROR_IF(zc->staticSize, memory_allocation, "static cctx : no resize"); in ZSTD_resetCCtx_internal()
1900 ZSTD_cwksp_free(ws, zc->customMem); in ZSTD_resetCCtx_internal()
1901 FORWARD_IF_ERROR(ZSTD_cwksp_create(ws, neededSpace, zc->customMem), ""); in ZSTD_resetCCtx_internal()
1908zc->blockState.prevCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1909 …RETURN_ERROR_IF(zc->blockState.prevCBlock == NULL, memory_allocation, "couldn't allocate prevCBloc… in ZSTD_resetCCtx_internal()
1910zc->blockState.nextCBlock = (ZSTD_compressedBlockState_t*) ZSTD_cwksp_reserve_object(ws, sizeof(ZS… in ZSTD_resetCCtx_internal()
1911 …RETURN_ERROR_IF(zc->blockState.nextCBlock == NULL, memory_allocation, "couldn't allocate nextCBloc… in ZSTD_resetCCtx_internal()
1912 zc->entropyWorkspace = (U32*) ZSTD_cwksp_reserve_object(ws, ENTROPY_WORKSPACE_SIZE); in ZSTD_resetCCtx_internal()
1913 …RETURN_ERROR_IF(zc->entropyWorkspace == NULL, memory_allocation, "couldn't allocate entropyWorkspa… in ZSTD_resetCCtx_internal()
1919 zc->blockState.matchState.cParams = params->cParams; in ZSTD_resetCCtx_internal()
1920 zc->pledgedSrcSizePlusOne = pledgedSrcSize+1; in ZSTD_resetCCtx_internal()
1921 zc->consumedSrcSize = 0; in ZSTD_resetCCtx_internal()
1922 zc->producedCSize = 0; in ZSTD_resetCCtx_internal()
1924 zc->appliedParams.fParams.contentSizeFlag = 0; in ZSTD_resetCCtx_internal()
1926 (unsigned)pledgedSrcSize, zc->appliedParams.fParams.contentSizeFlag); in ZSTD_resetCCtx_internal()
1927 zc->blockSize = blockSize; in ZSTD_resetCCtx_internal()
1929 XXH64_reset(&zc->xxhState, 0); in ZSTD_resetCCtx_internal()
1930 zc->stage = ZSTDcs_init; in ZSTD_resetCCtx_internal()
1931 zc->dictID = 0; in ZSTD_resetCCtx_internal()
1932 zc->dictContentSize = 0; in ZSTD_resetCCtx_internal()
1934 ZSTD_reset_compressedBlockState(zc->blockState.prevCBlock); in ZSTD_resetCCtx_internal()
1939 zc->seqStore.litStart = ZSTD_cwksp_reserve_buffer(ws, blockSize + WILDCOPY_OVERLENGTH); in ZSTD_resetCCtx_internal()
1940 zc->seqStore.maxNbLit = blockSize; in ZSTD_resetCCtx_internal()
1943 zc->bufferedPolicy = zbuff; in ZSTD_resetCCtx_internal()
1944 zc->inBuffSize = buffInSize; in ZSTD_resetCCtx_internal()
1945 zc->inBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffInSize); in ZSTD_resetCCtx_internal()
1946 zc->outBuffSize = buffOutSize; in ZSTD_resetCCtx_internal()
1947 zc->outBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffOutSize); in ZSTD_resetCCtx_internal()
1955 zc->ldmState.bucketOffsets = ZSTD_cwksp_reserve_buffer(ws, numBuckets); in ZSTD_resetCCtx_internal()
1956 ZSTD_memset(zc->ldmState.bucketOffsets, 0, numBuckets); in ZSTD_resetCCtx_internal()
1960 ZSTD_referenceExternalSequences(zc, NULL, 0); in ZSTD_resetCCtx_internal()
1961 zc->seqStore.maxNbSeq = maxNbSeq; in ZSTD_resetCCtx_internal()
1962 zc->seqStore.llCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1963 zc->seqStore.mlCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1964 zc->seqStore.ofCode = ZSTD_cwksp_reserve_buffer(ws, maxNbSeq * sizeof(BYTE)); in ZSTD_resetCCtx_internal()
1965zc->seqStore.sequencesStart = (seqDef*)ZSTD_cwksp_reserve_aligned(ws, maxNbSeq * sizeof(seqDef)); in ZSTD_resetCCtx_internal()
1968 &zc->blockState.matchState, in ZSTD_resetCCtx_internal()
1980zc->ldmState.hashTable = (ldmEntry_t*)ZSTD_cwksp_reserve_aligned(ws, ldmHSize * sizeof(ldmEntry_t)… in ZSTD_resetCCtx_internal()
1981 ZSTD_memset(zc->ldmState.hashTable, 0, ldmHSize * sizeof(ldmEntry_t)); in ZSTD_resetCCtx_internal()
1982zc->ldmSequences = (rawSeq*)ZSTD_cwksp_reserve_aligned(ws, maxNbLdmSeq * sizeof(rawSeq)); in ZSTD_resetCCtx_internal()
1983 zc->maxNbLdmSequences = maxNbLdmSeq; in ZSTD_resetCCtx_internal()
1985 ZSTD_window_init(&zc->ldmState.window); in ZSTD_resetCCtx_internal()
1986 zc->ldmState.loadedDictEnd = 0; in ZSTD_resetCCtx_internal()
1992 zc->initialized = 1; in ZSTD_resetCCtx_internal()
2814 static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize) in ZSTD_buildSeqStore() argument
2816 ZSTD_matchState_t* const ms = &zc->blockState.matchState; in ZSTD_buildSeqStore()
2820 ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams); in ZSTD_buildSeqStore()
2822 if (zc->appliedParams.cParams.strategy >= ZSTD_btopt) { in ZSTD_buildSeqStore()
2823 ZSTD_ldm_skipRawSeqStoreBytes(&zc->externSeqStore, srcSize); in ZSTD_buildSeqStore()
2825 … ZSTD_ldm_skipSequences(&zc->externSeqStore, srcSize, zc->appliedParams.cParams.minMatch); in ZSTD_buildSeqStore()
2829 ZSTD_resetSeqStore(&(zc->seqStore)); in ZSTD_buildSeqStore()
2831 ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy; in ZSTD_buildSeqStore()
2833 ms->opt.literalCompressionMode = zc->appliedParams.literalCompressionMode; in ZSTD_buildSeqStore()
2853 zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i]; in ZSTD_buildSeqStore()
2855 if (zc->externSeqStore.pos < zc->externSeqStore.size) { in ZSTD_buildSeqStore()
2856 assert(zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_disable); in ZSTD_buildSeqStore()
2859 ZSTD_ldm_blockCompress(&zc->externSeqStore, in ZSTD_buildSeqStore()
2860 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2861 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2862 zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2864 assert(zc->externSeqStore.pos <= zc->externSeqStore.size); in ZSTD_buildSeqStore()
2865 } else if (zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable) { in ZSTD_buildSeqStore()
2868 ldmSeqStore.seq = zc->ldmSequences; in ZSTD_buildSeqStore()
2869 ldmSeqStore.capacity = zc->maxNbLdmSequences; in ZSTD_buildSeqStore()
2871 FORWARD_IF_ERROR(ZSTD_ldm_generateSequences(&zc->ldmState, &ldmSeqStore, in ZSTD_buildSeqStore()
2872 &zc->appliedParams.ldmParams, in ZSTD_buildSeqStore()
2877 ms, &zc->seqStore, in ZSTD_buildSeqStore()
2878 zc->blockState.nextCBlock->rep, in ZSTD_buildSeqStore()
2879 zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2883 …ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.… in ZSTD_buildSeqStore()
2884zc->appliedParams.useRowMatchFinder, in ZSTD_buildSeqStore()
2887 … lastLLSize = blockCompressor(ms, &zc->seqStore, zc->blockState.nextCBlock->rep, src, srcSize); in ZSTD_buildSeqStore()
2890 ZSTD_storeLastLiterals(&zc->seqStore, lastLiterals, lastLLSize); in ZSTD_buildSeqStore()
2895 static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc) in ZSTD_copyBlockSequences() argument
2897 const seqStore_t* seqStore = ZSTD_getSeqStore(zc); in ZSTD_copyBlockSequences()
2904 ZSTD_Sequence* outSeqs = &zc->seqCollector.seqStart[zc->seqCollector.seqIndex]; in ZSTD_copyBlockSequences()
2908 assert(zc->seqCollector.seqIndex + 1 < zc->seqCollector.maxSequences); in ZSTD_copyBlockSequences()
2910 assert(zc->seqCollector.maxSequences >= seqStoreSeqSize + 1); in ZSTD_copyBlockSequences()
2911 ZSTD_memcpy(updatedRepcodes.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_copyBlockSequences()
2956 zc->seqCollector.seqIndex += seqStoreSeqSize; in ZSTD_copyBlockSequences()
2959 size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs, in ZSTD_generateSequences() argument
2972 zc->seqCollector = seqCollector; in ZSTD_generateSequences()
2974 ZSTD_compress2(zc, dst, dstCapacity, src, srcSize); in ZSTD_generateSequences()
2976 return zc->seqCollector.seqIndex; in ZSTD_generateSequences()
3350 …ic size_t ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(seqStore_t* seqStore, ZSTD_CCtx* zc) { in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize() argument
3351 ZSTD_entropyCTablesMetadata_t* entropyMetadata = &zc->blockSplitCtx.entropyMetadata; in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3354 &zc->blockState.prevCBlock->entropy, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3355 &zc->blockState.nextCBlock->entropy, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3356 &zc->appliedParams, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3358zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */), ""); in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3362 …&zc->blockState.nextCBlock->entropy, entropyMetadata, zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE, in ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize()
3498 ZSTD_compressSeqStore_singleBlock(ZSTD_CCtx* zc, seqStore_t* const seqStore, in ZSTD_compressSeqStore_singleBlock() argument
3518 &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy, in ZSTD_compressSeqStore_singleBlock()
3519 &zc->appliedParams, in ZSTD_compressSeqStore_singleBlock()
3522zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressSeqStore_singleBlock()
3523 zc->bmi2); in ZSTD_compressSeqStore_singleBlock()
3526 if (!zc->isFirstBlock && in ZSTD_compressSeqStore_singleBlock()
3536 if (zc->seqCollector.collectSequences) { in ZSTD_compressSeqStore_singleBlock()
3537 ZSTD_copyBlockSequences(zc); in ZSTD_compressSeqStore_singleBlock()
3538 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressSeqStore_singleBlock()
3553 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressSeqStore_singleBlock()
3559 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressSeqStore_singleBlock()
3560 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressSeqStore_singleBlock()
3587 ZSTD_CCtx* zc, const seqStore_t* origSeqStore) in ZSTD_deriveBlockSplitsHelper() argument
3589 seqStore_t* fullSeqStoreChunk = &zc->blockSplitCtx.fullSeqStoreChunk; in ZSTD_deriveBlockSplitsHelper()
3590 seqStore_t* firstHalfSeqStore = &zc->blockSplitCtx.firstHalfSeqStore; in ZSTD_deriveBlockSplitsHelper()
3591 seqStore_t* secondHalfSeqStore = &zc->blockSplitCtx.secondHalfSeqStore; in ZSTD_deriveBlockSplitsHelper()
3605 … estimatedOriginalSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(fullSeqStoreChunk, zc); in ZSTD_deriveBlockSplitsHelper()
3606 …estimatedFirstHalfSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(firstHalfSeqStore, zc); in ZSTD_deriveBlockSplitsHelper()
3607 …timatedSecondHalfSize = ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(secondHalfSeqStore, zc); in ZSTD_deriveBlockSplitsHelper()
3614 ZSTD_deriveBlockSplitsHelper(splits, startIdx, midIdx, zc, origSeqStore); in ZSTD_deriveBlockSplitsHelper()
3617 ZSTD_deriveBlockSplitsHelper(splits, midIdx, endIdx, zc, origSeqStore); in ZSTD_deriveBlockSplitsHelper()
3625 static size_t ZSTD_deriveBlockSplits(ZSTD_CCtx* zc, U32 partitions[], U32 nbSeq) { in ZSTD_deriveBlockSplits() argument
3632 ZSTD_deriveBlockSplitsHelper(&splits, 0, nbSeq, zc, &zc->seqStore); in ZSTD_deriveBlockSplits()
3644 ZSTD_compressBlock_splitBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCapacity, in ZSTD_compressBlock_splitBlock_internal() argument
3652 U32* partitions = zc->blockSplitCtx.partitions; /* size == ZSTD_MAX_NB_BLOCK_SPLITS */ in ZSTD_compressBlock_splitBlock_internal()
3653 seqStore_t* nextSeqStore = &zc->blockSplitCtx.nextSeqStore; in ZSTD_compressBlock_splitBlock_internal()
3654 seqStore_t* currSeqStore = &zc->blockSplitCtx.currSeqStore; in ZSTD_compressBlock_splitBlock_internal()
3655 size_t numSplits = ZSTD_deriveBlockSplits(zc, partitions, nbSeq); in ZSTD_compressBlock_splitBlock_internal()
3673 ZSTD_memcpy(dRep.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3674 ZSTD_memcpy(cRep.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3678 (unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, in ZSTD_compressBlock_splitBlock_internal()
3679 (unsigned)zc->blockState.matchState.nextToUpdate); in ZSTD_compressBlock_splitBlock_internal()
3682 size_t cSizeSingleBlock = ZSTD_compressSeqStore_singleBlock(zc, &zc->seqStore, in ZSTD_compressBlock_splitBlock_internal()
3693 ZSTD_deriveSeqStoreChunk(currSeqStore, &zc->seqStore, 0, partitions[0]); in ZSTD_compressBlock_splitBlock_internal()
3707 ZSTD_deriveSeqStoreChunk(nextSeqStore, &zc->seqStore, partitions[i], partitions[i+1]); in ZSTD_compressBlock_splitBlock_internal()
3710 cSizeChunk = ZSTD_compressSeqStore_singleBlock(zc, currSeqStore, in ZSTD_compressBlock_splitBlock_internal()
3715 …tual size: %zu", ZSTD_buildEntropyStatisticsAndEstimateSubBlockSize(currSeqStore, zc), cSizeChunk); in ZSTD_compressBlock_splitBlock_internal()
3728 ZSTD_memcpy(zc->blockState.prevCBlock->rep, dRep.rep, sizeof(repcodes_t)); in ZSTD_compressBlock_splitBlock_internal()
3733 ZSTD_compressBlock_splitBlock(ZSTD_CCtx* zc, in ZSTD_compressBlock_splitBlock() argument
3742 assert(zc->appliedParams.useBlockSplitter == ZSTD_ps_enable); in ZSTD_compressBlock_splitBlock()
3744 { const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_splitBlock()
3747 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_splitBlock()
3748 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_splitBlock()
3754 nbSeq = (U32)(zc->seqStore.sequences - zc->seqStore.sequencesStart); in ZSTD_compressBlock_splitBlock()
3757 …cSize = ZSTD_compressBlock_splitBlock_internal(zc, dst, dstCapacity, src, srcSize, lastBlock, nbSe… in ZSTD_compressBlock_splitBlock()
3763 ZSTD_compressBlock_internal(ZSTD_CCtx* zc, in ZSTD_compressBlock_internal() argument
3776 (unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, in ZSTD_compressBlock_internal()
3777 (unsigned)zc->blockState.matchState.nextToUpdate); in ZSTD_compressBlock_internal()
3779 { const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_internal()
3784 if (zc->seqCollector.collectSequences) { in ZSTD_compressBlock_internal()
3785 ZSTD_copyBlockSequences(zc); in ZSTD_compressBlock_internal()
3786 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_internal()
3791 cSize = ZSTD_entropyCompressSeqStore(&zc->seqStore, in ZSTD_compressBlock_internal()
3792 &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy, in ZSTD_compressBlock_internal()
3793 &zc->appliedParams, in ZSTD_compressBlock_internal()
3796 zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */, in ZSTD_compressBlock_internal()
3797 zc->bmi2); in ZSTD_compressBlock_internal()
3804 !zc->isFirstBlock && in ZSTD_compressBlock_internal()
3814 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_internal()
3820 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_internal()
3821 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_internal()
3826 static size_t ZSTD_compressBlock_targetCBlockSize_body(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize_body() argument
3837 !zc->isFirstBlock && in ZSTD_compressBlock_targetCBlockSize_body()
3838 ZSTD_maybeRLE(&zc->seqStore) && in ZSTD_compressBlock_targetCBlockSize_body()
3862 … size_t const cSize = ZSTD_compressSuperBlock(zc, dst, dstCapacity, src, srcSize, lastBlock); in ZSTD_compressBlock_targetCBlockSize_body()
3864 … size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, zc->appliedParams.cParams.strategy); in ZSTD_compressBlock_targetCBlockSize_body()
3867 ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState); in ZSTD_compressBlock_targetCBlockSize_body()
3881 static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc, in ZSTD_compressBlock_targetCBlockSize() argument
3887 const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize); in ZSTD_compressBlock_targetCBlockSize()
3889 …(unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit, (unsigned)zc->blockSt… in ZSTD_compressBlock_targetCBlockSize()
3892 …cSize = ZSTD_compressBlock_targetCBlockSize_body(zc, dst, dstCapacity, src, srcSize, bss, lastBloc… in ZSTD_compressBlock_targetCBlockSize()
3895 if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid) in ZSTD_compressBlock_targetCBlockSize()
3896 zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check; in ZSTD_compressBlock_targetCBlockSize()