mirror of
https://github.com/facebook/zstd.git
synced 2025-12-16 00:04:14 -05:00
ZSTD_entropyCompressSeqStore_internal() can accept an externally defined literals buffer
This commit is contained in:
parent
0442e43aca
commit
e9f8a119b4
@ -2894,11 +2894,12 @@ ZSTD_buildSequencesStatistics(
|
|||||||
#define SUSPECT_UNCOMPRESSIBLE_LITERAL_RATIO 20
|
#define SUSPECT_UNCOMPRESSIBLE_LITERAL_RATIO 20
|
||||||
MEM_STATIC size_t
|
MEM_STATIC size_t
|
||||||
ZSTD_entropyCompressSeqStore_internal(
|
ZSTD_entropyCompressSeqStore_internal(
|
||||||
|
void* dst, size_t dstCapacity,
|
||||||
|
const void* literals, size_t litSize,
|
||||||
const SeqStore_t* seqStorePtr,
|
const 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,
|
||||||
void* dst, size_t dstCapacity,
|
|
||||||
void* entropyWorkspace, size_t entropyWkspSize,
|
void* entropyWorkspace, size_t entropyWkspSize,
|
||||||
const int bmi2)
|
const int bmi2)
|
||||||
{
|
{
|
||||||
@ -2926,12 +2927,9 @@ ZSTD_entropyCompressSeqStore_internal(
|
|||||||
assert(entropyWkspSize >= HUF_WORKSPACE_SIZE);
|
assert(entropyWkspSize >= HUF_WORKSPACE_SIZE);
|
||||||
|
|
||||||
/* Compress literals */
|
/* Compress literals */
|
||||||
{ const BYTE* const literals = seqStorePtr->litStart;
|
{ size_t const numSequences = (size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||||
size_t const numSequences = (size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
|
||||||
size_t const numLiterals = (size_t)(seqStorePtr->lit - seqStorePtr->litStart);
|
|
||||||
/* Base suspicion of uncompressibility on ratio of literals to sequences */
|
/* Base suspicion of uncompressibility on ratio of literals to sequences */
|
||||||
unsigned const suspectUncompressible = (numSequences == 0) || (numLiterals / numSequences >= SUSPECT_UNCOMPRESSIBLE_LITERAL_RATIO);
|
int const suspectUncompressible = (numSequences == 0) || (litSize / numSequences >= SUSPECT_UNCOMPRESSIBLE_LITERAL_RATIO);
|
||||||
size_t const litSize = (size_t)(seqStorePtr->lit - literals);
|
|
||||||
|
|
||||||
size_t const cSize = ZSTD_compressLiterals(
|
size_t const cSize = ZSTD_compressLiterals(
|
||||||
op, dstCapacity,
|
op, dstCapacity,
|
||||||
@ -3012,7 +3010,7 @@ ZSTD_entropyCompressSeqStore_internal(
|
|||||||
return (size_t)(op - ostart);
|
return (size_t)(op - ostart);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_STATIC size_t
|
static size_t
|
||||||
ZSTD_entropyCompressSeqStore(
|
ZSTD_entropyCompressSeqStore(
|
||||||
const SeqStore_t* seqStorePtr,
|
const SeqStore_t* seqStorePtr,
|
||||||
const ZSTD_entropyCTables_t* prevEntropy,
|
const ZSTD_entropyCTables_t* prevEntropy,
|
||||||
@ -3024,8 +3022,9 @@ ZSTD_entropyCompressSeqStore(
|
|||||||
int bmi2)
|
int bmi2)
|
||||||
{
|
{
|
||||||
size_t const cSize = ZSTD_entropyCompressSeqStore_internal(
|
size_t const cSize = ZSTD_entropyCompressSeqStore_internal(
|
||||||
seqStorePtr, prevEntropy, nextEntropy, cctxParams,
|
|
||||||
dst, dstCapacity,
|
dst, dstCapacity,
|
||||||
|
seqStorePtr->litStart, (size_t)(seqStorePtr->lit - seqStorePtr->litStart),
|
||||||
|
seqStorePtr, prevEntropy, nextEntropy, cctxParams,
|
||||||
entropyWorkspace, entropyWkspSize, bmi2);
|
entropyWorkspace, entropyWkspSize, bmi2);
|
||||||
if (cSize == 0) return 0;
|
if (cSize == 0) return 0;
|
||||||
/* When srcSize <= dstCapacity, there is enough space to write a raw uncompressed block.
|
/* When srcSize <= dstCapacity, there is enough space to write a raw uncompressed block.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user