hcode is a huffman code with a bit code and bit length.codeuint16lenuint16 set sets the code and length of an hcode.
Data waiting to be written is the low nbits of bits.codegen[]uint8codegenEncoding*huffmanEncodercodegenFreq[19]int32dst[]byteliteralEncoding*huffmanEncoderliteralFreq[]int32nbitsuintoffsetEncoding*huffmanEncoderoffsetFreq[]int32(*huffmanBitWriter) Encode(dst []byte, src []byte, matches []matchfinder.Match, lastBlock bool) []byte(*huffmanBitWriter) Reset() dynamicSize returns the size of dynamically encoded data in bits. fixedSize returns the size of dynamically encoded data in bits.(*huffmanBitWriter) flush() RFC 1951 3.2.7 specifies a special run-length encoding for specifying
the literal and offset lengths arrays (which are concatenated into a single
array). This method generates that run-length encoding.
The result is written into the codegen array, and the frequencies
of each code is written into the codegenFreq array.
Codes 0-15 are single byte codes. Codes 16-18 are followed by additional
information. Code badCode is an end marker
numLiterals The number of literals in literalEncoding
numOffsets The number of offsets in offsetEncoding
litenc, offenc The literal and offset encoder to use makeStatistics indexes a slice of tokens, and updates
literalFreq and offsetFreq, and generates literalEncoding
and offsetEncoding.
The number of literal and offset tokens is returned. storedSize calculates the stored size, including header.
The function returns the size in bits and whether the block
fits inside a single block.(*huffmanBitWriter) writeBits(b int32, nb uint) writeBlock will write a block of tokens with the smallest encoding.(*huffmanBitWriter) writeBytes(bytes []byte)(*huffmanBitWriter) writeCode(c hcode) Write the header of a dynamic Huffman block to the output stream.
numLiterals The number of literals specified in codegen
numOffsets The number of offsets specified in codegen
numCodegens The number of codegens used in codegen(*huffmanBitWriter) writeFixedHeader(isEof bool)(*huffmanBitWriter) writeStoredHeader(length int, isEof bool) writeTokens writes a slice of tokens to the output.
codes for literal and offset encoding must be supplied.
*huffmanBitWriter : github.com/andybalholm/brotli/matchfinder.Encoder
bitCount[17]int32codes[]hcodefreqcache[]literalNode // stored to avoid repeated allocation in generate // stored to avoid repeated allocation in generate Look at the leaves and assign them a bit count and an encoding as specified
in RFC 1951 3.2.2 Return the number of literals assigned to each bit size in the Huffman encoding
This method is only called when list.length >= 3
The cases of 0, 1, and 2 literals are handled by special case code.
list An array of the literals with non-zero frequencies
and their associated frequencies. The array is in order of increasing
frequency, and has as its last element a special element with frequency
MaxInt32
maxBits The maximum number of bits that should be used to encode any literal.
Must be less than 16.
return An integer array in which array[i] indicates the number of literals
that should be encoded in i bits.(*huffmanEncoder) bitLength(freq []int32) int Update this Huffman Code object to be the minimum code for the specified frequency count.
freq An array of frequencies, in which frequency[i] gives the frequency of literal i.
maxBits The maximum number of bits to use for any literal.
func generateFixedLiteralEncoding() *huffmanEncoder
func generateFixedOffsetEncoding() *huffmanEncoder
func newHuffmanEncoder(size int) *huffmanEncoder
var fixedLiteralEncoding *huffmanEncoder
var fixedOffsetEncoding *huffmanEncoder
A levelInfo describes the state of the constructed tree for a given depth. The frequency of the last node at this level Our level. for better printing The number of chains remaining to generate for this level before moving
up to the next level The frequency of the next character to add to this level The frequency of the next pair (from level below) to add to this level.
Only valid if the "needed" value of the next lower level is 0.
NewGZIPWriter returns a new matchfinder.Writer that compresses data at the given
level, in gzip encoding. Levels 1–9 are available; levels outside this range
will be replaced by the closest level available.
NewWriter returns a new matchfinder.Writer that compresses data at the given level,
in flate encoding. Levels 1–9 are available; levels outside this range will
be replaced with the closest level available.
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.