• Home
Name Date Size #Lines LOC

..--

.gitignoreD03-May-202426 32

MakefileD03-May-20242.1 KiB6339

README.mdD03-May-20241.7 KiB3729

harness.cD03-May-20243.4 KiB12080

zstd_decompress.cD03-May-202488.4 KiB2,3211,297

zstd_decompress.hD03-May-20242.5 KiB6212

README.md

1Educational Decoder
2===================
3
4`zstd_decompress.c` is a self-contained implementation in C99 of a decoder,
5according to the [Zstandard format specification].
6While it does not implement as many features as the reference decoder,
7such as the streaming API or content checksums, it is written to be easy to
8follow and understand, to help understand how the Zstandard format works.
9It's laid out to match the [format specification],
10so it can be used to understand how complex segments could be implemented.
11It also contains implementations of Huffman and FSE table decoding.
12
13[Zstandard format specification]: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md
14[format specification]: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md
15
16While the library's primary objective is code clarity,
17it also happens to compile into a small object file.
18The object file can be made even smaller by removing error messages,
19using the macro directive `ZDEC_NO_MESSAGE` at compilation time.
20This can be reduced even further by foregoing dictionary support,
21by defining `ZDEC_NO_DICTIONARY`.
22
23`harness.c` provides a simple test harness around the decoder:
24
25    harness <input-file> <output-file> [dictionary]
26
27As an additional resource to be used with this decoder,
28see the `decodecorpus` tool in the [tests] directory.
29It generates valid Zstandard frames that can be used to verify
30a Zstandard decoder implementation.
31Note that to use the tool to verify this decoder implementation,
32the --content-size flag should be set,
33as this decoder does not handle streaming decoding,
34and so it must know the decompressed size in advance.
35
36[tests]: https://github.com/facebook/zstd/blob/dev/tests/
37