Intel Extensible Firmware Interface User Manual

Page 999

Advertising
background image

Decompression Source Code

Version 1.10

12/01/02

I-7

STATIC
UINT16
MakeTable (
IN SCRATCH_DATA *Sd,
IN UINT16 NumOfChar,
IN UINT8 *BitLen,
IN UINT16 TableBits,
OUT UINT16 *Table
)
/*++

Routine Description:

Creates Huffman Code mapping table according to code length array.

Arguments:

Sd - The global scratch data
NumOfChar - Number of symbols in the symbol set
BitLen - Code length array
TableBits - The width of the mapping table
Table - The table

Returns:

0 - OK.
BAD_TABLE - The table is corrupted.

--*/
{
UINT16 Count[17];
UINT16 Weight[17];
UINT16 Start[18];
UINT16 *p;
UINT16 k;
UINT16 i;
UINT16 Len;
UINT16 Char;
UINT16 JuBits;
UINT16 Avail;
UINT16 NextCode;
UINT16 Mask;


for (i = 1; i <= 16; i ++) {
Count[i] = 0;
}

for (i = 0; i < NumOfChar; i++) {
Count[BitLen[i]]++;
}

Start[1] = 0;

for (i = 1; i <= 16; i ++) {
Start[i + 1] = (UINT16)(Start[i] + (Count[i] << (16 - i)));
}

Advertising