mirror of
https://github.com/facebook/zstd.git
synced 2025-10-21 00:05:22 -04:00
Rename internal function compressSequences(), and promote new *_ext() functions to their actual name
This commit is contained in:
parent
013434e1e4
commit
c675fb46f1
@ -2115,10 +2115,10 @@ static int ZSTD_useTargetCBlockSize(const ZSTD_CCtx_params* cctxParams)
|
|||||||
return (cctxParams->targetCBlockSize != 0);
|
return (cctxParams->targetCBlockSize != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ZSTD_compressSequences_internal():
|
/* ZSTD_compressSeqs_internal():
|
||||||
* actually compresses both literals and sequences */
|
* actually compresses both literals and sequences */
|
||||||
MEM_STATIC size_t
|
MEM_STATIC size_t
|
||||||
ZSTD_compressSequences_internal(seqStore_t* seqStorePtr,
|
ZSTD_compressSeqs_internal(seqStore_t* seqStorePtr,
|
||||||
const ZSTD_entropyCTables_t* prevEntropy,
|
const ZSTD_entropyCTables_t* prevEntropy,
|
||||||
ZSTD_entropyCTables_t* nextEntropy,
|
ZSTD_entropyCTables_t* nextEntropy,
|
||||||
const ZSTD_CCtx_params* cctxParams,
|
const ZSTD_CCtx_params* cctxParams,
|
||||||
@ -2147,15 +2147,7 @@ ZSTD_compressSequences_internal(seqStore_t* seqStorePtr,
|
|||||||
entropyWorkspace = count + (MaxSeq + 1);
|
entropyWorkspace = count + (MaxSeq + 1);
|
||||||
entropyWkspSize -= (MaxSeq + 1) * sizeof(*count);
|
entropyWkspSize -= (MaxSeq + 1) * sizeof(*count);
|
||||||
|
|
||||||
DEBUGLOG(4, "ZSTD_compressSequences_internal (nbSeq=%zu)", nbSeq);
|
DEBUGLOG(4, "ZSTD_compressSeqs_internal (nbSeq=%zu)", nbSeq);
|
||||||
/*DEBUGLOG(4, "First seqs:", nbSeq);
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
|
||||||
DEBUGLOG(4, "(of: %u ml: %u ll: %u)", seqStorePtr->sequencesStart[i].offset, seqStorePtr->sequencesStart[i].matchLength, seqStorePtr->sequencesStart[i].litLength);
|
|
||||||
}
|
|
||||||
DEBUGLOG(4, "Final seqs:", nbSeq);
|
|
||||||
for (int i = 1; i < 5; ++i) {
|
|
||||||
DEBUGLOG(4, "(of: %u ml: %u ll: %u)", seqStorePtr->sequencesStart[nbSeq-i].offset, seqStorePtr->sequencesStart[nbSeq-i].matchLength, seqStorePtr->sequencesStart[nbSeq-i].litLength);
|
|
||||||
}*/
|
|
||||||
ZSTD_STATIC_ASSERT(HUF_WORKSPACE_SIZE >= (1<<MAX(MLFSELog,LLFSELog)));
|
ZSTD_STATIC_ASSERT(HUF_WORKSPACE_SIZE >= (1<<MAX(MLFSELog,LLFSELog)));
|
||||||
assert(entropyWkspSize >= HUF_WORKSPACE_SIZE);
|
assert(entropyWkspSize >= HUF_WORKSPACE_SIZE);
|
||||||
|
|
||||||
@ -2317,7 +2309,7 @@ ZSTD_compressSequences_internal(seqStore_t* seqStorePtr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC size_t
|
MEM_STATIC size_t
|
||||||
ZSTD_compressSequences(seqStore_t* seqStorePtr,
|
ZSTD_compressSeqs(seqStore_t* seqStorePtr,
|
||||||
const ZSTD_entropyCTables_t* prevEntropy,
|
const ZSTD_entropyCTables_t* prevEntropy,
|
||||||
ZSTD_entropyCTables_t* nextEntropy,
|
ZSTD_entropyCTables_t* nextEntropy,
|
||||||
const ZSTD_CCtx_params* cctxParams,
|
const ZSTD_CCtx_params* cctxParams,
|
||||||
@ -2326,7 +2318,7 @@ ZSTD_compressSequences(seqStore_t* seqStorePtr,
|
|||||||
void* entropyWorkspace, size_t entropyWkspSize,
|
void* entropyWorkspace, size_t entropyWkspSize,
|
||||||
int bmi2)
|
int bmi2)
|
||||||
{
|
{
|
||||||
size_t const cSize = ZSTD_compressSequences_internal(
|
size_t const cSize = ZSTD_compressSeqs_internal(
|
||||||
seqStorePtr, prevEntropy, nextEntropy, cctxParams,
|
seqStorePtr, prevEntropy, nextEntropy, cctxParams,
|
||||||
dst, dstCapacity,
|
dst, dstCapacity,
|
||||||
entropyWorkspace, entropyWkspSize, bmi2);
|
entropyWorkspace, entropyWkspSize, bmi2);
|
||||||
@ -2336,13 +2328,13 @@ ZSTD_compressSequences(seqStore_t* seqStorePtr,
|
|||||||
*/
|
*/
|
||||||
if ((cSize == ERROR(dstSize_tooSmall)) & (srcSize <= dstCapacity))
|
if ((cSize == ERROR(dstSize_tooSmall)) & (srcSize <= dstCapacity))
|
||||||
return 0; /* block not compressed */
|
return 0; /* block not compressed */
|
||||||
FORWARD_IF_ERROR(cSize, "ZSTD_compressSequences_internal failed");
|
FORWARD_IF_ERROR(cSize, "ZSTD_compressSeqs_internal failed");
|
||||||
|
|
||||||
/* Check compressibility */
|
/* Check compressibility */
|
||||||
{ size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, cctxParams->cParams.strategy);
|
{ size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, cctxParams->cParams.strategy);
|
||||||
if (cSize >= maxCSize) return 0; /* block not compressed */
|
if (cSize >= maxCSize) return 0; /* block not compressed */
|
||||||
}
|
}
|
||||||
DEBUGLOG(4, "compressSequences cSize: %u\n", cSize);
|
DEBUGLOG(4, "compressSeqs cSize: %u\n", cSize);
|
||||||
return cSize;
|
return cSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2652,7 +2644,7 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* encode sequences and literals */
|
/* encode sequences and literals */
|
||||||
cSize = ZSTD_compressSequences(&zc->seqStore,
|
cSize = ZSTD_compressSeqs(&zc->seqStore,
|
||||||
&zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy,
|
&zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy,
|
||||||
&zc->appliedParams,
|
&zc->appliedParams,
|
||||||
dst, dstCapacity,
|
dst, dstCapacity,
|
||||||
@ -4676,7 +4668,7 @@ static size_t ZSTD_copySequencesToSeqStore(seqStore_t* seqStore, const ZSTD_sequ
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_compressSequences_ext_internal(void* dst, size_t dstCapacity,
|
size_t ZSTD_compressSequences_internal(void* dst, size_t dstCapacity,
|
||||||
ZSTD_CCtx* cctx,
|
ZSTD_CCtx* cctx,
|
||||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
@ -4692,7 +4684,7 @@ size_t ZSTD_compressSequences_ext_internal(void* dst, size_t dstCapacity,
|
|||||||
blockSeqStore.longLengthPos = 0;
|
blockSeqStore.longLengthPos = 0;
|
||||||
size_t origDstCapacity = dstCapacity;
|
size_t origDstCapacity = dstCapacity;
|
||||||
|
|
||||||
DEBUGLOG(4, "ZSTD_compressSequences_ext_internal srcSize: %zu, inSeqsSize: %zu", srcSize, inSeqsSize);
|
DEBUGLOG(4, "ZSTD_compressSequences_internal srcSize: %zu, inSeqsSize: %zu", srcSize, inSeqsSize);
|
||||||
BYTE const* ip = (BYTE const*)src;
|
BYTE const* ip = (BYTE const*)src;
|
||||||
BYTE* op = (BYTE*)dst;
|
BYTE* op = (BYTE*)dst;
|
||||||
|
|
||||||
@ -4722,7 +4714,7 @@ size_t ZSTD_compressSequences_ext_internal(void* dst, size_t dstCapacity,
|
|||||||
|
|
||||||
FORWARD_IF_ERROR(ZSTD_copySequencesToSeqStore(&blockSeqStore, &seqRange, inSeqs, inSeqsSize, ip, blockSize, format),
|
FORWARD_IF_ERROR(ZSTD_copySequencesToSeqStore(&blockSeqStore, &seqRange, inSeqs, inSeqsSize, ip, blockSize, format),
|
||||||
"Sequence copying failed");
|
"Sequence copying failed");
|
||||||
compressedSeqsSize = ZSTD_compressSequences(&blockSeqStore,
|
compressedSeqsSize = ZSTD_compressSeqs(&blockSeqStore,
|
||||||
&cctx->blockState.prevCBlock->entropy, &cctx->blockState.nextCBlock->entropy,
|
&cctx->blockState.prevCBlock->entropy, &cctx->blockState.nextCBlock->entropy,
|
||||||
&cctx->appliedParams,
|
&cctx->appliedParams,
|
||||||
op + ZSTD_blockHeaderSize /* Leave space for block header */, dstCapacity - ZSTD_blockHeaderSize,
|
op + ZSTD_blockHeaderSize /* Leave space for block header */, dstCapacity - ZSTD_blockHeaderSize,
|
||||||
@ -4770,7 +4762,7 @@ size_t ZSTD_compressSequences_ext_internal(void* dst, size_t dstCapacity,
|
|||||||
return cSize;
|
return cSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_compressSequences_ext_CCtx(ZSTD_CCtx* const cctx, void* dst, size_t dstCapacity,
|
size_t ZSTD_compressSequencesCCtx(ZSTD_CCtx* const cctx, void* dst, size_t dstCapacity,
|
||||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
ZSTD_sequenceFormat_e format) {
|
ZSTD_sequenceFormat_e format) {
|
||||||
@ -4780,7 +4772,7 @@ size_t ZSTD_compressSequences_ext_CCtx(ZSTD_CCtx* const cctx, void* dst, size_t
|
|||||||
size_t frameHeaderSize = 0;
|
size_t frameHeaderSize = 0;
|
||||||
|
|
||||||
/* Transparent initialization stage, same as compressStream2() */
|
/* Transparent initialization stage, same as compressStream2() */
|
||||||
DEBUGLOG(4, "ZSTD_compressSequences_ext_CCtx()");
|
DEBUGLOG(4, "ZSTD_compressSequencesCCtx()");
|
||||||
assert(cctx != NULL);
|
assert(cctx != NULL);
|
||||||
FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, ZSTD_e_end, srcSize), "CCtx initialization failed");
|
FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, ZSTD_e_end, srcSize), "CCtx initialization failed");
|
||||||
if (dstCapacity < ZSTD_compressBound(srcSize)) {
|
if (dstCapacity < ZSTD_compressBound(srcSize)) {
|
||||||
@ -4799,13 +4791,12 @@ size_t ZSTD_compressSequences_ext_CCtx(ZSTD_CCtx* const cctx, void* dst, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cSize includes block header size and compressed sequences size */
|
/* cSize includes block header size and compressed sequences size */
|
||||||
compressedBlocksSize = ZSTD_compressSequences_ext_internal(op, dstCapacity,
|
compressedBlocksSize = ZSTD_compressSequences_internal(op, dstCapacity,
|
||||||
cctx, inSeqs, inSeqsSize,
|
cctx, inSeqs, inSeqsSize,
|
||||||
src, srcSize, format);
|
src, srcSize, format);
|
||||||
FORWARD_IF_ERROR(compressedBlocksSize, "Block compression failed!");
|
FORWARD_IF_ERROR(compressedBlocksSize, "Block compression failed!");
|
||||||
cSize += compressedBlocksSize;
|
cSize += compressedBlocksSize;
|
||||||
dstCapacity -= compressedBlocksSize;
|
dstCapacity -= compressedBlocksSize;
|
||||||
DEBUGLOG(4, "cSize after compressSequences_internal: %zu", cSize);
|
|
||||||
|
|
||||||
if (cctx->appliedParams.fParams.checksumFlag) {
|
if (cctx->appliedParams.fParams.checksumFlag) {
|
||||||
U32 const checksum = (U32) XXH64_digest(&cctx->xxhState);
|
U32 const checksum = (U32) XXH64_digest(&cctx->xxhState);
|
||||||
@ -4820,7 +4811,7 @@ size_t ZSTD_compressSequences_ext_CCtx(ZSTD_CCtx* const cctx, void* dst, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t ZSTD_compressSequences_ext(void* dst, size_t dstCapacity,
|
size_t ZSTD_compressSequences(void* dst, size_t dstCapacity,
|
||||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||||
const void* src, size_t srcSize, int compressionLevel,
|
const void* src, size_t srcSize, int compressionLevel,
|
||||||
ZSTD_sequenceFormat_e format)
|
ZSTD_sequenceFormat_e format)
|
||||||
@ -4832,8 +4823,8 @@ size_t ZSTD_compressSequences_ext(void* dst, size_t dstCapacity,
|
|||||||
FORWARD_IF_ERROR(ZSTD_CCtx_reset(cctx, ZSTD_reset_session_and_parameters), "CCtx reset failed");
|
FORWARD_IF_ERROR(ZSTD_CCtx_reset(cctx, ZSTD_reset_session_and_parameters), "CCtx reset failed");
|
||||||
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compressionLevel), "Parameter setting failed");
|
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compressionLevel), "Parameter setting failed");
|
||||||
|
|
||||||
cSize = ZSTD_compressSequences_ext_CCtx(cctx, dst, dstCapacity, inSeqs, inSeqsSize, src, srcSize, format);
|
cSize = ZSTD_compressSequencesCCtx(cctx, dst, dstCapacity, inSeqs, inSeqsSize, src, srcSize, format);
|
||||||
FORWARD_IF_ERROR(cSize, "ZSTD_compressSequences_ext_CCtx() failed");
|
FORWARD_IF_ERROR(cSize, "ZSTD_compressSequencesCCtx() failed");
|
||||||
|
|
||||||
ZSTD_freeCCtx(cctx);
|
ZSTD_freeCCtx(cctx);
|
||||||
return cSize;
|
return cSize;
|
||||||
|
@ -1327,7 +1327,13 @@ ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
|||||||
* @return : number of sequences left after merging
|
* @return : number of sequences left after merging
|
||||||
*/
|
*/
|
||||||
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
||||||
ZSTDLIB_API size_t ZSTD_compressSequences_ext(void* dst, size_t dstSize,
|
|
||||||
|
ZSTDLIB_API size_t ZSTD_compressSequencesCCtx(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
|
||||||
|
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||||
|
const void* src, size_t srcSize,
|
||||||
|
ZSTD_sequenceFormat_e format);
|
||||||
|
|
||||||
|
ZSTDLIB_API size_t ZSTD_compressSequences(void* dst, size_t dstSize,
|
||||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||||
const void* src, size_t srcSize, int compressionLevel,
|
const void* src, size_t srcSize, int compressionLevel,
|
||||||
ZSTD_sequenceFormat_e format);
|
ZSTD_sequenceFormat_e format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user