On this page

Appendix A - Decoding tables for predefined codes

This appendix contains FSE decoding tables for the predefined literal length, match length, and offset codes. The tables have been constructed using the algorithm as given above in chapter “from normalized distribution to decoding tables”. The tables here can be used as examples to crosscheck that an implementation build its decoding tables correctly.

Literal Length Code:

StateSymbolNumber_Of_BitsBase
0040
10416
21532
3350
4450
5650
6750
7950
81050
91250
101460
111650
121850
131950
142150
152250
162450
1725532
182650
192760
202960
213160
220432
23140
24250
254532
26550
277532
28850
2910532
301150
311360
3216532
331750
3419532
352050
3622532
372350
382540
3925416
4026532
412860
423060
430448
441416
452532
463532
475532
486532
498532
509532
5111532
5212532
531560
5417532
5518532
5620532
5721532
5823532
5924532
603560
613460
623360
633260

Match Length Code:

StateSymbolNumber_Of_BitsBase
0060
1140
22532
3350
4550
5650
6850
71060
81360
91660
101960
112260
122560
132860
143160
153360
163560
173760
183960
194160
204360
214560
221416
23240
243532
25450
266532
27750
28960
291260
301560
311860
322160
332460
342760
353060
363260
373460
383660
393860
404060
414260
424460
431432
441448
452416
464532
475532
487532
498532
501160
511460
521760
532060
542360
552660
562960
575260
585160
595060
604960
614860
624760
634660

Offset Code:

StateSymbolNumber_Of_BitsBase
0050
1640
2950
31550
42150
5350
6740
71250
81850
92350
10550
11840
121450
132050
14250
157416
161150
171750
182250
19450
208416
211350
221950
23150
246416
251050
261650
272850
282750
292650
302550
312450

Appendix B - Resources for implementers

An open source reference implementation is available on : https://github.com/facebook/zstd

The project contains a frame generator, called decodeCorpus, which can be used by any 3rd-party implementation to verify that a tested decoder is compliant with the specification.

decodeCorpus generates random valid frames. A compliant decoder should be able to decode them all, or at least provide a meaningful error code explaining for which reason it cannot (memory limit restrictions for example).

Version changes

  • 0.4.3 : clarifications for Huffman prefix code assignment example
  • 0.4.2 : refactor FSE table construction process, inspired by Donald Pian
  • 0.4.1 : clarifications on a few error scenarios, by Eric Lasota
  • 0.4.0 : fixed imprecise behavior for nbSeq==0, detected by Igor Pavlov
  • 0.3.9 : clarifications for Huffman-compressed literal sizes.
  • 0.3.8 : clarifications for Huffman Blocks and Huffman Tree descriptions.
  • 0.3.7 : clarifications for Repeat_Offsets, matching RFC8878
  • 0.3.6 : clarifications for Dictionary_ID
  • 0.3.5 : clarifications for Block_Maximum_Size
  • 0.3.4 : clarifications for FSE decoding table
  • 0.3.3 : clarifications for field Block_Size
  • 0.3.2 : remove additional block size restriction on compressed blocks
  • 0.3.1 : minor clarification regarding offset history update rules
  • 0.3.0 : minor edits to match RFC8478
  • 0.2.9 : clarifications for huffman weights direct representation, by Ulrich Kunitz
  • 0.2.8 : clarifications for IETF RFC discuss
  • 0.2.7 : clarifications from IETF RFC review, by Vijay Gurbani and Nick Terrell
  • 0.2.6 : fixed an error in huffman example, by Ulrich Kunitz
  • 0.2.5 : minor typos and clarifications
  • 0.2.4 : section restructuring, by Sean Purcell
  • 0.2.3 : clarified several details, by Sean Purcell
  • 0.2.2 : added predefined codes, by Johannes Rudolph
  • 0.2.1 : clarify field names, by Przemyslaw Skibinski
  • 0.2.0 : numerous format adjustments for zstd v0.8+
  • 0.1.2 : limit Huffman tree depth to 11 bits
  • 0.1.1 : reserved dictID ranges
  • 0.1.0 : initial release