priceFunc
This commit is contained in:
parent
15174b0cfb
commit
e0010e9baf
@ -1919,8 +1919,10 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
|
||||
BYTE* op = ostart;
|
||||
const U32 maxDist = 1 << zc->params.windowLog;
|
||||
seqStore_t* ssPtr = &zc->seqStore;
|
||||
static U32 priceFunc = 0;
|
||||
|
||||
ssPtr->realMatchSum = ssPtr->realLitSum = ssPtr->realSeqSum = ssPtr->realRepSum = 0;
|
||||
ssPtr->realMatchSum = ssPtr->realLitSum = ssPtr->realSeqSum = ssPtr->realRepSum = 1;
|
||||
ssPtr->priceFunc = priceFunc;
|
||||
|
||||
while (remaining) {
|
||||
size_t cSize;
|
||||
@ -1954,9 +1956,11 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
|
||||
op += cSize;
|
||||
}
|
||||
|
||||
|
||||
#if ZSTD_OPT_DEBUG >= 3
|
||||
ssPtr->realMatchSum += ssPtr->realSeqSum * ((zc->params.searchLength == 3) ? 3 : 4);
|
||||
printf("avgMatchL=%.2f avgLitL=%.2f match=%.1f%% lit=%.1f%% reps=%d seq=%d\n", (float)ssPtr->realMatchSum/ssPtr->realSeqSum, (float)ssPtr->realLitSum/ssPtr->realSeqSum, 100.0*ssPtr->realMatchSum/(ssPtr->realMatchSum+ssPtr->realLitSum), 100.0*ssPtr->realLitSum/(ssPtr->realMatchSum+ssPtr->realLitSum), ssPtr->realRepSum, ssPtr->realSeqSum);
|
||||
printf("avgMatchL=%.2f avgLitL=%.2f match=%.1f%% lit=%.1f%% reps=%d seq=%d priceFunc=%d\n", (float)ssPtr->realMatchSum/ssPtr->realSeqSum, (float)ssPtr->realLitSum/ssPtr->realSeqSum, 100.0*ssPtr->realMatchSum/(ssPtr->realMatchSum+ssPtr->realLitSum), 100.0*ssPtr->realLitSum/(ssPtr->realMatchSum+ssPtr->realLitSum), ssPtr->realRepSum, ssPtr->realSeqSum, ssPtr->priceFunc);
|
||||
priceFunc++;
|
||||
#endif
|
||||
|
||||
return op-ostart;
|
||||
|
@ -176,6 +176,7 @@ typedef struct {
|
||||
U32* litFreq;
|
||||
U32* offCodeFreq;
|
||||
U32 matchLengthSum;
|
||||
U32 matchSum;
|
||||
U32 litLengthSum;
|
||||
U32 litSum;
|
||||
U32 offCodeSum;
|
||||
@ -183,6 +184,7 @@ typedef struct {
|
||||
U32 realLitSum;
|
||||
U32 realSeqSum;
|
||||
U32 realRepSum;
|
||||
U32 priceFunc;
|
||||
} seqStore_t;
|
||||
|
||||
seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx);
|
||||
|
@ -46,18 +46,20 @@ FORCE_INLINE U32 ZSTD_GETPRICE(seqStore_t* seqStorePtr, U32 litLength, const BYT
|
||||
if (matchLength >= MaxML) matchLength = MaxML;
|
||||
price += ZSTD_highbit(seqStorePtr->matchLengthSum) - ZSTD_highbit(seqStorePtr->matchLengthFreq[matchLength]);
|
||||
|
||||
#if 0
|
||||
if (!litLength)
|
||||
return price + 1 + ((seqStorePtr->litSum>>4) / seqStorePtr->litLengthSum) + (matchLength==0);
|
||||
|
||||
return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + ((seqStorePtr->litSum>>4) / seqStorePtr->litLengthSum) + (matchLength==0);
|
||||
#else
|
||||
if (!litLength)
|
||||
return price + 1;
|
||||
|
||||
#define ZSTD_PRICE_MULT 2
|
||||
switch (seqStorePtr->priceFunc)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
if (!litLength) return price + 1 + ((seqStorePtr->litSum<<ZSTD_PRICE_MULT) / (seqStorePtr->litSum + seqStorePtr->matchSum)) + (matchLength==0);
|
||||
return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + ((seqStorePtr->litSum<<ZSTD_PRICE_MULT) / (seqStorePtr->litSum + seqStorePtr->matchSum)) + (matchLength==0);
|
||||
case 1:
|
||||
if (!litLength) return price + 1 + ((seqStorePtr->litSum>>5) / seqStorePtr->litLengthSum) + (matchLength==0);
|
||||
return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + ((seqStorePtr->litSum>>5) / seqStorePtr->litLengthSum) + (matchLength==0);
|
||||
case 2:
|
||||
if (!litLength) return price + 1;
|
||||
return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals);
|
||||
// return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define ZSTD_OPT_NUM (1<<12)
|
||||
#define ZSTD_FREQ_START 1
|
||||
#define ZSTD_FREQ_STEP 1
|
||||
#define ZSTD_FREQ_DIV 6
|
||||
#define ZSTD_FREQ_DIV 5
|
||||
|
||||
/*- Debug -*/
|
||||
#if defined(ZSTD_OPT_DEBUG) && ZSTD_OPT_DEBUG>=9
|
||||
@ -94,6 +94,7 @@ MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr)
|
||||
ssPtr->matchLengthSum = 0;
|
||||
ssPtr->litLengthSum = 0;
|
||||
ssPtr->litSum = 0;
|
||||
ssPtr->matchSum = 0;
|
||||
ssPtr->offCodeSum = 0;
|
||||
|
||||
for (u=0; u<=MaxLit; u++) {
|
||||
@ -107,6 +108,7 @@ MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr)
|
||||
for (u=0; u<=MaxML; u++) {
|
||||
ssPtr->matchLengthFreq[u] = ZSTD_FREQ_START + (ssPtr->matchLengthFreq[u]>>ZSTD_FREQ_DIV);
|
||||
ssPtr->matchLengthSum += ssPtr->matchLengthFreq[u];
|
||||
ssPtr->matchSum += ssPtr->matchLengthFreq[u] * (u + 3);
|
||||
}
|
||||
for (u=0; u<=MaxOff; u++) {
|
||||
ssPtr->offCodeFreq[u] = ZSTD_FREQ_START + (ssPtr->offCodeFreq[u]>>ZSTD_FREQ_DIV);
|
||||
|
Loading…
Reference in New Issue
Block a user