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