Do you have any ideas on decreasing memory?
These are my structures:
Code:
const static int TABLE_BITS = 12;
const static int HASH_BITS = 12;
const static int HASH_SIZE = 1 << HASH_BITS;
const static int HASH_MASK = HASH_SIZE - 1;
const static int TABLE_SIZE = 1 << TABLE_BITS;
const static int TABLE_MASK = TABLE_SIZE - 1;
struct MatchModel
{
struct Table
{
uint32 offsets[TABLE_SIZE]; // Upper bits 12 = hash, lower bits 24 = offset
int16 head;
};
struct EncoderTable
{
uint32 next[TABLE_SIZE];
uint32 root[HASH_SIZE];
};
Table tables[0x100];
EncoderTable enc_tables[0x100];
void Reset()
{
for (int i = 0; i < 0x100; i++)
{
tables[i].head = 0;
memset(tables[i].offsets, 0, sizeof(tables[i].offsets));
memset(enc_tables[i].root, -1, sizeof(enc_tables[i].root));
memset(enc_tables[i].next, -1, sizeof(enc_tables[i].next));
}
}
};
struct MatchModel_Decoding
{
MatchModel::Table tables[0x100];
void Reset()
{
memset(tables, 0, sizeof(tables));
}
};
The size for decoding is fine, but the hash tables for encoding take up too much memory. Reducing HASH_BITS (depth=8 is less effective) or TABLE_BITS (any depth is less effective) is still fairly large. The alternative is I switch to 64k windows and use 16-bit offsets, but I would much rather 4 MB blocks.