Extensible Firmware Interface Specification
H-20 12/01/02 Version 1.10
Routine Description:
Huffman code the block and output it.
Argument: (VOID)
Returns: (VOID)
--*/
{
UINT32 i, k, Flags, Root, Pos, Size;
Flags = 0;
Root = MakeTree(NC, mCFreq, mCLen, mCCode);
Size = mCFreq[Root];
PutBits(16, Size);
if (Root >= NC) {
CountTFreq();
Root = MakeTree(NT, mTFreq, mPTLen, mPTCode);
if (Root >= NT) {
WritePTLen(NT, TBIT, 3);
} else {
PutBits(TBIT, 0);
PutBits(TBIT, Root);
}
WriteCLen();
} else {
PutBits(TBIT, 0);
PutBits(TBIT, 0);
PutBits(CBIT, 0);
PutBits(CBIT, Root);
}
Root = MakeTree(NP, mPFreq, mPTLen, mPTCode);
if (Root >= NP) {
WritePTLen(NP, PBIT, -1);
} else {
PutBits(PBIT, 0);
PutBits(PBIT, Root);
}
Pos = 0;
for (i = 0; i < Size; i++) {
if (i % UINT8_BIT == 0) {
Flags = mBuf[Pos++];
} else {
Flags <<= 1;
}
if (Flags & (1U << (UINT8_BIT - 1))) {
EncodeC(mBuf[Pos++] + (1U << UINT8_BIT));
k = mBuf[Pos++] << UINT8_BIT;
k += mBuf[Pos++];
EncodeP(k);
} else {
EncodeC(mBuf[Pos++]);
}
}
for (i = 0; i < NC; i++) {
mCFreq[i] = 0;
}