...
1
11
12 package xz
13
14 type xzDecDelta struct {
15 delta [256]byte
16 pos byte
17 distance int
18 }
19
20
23 func xzDecDeltaRun(s *xzDecDelta, b *xzBuf, chain func(*xzBuf) xzRet) xzRet {
24 outStart := b.outPos
25 ret := chain(b)
26 for i := outStart; i < b.outPos; i++ {
27 tmp := b.out[i] + s.delta[byte(s.distance+int(s.pos))]
28 s.delta[s.pos] = tmp
29 b.out[i] = tmp
30 s.pos--
31 }
32 return ret
33 }
34
35
39 func xzDecDeltaCreate() *xzDecDelta {
40 return new(xzDecDelta)
41 }
42
43
47 func xzDecDeltaReset(s *xzDecDelta, distance int) xzRet {
48 if distance < 1 || distance > 256 {
49 return xzOptionsError
50 }
51 s.delta = [256]byte{}
52 s.pos = 0
53 s.distance = distance
54 return xzOK
55 }
56
View as plain text