🏹 Where do we stand?

Why did we implement all this? In order to decode Zstandard compressed data, we will need to manipulate several entities that belong to the current block being decoded. Please refer to the Zstandard in a nutshell explanation if you do not remember all the terms used here.

We need to first decode the literals. Those literals, which serve as the initial source of data copied to the output, are often compressed using a Huffman table whose weights are encoded using FSE.

Once we have decoded the literals section, sequences will be executed, one after the other, indicating what to do, such as "extract the first M unused bytes from the literals into the decompressed file, then copy N bytes from the already decoded output starting P bytes before the current point". Those M, N and P values are encoded using FSE, and their decoding is followed by some post-processing to obtain the correct values.

We have all the building blocks needed to achieve the Zstandard decompression process.