Intel Extensible Firmware Interface User Manual

Page 990

Advertising
background image

Extensible Firmware Interface Specification

H-26

12/01/02

Version 1.10

STATIC
VOID
DownHeap (
IN INT32 i
)
{
INT32 j, k;

//
// priority queue: send i-th entry down heap
//

k = mHeap[i];
while ((j = 2 * i) <= mHeapSize) {
if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) {
j++;
}
if (mFreq[k] <= mFreq[mHeap[j]]) {
break;
}
mHeap[i] = mHeap[j];
i = j;
}
mHeap[i] = (INT16)k;
}

STATIC
VOID
MakeCode (
IN INT32 n,
IN UINT8 Len[],
OUT UINT16 Code[]
)
/*++

Routine Description:

Assign code to each symbol based on the code length array

Arguments:

n - number of symbols
Len - the code length array
Code - stores codes for each symbol

Returns: (VOID)

--*/
{
INT32 i;
UINT16 Start[18];

Start[1] = 0;
for (i = 1; i <= 16; i++) {
Start[i + 1] = (UINT16)((Start[i] + mLenCnt[i]) << 1);
}
for (i = 0; i < n; i++) {
Code[i] = Start[Len[i]]++;
}
}

Advertising