I have huffman and lz77 codes, but I need any way to merge this algorithms to make deflate
How i can do this?
I have to write it manually without using libraries.
I have huffman and lz77 codes, but I need any way to merge this algorithms to make deflate
How i can do this?
I have to write it manually without using libraries.
LZ77 gives you a sequence of literal and length/distance pairs. There are many ways to apply Huffman coding to that. The first step would be to apply Huffman coding to the literals, as if there were no LZ77. Then just pass the length/distance pairs through as is, making sure you can tell whether the next thing is a literal or a length/distance pair.
After that you can also try to code the length/distance pairs. Deflate puts the literals and lengths in a single Huffman code, and the distances in a second Huffman code. Or you could code a count of literals that are followed by one length, then put the literals and length in different Huffman codes. Or ... many other ways.
In order to be able to decode, you also need to describe the Huffman codes you use at the start of the stream.
You can read the deflate description for how it does all that.