Skip to content

Commit

Permalink
Add simple API for converting ZSTD_Sequence into seqStore
Browse files Browse the repository at this point in the history
  • Loading branch information
senhuang42 committed Jun 23, 2021
1 parent dd4f6aa commit bebaf60
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -3721,6 +3721,17 @@ static size_t ZSTD_compressBlock_splitBlock(ZSTD_CCtx* zc,
return cSize;
}

/* ZSTD_convertBlockSequencesToSeqStore()
* Converts an array of ZSTD_Sequence* with the corresponding original src buffer into a seqStore.
* Returns 0 on success, ZSTD_error on failure.
*/
static size_t ZSTD_convertBlockSequencesToSeqStore(ZSTD_CCtx* cctx,
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
const void* src, size_t srcSize) {
ZSTD_sequencePosition dummySeqPos = {0, 0, 0};
return ZSTD_copySequencesToSeqStoreExplicitBlockDelim(cctx, &dummySeqPos, inSeqs, inSeqsSize, src, srcSize);
}

static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize, U32 frame)
Expand Down Expand Up @@ -3757,12 +3768,6 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */,
zc->bmi2);

if (zc->seqCollector.collectSequences) {
ZSTD_copyBlockSequences(zc);
return 0;
}


if (frame &&
/* We don't want to emit our first block as a RLE even if it qualifies because
* doing so will cause the decoder (cli only) to throw a "should consume all input error."
Expand Down

0 comments on commit bebaf60

Please sign in to comment.