minor update of literal cost function
just assert() there is no negative cost evaluation for literals
This commit is contained in:
@@ -189,12 +189,11 @@ static U32 ZSTD_rawLiteralsCost(const BYTE* const literals, U32 const litLength,
|
|||||||
return (litLength*6) * BITCOST_MULTIPLIER; /* 6 bit per literal - no statistic used */
|
return (litLength*6) * BITCOST_MULTIPLIER; /* 6 bit per literal - no statistic used */
|
||||||
|
|
||||||
/* dynamic statistics */
|
/* dynamic statistics */
|
||||||
{ U32 price, u;
|
{ U32 price = litLength * optPtr->litSumBasePrice;
|
||||||
for (u=0, price=0; u < litLength; u++) {
|
U32 u;
|
||||||
U32 const litWeight = WEIGHT(optPtr->litFreq[literals[u]], optLevel);
|
for (u=0; u < litLength; u++) {
|
||||||
U32 litCost = optPtr->litSumBasePrice - litWeight;
|
assert(WEIGHT(optPtr->litFreq[literals[u]], optLevel) <= optPtr->litSumBasePrice); /* literal cost should never be negative */
|
||||||
//if (litCost < BITCOST_MULTIPLIER) litCost = BITCOST_MULTIPLIER; /* minimum 1 bit per symbol (huffman) */
|
price -= WEIGHT(optPtr->litFreq[literals[u]], optLevel);
|
||||||
price += litCost;
|
|
||||||
}
|
}
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user