freebsd-nq/sys/contrib/zstd/doc/educational_decoder
Conrad Meyer 37f1f2684f Update to Zstandard 1.4.5
As usual, the full release notes are found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.5

Notable changes include:

* Improved decompress performance on amd64 and arm (5-10%
  and 15-50%, respectively).
* '--patch-from' zstd(1) CLI option, which provides something like a very fast
  version of bspatch(1) with slightly worse compression.  See release notes.

In this update, I dropped the 3-year old -O0 workaround for an LLVM ARM bug;
the bug was fixed in LLVM SVN in 2017, but we didn't remove this workaround
from our tree until now.

MFC after:	I won't, but feel free
Relnotes:	yes
2020-05-23 21:23:46 +00:00
..
harness.c Update to Zstandard 1.4.5 2020-05-23 21:23:46 +00:00
Makefile Update to Zstandard 1.4.5 2020-05-23 21:23:46 +00:00
README.md Update to Zstandard 1.4.5 2020-05-23 21:23:46 +00:00
zstd_decompress.c Update to Zstandard 1.4.5 2020-05-23 21:23:46 +00:00
zstd_decompress.h Update to Zstandard 1.4.5 2020-05-23 21:23:46 +00:00

Educational Decoder

zstd_decompress.c is a self-contained implementation in C99 of a decoder, according to the Zstandard format specification. While it does not implement as many features as the reference decoder, such as the streaming API or content checksums, it is written to be easy to follow and understand, to help understand how the Zstandard format works. It's laid out to match the format specification, so it can be used to understand how complex segments could be implemented. It also contains implementations of Huffman and FSE table decoding.

While the library's primary objective is code clarity, it also happens to compile into a small object file. The object file can be made even smaller by removing error messages, using the macro directive ZDEC_NO_MESSAGE at compilation time. This can be reduced even further by foregoing dictionary support, by defining ZDEC_NO_DICTIONARY.

harness.c provides a simple test harness around the decoder:

harness <input-file> <output-file> [dictionary]

As an additional resource to be used with this decoder, see the decodecorpus tool in the tests directory. It generates valid Zstandard frames that can be used to verify a Zstandard decoder implementation. Note that to use the tool to verify this decoder implementation, the --content-size flag should be set, as this decoder does not handle streaming decoding, and so it must know the decompressed size in advance.