3.1.8.1.4.3.2 Encoding the Length-of-Match

Encoding of the length-of-match is shown in the previous figure by the Action B item. The following describes the algorithm for encoding the length-of-match.

 LUTIndex = IndexOfEqualOrSmallerEntry(LoM, LoMBaseLUT)
 OutputBits(HuffCodeL[LUTIndex], HuffLengthL[LUTIndex])
  
 ExtraBitsLength = LoMBitsLUT[LUTIndex]
 ExtraBits = (LoM - 2) & ((2 ^ ExtraBitsLength) - 1)
 OutputBits (ExtraBits, ExtraBitsLength)

The definitions of the functions used in this pseudocode are the same as those described in section 3.1.8.1.4.3.1.