SBARINFO patch:

- Fixed: SBarInfo's string drawing sometimes used the wrong variable.

SVN r1594 (trunk)
This commit is contained in:
Randy Heit 2009-05-20 01:42:47 +00:00
commit b7dab65754
3 changed files with 82 additions and 82 deletions

View file

@ -79,9 +79,9 @@
DROPBITS(a); \
} while (0)
/****************************************************************
Shannon-Fano tree routines
****************************************************************/
/****************************************************************
Shannon-Fano tree routines
****************************************************************/
static const unsigned char BitReverse4[] = {
0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e,
@ -146,42 +146,42 @@ int STACK_ARGS FZipExploder::buildercmp(const void *a, const void *b)
return d;
}
int FZipExploder::BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals)
{
int i;
qsort(values, numvals, sizeof(*values), buildercmp);
// Generate the Shannon-Fano tree:
unsigned short code = 0;
unsigned short code_increment = 0;
unsigned short last_bit_length = 0;
for (i = numvals - 1; i >= 0; --i)
{
code += code_increment;
if (values[i].Length != last_bit_length)
{
last_bit_length = values[i].Length;
code_increment = 1 << (16 - last_bit_length);
}
// Reverse the order of the bits in the code before storing it.
values[i].Code = BitReverse4[code >> 12] |
(BitReverse4[(code >> 8) & 0xf] << 4) |
(BitReverse4[(code >> 4) & 0xf] << 8) |
(BitReverse4[code & 0xf] << 12);
}
// Insert each code into the hierarchical table. The top level is FIRST_BIT_LEN bits,
// and the other levels are REST_BIT_LEN bits. If a code does not completely fill
// a level, every permutation for the remaining bits is filled in to
// match this one.
InitTable(decoder, 1 << FIRST_BIT_LEN); // Set up the top level.
for (i = 0; i < numvals; ++i)
{
InsertCode(decoder, 0, FIRST_BIT_LEN, values[i].Code, values[i].Length, values[i].Value);
}
return 0;
}
int FZipExploder::BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals)
{
int i;
qsort(values, numvals, sizeof(*values), buildercmp);
// Generate the Shannon-Fano tree:
unsigned short code = 0;
unsigned short code_increment = 0;
unsigned short last_bit_length = 0;
for (i = numvals - 1; i >= 0; --i)
{
code += code_increment;
if (values[i].Length != last_bit_length)
{
last_bit_length = values[i].Length;
code_increment = 1 << (16 - last_bit_length);
}
// Reverse the order of the bits in the code before storing it.
values[i].Code = BitReverse4[code >> 12] |
(BitReverse4[(code >> 8) & 0xf] << 4) |
(BitReverse4[(code >> 4) & 0xf] << 8) |
(BitReverse4[code & 0xf] << 12);
}
// Insert each code into the hierarchical table. The top level is FIRST_BIT_LEN bits,
// and the other levels are REST_BIT_LEN bits. If a code does not completely fill
// a level, every permutation for the remaining bits is filled in to
// match this one.
InitTable(decoder, 1 << FIRST_BIT_LEN); // Set up the top level.
for (i = 0; i < numvals; ++i)
{
InsertCode(decoder, 0, FIRST_BIT_LEN, values[i].Code, values[i].Length, values[i].Value);
}
return 0;
}
int FZipExploder::DecodeSFValue(const TArray<HuffNode> &decoder)