implemented fractional bit cost evaluation
for FSE symbols. While it seems to work, the gains are negligible compared to rough maxNbBits evaluation. There are even a few losses sometimes, that still need to be explained. Furthermode, there are still cases where btlazy2 does a better job than btopt, which seems rather strange too.
This commit is contained in:
+14
-1
@@ -577,10 +577,23 @@ MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePt
|
||||
|
||||
MEM_STATIC U32 FSE_getMaxNbBits(const FSE_symbolCompressionTransform* symbolTT, U32 symbolValue)
|
||||
{
|
||||
assert(symbolValue <= FSE_MAX_SYMBOL_VALUE);
|
||||
return (symbolTT[symbolValue].deltaNbBits + ((1<<16)-1)) >> 16;
|
||||
}
|
||||
|
||||
/* FSE_bitCost_b256() :
|
||||
* Approximate symbol cost,
|
||||
* provide fractional value, using fixed-point format (8 bit) */
|
||||
MEM_STATIC U32 FSE_bitCost_b256(const FSE_symbolCompressionTransform* symbolTT, U32 tableLog, U32 symbolValue)
|
||||
{
|
||||
U32 const minNbBits = symbolTT[symbolValue].deltaNbBits >> 16;
|
||||
U32 const threshold = (minNbBits+1) << 16;
|
||||
assert(symbolTT[symbolValue].deltaNbBits + (1<<tableLog) <= threshold);
|
||||
U32 const deltaFromThreshold = threshold - (symbolTT[symbolValue].deltaNbBits + (1 << tableLog));
|
||||
U32 const normalizedDeltaFromThreshold = (deltaFromThreshold << 8) >> tableLog; /* linear interpolation (very approximate) */
|
||||
assert(normalizedDeltaFromThreshold <= 256);
|
||||
return (minNbBits+1)*256 - normalizedDeltaFromThreshold;
|
||||
}
|
||||
|
||||
|
||||
/* ====== Decompression ====== */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user