feat(compress): move sequence API orchestration into Rust
Move the high-level orchestration of ZSTD_compressSequences() and ZSTD_compressSequencesAndLiterals() into Rust. Rust now owns the validation precedence, CCtx initialization handoff, frame-header and checksum ordering, block-loop dispatch, and output accounting for both public sequence APIs. Keep the private CCtx, sequence-store, block-state, checksum, and conversion layouts in C. C supplies scalar block projections and callbacks for private initialization, frame-header emission, checksum operations, and sequence-state preparation, preserving the ABI boundary and the existing codec leaves. Test Plan: - focused sequence API policy tests: 4 passed - cargo test --manifest-path rust/Cargo.toml --all-targets -- --test-threads=1: 533 passed - cargo test --manifest-path rust/cli/Cargo.toml --all-targets -- --test-threads=1: 169 passed - legacy compression/decompression/dictionary-builder feature matrix: 588 passed - six library/CLI clippy gates with -D warnings - capped serial native library/program rebuilds, 41 CLI tests, Rust library smoke, and full test-zstd round trips - capped serial stress gates: 278 fuzzer cases, 84+129+143 zstream cases, and 1,601 decode-corpus cases - every heavyweight command used CARGO_BUILD_JOBS=1 or make -j1 and ulimit -v 41943040; no worker/native process remained afterward Commit is intentionally unsigned because GPG pinentry hangs in this non-interactive environment.
This commit is contained in:
+218
-162
@@ -1021,6 +1021,72 @@ typedef char ZSTD_rust_sequence_literals_state_layout[
|
||||
== 6 * sizeof(void*) + 4 * sizeof(int) + 3 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
|
||||
/* The public sequence APIs keep their CCtx initialization, frame header, and
|
||||
* checksum state in C, but Rust owns the ordering and output accounting. The
|
||||
* two block-loop projections above are populated by the initialization
|
||||
* callback after the private CCtx has been initialized. */
|
||||
typedef struct ZSTD_rust_sequenceApiState_s ZSTD_rust_sequenceApiState;
|
||||
typedef size_t (*ZSTD_rust_sequenceApiInit_f)(
|
||||
void* context, size_t pledgedSrcSize,
|
||||
ZSTD_rust_sequenceApiState* state);
|
||||
typedef size_t (*ZSTD_rust_sequenceApiWriteFrameHeader_f)(
|
||||
void* context, void* dst, size_t dstCapacity, size_t pledgedSrcSize);
|
||||
typedef void (*ZSTD_rust_sequenceApiUpdateChecksum_f)(
|
||||
void* context, const void* src, size_t srcSize);
|
||||
typedef U32 (*ZSTD_rust_sequenceApiDigestChecksum_f)(void* context);
|
||||
typedef void (*ZSTD_rust_sequenceApiWriteChecksum_f)(
|
||||
void* context, void* dst, U32 checksum);
|
||||
|
||||
struct ZSTD_rust_sequenceApiState_s {
|
||||
void* callbackContext;
|
||||
ZSTD_rust_sequenceCompressionState* sequenceState;
|
||||
ZSTD_rust_sequenceLiteralsState* sequenceLiteralsState;
|
||||
ZSTD_rust_sequenceApiInit_f init;
|
||||
ZSTD_rust_sequenceApiWriteFrameHeader_f writeFrameHeader;
|
||||
ZSTD_rust_sequenceApiUpdateChecksum_f updateChecksum;
|
||||
ZSTD_rust_sequenceApiDigestChecksum_f digestChecksum;
|
||||
ZSTD_rust_sequenceApiWriteChecksum_f writeChecksum;
|
||||
int checksumFlag;
|
||||
int blockDelimiters;
|
||||
int validateSequences;
|
||||
};
|
||||
size_t ZSTD_rust_compressSequences(
|
||||
ZSTD_rust_sequenceApiState* state,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize);
|
||||
size_t ZSTD_rust_compressSequencesAndLiterals(
|
||||
ZSTD_rust_sequenceApiState* state,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* literals, size_t litSize, size_t litCapacity,
|
||||
size_t decompressedSize);
|
||||
typedef char ZSTD_rust_sequence_api_state_layout[
|
||||
(offsetof(ZSTD_rust_sequenceApiState, callbackContext) == 0
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, sequenceState)
|
||||
== sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, sequenceLiteralsState)
|
||||
== 2 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, init)
|
||||
== 3 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, writeFrameHeader)
|
||||
== 4 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, updateChecksum)
|
||||
== 5 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, digestChecksum)
|
||||
== 6 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, writeChecksum)
|
||||
== 7 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, checksumFlag)
|
||||
== 8 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, blockDelimiters)
|
||||
== 8 * sizeof(void*) + sizeof(int)
|
||||
&& offsetof(ZSTD_rust_sequenceApiState, validateSequences)
|
||||
== 8 * sizeof(void*) + 2 * sizeof(int)
|
||||
&& sizeof(ZSTD_rust_sequenceApiState)
|
||||
== (sizeof(void*) == 8 ? 80 : 44))
|
||||
? 1 : -1];
|
||||
|
||||
typedef char ZSTD_rust_stats_seqdef_layout[(sizeof(SeqDef) == 8) ? 1 : -1];
|
||||
typedef char ZSTD_rust_stats_block_summary_layout[
|
||||
(sizeof(BlockSummary) == 3 * sizeof(size_t)) ? 1 : -1];
|
||||
@@ -5387,100 +5453,6 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
|
||||
ZSTD_hasExtSeqProd(&cctx->appliedParams));
|
||||
}
|
||||
|
||||
/* Compress all provided sequences, block-by-block.
|
||||
*
|
||||
* Returns the cumulative size of all compressed blocks (including their headers),
|
||||
* otherwise a ZSTD error.
|
||||
*/
|
||||
static size_t
|
||||
ZSTD_compressSequences_internal(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
U32 dictSize;
|
||||
ZSTD_rust_sequenceCompressionState state;
|
||||
|
||||
if (cctx->cdict) {
|
||||
dictSize = (U32)cctx->cdict->dictContentSize;
|
||||
} else if (cctx->prefixDict.dict) {
|
||||
dictSize = (U32)cctx->prefixDict.dictSize;
|
||||
} else {
|
||||
dictSize = 0;
|
||||
}
|
||||
|
||||
state.seqStore = &cctx->seqStore;
|
||||
state.prevCBlock = &cctx->blockState.prevCBlock;
|
||||
state.nextCBlock = &cctx->blockState.nextCBlock;
|
||||
state.tmpWorkspace = cctx->tmpWorkspace;
|
||||
state.tmpWkspSize = cctx->tmpWkspSize;
|
||||
state.blockSizeMax = cctx->blockSizeMax;
|
||||
state.bmi2 = cctx->bmi2;
|
||||
state.blockDelimiters = (int)cctx->appliedParams.blockDelimiters;
|
||||
state.strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
state.disableLiteralCompression = ZSTD_literalsCompressionIsDisabled(&cctx->appliedParams);
|
||||
state.searchForExternalRepcodes = (int)cctx->appliedParams.searchForExternalRepcodes;
|
||||
state.validateSequences = cctx->appliedParams.validateSequences;
|
||||
state.minMatch = cctx->appliedParams.cParams.minMatch;
|
||||
state.windowLog = cctx->appliedParams.cParams.windowLog;
|
||||
state.dictSize = dictSize;
|
||||
state.useSequenceProducer = ZSTD_hasExtSeqProd(&cctx->appliedParams);
|
||||
state.isFirstBlock = &cctx->isFirstBlock;
|
||||
|
||||
DEBUGLOG(4, "ZSTD_compressSequences_internal srcSize: %zu, inSeqsSize: %zu", srcSize, inSeqsSize);
|
||||
return ZSTD_rust_compressSequencesInternal(&state, dst, dstCapacity,
|
||||
inSeqs, inSeqsSize, src, srcSize);
|
||||
}
|
||||
|
||||
size_t ZSTD_compressSequences(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
BYTE* op = (BYTE*)dst;
|
||||
size_t cSize = 0;
|
||||
|
||||
/* Transparent initialization stage, same as compressStream2() */
|
||||
DEBUGLOG(4, "ZSTD_compressSequences (nbSeqs=%zu,dstCapacity=%zu)", inSeqsSize, dstCapacity);
|
||||
assert(cctx != NULL);
|
||||
FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, ZSTD_e_end, srcSize), "CCtx initialization failed");
|
||||
|
||||
/* Begin writing output, starting with frame header */
|
||||
{ size_t const frameHeaderSize = ZSTD_writeFrameHeader(op, dstCapacity,
|
||||
&cctx->appliedParams, srcSize, cctx->dictID);
|
||||
op += frameHeaderSize;
|
||||
assert(frameHeaderSize <= dstCapacity);
|
||||
dstCapacity -= frameHeaderSize;
|
||||
cSize += frameHeaderSize;
|
||||
}
|
||||
if (cctx->appliedParams.fParams.checksumFlag && srcSize) {
|
||||
XXH64_update(&cctx->xxhState, src, srcSize);
|
||||
}
|
||||
|
||||
/* Now generate compressed blocks */
|
||||
{ size_t const cBlocksSize = ZSTD_compressSequences_internal(cctx,
|
||||
op, dstCapacity,
|
||||
inSeqs, inSeqsSize,
|
||||
src, srcSize);
|
||||
FORWARD_IF_ERROR(cBlocksSize, "Compressing blocks failed!");
|
||||
cSize += cBlocksSize;
|
||||
assert(cBlocksSize <= dstCapacity);
|
||||
dstCapacity -= cBlocksSize;
|
||||
}
|
||||
|
||||
/* Complete with frame checksum, if needed */
|
||||
if (cctx->appliedParams.fParams.checksumFlag) {
|
||||
U32 const checksum = (U32) XXH64_digest(&cctx->xxhState);
|
||||
RETURN_ERROR_IF(dstCapacity<4, dstSize_tooSmall, "no room for checksum");
|
||||
DEBUGLOG(4, "Write checksum : %08X", (unsigned)checksum);
|
||||
MEM_writeLE32((char*)dst + cSize, checksum);
|
||||
cSize += 4;
|
||||
}
|
||||
|
||||
DEBUGLOG(4, "Final compressed size: %zu", cSize);
|
||||
return cSize;
|
||||
}
|
||||
|
||||
/* The public symbol remains C-facing for fullbench and the sequence API, but
|
||||
* the sequence-store conversion itself is Rust-owned. */
|
||||
size_t ZSTD_convertBlockSequences(ZSTD_CCtx* cctx,
|
||||
@@ -5505,41 +5477,151 @@ static size_t ZSTD_convertBlockSequencesForRust(
|
||||
repcodeResolution);
|
||||
}
|
||||
|
||||
BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs)
|
||||
static void ZSTD_rust_sequenceApi_prepareStates(
|
||||
ZSTD_CCtx* cctx,
|
||||
ZSTD_rust_sequenceCompressionState* sequenceState,
|
||||
ZSTD_rust_sequenceLiteralsState* sequenceLiteralsState)
|
||||
{
|
||||
return ZSTD_rust_get1BlockSummary(seqs, nbSeqs);
|
||||
}
|
||||
U32 dictSize;
|
||||
|
||||
if (cctx->cdict) {
|
||||
dictSize = (U32)cctx->cdict->dictContentSize;
|
||||
} else if (cctx->prefixDict.dict) {
|
||||
dictSize = (U32)cctx->prefixDict.dictSize;
|
||||
} else {
|
||||
dictSize = 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
ZSTD_compressSequencesAndLiterals_internal(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t nbSequences,
|
||||
const void* literals, size_t litSize, size_t srcSize)
|
||||
{
|
||||
ZSTD_rust_sequenceLiteralsState state;
|
||||
int const repcodeResolution =
|
||||
(cctx->appliedParams.searchForExternalRepcodes == ZSTD_ps_enable);
|
||||
sequenceState->seqStore = &cctx->seqStore;
|
||||
sequenceState->prevCBlock = &cctx->blockState.prevCBlock;
|
||||
sequenceState->nextCBlock = &cctx->blockState.nextCBlock;
|
||||
sequenceState->tmpWorkspace = cctx->tmpWorkspace;
|
||||
sequenceState->tmpWkspSize = cctx->tmpWkspSize;
|
||||
sequenceState->blockSizeMax = cctx->blockSizeMax;
|
||||
sequenceState->bmi2 = cctx->bmi2;
|
||||
sequenceState->blockDelimiters = (int)cctx->appliedParams.blockDelimiters;
|
||||
sequenceState->strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
sequenceState->disableLiteralCompression =
|
||||
ZSTD_literalsCompressionIsDisabled(&cctx->appliedParams);
|
||||
sequenceState->searchForExternalRepcodes =
|
||||
(int)cctx->appliedParams.searchForExternalRepcodes;
|
||||
sequenceState->validateSequences = cctx->appliedParams.validateSequences;
|
||||
sequenceState->minMatch = cctx->appliedParams.cParams.minMatch;
|
||||
sequenceState->windowLog = cctx->appliedParams.cParams.windowLog;
|
||||
sequenceState->dictSize = dictSize;
|
||||
sequenceState->useSequenceProducer = ZSTD_hasExtSeqProd(&cctx->appliedParams);
|
||||
sequenceState->isFirstBlock = &cctx->isFirstBlock;
|
||||
|
||||
assert(cctx->appliedParams.searchForExternalRepcodes != ZSTD_ps_auto);
|
||||
state.seqStore = &cctx->seqStore;
|
||||
state.prevCBlock = &cctx->blockState.prevCBlock;
|
||||
state.nextCBlock = &cctx->blockState.nextCBlock;
|
||||
state.tmpWorkspace = cctx->tmpWorkspace;
|
||||
state.tmpWkspSize = cctx->tmpWkspSize;
|
||||
state.blockSizeMax = cctx->blockSizeMax;
|
||||
state.bmi2 = cctx->bmi2;
|
||||
state.strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
state.disableLiteralCompression =
|
||||
sequenceLiteralsState->seqStore = &cctx->seqStore;
|
||||
sequenceLiteralsState->prevCBlock = &cctx->blockState.prevCBlock;
|
||||
sequenceLiteralsState->nextCBlock = &cctx->blockState.nextCBlock;
|
||||
sequenceLiteralsState->tmpWorkspace = cctx->tmpWorkspace;
|
||||
sequenceLiteralsState->tmpWkspSize = cctx->tmpWkspSize;
|
||||
sequenceLiteralsState->blockSizeMax = cctx->blockSizeMax;
|
||||
sequenceLiteralsState->bmi2 = cctx->bmi2;
|
||||
sequenceLiteralsState->strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
sequenceLiteralsState->disableLiteralCompression =
|
||||
ZSTD_literalsCompressionIsDisabled(&cctx->appliedParams);
|
||||
state.repcodeResolution = repcodeResolution;
|
||||
state.isFirstBlock = &cctx->isFirstBlock;
|
||||
state.callbackContext = cctx;
|
||||
state.convertBlockSequences = ZSTD_convertBlockSequencesForRust;
|
||||
sequenceLiteralsState->repcodeResolution =
|
||||
(cctx->appliedParams.searchForExternalRepcodes == ZSTD_ps_enable);
|
||||
sequenceLiteralsState->isFirstBlock = &cctx->isFirstBlock;
|
||||
sequenceLiteralsState->callbackContext = cctx;
|
||||
sequenceLiteralsState->convertBlockSequences =
|
||||
ZSTD_convertBlockSequencesForRust;
|
||||
}
|
||||
|
||||
return ZSTD_rust_compressSequencesAndLiteralsInternal(
|
||||
&state, dst, dstCapacity, inSeqs, nbSequences, literals, litSize,
|
||||
srcSize);
|
||||
static size_t ZSTD_rust_sequenceApi_init(
|
||||
void* context, size_t pledgedSrcSize,
|
||||
ZSTD_rust_sequenceApiState* state)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
size_t initResult;
|
||||
|
||||
if (cctx == NULL || state == NULL
|
||||
|| state->sequenceState == NULL
|
||||
|| state->sequenceLiteralsState == NULL) {
|
||||
return ERROR(GENERIC);
|
||||
}
|
||||
|
||||
initResult = ZSTD_CCtx_init_compressStream2(
|
||||
cctx, ZSTD_e_end, pledgedSrcSize);
|
||||
if (ERR_isError(initResult)) {
|
||||
return initResult;
|
||||
}
|
||||
|
||||
ZSTD_rust_sequenceApi_prepareStates(
|
||||
cctx, state->sequenceState, state->sequenceLiteralsState);
|
||||
state->checksumFlag = cctx->appliedParams.fParams.checksumFlag;
|
||||
state->blockDelimiters = (int)cctx->appliedParams.blockDelimiters;
|
||||
state->validateSequences = cctx->appliedParams.validateSequences;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_sequenceApi_writeFrameHeader(
|
||||
void* context, void* dst, size_t dstCapacity, size_t pledgedSrcSize)
|
||||
{
|
||||
ZSTD_CCtx const* const cctx = (ZSTD_CCtx const*)context;
|
||||
return ZSTD_writeFrameHeader(dst, dstCapacity, &cctx->appliedParams,
|
||||
pledgedSrcSize, cctx->dictID);
|
||||
}
|
||||
|
||||
static void ZSTD_rust_sequenceApi_updateChecksum(
|
||||
void* context, const void* src, size_t srcSize)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
(void)XXH64_update(&cctx->xxhState, src, srcSize);
|
||||
}
|
||||
|
||||
static U32 ZSTD_rust_sequenceApi_digestChecksum(void* context)
|
||||
{
|
||||
ZSTD_CCtx const* const cctx = (ZSTD_CCtx const*)context;
|
||||
return (U32)XXH64_digest(&cctx->xxhState);
|
||||
}
|
||||
|
||||
static void ZSTD_rust_sequenceApi_writeChecksum(
|
||||
void* context, void* dst, U32 checksum)
|
||||
{
|
||||
(void)context;
|
||||
DEBUGLOG(4, "Write checksum : %08X", (unsigned)checksum);
|
||||
MEM_writeLE32((char*)dst, checksum);
|
||||
}
|
||||
|
||||
static void ZSTD_rust_sequenceApi_initState(
|
||||
ZSTD_rust_sequenceApiState* state,
|
||||
ZSTD_CCtx* cctx,
|
||||
ZSTD_rust_sequenceCompressionState* sequenceState,
|
||||
ZSTD_rust_sequenceLiteralsState* sequenceLiteralsState)
|
||||
{
|
||||
state->callbackContext = cctx;
|
||||
state->sequenceState = sequenceState;
|
||||
state->sequenceLiteralsState = sequenceLiteralsState;
|
||||
state->init = ZSTD_rust_sequenceApi_init;
|
||||
state->writeFrameHeader = ZSTD_rust_sequenceApi_writeFrameHeader;
|
||||
state->updateChecksum = ZSTD_rust_sequenceApi_updateChecksum;
|
||||
state->digestChecksum = ZSTD_rust_sequenceApi_digestChecksum;
|
||||
state->writeChecksum = ZSTD_rust_sequenceApi_writeChecksum;
|
||||
state->checksumFlag = 0;
|
||||
state->blockDelimiters = 0;
|
||||
state->validateSequences = 0;
|
||||
}
|
||||
|
||||
size_t ZSTD_compressSequences(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
ZSTD_rust_sequenceCompressionState sequenceState;
|
||||
ZSTD_rust_sequenceLiteralsState sequenceLiteralsState;
|
||||
ZSTD_rust_sequenceApiState state;
|
||||
|
||||
DEBUGLOG(4, "ZSTD_compressSequences (nbSeqs=%zu,dstCapacity=%zu)",
|
||||
inSeqsSize, dstCapacity);
|
||||
assert(cctx != NULL);
|
||||
ZSTD_rust_sequenceApi_initState(
|
||||
&state, cctx, &sequenceState, &sequenceLiteralsState);
|
||||
return ZSTD_rust_compressSequences(
|
||||
&state, dst, dstCapacity, inSeqs, inSeqsSize, src, srcSize);
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -5549,49 +5631,23 @@ ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
|
||||
const void* literals, size_t litSize, size_t litCapacity,
|
||||
size_t decompressedSize)
|
||||
{
|
||||
BYTE* op = (BYTE*)dst;
|
||||
size_t cSize = 0;
|
||||
ZSTD_rust_sequenceCompressionState sequenceState;
|
||||
ZSTD_rust_sequenceLiteralsState sequenceLiteralsState;
|
||||
ZSTD_rust_sequenceApiState state;
|
||||
|
||||
/* Transparent initialization stage, same as compressStream2() */
|
||||
DEBUGLOG(4, "ZSTD_compressSequencesAndLiterals (dstCapacity=%zu)", dstCapacity);
|
||||
DEBUGLOG(4, "ZSTD_compressSequencesAndLiterals (dstCapacity=%zu)",
|
||||
dstCapacity);
|
||||
assert(cctx != NULL);
|
||||
if (litCapacity < litSize) {
|
||||
RETURN_ERROR(workSpace_tooSmall, "literals buffer is not large enough: must be at least 8 bytes larger than litSize (risk of read out-of-bound)");
|
||||
}
|
||||
FORWARD_IF_ERROR(ZSTD_CCtx_init_compressStream2(cctx, ZSTD_e_end, decompressedSize), "CCtx initialization failed");
|
||||
ZSTD_rust_sequenceApi_initState(
|
||||
&state, cctx, &sequenceState, &sequenceLiteralsState);
|
||||
return ZSTD_rust_compressSequencesAndLiterals(
|
||||
&state, dst, dstCapacity, inSeqs, inSeqsSize, literals, litSize,
|
||||
litCapacity, decompressedSize);
|
||||
}
|
||||
|
||||
if (cctx->appliedParams.blockDelimiters == ZSTD_sf_noBlockDelimiters) {
|
||||
RETURN_ERROR(frameParameter_unsupported, "This mode is only compatible with explicit delimiters");
|
||||
}
|
||||
if (cctx->appliedParams.validateSequences) {
|
||||
RETURN_ERROR(parameter_unsupported, "This mode is not compatible with Sequence validation");
|
||||
}
|
||||
if (cctx->appliedParams.fParams.checksumFlag) {
|
||||
RETURN_ERROR(frameParameter_unsupported, "this mode is not compatible with frame checksum");
|
||||
}
|
||||
|
||||
/* Begin writing output, starting with frame header */
|
||||
{ size_t const frameHeaderSize = ZSTD_writeFrameHeader(op, dstCapacity,
|
||||
&cctx->appliedParams, decompressedSize, cctx->dictID);
|
||||
op += frameHeaderSize;
|
||||
assert(frameHeaderSize <= dstCapacity);
|
||||
dstCapacity -= frameHeaderSize;
|
||||
cSize += frameHeaderSize;
|
||||
}
|
||||
|
||||
/* Now generate compressed blocks */
|
||||
{ size_t const cBlocksSize = ZSTD_compressSequencesAndLiterals_internal(cctx,
|
||||
op, dstCapacity,
|
||||
inSeqs, inSeqsSize,
|
||||
literals, litSize, decompressedSize);
|
||||
FORWARD_IF_ERROR(cBlocksSize, "Compressing blocks failed!");
|
||||
cSize += cBlocksSize;
|
||||
assert(cBlocksSize <= dstCapacity);
|
||||
dstCapacity -= cBlocksSize;
|
||||
}
|
||||
|
||||
DEBUGLOG(4, "Final compressed size: %zu", cSize);
|
||||
return cSize;
|
||||
BlockSummary ZSTD_get1BlockSummary(const ZSTD_Sequence* seqs, size_t nbSeqs)
|
||||
{
|
||||
return ZSTD_rust_get1BlockSummary(seqs, nbSeqs);
|
||||
}
|
||||
|
||||
/*====== Finalize ======*/
|
||||
|
||||
Reference in New Issue
Block a user