#define BLOCKSIZE_MIN 3500
#define THRESHOLD_PENALTY_RATE 16
#define THRESHOLD_BASE (THRESHOLD_PENALTY_RATE - 2)
-#define THRESHOLD_PENALTY 4
+#define THRESHOLD_PENALTY 3
#define HASHLENGTH 2
#define HASHLOG 10
const FingerPrint* newfp,
int penalty)
{
- if (ref->nbEvents <= BLOCKSIZE_MIN)
- return 0;
+ assert(ref->nbEvents > 0);
+ assert(newfp->nbEvents > 0);
{ S64 p50 = ref->nbEvents * newfp->nbEvents;
S64 deviation = fpDistance(ref, newfp);
S64 threshold = p50 * (THRESHOLD_BASE + penalty) / THRESHOLD_PENALTY_RATE;
assert(wkspSize >= sizeof(FPStats)); (void)wkspSize;
initStats(fpstats);
- for (pos = 0; pos < blockSizeMax;) {
+ recordFingerprint(&fpstats->pastEvents, p, CHUNKSIZE);
+ for (pos = CHUNKSIZE; pos < blockSizeMax; pos += CHUNKSIZE) {
assert(pos <= blockSizeMax - CHUNKSIZE);
recordFingerprint(&fpstats->newEvents, p + pos, CHUNKSIZE);
if (compareFingerprints(&fpstats->pastEvents, &fpstats->newEvents, penalty)) {
ZSTD_memset(&fpstats->newEvents, 0, sizeof(fpstats->newEvents));
penalty = penalty - 1 + (penalty == 0);
}
- pos += CHUNKSIZE;
}
return blockSizeMax;
(void)flushEvents; (void)removeEvents;
/* note:
* @workspace must be aligned on 8-bytes boundaries
* @wkspSize must be at least >= ZSTD_SLIPBLOCK_WORKSPACESIZE
+ * note2:
+ * for the time being, this function only accepts full 128 KB blocks,
+ * therefore @blockSizeMax must be == 128 KB.
+ * This could be extended to smaller sizes in the future.
*/
size_t ZSTD_splitBlock_4k(const void* src, size_t srcSize, size_t blockSizeMax, void* workspace, size_t wkspSize);