Home | History | Annotate | Download | only in lzw

Lines Matching refs:code

2 // Use of this source code is governed by a BSD-style
11 // two non-literal codes are a clear code and an EOF code.
46 // stream into a code stream.
59 // with the upper bound incrementing on each code seen.
61 // overflow is the code at which hi overflows the code width. It always
64 // last is the most recently seen code, or decoderInvalidCode.
70 // Each code c in [lo, hi] expands to two or more bytes. For c != hi:
72 // prefix[c] is the code for all but the last byte.
73 // This code can either be a literal code or another code in [lo, c).
84 // so that there is always room to decode an entire code.
90 // readLSB returns the next code for "Least Significant Bits first" data.
100 code := uint16(d.bits & (1<<d.width - 1))
103 return code, nil
106 // readMSB returns the next code for "Most Significant Bits first" data.
116 code := uint16(d.bits >> (32 - d.width))
119 return code, nil
140 // Loop over the code stream, converting codes into decompressed bytes.
143 code, err := d.read(d)
152 case code < d.clear:
153 // We have a literal code.
154 d.output[d.o] = uint8(code)
157 // Save what the hi code expands to.
158 d.suffix[d.hi] = uint8(code)
161 case code == d.clear:
167 case code == d.eof:
170 case code <= d.hi:
171 c, i := code, len(d.output)-1
172 if code == d.hi && d.last != decoderInvalidCode {
173 // code == hi is a special case which expands to the last expansion
175 // the prefix chain until we find a literal code.
193 // Save what the hi code expands to.
198 d.err = errors.New("lzw: invalid code")
201 d.last, d.hi = code, d.hi+1