mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Move Fast in HuffmanTable to start of struct, given that common case is <= 9 bits
This commit is contained in:
parent
91ab867d5e
commit
cdba690aff
@ -734,22 +734,6 @@ static void Deflate_Lit(DeflateState* state, Int32 lit) {
|
||||
//Platform_Log1("lit %i", &lit);
|
||||
}
|
||||
|
||||
Int32 DecodeHack(HuffmanTable* table, Int32 value, Int32* bits) {
|
||||
UInt32 codeword = 0;
|
||||
UInt32 i, j;
|
||||
|
||||
for (i = 1, j = 0; i < INFLATE_MAX_BITS; i++, j++) {
|
||||
codeword = (codeword << 1) | ((value >> j) & 1);
|
||||
|
||||
if (codeword < table->EndCodewords[i]) {
|
||||
Int32 offset = table->FirstOffsets[i] + (codeword - table->FirstCodewords[i]);
|
||||
*bits = i;
|
||||
return table->Values[offset];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void Deflate_LenDist(DeflateState* state, Int32 len, Int32 dist) {
|
||||
Int32 j;
|
||||
len_base[29] = UInt16_MaxValue;
|
||||
|
@ -35,11 +35,11 @@ void ZLibHeader_Read(Stream* s, ZLibHeader* header);
|
||||
#define INFLATE_WINDOW_MASK 0x7FFFUL
|
||||
|
||||
typedef struct HuffmanTable_ {
|
||||
Int16 Fast[1 << INFLATE_FAST_BITS]; /* Fast lookup table for huffman codes */
|
||||
UInt16 FirstCodewords[INFLATE_MAX_BITS]; /* Starting codeword for each bit length */
|
||||
UInt16 EndCodewords[INFLATE_MAX_BITS]; /* (Last codeword + 1) for each bit length. 0 is ignored. */
|
||||
UInt16 FirstOffsets[INFLATE_MAX_BITS]; /* Base offset into Values for codewords of each bit length. */
|
||||
UInt16 Values[INFLATE_MAX_LITS]; /* Values/Symbols list */
|
||||
Int16 Fast[1 << INFLATE_FAST_BITS]; /* Fast lookup table for huffman codes */
|
||||
} HuffmanTable;
|
||||
|
||||
typedef struct InflateState_ {
|
||||
|
Loading…
x
Reference in New Issue
Block a user