package decompress
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0130ea6acb61b0a25393fa23148e116d7a17c77558196f7abddaee9e05a1d7a8
sha512=1668df538fba7c96574146a18fcbeef5200ea0e36110ec94c9b9924e368f465447702029fdb00d2749ca55081169b0e7c74e2f0887e4367ec580633e1e2a1c6c
doc/decompress.de/De/Def/index.html
Module De.DefSource
The type for output destinations. With a `Manual destination the client must provide output storage with dst. With `String or `Channel destination the client can safely discard `Flush case (with assert false).
The type for DEFLATE DYNAMIC block.
type kind = | Flat of int(*A
*)Flat lenblock is a non-compressed block oflenbyte(s). After a flat block, output is aligned on bytes.| Fixed(*A
*)Fixedblock is a compressed block by a precomputed Huffman tree. Any symbols can be encoded with this kind of block -encodeshould never return`Blockwith it.| Dynamic of dynamic(*A
*)Dynamic hblock is a compressed block by an Huffman tree represented byh. It allows to encode a subset of symbols (or any symbols).
The type for DEFLATE header block.
dynamic_of_frequencies ~literals ~distances is a DEFLATE DYNAMIC block header computed from given frequencies. According frequencies, dynamic_of_frequencies makes a Huffman tree which provides smaller representation for symbols which frequency is upper than 0 (others symbols are not a part of resulted Huffman tree). At the end, a dynamic Huffman tree is able to encode a subset of symbols.
If all frequencies are upper than 0, resulted dynamic Huffman tree is able to encode any symbols.
The type for DEFLATE encoders.
encoder dst ~q is an encoder that outputs to dst.
Internal queue.
encoder needs a side-channel about compressed inputs. To pass compression values to encoder, we use a queue q. Length of it can be a bottleneck where a small one will let encode to emit too many `Flush (which is commonly associated to a syscall). We recommend a queue as large as output buffer.
encode e v is:
`Partialiffehas a`Manualdestination and needs more output storage. The client must usedstto provide a new buffer and then callencodewith`Awaituntil`Okis returned.`Okwhen the encoder is ready to encode a newencodeaction.`Blockwhen the encoder reachs aQueue.cmdwhich can not be encoded with the currentblock. The client must respond with`Block blockwhereblockis a new block able to encode currentQueue.cmd.
How to signal end of flow?
End of flow is characterized by a block where last = true. Then, the client must emit into the queue q Queue.eob.
Limitation.
The encoder must manipulate an output buffer of, at least, 2 bytes. If it's not the case, encode does nothing - and it tells you nothing more than it did nothing. Depending on what you do, a loop can infinitely call encode without any updates until the given output still has less than 2 bytes.
dst e s j l provides e with l bytes available to write, starting at j in s. This byte range is read by calls to encode with e until `Flush is returned.
bits_rem e is how many bits it remains in given output buffer. A DEFLATE flow is not necessary aligned on bytes. The client can call bits_rem only when he reachs `End case. Otherwise, we raises an Invalid_argument.