mirror of
https://github.com/facebook/zstd.git
synced 2025-11-29 00:04:37 -05:00
Merge pull request #3262 from daniellerozenblit/sequence-bound
Add sequenceBound(srcSize) method
This commit is contained in:
commit
74ece5037c
@ -22,9 +22,7 @@ int main(int argc, char *argv[]) {
|
|||||||
fread(inBuf, inBufSize, 1, f);
|
fread(inBuf, inBufSize, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
// Should work fine for this benchmark, but we really need
|
size_t seqsSize = ZSTD_sequenceBound(inBufSize);
|
||||||
// a function like ZSTD_compressBound() for sequences
|
|
||||||
size_t seqsSize = 2 * (inBufSize / sizeof(ZSTD_Sequence));
|
|
||||||
ZSTD_Sequence *seqs = (ZSTD_Sequence*)malloc(seqsSize * sizeof(ZSTD_Sequence));
|
ZSTD_Sequence *seqs = (ZSTD_Sequence*)malloc(seqsSize * sizeof(ZSTD_Sequence));
|
||||||
char *outBuf = malloc(ZSTD_compressBound(inBufSize));
|
char *outBuf = malloc(ZSTD_compressBound(inBufSize));
|
||||||
|
|
||||||
|
|||||||
@ -3003,6 +3003,10 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
|
|||||||
zc->seqCollector.seqIndex += seqStoreSeqSize;
|
zc->seqCollector.seqIndex += seqStoreSeqSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ZSTD_sequenceBound(size_t srcSize) {
|
||||||
|
return (srcSize / ZSTD_MINMATCH_MIN) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
||||||
size_t outSeqsSize, const void* src, size_t srcSize)
|
size_t outSeqsSize, const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1396,6 +1396,15 @@ typedef enum {
|
|||||||
ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
||||||
} ZSTD_sequenceFormat_e;
|
} ZSTD_sequenceFormat_e;
|
||||||
|
|
||||||
|
/*! ZSTD_sequenceBound() :
|
||||||
|
* `srcSize` : size of the input buffer
|
||||||
|
* @return : upper-bound for the number of sequences that can be generated
|
||||||
|
* from a buffer of srcSize bytes
|
||||||
|
*
|
||||||
|
* note : returns number of sequences - to get bytes, multiply by sizeof(ZSTD_Sequence).
|
||||||
|
*/
|
||||||
|
ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
|
||||||
|
|
||||||
/*! ZSTD_generateSequences() :
|
/*! ZSTD_generateSequences() :
|
||||||
* Generate sequences using ZSTD_compress2(), given a source buffer.
|
* Generate sequences using ZSTD_compress2(), given a source buffer.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user