vendor
This commit is contained in:
go.modvgo.list
vendor
github.com
sparrc
ulikunitz
xz
.gitignoreLICENSEREADME.mdTODO.mdbits.gobits_test.gocrc.goexample.goformat.goformat_test.gofox.xz
internal
hash
randtxt
xlog
lzma
bintree.gobintree_test.gobitops.gobreader.gobuffer.gobuffer_test.gobytewriter.godecoder.godecoder_test.godecoderdict.godecoderdict_test.godirectcodec.godistcodec.goencoder.goencoder_test.goencoderdict.gofox.lzmahashtable.gohashtable_test.goheader.goheader2.goheader2_test.goheader_test.golengthcodec.goliteralcodec.gomatchalgorithm.gooperation.goprob.goproperties.gorangecodec.goreader.goreader2.goreader_test.gostate.gotreecodecs.gowriter.gowriter2.gowriter2_test.gowriter_test.go
lzmafilter.gomake-docsreader.goreader_test.gowriter.gowriter_test.gogolang.org
x
net
bpf
asm.goconstants.godoc.goinstructions.goinstructions_test.gosetter.go
testdata
vm.govm_aluop_test.govm_bpf_test.govm_extension_test.govm_instructions.govm_jump_test.govm_load_test.govm_ret_test.govm_scratch_test.govm_test.goicmp
diag_test.godstunreach.goecho.goendpoint.goexample_test.goextension.goextension_test.gohelper_posix.gointerface.goipv4.goipv4_test.goipv6.golisten_posix.golisten_stub.gomessage.gomessage_test.gomessagebody.gompls.gomultipart.gomultipart_test.gopackettoobig.goparamprob.gosys_freebsd.gotimeexceeded.go
internal
iana
nettest
helper_bsd.gohelper_nobsd.gohelper_posix.gohelper_stub.gohelper_unix.gohelper_windows.gointerface.gorlimit.gostack.go
socket
cmsghdr.gocmsghdr_bsd.gocmsghdr_linux_32bit.gocmsghdr_linux_64bit.gocmsghdr_solaris_64bit.gocmsghdr_stub.godefs_darwin.godefs_dragonfly.godefs_freebsd.godefs_linux.godefs_netbsd.godefs_openbsd.godefs_solaris.goerror_unix.goerror_windows.goiovec_32bit.goiovec_64bit.goiovec_solaris_64bit.goiovec_stub.gommsghdr_stub.gommsghdr_unix.gomsghdr_bsd.gomsghdr_bsdvar.gomsghdr_linux.gomsghdr_linux_32bit.gomsghdr_linux_64bit.gomsghdr_openbsd.gomsghdr_solaris_64bit.gomsghdr_stub.gorawconn.gorawconn_mmsg.gorawconn_msg.gorawconn_nommsg.gorawconn_nomsg.gorawconn_stub.goreflect.gosocket.gosocket_go1_9_test.gosocket_test.gosys.gosys_bsd.gosys_bsdvar.gosys_darwin.gosys_dragonfly.gosys_linux.gosys_linux_386.gosys_linux_386.ssys_linux_amd64.gosys_linux_arm.gosys_linux_arm64.gosys_linux_mips.gosys_linux_mips64.gosys_linux_mips64le.gosys_linux_mipsle.gosys_linux_ppc64.gosys_linux_ppc64le.gosys_linux_s390x.gosys_linux_s390x.ssys_netbsd.gosys_posix.gosys_solaris.gosys_solaris_amd64.ssys_stub.gosys_unix.gosys_windows.gozsys_darwin_386.gozsys_darwin_amd64.gozsys_darwin_arm.gozsys_darwin_arm64.gozsys_dragonfly_amd64.gozsys_freebsd_386.gozsys_freebsd_amd64.gozsys_freebsd_arm.gozsys_linux_386.gozsys_linux_amd64.gozsys_linux_arm.gozsys_linux_arm64.gozsys_linux_mips.gozsys_linux_mips64.gozsys_linux_mips64le.gozsys_linux_mipsle.gozsys_linux_ppc64.gozsys_linux_ppc64le.gozsys_linux_s390x.gozsys_netbsd_386.gozsys_netbsd_amd64.gozsys_netbsd_arm.gozsys_openbsd_386.gozsys_openbsd_amd64.gozsys_openbsd_arm.gozsys_solaris_amd64.go
ipv4
batch.gobpf_test.gocontrol.gocontrol_bsd.gocontrol_pktinfo.gocontrol_stub.gocontrol_test.gocontrol_unix.gocontrol_windows.godefs_darwin.godefs_dragonfly.godefs_freebsd.godefs_linux.godefs_netbsd.godefs_openbsd.godefs_solaris.godgramopt.godoc.goendpoint.goexample_test.gogen.gogenericopt.goheader.goheader_test.gohelper.goiana.goicmp.goicmp_linux.goicmp_stub.goicmp_test.gomulticast_test.gomulticastlistener_test.gomulticastsockopt_test.gopacket.gopacket_go1_8.gopacket_go1_9.gopayload.gopayload_cmsg.gopayload_cmsg_go1_8.gopayload_cmsg_go1_9.gopayload_nocmsg.goreadwrite_go1_8_test.goreadwrite_go1_9_test.goreadwrite_test.gosockopt.gosockopt_posix.gosockopt_stub.gosys_asmreq.gosys_asmreq_stub.gosys_asmreqn.gosys_asmreqn_stub.gosys_bpf.gosys_bpf_stub.gosys_bsd.gosys_darwin.gosys_dragonfly.gosys_freebsd.gosys_linux.gosys_solaris.gosys_ssmreq.gosys_ssmreq_stub.gosys_stub.gosys_windows.gounicast_test.gounicastsockopt_test.gozsys_darwin.gozsys_dragonfly.gozsys_freebsd_386.gozsys_freebsd_amd64.gozsys_freebsd_arm.gozsys_linux_386.gozsys_linux_amd64.gozsys_linux_arm.gozsys_linux_arm64.gozsys_linux_mips.gozsys_linux_mips64.gozsys_linux_mips64le.gozsys_linux_mipsle.gozsys_linux_ppc.gozsys_linux_ppc64.gozsys_linux_ppc64le.gozsys_linux_s390x.gozsys_netbsd.gozsys_openbsd.gozsys_solaris.go
ipv6
batch.gobpf_test.gocontrol.gocontrol_rfc2292_unix.gocontrol_rfc3542_unix.gocontrol_stub.gocontrol_test.gocontrol_unix.gocontrol_windows.godefs_darwin.godefs_dragonfly.godefs_freebsd.godefs_linux.godefs_netbsd.godefs_openbsd.godefs_solaris.godgramopt.godoc.goendpoint.goexample_test.gogen.gogenericopt.goheader.goheader_test.gohelper.goiana.goicmp.goicmp_bsd.goicmp_linux.goicmp_solaris.goicmp_stub.goicmp_test.goicmp_windows.gomocktransponder_test.gomulticast_test.gomulticastlistener_test.gomulticastsockopt_test.gopayload.gopayload_cmsg.gopayload_cmsg_go1_8.gopayload_cmsg_go1_9.gopayload_nocmsg.goreadwrite_go1_8_test.goreadwrite_go1_9_test.goreadwrite_test.gosockopt.gosockopt_posix.gosockopt_stub.gosockopt_test.gosys_asmreq.gosys_asmreq_stub.gosys_bpf.gosys_bpf_stub.gosys_bsd.gosys_darwin.gosys_freebsd.gosys_linux.gosys_solaris.gosys_ssmreq.gosys_ssmreq_stub.gosys_stub.gosys_windows.gounicast_test.gounicastsockopt_test.gozsys_darwin.gozsys_dragonfly.gozsys_freebsd_386.gozsys_freebsd_amd64.gozsys_freebsd_arm.gozsys_linux_386.gozsys_linux_amd64.gozsys_linux_arm.gozsys_linux_arm64.gozsys_linux_mips.gozsys_linux_mips64.gozsys_linux_mips64le.gozsys_linux_mipsle.gozsys_linux_ppc.gozsys_linux_ppc64.gozsys_linux_ppc64le.gozsys_linux_s390x.gozsys_netbsd.gozsys_openbsd.gozsys_solaris.go
gopkg.in
check.v1
.gitignore.travis.ymlLICENSEREADME.mdTODObenchmark.gobenchmark_test.gobootstrap_test.gocheck.gocheck_test.gocheckers.gocheckers_test.goexport_test.gofixture_test.gofoundation_test.gohelpers.gohelpers_test.goprinter.goprinter_test.goreporter.goreporter_test.gorun.gorun_test.go
yaml.v2
novit.nc
direktil
pkg
133
vendor/github.com/ulikunitz/xz/lzma/treecodecs.go
generated
vendored
Normal file
133
vendor/github.com/ulikunitz/xz/lzma/treecodecs.go
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
// Copyright 2014-2017 Ulrich Kunitz. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package lzma
|
||||
|
||||
// treeCodec encodes or decodes values with a fixed bit size. It is using a
|
||||
// tree of probability value. The root of the tree is the most-significant bit.
|
||||
type treeCodec struct {
|
||||
probTree
|
||||
}
|
||||
|
||||
// makeTreeCodec makes a tree codec. The bits value must be inside the range
|
||||
// [1,32].
|
||||
func makeTreeCodec(bits int) treeCodec {
|
||||
return treeCodec{makeProbTree(bits)}
|
||||
}
|
||||
|
||||
// deepcopy initializes tc as a deep copy of the source.
|
||||
func (tc *treeCodec) deepcopy(src *treeCodec) {
|
||||
tc.probTree.deepcopy(&src.probTree)
|
||||
}
|
||||
|
||||
// Encode uses the range encoder to encode a fixed-bit-size value.
|
||||
func (tc *treeCodec) Encode(e *rangeEncoder, v uint32) (err error) {
|
||||
m := uint32(1)
|
||||
for i := int(tc.bits) - 1; i >= 0; i-- {
|
||||
b := (v >> uint(i)) & 1
|
||||
if err := e.EncodeBit(b, &tc.probs[m]); err != nil {
|
||||
return err
|
||||
}
|
||||
m = (m << 1) | b
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decodes uses the range decoder to decode a fixed-bit-size value. Errors may
|
||||
// be caused by the range decoder.
|
||||
func (tc *treeCodec) Decode(d *rangeDecoder) (v uint32, err error) {
|
||||
m := uint32(1)
|
||||
for j := 0; j < int(tc.bits); j++ {
|
||||
b, err := d.DecodeBit(&tc.probs[m])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
m = (m << 1) | b
|
||||
}
|
||||
return m - (1 << uint(tc.bits)), nil
|
||||
}
|
||||
|
||||
// treeReverseCodec is another tree codec, where the least-significant bit is
|
||||
// the start of the probability tree.
|
||||
type treeReverseCodec struct {
|
||||
probTree
|
||||
}
|
||||
|
||||
// deepcopy initializes the treeReverseCodec as a deep copy of the
|
||||
// source.
|
||||
func (tc *treeReverseCodec) deepcopy(src *treeReverseCodec) {
|
||||
tc.probTree.deepcopy(&src.probTree)
|
||||
}
|
||||
|
||||
// makeTreeReverseCodec creates treeReverseCodec value. The bits argument must
|
||||
// be in the range [1,32].
|
||||
func makeTreeReverseCodec(bits int) treeReverseCodec {
|
||||
return treeReverseCodec{makeProbTree(bits)}
|
||||
}
|
||||
|
||||
// Encode uses range encoder to encode a fixed-bit-size value. The range
|
||||
// encoder may cause errors.
|
||||
func (tc *treeReverseCodec) Encode(v uint32, e *rangeEncoder) (err error) {
|
||||
m := uint32(1)
|
||||
for i := uint(0); i < uint(tc.bits); i++ {
|
||||
b := (v >> i) & 1
|
||||
if err := e.EncodeBit(b, &tc.probs[m]); err != nil {
|
||||
return err
|
||||
}
|
||||
m = (m << 1) | b
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decodes uses the range decoder to decode a fixed-bit-size value. Errors
|
||||
// returned by the range decoder will be returned.
|
||||
func (tc *treeReverseCodec) Decode(d *rangeDecoder) (v uint32, err error) {
|
||||
m := uint32(1)
|
||||
for j := uint(0); j < uint(tc.bits); j++ {
|
||||
b, err := d.DecodeBit(&tc.probs[m])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
m = (m << 1) | b
|
||||
v |= b << j
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// probTree stores enough probability values to be used by the treeEncode and
|
||||
// treeDecode methods of the range coder types.
|
||||
type probTree struct {
|
||||
probs []prob
|
||||
bits byte
|
||||
}
|
||||
|
||||
// deepcopy initializes the probTree value as a deep copy of the source.
|
||||
func (t *probTree) deepcopy(src *probTree) {
|
||||
if t == src {
|
||||
return
|
||||
}
|
||||
t.probs = make([]prob, len(src.probs))
|
||||
copy(t.probs, src.probs)
|
||||
t.bits = src.bits
|
||||
}
|
||||
|
||||
// makeProbTree initializes a probTree structure.
|
||||
func makeProbTree(bits int) probTree {
|
||||
if !(1 <= bits && bits <= 32) {
|
||||
panic("bits outside of range [1,32]")
|
||||
}
|
||||
t := probTree{
|
||||
bits: byte(bits),
|
||||
probs: make([]prob, 1<<uint(bits)),
|
||||
}
|
||||
for i := range t.probs {
|
||||
t.probs[i] = probInit
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// Bits provides the number of bits for the values to de- or encode.
|
||||
func (t *probTree) Bits() int {
|
||||
return int(t.bits)
|
||||
}
|
Reference in New Issue
Block a user